I have a NestJS project that establishes websocket connections between client and server,
I have realized that websockets are not scalable and adopted Redis Pub/Sub so i can emit every message (publish) that client sends to API and receive the emited message (subscribe) on all instances of API
Thinking if i scale the API horizontally and the clients are connected in different websocket instances then i am publishing the message so anyway the message will reach the other API instance with websocket and finally gets delivered to client
I had this realization that All the instace of API will subscribe to the published message
Ideally i want my redis pub/sub to be able to deliver to specific API instance that the Client Websocket is connected
So my Question is
How do we handle the load balancing and stuff? is there any other way or am i just over thinking in this regard
Is there a way to emit to specific subscriber ?