Command Palette

Search for a command to run...

Hectal
Phase 11Advanced12 of 17 in Redis

Redis Cluster

16,384 hash slots, CRC16, hash tags and CROSSSLOT, MOVED vs ASK, resharding without downtime, replica elections, and running clusters in production.

When one Redis can't hold the data or serve the traffic, Redis Cluster shards keys across many primaries, each with replicas, and fails over automatically without Sentinel.

Senior interviews expect you to trace a key from its name to a node, explain every redirect a client can see, and describe what happens to availability and data when a shard's primary dies.

0/5 · 0%
5 topics ~46 min 10 code blocks & diagrams
Start with the first topic
1
11.1

Cluster Architecture: Slots, Nodes, and the Cluster Bus

Redis Cluster splits the keyspace into 16,384 hash slots: slot = CRC16(key) mod 16384. Each primary owns a range of slots, replicas copy their primary, and nodes gossip over a cluster bus to agree on topology and detect failures. Clients cache the slot map and talk directly to the right node.

10 min 1 diagram 1 code practice

2
11.2

Hash Tags and Multi-Key Operations

If a key contains {...} with at least one character inside, only that part is hashed. Keys that share a tag land in the same slot, which makes MGET, transactions and Lua across them possible. Choose tags carefully: too coarse a tag creates hot and oversized shards.

9 min 2 code practice

3
11.3

MOVED, ASK, and Resharding

MOVED tells a client a slot now lives on another node permanently, so update the slot map. ASK tells it that during a migration this one key has already moved, so try once on the target with ASKING. Resharding moves slots key by key while the cluster keeps serving.

9 min 1 diagram 1 code practice

4
11.4

Cluster Failover and Failure Modes

When a primary stops responding for cluster-node-timeout, other primaries mark it PFAIL then FAIL, its replicas hold an election that needs a majority of primaries, and the winner takes over the slots with a higher config epoch. If a shard loses its primary and all replicas, the cluster stops serving by default.

9 min 1 diagram 1 code practice

5
11.5

Operating Clusters and Choosing a Topology

Choose between standalone with replicas, Sentinel, Cluster, client-side sharding or a proxy based on data size, throughput, multi-key needs and client support. Then operate it: balanced slots, zone-aware placement, per-node monitoring, safe upgrades and capacity headroom.

9 min 1 diagram 1 code practice