Redis Cluster with 3 shards (master + replica), Sentinel failover, write/read/failover scenarios
This architecture demonstrates a production Redis Cluster deployment with automatic failover. The cluster is sharded across 3 master nodes, each with a dedicated replica for high availability. A Sentinel ensemble monitors all masters and orchestrates automatic promotion of replicas when a master fails. This design provides horizontal write scalability, read scaling through replicas, and sub-second failover without manual intervention.
Redis Cluster divides the keyspace into 16,384 hash slots. Each master node owns a contiguous range of slots. When a client writes a key, Redis computes CRC16(key) mod 16384 to determine which slot (and therefore which master) owns that key.
In a 3-shard cluster, the typical slot distribution is:
This deterministic mapping means clients can compute the target node locally, avoiding a central routing layer. When a client sends a command to the wrong node, Redis returns a MOVED redirect, and smart client libraries cache the slot-to-node mapping to minimize redirects.
Each shard consists of one master and one (or more) replicas:
READONLY mode.The replication is asynchronous by default, which means a master acknowledges writes before the replica confirms receipt. This provides lower write latency at the cost of potential data loss during failover (the replica may be slightly behind the master). For workloads that require stronger guarantees, WAIT can be used to block until a specified number of replicas acknowledge the write.
Three shards is the minimum for a production Redis Cluster because:
Redis Sentinel is a distributed monitoring system that runs alongside the cluster. Sentinel instances continuously ping all master and replica nodes. When a master becomes unreachable, Sentinel coordinates a failover:
down-after-milliseconds of missed heartbeats.A minimum of 3 Sentinel instances is required for reliable failover. The quorum (typically 2 out of 3) prevents split-brain scenarios where network partitions cause conflicting failovers. Sentinel instances should be deployed on separate hosts or availability zones to tolerate infrastructure failures.
sentinel monitor shard-1 master-1-host 6379 2
sentinel monitor shard-2 master-2-host 6379 2
sentinel monitor shard-3 master-3-host 6379 2
sentinel down-after-milliseconds shard-1 5000
sentinel failover-timeout shard-1 15000
MOVED redirect).For read-heavy workloads, clients can direct read queries to replicas:
READONLY to a replica node.Note that reads from replicas may return slightly stale data due to asynchronous replication. This is acceptable for caching use cases but not for operations that require read-after-write consistency.
When Master 1 crashes:
Choose Redis Cluster when:
Choose Sentinel without Cluster when:
| Feature | Redis Cluster + Sentinel | Sentinel Only |
|---|---|---|
| Sharding | Automatic (hash slots) | None (single master) |
| Write scaling | Horizontal (across shards) | Vertical (single node) |
| Max dataset size | Sum of all shard memories | Single node memory |
| Client complexity | Cluster-aware client required | Standard client with Sentinel discovery |
| Operational complexity | Higher (more nodes to manage) | Lower (3 nodes + Sentinels) |
appendonly yes with appendfsync everysec for durability without sacrificing throughput.info replication), memory usage, and command latency per shard. Alert on replication lag exceeding 1 second.redis-cli --cluster reshard to migrate slots from existing masters to the new one with zero downtime.