Difficulty: Advanced
What is the difference between Redis Sentinel and Redis Cluster? When would you choose each?
Redis Sentinel provides high availability for a single primary with replicas: a group of Sentinel processes monitors the primary, agrees when it is down, promotes a replica, and tells clients the new address. Redis Cluster shards data across multiple primaries using 16,384 hash slots, and each primary has replicas with failover built in. Use Sentinel when your data fits on one machine and you just need failover; use Cluster when you need to scale memory or write throughput beyond one node.
down-after-milliseconds, it marks it subjectively down (SDOWN).quorum Sentinels agree, the primary is objectively down (ODOWN). A leader Sentinel is then elected (needs a majority of all Sentinels) and runs the failover: picks the best replica by priority and replication offset, sends REPLICAOF NO ONE, and repoints the others.SENTINEL get-master-addr-by-name mymaster to discover the current primary.CRC16(key) mod 16384. Each primary owns a range of slots.MOVED redirect; during resharding it may get ASK. Cluster-aware clients cache the slot map.{user:42}:cart and {user:42}:orders hash only user:42.| Aspect | Sentinel | Cluster |
|---|---|---|
| Main goal | High availability | Horizontal scaling plus HA |
| Data distribution | Full dataset on every node | Split across primaries by slot |
| Write scaling | One primary only | One primary per shard |
| Multi-key operations | Any keys | Same slot only (CROSSSLOT error otherwise) |
| Extra processes | Sentinel daemons | None |
| Client requirement | Sentinel-aware discovery | Cluster-aware, handles redirects |
| Multiple databases | Yes | Only DB 0 |
WAIT and min-replicas-to-write reduce, but do not remove, this window.A session store of a few GB for a startup: one primary, two replicas, three Sentinels. A product cache or rate limiter for a Swiggy-scale app that needs hundreds of GB and very high write throughput: Cluster. Managed services (AWS ElastiCache, Azure Cache, Redis Cloud) offer both as "cluster mode disabled" and "cluster mode enabled".
# sentinel.conf (run on 3 separate hosts)
sentinel monitor mymaster 10.0.0.1 6379 2 # quorum = 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 60000
# Ask a Sentinel where the primary is
redis-cli -p 26379 SENTINEL get-master-addr-by-name mymaster
# Create a 3-primary, 3-replica cluster (nodes started with cluster-enabled yes)
redis-cli --cluster create \
10.0.0.1:6379 10.0.0.2:6379 10.0.0.3:6379 \
10.0.0.4:6379 10.0.0.5:6379 10.0.0.6:6379 \
--cluster-replicas 1
# Which slot does a key live in?
redis-cli -c CLUSTER KEYSLOT '{user:42}:cart'
Sentinel needs a monitor line with a quorum; Cluster nodes are joined with redis-cli --cluster and keys are routed by slot, with hash tags controlling co-location.
Redis Sentinel, Redis Cluster, Automatic Failover, Hash Slots, Sharding, Quorum