How to Build a Massive Chat Room with Cloudflare?

Hello, recently I've been trying to create a chat system, in the style of Twitch or YouTube, and I've found myself wondering what will happen when I reach the limit of a Durable Object? Is there any way to scale a chat room using multiple DOs? That's when I started investigating the solutions provided by Cloudflare in case I need this. It turns out that besides discovering some new limits that weren't in the documentation, such as the fact that a DO cannot handle more than approximately 32,000 WebSocket connections. I also couldn't find a solution to my hypothetical problem, apart from Queues, which I'm not sure if it's a good fit for this scenario. So my question is: Is there a way to link multiple DOs together and combine them to create a HUGE chat room? Or should I take care of something like this on my own due to the current limitations? Thank you very much in advance.
3 Replies
Unsmart
Unsmart•14mo ago
The DO limit of websockets is in the docs fwiw: https://developers.cloudflare.com/durable-objects/api/hibernatable-websockets-api/
The Hibernatable WebSockets API permits a maximum of 32,768 WebSocket connections per Durable Object instance, but the CPU and memory usage of a given workload may further limit the practical number of simultaneous connections.
You can send messages between DOs so if you really wanted you can have 1 central DO as a coordination layer between many different nodes but that's beyond the scope of stuff we can help with here that would be up to you to figure out how to work out 🤷
Eupheminis
EupheminisOP•14mo ago
uh yeah that's a fantastic idea huh how I never think on it before, thank you so much
Tin Cap
Tin Cap•14mo ago
I know we're in the Cloudflare world on this Discord, but I would at least consider other services designed for handling massive chat rooms
Want results from more Discord servers?
Add your server