I'm currently using a setup with 3 shards, where each shard has a replica. I use non-sharded Publish with the intent of having the channel available on all nodes (shards and replicas) and randomly distributing Subscribe workers across all nodes.
When connecting my clients to the Redis Cluster, I noticed that all Subscribe commands go to a single shard; the only thing I can configure is whether it targets the master or a replica. The culprit seems to be here:
|
slot := hashtag.Slot(channels[0]) |
. A slot is being picked for the channel even though it is not a sharded Pub/Sub.
I tried to circumvent this by creating an empty subscription to pick a node at random, then using that subscription to subscribe to the channel once the node and connection were assigned. However, everything still ended up on the same shard. I suspect this could be due to pseudorandom node picking; as I am doing this at app startup, it may always be getting the same random number sequence.
Is something similar already in progress? If not, I would like to contribute and add a way to have a configurable strategy for Subscribe on the Cluster client (e.g., ReadOnly, Master, or Random).
I'm currently using a setup with 3 shards, where each shard has a replica. I use non-sharded Publish with the intent of having the channel available on all nodes (shards and replicas) and randomly distributing Subscribe workers across all nodes.
When connecting my clients to the Redis Cluster, I noticed that all Subscribe commands go to a single shard; the only thing I can configure is whether it targets the master or a replica. The culprit seems to be here:
go-redis/osscluster.go
Line 1969 in 33ca5cb
I tried to circumvent this by creating an empty subscription to pick a node at random, then using that subscription to subscribe to the channel once the node and connection were assigned. However, everything still ended up on the same shard. I suspect this could be due to pseudorandom node picking; as I am doing this at app startup, it may always be getting the same random number sequence.
Is something similar already in progress? If not, I would like to contribute and add a way to have a configurable strategy for Subscribe on the Cluster client (e.g., ReadOnly, Master, or Random).