typicallearner
typicallearner

Reputation: 256

Is creating redis subscription for each connecting user a good approach to scale?

Context and Problem

We are building a notification system.

Publisher users can send messages to other online subscriber users

online subscriber users will receive the sent messages.

Publisher users and Subscriber users are on different instances and have no direct way to reach each other.

It's okay for subscribers to miss some notifications in rare scenarios (other methods of retrieving all notifications are provided)

Solution

- Publishing

Publisher user publishes a message into RabbitMQ.

Business logic is applied to the message in RabbitMQ consumer.

RabbitMQ consumer publishes the message to Redis event notification_[subscriber_id].

- Subscribing

Subscriber user connects to a WebSocket server.

WebSocket server has a connection to Redis and subscribes to Redis event notification_[subscriber_id] on user connection.

Upon receiving messages on notification_[subscriber_id] a message is sent to the user over WebSocket.

Question

Both publisher users and subscriber users can be any amount (infinite), from my research it seems Redis has no limit on the number of subscriptions (around 4billion if there's any), so

Is this "dynamic" way of creating subscriptions in Redis, scalable?

Upvotes: 0

Views: 834

Answers (1)

Ron
Ron

Reputation: 6601

Yes,
you can scale horizontally in Redis Cluster mode, which will allow you to continue serving requests during the scaling process.

Also,
It will be smart to also design your application to cleanup subscriptions, as you seem to be planning to deal with millions/billions of subscriptions, so a good planning before implementation is important.

Upvotes: 1

Related Questions