Scaling a Websocket server with a Kafka consumer

Posted by Bayul@reddit | ExperiencedDevs | View on Reddit | 18 comments

Hello everyone,

I'm currently building a real-time service where a user sends data over a WebSocket, which gets sent out to downstream services via Kafka. Then, the results are received also via Kafka, and sent back to the client over the same WebSocket. I was wondering how you would scale such a system horizontally.

The biggest issue for me is when I have multiple replicas of the WebSocket server coming in how do I ensure the correct one reads the Kafka message with results that belong to that client (and thus connection)? Tips and reading material would be greatly appreciated.