Advertisement
Advanced Redis, Pub/Sub

How does Redis Pub/Sub behave differently in a Redis Cluster environment compared to a single instance setup?

Short answer

In a standard Redis Cluster, published messages are automatically forwarded to all nodes in the cluster so that a subscriber connected to any node receives messages published from any other node, though this cluster wide message propagation adds some additional overhead, and…

Save Redis mock interview
Advertisement
AModel answer
In a standard Redis Cluster, published messages are automatically forwarded to all nodes in the cluster so that a subscriber connected to any node receives messages published from any other node, though this cluster wide message propagation adds some additional overhead, and Redis also offers sharded Pub/Sub as an alternative that restricts message propagation to reduce this overhead for cluster deployments with heavy Pub/Sub usage.
Example

-- Sharded Pub/Sub commands, introduced for cluster efficiency SSUBSCRIBE mychannel SPUBLISH mychannel 'message'

Real-world example
A large scale application running Redis Cluster switches from regular Pub/Sub to sharded Pub/Sub commands, reducing the cluster wide message propagation overhead that had been affecting performance under their heavy notification traffic.
Likely follow-ups
  • What is the specific difference between regular and sharded Pub/Sub commands?
  • When does the overhead of cluster wide Pub/Sub propagation actually become a meaningful problem?
Related topics