3 ms·
From what I understand websockets are great until you have to load balance them. And then you learn why they aren’t so great.
by virtue3 2y ago
From what I understand websockets are great until you have to load balance them. And then you learn why they aren’t so great.
- com2kid 2y agoI've scaled websockets before, it isn't that hard. You need to scale up before your servers become overloaded, and basically new connections go north to the newly brought up server. It is a different mentality than scaling stateless services but it isn't super duper hard.
- hooli_gan 2y agoCan you suggest some resources to learn more about Websocket scaling? Seems like an interesting topic
- com2kid 2y agoHonestly I just flipped the right bits in the aws load balancer (maintain persistent connections, just the first thing you are told to do when googling aws load balancers and web sockets) and setup the instance scaler to trigger based upon "# open connections / num servers > threshold". Ideally it is based on the rate of incoming connections, but so long as you leave enough headroom when doing the stupid simple scaling rule you should be fine. Just ensure new instances don't take too long to start up.
- hamandcheese 2y agoMy understanding is the hard part about scaling WebSockets is that they are stateful and long lived connections. That is also true of SSE. Is there some other aspect of WebSockets that make them harder to scale than WebSockets? I guess with WebSockets, if you choose to send messages from the client to the server, then you have some additional work that you wouldn't have with SSE.