cost of Websocket worker

I want to know who's used Websockets in cloudflare workers at scale to understand what the cost ends up being. I would love to hear your usecase and how much you've been paying. I'm building a real-time FAQ app where students ask questions, teaching assistants (and eventually an LLM or vector-db) merge similar questions, and then tesching assistants answer the question via text or via a separate video calling service. Right now we have ~100 students simultaneously, but we will have 1000s of students in a couple months. Our goal is to hit 10k simultaneous students in a year and eventually 100k in 3-4 yrs and 1M in 5-10. I would love to know how much this is going to cost me on workers vs a dedicated EC3 instance or something. Thanks!
2 Replies
DaniFoldi
DaniFoldi15mo ago
I can't give you exact numbers, since the cost depends on the workload (and won't, to avoid any responsibility), however, referencing the pricing pages (https://developers.cloudflare.com/workers/platform/pricing/ for Workers and https://developers.cloudflare.com/durable-objects/platform/pricing/ for Durable Objects), here are the factors you should look at: - new connections are a Worker request + a DO request - for long-term I recommend you take a look at the new Workers pricing tier (standard) - incoming WS messages are a DO request (+ billed for duration the DO is active) -> take a look at the Hibernation API, which reduces "message gateway"-type DO costs significantly - outgoing messages to other WebSockets are free, but may increase duration if you send to many peers From here, it should be easy to create an estimate per user - it greatly depends on how chatty your application is.
Nikil
NikilOP15mo ago
@Dani Foldi do you know if you have to use durable objects for Websockets? Is it only necessary if your function lasts more than ~30s CPU time with the new pricing? 1,000,000 seconds * 128 MB / 1 GB = 128,000 GB-s I think Cloudflare should update this doc to say * 1 GB / 1000 MB, not divide by GB Relatedly, is cloudflare counting costs as if 1GB = 1000 MB?
Want results from more Discord servers?
Add your server