Skip to content

[FEATURE] Provide shard id to clients #650

@kihaloul

Description

@kihaloul

We require to know to which shard the redis command will be sent. The reason is that we a re implementing a migration procedure from one redis cluster to another, and we need to know if the redis shard is under migration or not, so that the DB clients can then switch to the other redis cluster.

I think a good solution for this could be:

  1. Create a variant of the ShardPool::fetch() method, which also returns the shard index or shard name
  2. Expose this variant via the RedisCluster class
  3. Create a variant of the RedisCluster ::eval(), evalsha() and RedisCluster ::command() functions, which will accept the shard as an argument, This is only for performance, because the client that has already called fetch() already knows the shard and can then pass the shard to the eval() or command, in order to avoid the extra call to ShardPool::fetch().

Actually 3) is optional, as it is only for better performance. Most important for our purposes are 1) and 2).

We have considered other alternatives, mainly to synchronize the DB clients to switch to the other redis cluster. However using the redis itself to synchronize provides the best guarantees for data consistency.

Do you think implementing something like the above is possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions