Using the socket.io-redis module, all of your server servers will use the same pool of connected users. You can emit from Backend1, and if the client is connected to Backend4, it will receive a message.
The key to this work, although with Socket.io is to use sticky sessions on nginx, so that as soon as I connect the client, it will remain on one computer. This is because the socket.io path starts with a WebSocket and several long poll threads, all of which must be on the same backend server for it to work properly.
Instead of using sticky sessions, you can change the client connection option to use only Websockets, and this will fix problems with multiple connections to multiple servers, as there will be only one connection - a single website. This will also cause your application to lose the ability to switch to longer polling instead of WebSockets.
source share