How to design Websocket load balancing with custom stickiness

21 Views Asked by At

I am designing a system which enables client applications to negotiate a connection with server node and then establish a persistent websocket channel. It is supposed to be a Publish-Subscribe server, where client apps subscribe to a particular topic(create if not exists). As part of subscription confirmation, a websocket channel is opened between client and server node for all the publish events delivery/response.

My main issue is that I want to keep all the websocket subscribers for a particular topic connected to same server node so that its simpler to deliver and manage the events published on that topic.

The default load-balanced behavior can send the websocket connection to any server node which will be very complicated to manage for events on any particular topic as we have to observe the success/failure of the event by receiving clients as well.

I am planning to use Redis to maintain the communication between the pods and share information.

Please help with ideas about how can I configure the load balancer to forward the websocket requests for a particular topic to the node which already has connections for that topic.

Current design proposal

0

There are 0 best solutions below