10

Could anyone tell me whats the maximum number of concurrent channels Redis pub-sub can support?. Is there any cap to the number of subscribers and publishers

J.George
  • 309
  • 1
  • 2
  • 5

2 Answers2

11

Redis uses a dict, same struct as for keys, to store channel subscriptions, both per client and for all clients (keeps a per-subscription hash with a list of clients subscribed), so it is up to 2^32 channel subscriptions in total.

It uses a list to store pattern subscriptions per client, so it is theoretically limited only by the node memory available.

However, in general, you can have infinite channels. Think of a channel as a label when a message is published. Messages are never stored. When the message is published, Redis will look for the clients subscribed to that channel, and test for every pattern subscription. The channel really exists only while the message is being published.

As there are pattern subscriptions, there are unlimited 'logical' channels.

Just in events notifications we have 2^32 * databases * key event types possible 'logical' channels.

Regarding the number of subscribers and publishers, it is limited by the maxclients setting, 10,000 by default. There is no limitation for subscribers and publishers, but the maximum clients (connections) limit applies.

As indicated by @Roman, there are buffer limitations, but this refers mostly to throughput (message processing).

LeoMurillo
  • 6,048
  • 1
  • 19
  • 34
  • So would it be wrong if I have around 100,000 subscribers, would redis-cluster solve this issue? – J.George Jan 23 '20 at 08:57
  • 1
    This is large scale. Change the `maxclients` setting to allow that many clients, redis-cluster may help if you can distribute the subscribers among the nodes. The heavy lifting here is pushing the message to that many clients, so try to come up with a way for your clients to connect as evenly as possible among your nodes. Keep an eye on performance and memory usage for buffering. See these issues for more detailed discussions: https://github.com/antirez/redis/issues/1927 https://github.com/antirez/redis/issues/2672 https://github.com/antirez/redis/issues/122 – LeoMurillo Jan 23 '20 at 09:17
1

Pub/Sub clients have a default hard limit of 32 megabytes and a soft limit of 8 megabytes per 60 seconds.

Is that what you have been looking for?

documentation

Roman Alekseiev
  • 1,854
  • 16
  • 24