Horizontal scaling a Websockets

Yulian
1 min readFeb 16, 2021

This article is inspired from my github repository https://github.com/beruangcoklat/mspaint-socket.

What is a websocket ? Websocket is a protocol for real time communication from client to server and vice versa. For example, there are 5 people in a chat room. If user 1 sends a message to the chat room, then the websocket server will send the message to the other 4 people. But what if there is a person that is connected to a different websocket server ?

Websocket server 1 can’t send messages to user 4 and user 5 because they are connected with websocket server 2. So, how to solve this problem ? We can use pub/sub.

Publish/subscribe or pub/sub is a service to service communication. Every message published to a specific topic will be consumed by a server who subscribes to that topic. We can use this model to notify other websocket servers and every websocket server will send a message to the desired user.

--

--