Search code examples
websocketarchitecturescalabilitypublish-subscribeevent-bus

How to effectively scale Websocket servers?


So, let's consider group of Websocket applications. Each user is connected to one of these servers. I need to implement chat application, in which each user can send message to any user.

I am looking for fast, reliable, scalable approach, how to do it.

I think, that I need some good implementation of event bus. Each user, when he connects to websocket, has to be registered (or subscribed) in event bus. Then, when some another user sends message to given user, event bus publish message to given user.

So, what event bus should I use?

Of course, I know about Redis Pub/Sub, but I am not sure, that this is the best option in 2019 year.


Solution

  • Redis Pub/Sub is a really good option. One thing you need to actually worry about is the number of connection limit in certain scenarios. Since you know WebSockets are long-lived connections, load balancing of this thing works little different then Http. I suggest you read this thing I am sure you will find some good resources for this.