You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Sharded pub/sub support via dedicated subscribers (#1956)
* Added sharded pub/sub support by implementing a cluster subscriber group
* Rewrote the resubscribe logic for sharded PubSub by making the sharded subscriber group aware of the channels.
* Fixed potentially leaking connections when calling disconnect on the cluster object
* Added and extended the integration test cases in regards to sharded pubsub.
* Added a Github action that allows running tests manually
* Provided documentation about how to use sharded pub/sub
---------
Co-authored-by: Tihomir Krasimirov Mateev <[email protected]>
For sharded Pub/Sub, use the `spublish` and `ssubscribe` commands instead of the traditional `publish` and `subscribe`. With the old commands, the Redis cluster handles message propagation behind the scenes, allowing you to publish or subscribe to any node without considering sharding. However, this approach has scalability limitations that are addressed with sharded Pub/Sub. Here’s what you need to know:
1202
+
1203
+
1. Instead of a single subscriber connection, there is now one subscriber connection per shard. Because of the potential overhead, you can enable or disable the use of the cluster subscriber group with the `shardedSubscribers` option. By default, this option is set to `false`, meaning sharded subscriptions are disabled. You should enable this option when establishing your cluster connection before using `ssubscribe`.
1204
+
2. All channel names that you pass to a single `ssubscribe` need to map to the same hash slot. You can call `ssubscribe` multiple times on the same cluster client instance to subscribe to channels across slots. The cluster's subscriber group takes care of forwarding the `ssubscribe` command to the shard that is responsible for the channels.
1205
+
1206
+
The following basic example shows you how to use sharded Pub/Sub:
0 commit comments