Skip to content

Lesson 9 of 9 · 30m

Redis Cluster Operations: Slots, Resharding, and Scaling Honestly

Operate hash slots, multi-key constraints, node failure, resharding, client routing, and capacity growth without breaking application invariants.

Redis Cluster solves a specific problem: horizontal partitioning of the keyspace across multiple primaries with automatic failover. It does not solve application design, cross-key transactions, operational discipline, or the human desire to pretend distributed systems are simpler than they are. If you cannot explain hash slots, do not put cluster mode into production.

Hash slots are the unit of ownership

Redis Cluster divides the keyspace into 16,384 slots. A key maps by CRC16 of its hash tag:

user:{u_934}:profile   slot determined by u_934
user:{u_934}:settings  same slot as above
session:01JRYC          slot determined by whole key

Curly-brace hash tags let related keys live together. Use them only when commands genuinely need multi-key access. Overusing one tag creates a hot slot and defeats sharding.

Inspect ownership:

redis-cli --cluster info 10.20.30.10:6379
redis-cli cluster slots
redis-cli cluster keyslot 'user:{u_934}:profile'

Multi-key operations have hard boundaries

MGET, SUNION, Lua scripts touching multiple keys, and transactions require keys in the same slot when evaluated in cluster mode. Clients receive CROSSSLOT otherwise:

CROSSSLOT Keys in request don't hash to the same slot

This is not Redis being fussy. Network partitions and independent nodes make arbitrary multi-key atomicity expensive or impossible. Redesign the data model, use hash tags, denormalize, or perform controlled multi-step application logic with idempotency.

Cluster-aware clients are mandatory

Clients must follow MOVED and ASK redirects, refresh topology, and reconnect intelligently. Test client behavior during resharding before production. A naive client can amplify redirects into latency and error storms even when Redis itself is healthy.

redis-cli -c GET user:{u_934}:profile

The -c mode makes redis-cli follow redirects, useful for exploration. It does not prove your application client behaves correctly under failover.

Resharding is online but not invisible

Moving slots migrates key ownership while serving traffic. The workflow is conceptually:

redis-cli --cluster reshard 10.20.30.10:6379   --cluster-from <source-node-id>   --cluster-to <target-node-id>   --cluster-slots 1000   --cluster-yes

During migration, keys can be in source, target, or transitional ASK states. Operations need enough capacity for both migration traffic and client behavior. Reshard gradually during controlled windows, monitor latency, and do not treat automation as proof that applications tolerate it.

Scaling reads and writes are different problems

Adding primaries increases write and memory capacity but reshuffles ownership. Adding replicas can increase read capacity and failover resilience but does not increase write throughput. Cluster mode also multiplies operational surface: more nodes, more replication links, more gossip, more failure combinations.

Operations checklist

before change: cluster state stable, no failed nodes, backups/restores known
during change: migration progress, latency, errors, memory, client redirects
after change:  slot coverage complete, replicas aligned, topology refreshed

The cluster must show exactly 16,384 slots covered by healthy primaries. Gaps mean some keys are simply unreachable.

Field notes

  • Cluster failover still uses asynchronous replication. Write loss windows do not vanish because partitioning exists.
  • Do not scale by adding nodes during an active incident unless the incident is understood; resharding adds load.
  • Hot keys remain hot regardless of slot count. Partitioning cannot fix a single extremely hot key.
  • Redis Cluster bus ports matter. Firewalls that allow 6379 but block the cluster bus produce confusing partial failures.

Was this lesson helpful?

Sign in to rate