0
0
Redisquery~10 mins

Automatic failover in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Automatic failover
Primary Redis Server
Health Check by Sentinel
Continue
Replica Becomes New Primary
Clients Redirected to New Primary
The Sentinel monitors the primary Redis server. If it detects failure, it promotes a replica to primary and redirects clients automatically.
Execution Sample
Redis
SENTINEL MONITOR mymaster 127.0.0.1 6379 2
SENTINEL FAILOVER mymaster
Sentinel monitors the primary Redis server and triggers failover to a replica if needed.
Execution Table
StepActionConditionResultNotes
1Sentinel checks primary serverPrimary respondsNo failoverPrimary is healthy
2Sentinel checks primary serverPrimary does not respondFailover triggeredPrimary is down
3Sentinel selects replicaReplica is reachableReplica promotedReplica becomes new primary
4Clients redirectedClients connect to new primaryOperations continueFailover complete
5Sentinel continues monitoringNew primary respondsSystem stableMonitoring resumes
💡 Failover completes when a replica is promoted and clients connect to it successfully.
Variable Tracker
VariableStartAfter Step 2After Step 3Final
Primary StatusAliveDownDownDown
Replica StatusReplicaReplicaPromoted to PrimaryPrimary
Client ConnectionPrimaryPrimary (failed)SwitchingNew Primary
Key Moments - 3 Insights
Why does Sentinel promote a replica instead of restarting the primary?
Sentinel promotes a replica because the primary is unresponsive (see execution_table step 2), ensuring minimal downtime by switching to a healthy server.
How do clients know to connect to the new primary?
Clients are redirected after failover (execution_table step 4) because Sentinel updates the configuration or clients query Sentinel to find the current primary.
What happens if no replicas are available during failover?
Failover cannot complete without a reachable replica (execution_table step 3), so the system remains down until a replica is available.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step does Sentinel detect the primary is down?
AStep 2
BStep 3
CStep 1
DStep 4
💡 Hint
Check the 'Condition' and 'Result' columns in step 2 for primary server status.
According to variable_tracker, what is the status of the replica after step 3?
ADown
BPromoted to Primary
CStill a replica
DDisconnected
💡 Hint
Look at the 'Replica Status' row after step 3 in variable_tracker.
If the primary server never fails, what will the failover process do?
APromote a replica anyway
BClients will be redirected
CFailover will not trigger
DSentinel stops monitoring
💡 Hint
Refer to execution_table step 1 where primary responds and no failover occurs.
Concept Snapshot
Automatic failover in Redis Sentinel:
- Sentinel monitors primary Redis server health.
- If primary fails, Sentinel promotes a replica to primary.
- Clients are redirected to the new primary automatically.
- Ensures high availability with minimal downtime.
- Requires at least one healthy replica for failover.
Full Transcript
Automatic failover in Redis works by Sentinel continuously checking if the primary Redis server is alive. If Sentinel detects the primary is down, it promotes one of the replicas to become the new primary. Then, clients are redirected to connect to this new primary so operations can continue without interruption. This process ensures the system stays available even if the main server fails. Sentinel keeps monitoring the new primary to maintain system stability.