-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Description
Edit: full mailing list discussion
Hi all,
I also posted this on the mailing list, but as I think it is a bug, I'll add it here, too.
according to [1] and [2] PubSub works by broadcasting every publish to every other Redis Cluster node. This limits the PubSub throughput to the bisection bandwidth of the underlying network infrastructure divided by the number of nodes times message size. So if a typical message has 1KB, the cluster has 10 nodes and bandwidth is 1 GBit/s, throughput is already limited to 12.5K RPS. If we increase the message size to 5 KB and the number of nodes to 50, we only get 500 RPS - much less than a single Redis instance could service (>100K RPS), while putting maximum pressure on the network. PubSub thus scales linearly wrt. to the cluster size, but in the the negative direction!
This leads me to my question: why not just redirect clients to the node responsible for the PubSub channel's hash slot owner, similar to normal data operations? Cluster nodes would thus only have to publish and notify locally, similar to keyspace notifications [3], and PubSub would be perfectly scalable. Sure, this would break PSUBSCRIBE for the cluster, but PSUBSCRIBE could be limited to only allow patterns containing a {hash-tag}, meaning that the subscription only pertains to channels containing that hash tag + matching the pattern (i.e. one specific node). As PSUBSCRIBE is semantically a multi-key operation, this would make perfect sense and be consistent with the rest of Redis Cluster.
In summary, I think the assumption that clients may publish and subscribe to any node is a dangerous guarantee that kills scalability. What do you think - could the above be the way to handle PubSub in Redis Cluster? Are there currently any workarounds to have PubSub scale in a Redis Cluster deployment?
[1] https://github.com/antirez/redis/issues/1927
[2] http://redis.io/topics/cluster-spec
[3] https://github.com/antirez/redis/issues/2541
P.S. Redis Cluster is a great project and highly value all the effort that goes into it!