Any real world examples of using a load balancer to route messages for websocket connections?
Something I’ve been wondering about from studying system design. For building an instant messaging app (such as Facebook messenger), one of the pressing concerns is making sure that a message sent from a user connected to one server is able to reach a user connected to another server (horizontally scaling websocket connections). The most common solution I’ve seen used is to route the messages through a PubSub message broker that will be picked up by every single application server in the cluster. As one example this is what Phoenix Realtime does; every application server will receive every message, regardless of whether or not it has a client listening for it.
Another solution is to route the messages only to the application servers that are listening for it by using a Load balancer with consistent hashing based on the recipient’s ID. The advantages mentioned for this approach are that it doesn’t require a message broker and it only requires sending messages to servers that actually have listening clients. This article goes into depth about it.
My question is: Are there any real-world examples that use a consistent hashing load balancer for horizontally scaling websocket connections? All the real-world examples I’ve come across so far just use the message broker approach. Ideally, I’d be curious to see an example that’s open source.
Posted Mar 16, 2025, 1:05 AM UTC