What is the purpose of the ASK redirect in Redis Cluster?
sobes.tech AI
Answer from AI
In Redis Cluster, the ASK redirect is used in situations where the key the client is accessing is temporarily moved to another cluster node, for example, during the process of migrating a slot between nodes. In this case, the server sends an ASK response to the client, which means: "Make a request to the specified node, but first send the ASKING command."
The ASKING command informs the new node that the next request is related to slot migration, and it should accept this request even if the slot is not fully assigned to it yet. This differs from the MOVED redirect, which indicates that the slot is permanently assigned to another node, and the client should update its slot map.
Example sequence:
- The client sends a command to node A.
- Node A responds with ASK, providing the address of node B.
- The client sends the ASKING command to node B.
- The client resends the original command to node B.
Thus, the ASK redirect ensures correct client operation during dynamic data migration in Redis cluster.