redispublish-subscribespring-data-redis

Redis pub sub performance impact and limitations when using single channel with thousands of consumers


In our Spring boot apps, we want to use Redis pub-sub to publish messages to a channel that in normal conditions has around 500 listeners. But on certain rare times/days, the listeners can be as large as 10000.

The system characteristics are the following:

I had the following questions for the below:

  1. Is this feasible or is there any limit on the number of listeners/subscribers for a channel?
  2. In this setup, when there are say 10K clients will this lead to 10K open connections in Redis?
  3. Is there a better approach to do this? (e.g. Instead of publishing to pub-sub the producer creates a key in Redis, whereas consumers can check for the existence of a Redis key on a schedule)

Solution

  • is there any limit on the number of listeners/subscribers for a channel?

    There's no limit on the number of subscribers. However, Redis limit the number of clients, i.e. connections, by maxclients config, which is 10000 by default. NOTE: you also need to ensure that your system allow a large number of open files.

    In this setup, when there are say 10K clients will this lead to 10K open connections in Redis?

    YES

    Is there a better approach to do this? (e.g. Instead of publishing to pub-sub the producer creates a key in Redis, whereas consumers can check for the existence of a Redis key on a schedule)

    Your proposal is not bad, since too many subscribers is a rare case.

    Also, you can setup multiple replicas for the master, and distribute subscribers to these replicas. So that each replica does not have to maintain too many connections.