Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis pub sub max subscribers and publishers

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

like image 404
J.George Avatar asked Jan 23 '20 07:01

J.George


People also ask

How many subscribers Redis can handle?

Large number of connections Individual ElastiCache for Redis nodes support up to 65,000 concurrent client connections. However, to optimize for performance, we advise that client applications do not constantly operate at that level of connection.

Is Redis good for pub sub?

Aside from data storage, Redis can be used as a Publisher/Subscriber platform. In this pattern, publishers can issue messages to any number of subscribers on a channel. These messages are fire-and-forget, in that if a message is published and no subscribers exists, the message evaporates and cannot be recovered.

How fast is Redis pub sub?

Redis Pub/Sub is designed for speed (low latency), but only with low numbers of subscribers. Subscribers don't poll and while subscribed/connected are able to receive push notifications very quickly from the Redis broker — in the low milliseconds, even less than 1 millisecond as confirmed by this benchmark.

Is Redis pub/sub persistent?

More precisely, Redis Pub/Sub is designed for real-time communication between instances where low latency is of the utmost importance, and as such doesn't feature any form of persistence or acknowledgment.


1 Answers

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).

like image 175
LeoMurillo Avatar answered Sep 30 '22 18:09

LeoMurillo