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
We use redis.Ring to shard load across servers. We shard mainly PubSub related commands, PSUBSCRIBE, SUBSCRIBE, PUNSUBSCRIBE and UNSUBSCRIBE.
Because these commands put the redis connection in a special "pubsub" mode, after which you cannot use it for anything else than pubsub, we try to re-use these connections as much as possible.
What we'd like to do is set up a pubsub connection for every shard in the ring at application start, and then re-use that pubsub connection when we need to subscribe or unsubscribe on a topic.
However for that to be possible, we need two things:
access to the list of shards, so we can immediately create a pubsub connection for each shard in the ring
access to ringSharding.GetByKey so we can determine which shard pubsub connection we can re-use for a given topic
However, on redis.Ring the sharding attribute, which contains an instance of *ringSharding, is not publicly accessible, so we cannot access the shards list or the GetByKey function.
We are working around this for now, but it's rather ugly, because we need to make assumptions in our own code on how topics are distributed over the ring.
Would it be possible to make redis.Ring.sharding public, or at least provide some public methods on redis.Ring to return the list of shards access the GetByKey function?
I would be open to create a merge request if there is a chance of it being accepted.
The text was updated successfully, but these errors were encountered:
Hello @jaapz , as far as I remember, the distribution of keys for Ring will be done with consistent hashing and you can even provide the algorithm. @htemelski maybe you can take a look if it makes sense to export the ring sharding.
Correct, we're using that as well. But if we want to determine on our side which server will be returned for a given topic, then we need to basically copy code that is already present in redis.Ring. It would be nicer if we could simply call something like redis.Ring.Sharding.GetByKey(mytopic) or redis.Ring.GetByKey(mytopic) and get the shard like that.
We use
redis.Ring
to shard load across servers. We shard mainly PubSub related commands,PSUBSCRIBE
,SUBSCRIBE
,PUNSUBSCRIBE
andUNSUBSCRIBE
.Because these commands put the redis connection in a special "pubsub" mode, after which you cannot use it for anything else than pubsub, we try to re-use these connections as much as possible.
What we'd like to do is set up a pubsub connection for every shard in the ring at application start, and then re-use that pubsub connection when we need to subscribe or unsubscribe on a topic.
However for that to be possible, we need two things:
ringSharding.GetByKey
so we can determine which shard pubsub connection we can re-use for a given topicHowever, on
redis.Ring
thesharding
attribute, which contains an instance of*ringSharding
, is not publicly accessible, so we cannot access the shards list or the GetByKey function.We are working around this for now, but it's rather ugly, because we need to make assumptions in our own code on how topics are distributed over the ring.
Would it be possible to make
redis.Ring.sharding
public, or at least provide some public methods onredis.Ring
to return the list of shards access theGetByKey
function?I would be open to create a merge request if there is a chance of it being accepted.
The text was updated successfully, but these errors were encountered: