Sentinel as an independent high-availability process, subjective down vs objective down, the failover election sequence, min-replicas-to-write for split-brain prevention, and what Sentinel cannot protect against.
A-8 — Redis Sentinel: Quorum, Failover, and Split-Brain Prevention
Who this module is for: You want Redis to automatically recover from a primary failure — promoting a replica and reconfiguring clients — without manual intervention. Redis Sentinel is the high-availability solution for single-node (non-Cluster) Redis deployments. This module covers the Sentinel model, the failover sequence, split-brain prevention, and Sentinel's limitations.
What Sentinel Is
Redis Sentinel is a separate process (not part of Redis itself) that monitors a Redis primary and its replicas. When the primary fails, Sentinel:
- Detects the failure (agrees with other Sentinels that the primary is down)
- Elects a leader Sentinel to run the failover
- Selects the best replica to promote
- Promotes the chosen replica to primary
- Configures other replicas to replicate from the new primary
- Notifies clients of the new primary address
Sentinel is not a proxy — it does not route traffic. It is a monitoring and orchestration layer that clients query to discover the current primary address.
Deployment Topology
A minimum Sentinel setup requires 3 Sentinel processes on separate machines. An odd number is required for quorum.
Machine 1: Redis Primary + Sentinel 1
Machine 2: Redis Replica + Sentinel 2
Machine 3: Redis Replica + Sentinel 3
Clients connect to any Sentinel to discover the current primary's IP and port. They then connect directly to the primary for all operations.
Sentinel Configuration
# sentinel.conf (same format for all Sentinel instances)
sentinel monitor mymaster 10.0.1.50 6379 2
# Name: mymaster
# Primary: 10.0.1.50:6379
# Quorum: 2 (how many Sentinels must agree the primary is down before failover)
sentinel auth-pass mymaster your-primary-password
sentinel down-after-milliseconds mymaster 5000
# Mark primary as "subjectively down" if unreachable for 5 seconds
sentinel failover-timeout mymaster 60000
# Maximum time to complete a failover (60 seconds)
sentinel parallel-syncs mymaster 1
# How many replicas can sync from new primary simultaneously during failover
# 1 = replicas sync one at a time (slower failover but less load spike)
The Failure Detection Sequence
Step 1: Subjective Down (SDOWN)
A single Sentinel marks the primary as "subjectively down" if it cannot reach the primary within down-after-milliseconds. This is one Sentinel's opinion — a network blip between just that Sentinel and the primary would cause an SDOWN that does not represent a real failure.
Sentinel 1: PING to primary... timeout (5 seconds)
Sentinel 1: Primary is SDOWN (subjectively down — my opinion only)
Step 2: Objective Down (ODOWN)
A Sentinel queries other Sentinels: "Do you also think the primary is down?" If at least quorum Sentinels agree, the primary is declared "objectively down" (ODOWN) — a real failure.
Sentinel 1 → Sentinel 2: "Is mymaster down?" → Yes (SDOWN)
Sentinel 1 → Sentinel 3: "Is mymaster down?" → Yes (SDOWN)
Sentinel 1: Quorum reached (2/3) → primary is ODOWN
With quorum 2: at least 2 of 3 Sentinels must agree. This prevents a single Sentinel's network issue from triggering an unnecessary failover.
Step 3: Leader Election
One Sentinel must be elected to lead the failover. Sentinel uses a Raft-like election: each Sentinel requests votes from others. The first to receive a majority becomes the failover leader.
Step 4: Replica Selection
The leader Sentinel chooses which replica to promote. Selection criteria (in order of preference):
- Replica with the lowest
slave-priority(configured asreplica-priorityin replica's redis.conf) - Replica with the smallest replication lag (most up-to-date data)
- Replica with the smallest Run ID (lexicographically) as tiebreaker
sentinel slave-priority: lower is preferred for promotion
# replica-priority 100 (default)
# replica-priority 0 means "never promote this replica" (e.g., replica used for backups)
Step 5: Failover Execution
1. Leader Sentinel sends REPLICAOF NO ONE to the chosen replica → it becomes primary
2. Leader Sentinel configures remaining replicas: REPLICAOF {new-primary-ip} {port}
3. Leader Sentinel updates its own configuration with the new primary address
4. Other Sentinels update their configuration
5. Sentinel publishes +switch-master event on the __sentinel__:hello channel
Sign in to keep reading
The rest of this module is free — sign in with Google to unlock it and track your progress.
Sign in & RegisterDiscussion
0Join the discussion