websocketredispublish-subscriberedis-cluster

What options do I have to scale out Redis pub/sub?


I am implementing a real-time notification system with websockets and redis pub/sub. Basically, the client connects to the server through websockets and from the backend I subscribe to a specific Redis channel of my Redis instance, therefore I can serve the client all the messages that arrive from the channel. However, I am a little worried about the scalability of this, what can I do if I need more than one Redis instance? That is, different components of the system send messages to the Redis channel depending on certain events that happen, but how can I know which Redis instance I should send it to if there is more than one and I don't know which client is interested in which one it is linked to?


Solution

  • With Redis 7.0, you can use the sharded pubsub feature to scale.

    You can send different events to different channels, and have different consumers listening to different channels to process events.