How does Redis Sentinel provide high availability?
Redis Sentinel monitors your primary, detects failure by quorum, and auto-promotes a replica. Learn how Sentinel delivers Redis high availability.
Expected Interview Answer
Redis Sentinel is a monitoring and failover system that watches a primary and its replicas, detects when the primary goes down, and automatically promotes a replica to primary so the service stays available without manual intervention.
A group of Sentinel processes continuously health-check the primary; when enough of them agree it is unreachable (the quorum), they elect a leader Sentinel that promotes the best replica and reconfigures the remaining replicas to follow the new primary. Sentinels also act as a discovery service, so clients ask Sentinel for the current primary address rather than hardcoding it, and they gossip state to each other for a consistent view of the topology.
- Automatic failover with no human intervention
- Continuous monitoring of primary and replicas
- Service discovery so clients always find the current primary
- Quorum-based decisions avoid false-positive failovers
- Notifications on state changes via pub/sub or scripts
AI Mentor Explanation
Sentinel is like the third umpire and match officials watching the on-field captain; the moment the captain is injured they confirm it together, agree on a vice-captain to lead, and tell every fielder who now calls the shots, all without stopping play.
Step-by-Step Explanation
Step 1
Deploy multiple Sentinels
Run at least three Sentinel processes on separate hosts so they can form a reliable quorum.
Step 2
Monitor the primary
Each Sentinel pings the primary and replicas on an interval to detect unresponsiveness.
Step 3
Subjective then objective down
One Sentinel marks the primary subjectively down; once the quorum agrees, it becomes objectively down.
Step 4
Elect a leader Sentinel
The Sentinels run a leader election so a single Sentinel coordinates the failover.
Step 5
Promote and reconfigure
The leader promotes the best replica to primary and repoints the other replicas and clients to it.
What Interviewer Expects
- Explaining monitoring, notification, failover, and discovery roles
- Describing subjective down versus objective down
- Understanding the quorum concept for failover decisions
- Knowing clients query Sentinel for the current primary
- Recommending an odd number of Sentinels (three or more)
Common Mistakes
- Confusing Sentinel with Redis Cluster's built-in failover
- Running only one or two Sentinels, breaking quorum guarantees
- Assuming Sentinel shards data — it only manages availability
- Forgetting clients must be Sentinel-aware to discover the new primary
Best Answer (HR Friendly)
“Redis Sentinel is like a set of supervisors that constantly checks whether the main Redis server is healthy. If it fails, they agree it is down, promote one of the backup servers to take over, and tell all the applications where the new main server is, so users barely notice.”
Code Example
# Monitor a primary named 'mymaster' at this address
# The trailing 2 is the quorum needed to declare failure
sentinel monitor mymaster 192.168.1.10 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 60000
sentinel parallel-syncs mymaster 1redis-cli -p 26379 SENTINEL get-master-addr-by-name mymaster
# 1) "192.168.1.10"
# 2) "6379"
# Start a Sentinel process
redis-sentinel /etc/redis/sentinel.confFollow-up Questions
- What is the difference between subjective down and objective down?
- Why should you run an odd number of Sentinels?
- How do clients discover the new primary after a failover?
- How does Sentinel differ from Redis Cluster failover?
- What happens if the old primary comes back online after failover?
MCQ Practice
1. What triggers Redis Sentinel to start a failover?
A failover starts only after the configured quorum of Sentinels marks the primary objectively down, avoiding failover on a single false alarm.
2. Besides failover, what other role does Sentinel serve?
Sentinel acts as a discovery service: clients ask it for the current primary's address instead of hardcoding it.
3. How many Sentinel processes are recommended for reliable quorum?
At least three Sentinels on separate hosts are recommended so a majority can still form a quorum if one fails.
Flash Cards
What are Sentinel's four roles? — Monitoring, notification, automatic failover, and configuration/service discovery.
Subjective vs objective down? — Subjective down is one Sentinel's opinion; objective down is when the quorum agrees the primary is unreachable.
What is the quorum? — The number of Sentinels that must agree the primary is down before failover begins.
How do clients find the new primary? — They query Sentinel with SENTINEL get-master-addr-by-name instead of hardcoding an address.
Continue Learning
Related Interview Questions
Why can a Redis failover lose acknowledged writes, and how do you reduce that risk?
hard
What is the difference between Redis replication and Redis Cluster?
medium
Can a read from a Redis replica return a key that has already expired, and how do you reason about staleness?
hard
How would you upgrade or migrate a live Redis deployment without downtime or data loss?
hard