-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieving Shards information from RedisCluster #260
Comments
What's your scenario? Can you give some example? Since redis-plus-plus will cache the slot mapping, when you send commands to Redis Cluster, it, in fact, sends the command to the right node directly. There won't be any performance penalty. Even if you get the underlying ShardPool, it might not help. Because if the slot-mapping changes (it might change just after you get the ShardsPool), ShardsPool will be out-of-date, and you need to manually update it. Regards |
Thanks for the quick response. The use case is specific to a Redis module being used. The general idea is that a copy of data is placed on every cluster node to facilitate efficient parallel computation. This placement of copied data requires knowing the cluster slots assigned to each database node. Re-sharding is not a concern in this specific use case. |
If I understand correctly, it seems that you don't even need a Redis Cluster, instead, you need several standalone Redis instances. So that you can parallel the computation. You can create a If you insist on using a
In fact, you can manually create a
The constructor will call
As I mentioned in above comments, this mapping might change at any time. With such a method, you might get an out-of-date info, and it might mislead you. I'll keep this issue open to see if others have similar requirements for the node-slot mapping. If you still have any problem on it, feel free to post it. Regards |
I have a use case for this, actually. We're using Redis JSON, and in particular, JSON.MGET which (with redis++) demands that we use the command interface. However, general multikey queries will only be routed to the node associated to the first key, so we need to collect keys which we know (via the hashslot) will be on a particular node and send them in one batch. For example, if we have five keys (1, 2, 3, 4, 5) on two nodes (A, B), where 1,2,3 are on A and 4,5 are on B, then this command will fail: JSON.MGET 1 2 3 4 5 $ And there will be two nil's in the output (associated to keys 4, 5). Thus we need to send two commands: JSON.MGET 1 2 3 $ Where we compute the hashslots of 1, 2, 3, 4, 5 and divide them properly. In our case, we have several million keys that need to be divided in this way. Consequently, having access to the hashslot ranges associated to each node would be helpful. |
@mlaczin If I understand correctly, even if you get the slot range info, you cannot call One solution is that you can use hash-tag to ensure these keys belong to the same slot. Once you do that, you can call Regards |
For the application I am working on, it is helpful for performance to know the layout of the redis cluster with regards to hash slot distribution between the nodes. Is it possible to retrieve this information from RedisCluster? It seems like there isn't any access methods for the private member variable
ShardsPool _pool
. I'd like to avoid a redundantCLUSTER SLOTS
command since this is done duringRedisCluster
object creation, andRedisCluster
maintains the most up-to-date information on shards. If there isn't a method, would the community be open to a method that returns access to_pool
for inspection but not modification?The text was updated successfully, but these errors were encountered: