Databases 4 min read

Understanding MOVED and ASK Redirection in Redis Cluster

Redis clusters use two redirection commands—MOVED for permanently migrated hash slots and ASK for temporary redirects during slot migration—explaining their trigger conditions, typical scenarios, and step-by-step client interaction examples, including sample CLI output.

Full-Stack Internet Architecture
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Understanding MOVED and ASK Redirection in Redis Cluster

In a Redis cluster, when a client requests a key whose hash slot is not served by the current node, the node returns a redirection error directing the client to the correct node.

There are two redirection commands: MOVED and ASK . Both cause redirection but are used at different times. MOVED is returned when the slot has permanently moved to another node, while ASK is a temporary redirect during slot migration, such as when re‑sharding.

1. MOVED redirection

Trigger condition: The requested key’s hash slot is permanently assigned to another node.

Typical scenario: Cluster topology changes like node scaling or slot reallocation.

Example flow:

1. Client sends GET key1 to node A.

2. Node A checks the slot; if key1’s slot (e.g., 5000) is outside A’s range (0‑4000), it returns a MOVED error.

3. Node A replies MOVED 5000 127.0.0.1:7002 .

4. The client caches the mapping of slot 5000 to node B and directs subsequent requests to node B.

Example CLI output:

127.0.0.1:7000> get love (error) MOVED 16198 127.0.0.1:7002

2. ASK redirection

Trigger condition: The key’s hash slot is in the process of migrating, with data split between the old and new nodes.

Typical scenario: During slot migration before it is fully completed.

Example flow:

1. Slot 5000 is moving from node B to node C; key1 has already moved to node C, but node B’s metadata is not updated.

2. Client sends GET key1 to node B.

3. Node B replies ASK 5000 127.0.0.1:7003 .

4. The client temporarily redirects by sending an ASKING command to node C, then executes GET key1 without updating its slot cache, because the slot is still owned by node B until migration finishes.

databaseRedisClusterASKMOVEDRedirection
Full-Stack Internet Architecture
Written by

Full-Stack Internet Architecture

Introducing full-stack Internet architecture technologies centered on Java

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.