Adding a node to a running cluster, assigning slots, CLUSTER SETSLOT MIGRATING/IMPORTING, the MIGRATE command, zero-downtime resharding with ASKING redirections, and why resharding time scales with key count.
A-10 — Resharding, Node Addition, and Live Slot Migration
Who this module is for: Your Redis Cluster is under capacity and you need to add nodes, or you need to rebalance slot distribution after node failures and recoveries. Resharding moves hash slots between nodes while serving live traffic. This module covers the mechanics of slot migration, the ASKING redirection that enables zero-downtime resharding, and how to use the redis-cli cluster tooling.
Why Resharding?
After initial cluster creation, hash slots are distributed evenly. But over time, the distribution may become uneven:
- Capacity scaling: adding a new node requires migrating slots to it from existing nodes
- Data imbalance: some slots hold more data than others due to access patterns
- Node removal: removing a node requires migrating its slots elsewhere first
- Hotspot correction: if one node handles most traffic, rebalancing moves some slots to less-loaded nodes
Resharding is live — traffic continues flowing during migration. Keys in migrating slots are briefly accessible from both the source and destination during the transition.
Slot Migration: The States
A slot can be in one of three states during migration:
The MIGRATE Command
The low-level operation that moves a single key from one node to another:
MIGRATE host port key destination-db timeout [COPY] [REPLACE] [KEYS key [key ...]]
MIGRATE:
- Dumps the key's value (serializes to RDB format)
- Sends it to the destination node with
RESTOREsemantics - If the destination acknowledges: deletes the key from the source
- Atomic from the perspective of each node (the key exists on exactly one node at any moment)
Bulk migration with KEYS option:
MIGRATE 10.0.1.52 6379 "" 0 5000 KEYS user:1001 user:1002 user:1003
Slot Migration Protocol
The full protocol for migrating slot 7638 from Node A to Node B:
After CLUSTER SETSLOT 7638 NODE <node-B-id> is propagated to all nodes, the migration is complete. Normal MOVED redirections take over for slot 7638 pointing to Node B.
The ASKING Redirection During Migration
While slot 7638 is in MIGRATING state on Node A:
- Keys that haven't been migrated yet are still on Node A → served normally
- Keys that have been migrated are on Node B → Node A returns
-ASK 7638 10.0.1.52:6379
The client receiving an ASK redirection must:
- Send
ASKINGto Node B (one-time flag — tells Node B "I know you're importing this slot, accept this command") - Resend the original command to Node B
- Not update its slot map — slot 7638 is still officially on Node A until migration completes
Sign in to keep reading
The rest of this module is free — sign in with Google to unlock it and track your progress.
Sign in & RegisterDiscussion
0Join the discussion