Quick revision
The short answer
Each Sentinel pings the primary and marks it subjectively down after down-after-milliseconds without a valid reply; when at least quorum Sentinels agree, it is objectively down. A failover then needs one Sentinel elected leader by a majority of all Sentinels, which picks the best replica by priority, replication offset and run ID, promotes it with REPLICAOF NO ONE and repoints the others. Clients ask a Sentinel for the current primary's address and ask again after a switch or a connection error.
What to remember
In this answer, we saw that Sentinels detect a failure in two stages, subjectively down after down-after-milliseconds and objectively down when quorum Sentinels agree, and that a failover also needs a leader elected by a majority of all Sentinels. The leader picks the replica by priority, offset and run ID, promotes it with REPLICAOF NO ONE and repoints the rest, and clients resolve the primary through SENTINEL get-master-addr-by-name, which Spring Boot does from its sentinel properties. We closed with three Sentinels in independent failure domains and the reminder that Sentinel is failover, not sharding.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Each Sentinel pings the primary and marks it subjectively down after down-after-milliseconds without a valid reply; when at least quorum Sentinels agree, it is objectively down. A failover then needs one Sentinel elected leader by a majority of all Sentinels, which picks the best replica by priority, replication offset and run ID, promotes it with REPLICAOF NO ONE and repoints the others. Clients ask a Sentinel for the current primary's address and ask again after a switch or a connection error.
Why this question is asked
Sentinel is the standard high-availability setup for a Redis dataset that fits on one primary, and most Spring Boot services that use Redis in production sit behind one. Knowing how it decides makes the difference when something goes wrong: why a failover did not happen, why it took 30 seconds, or why two primaries appeared. Interviewers ask this question to check that we can separate detection from authorisation and explain how clients follow the change. In this answer, we will recap what Sentinel is, follow the detection, the leader election and the replica choice, look at how clients find the new primary, and finish with deployment rules.
1A Quick Recap of Sentinel
Sentinel is a separate Redis process, usually on port 26379, that monitors a named primary such as mymaster. It discovers the replicas from the primary's INFO output and the other Sentinels through a shared pub/sub channel on the primary. A deployment typically has three or five Sentinels on different machines. Together they detect failures, agree on a failover, promote a replica and publish the new address.
2Detecting a Failure: SDOWN and ODOWN
Each Sentinel sends PING to the primary every second. If no valid reply arrives for down-after-milliseconds, 30 seconds by default and usually lowered to a few seconds, that Sentinel marks the primary subjectively down, SDOWN. Subjective because it is one opinion, which may be caused by that Sentinel's own network problem.
The Sentinel then asks the others what they see. When at least quorum Sentinels report the primary as down, it becomes objectively down, ODOWN. The quorum is the number in the sentinel monitor line, 2 above. It controls only detection: how many opinions are needed before anyone tries to fail over.
3Electing a Leader and Choosing the Replica
Detection is not permission. To actually fail over, a Sentinel must be elected leader for a new configuration epoch, a counter that numbers each failover attempt, by a majority of all Sentinels, not just of those that are reachable. Each Sentinel votes once per epoch. So with five Sentinels and a quorum of 2, two Sentinels can declare ODOWN, but three must vote for a leader. If only two are reachable, nobody fails over. This majority rule is what prevents a minority partition from promoting its own primary.
The leader then chooses a replica. It drops replicas with replica-priority 0, which are configured never to be promoted, and replicas whose link to the primary has been down too long, because their data is likely old. Among the rest, it prefers the lowest replica-priority value, then the largest replication offset (the most data), then the lexicographically smallest run ID as a tie-breaker. It sends REPLICAOF NO ONE to the winner, waits for it to report itself as primary, and sends REPLICAOF to the other replicas, a few at a time according to parallel-syncs.
- Sentinel gets no valid reply for down-after-millisecondsSDOWN
- At least quorum Sentinels agree?YesODOWNNoKeep watching
- Leader elected by a majority of all Sentinels?YesLeader runs the failoverNoNo failover, retry later
- Pick replica: priority, then offset, then run IDskip priority 0 and stale links
- REPLICAOF NO ONE to the winnernew primary
- Repoint other replicas, publish +switch-masterclients follow
6 steps in order. Play them, or step through them one at a time.
4How Clients Find the New Primary
Clients do not hard-code the primary's address. They connect to any Sentinel and ask SENTINEL get-master-addr-by-name mymaster, which returns the current IP and port. After a failover, Sentinels publish a +switch-master event, and a client that sees it, or sees connection errors, asks again and reconnects.
With these two properties, Spring Boot builds a Sentinel-aware Lettuce connection that resolves the primary through the Sentinels and resolves again after a failover, so application code does not change.
5Deployment Rules
Run at least three Sentinels, each in its own failure domain, such as separate hosts or availability zones, so losing one machine leaves a majority. Placing two of three on the same host as the primary means one host failure removes the majority and no failover can happen.
And remember what Sentinel does not do. It provides failover for one primary and its replicas. It does not shard data, add write capacity or make replication synchronous. When the dataset or the write load outgrows one primary, the answer is Redis Cluster.
6Follow-up questions
Why is a quorum of 1 dangerous?
With quorum 1, a single Sentinel's opinion is enough for ODOWN. If that Sentinel has a network problem and cannot reach a healthy primary, it declares ODOWN and asks to be leader, and the others vote for it because votes are granted per epoch. The result is a needless failover, with clients reconnecting and recent writes possibly lost. A quorum of 2 with three Sentinels means at least two independent views must agree before a failover starts.
Can a failover lose writes?
Yes. Replication is asynchronous, so writes acknowledged by the old primary but not yet replicated are lost when a replica is promoted. min-replicas-to-write limits this for an isolated primary, but does not eliminate it.
What happens when the old primary comes back?
The Sentinels see it and reconfigure it as a replica of the new primary. It then performs a sync and discards any writes it accepted that were not replicated.
7Conclusion
In this answer, we saw that Sentinels detect a failure in two stages, subjectively down after down-after-milliseconds and objectively down when quorum Sentinels agree, and that a failover also needs a leader elected by a majority of all Sentinels. The leader picks the replica by priority, offset and run ID, promotes it with REPLICAOF NO ONE and repoints the rest, and clients resolve the primary through SENTINEL get-master-addr-by-name, which Spring Boot does from its sentinel properties. We closed with three Sentinels in independent failure domains and the reminder that Sentinel is failover, not sharding.
Open with
Each Sentinel pings the primary every second, and if it gets no valid reply for down-after-milliseconds, which is 30 seconds by default but usually lowered, it marks the primary subjectively down.
Then, if they want more
It asks the other Sentinels, and when at least the quorum agree, the primary is objectively down. The quorum only controls detection, though. To actually fail over, one Sentinel must be elected leader for a new configuration epoch by a majority of all Sentinels, so with five Sentinels and quorum 2, three still have to be reachable.
The leader then picks a replica: it skips replicas with priority 0 or a link that has been down too long, prefers the lowest priority value, then the largest replication offset, then the smallest run ID. It sends REPLICAOF NO ONE to the winner and points the other replicas at it.
Clients never hard-code the primary; they ask a Sentinel with SENTINEL get-master-addr-by-name and ask again after a switch-master event or a connection error. In Spring Boot I just set spring.data.redis.sentinel.master and the sentinel nodes, and Lettuce handles that.
I would run at least three Sentinels in independent failure domains, and I would remember that Sentinel gives failover only, not sharding or more write capacity.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Redis documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How do Sentinels decide that a primary is down and who runs the failover, how is the new...": https://scrivio-interview-library.netlify.app/databases/redis-scaling/45aa41eab3/