Purpose of this is achieving a scalable environment when WebSocket are involved. The pattern to reproduce is a Multi-Server to Multi-client communication via websocket.
The result should be a client connected to a specific server host and keeping its connection bound to it (sticky
connection).
Whereas the server hosts will broadcast messages in turn and all the connected clients should receive them.
The latter will be achieved leveraging the pub/sub paradigm of Redis
.
The application is made of server and client part. Both are based socket.io
library.
- it employs a dedicated adapter implementing native Redis support.
- an instance will advertise periodically its private ip. NOTE that this message should be received by ALL the clients connected.
-
it is configured to employ native websockets, without attempting to use naïfes solutions as http polling.
{ transports: ['websocket'] }
-
it will send a message to a single server instance at connection time. NOTE that this message should be received only by a single server instance.
See Stack configuration.
See Kubernates configuration.