Why Sentinel provides high availability in Redis - Performance Analysis
We want to understand how Redis Sentinel manages to keep your data available even if some parts fail.
How does the system react and how fast does it do this as the number of servers grows?
Analyze the time complexity of Sentinel's failover process.
# Sentinel monitors master and replicas
SENTINEL MONITOR mymaster 127.0.0.1 6379 2
# Detects master failure
SENTINEL FAILOVER mymaster
# Sets failover timeout
SENTINEL SET mymaster failover-timeout 60000
This code shows Sentinel monitoring a master, detecting failure, and promoting a replica to master.
Sentinel repeatedly checks the health of each server.
- Primary operation: Periodic health checks (pings) to all monitored servers.
- How many times: Once per server, repeated continuously.
As the number of servers increases, Sentinel must check more servers.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 servers | 10 health checks per cycle |
| 100 servers | 100 health checks per cycle |
| 1000 servers | 1000 health checks per cycle |
Pattern observation: The number of health checks grows directly with the number of servers.
Time Complexity: O(n)
This means the time Sentinel spends checking servers grows in a straight line as you add more servers.
[X] Wrong: "Sentinel can detect failures instantly no matter how many servers there are."
[OK] Correct: Because Sentinel must check each server, more servers mean more checks and slightly longer detection times.
Understanding how Sentinel scales its monitoring helps you explain real-world system reliability and how distributed systems handle failures.
"What if Sentinel used a different method that only checked a few servers each cycle? How would that change the time complexity?"