Part 5 · 1 chapters · ~8 min
Replication, Sentinel and Cluster
Asynchronous replication with full and partial resync, WAIT, replica reads and staleness, Sentinel for automatic failover, Redis Cluster with 16,384 hash slots, gossip and failover, MOVED and ASK redirects, hash tags for multi-key operations, resharding, and managed offerings.
7
High availability and sharding
code
WAIT 1 100 # block until 1 replica acknowledged, up to 100 ms
redis-cli --cluster create a:6379 b:6379 c:6379 d:6379 e:6379 f:6379 --cluster-replicas 1
CLUSTER KEYSLOT "{acct:7}:balance" # same slot as "{acct:7}:limits" thanks to the hash tag
MSET {acct:7}:balance 500000 {acct:7}:limit 20000000 # works: one slotREPLICATION, SENTINEL AND CLUSTER
from one replica to 16,384 hash slots
swipe the figure sideways, or tap expand for full screen
1/5
replication
Replicas copy the primary asynchronously: a full sync (RDB transfer) first, then a stream of commands. Acknowledged writes can be lost if the primary fails before replicating them; WAIT numreplicas narrows that window.
asynchronous replicationWAIT for stronger acknowledgement