0
0
Redisquery~10 mins

Client discovery through Sentinel in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Client discovery through Sentinel
Client starts
Query Sentinel for master info
Sentinel responds with master address
Client connects to master
If master fails
Sentinel elects new master
Client queries Sentinel again
Client connects to new master
Repeat as needed
Client asks Sentinel for the current master address, connects to it, and if the master changes, repeats the discovery to stay connected to the right server.
Execution Sample
Redis
SENTINEL get-master-addr-by-name mymaster
// Client receives master IP and port
// Client connects to master
// On failover, client queries Sentinel again
Client asks Sentinel for the master address, then connects to that master, updating if Sentinel reports a new master.
Execution Table
StepActionSentinel ResponseClient ActionResult
1Client sends 'SENTINEL get-master-addr-by-name mymaster'Returns ['192.168.1.10', '6379']Connect to 192.168.1.10:6379Connected to master
2Master failsSentinel elects new master '192.168.1.11:6379'Client sends 'SENTINEL get-master-addr-by-name mymaster' againGets new master address
3Client receives new master addressReturns ['192.168.1.11', '6379']Connect to 192.168.1.11:6379Connected to new master
4No further failoverSentinel continues monitoringClient continues normal operationsStable connection
5Client stops querying SentinelNo new infoClient stays connected to last known masterPotential stale connection if failover occurs
6ExitN/AClient disconnects or stopsEnd of discovery process
💡 Client stops querying Sentinel or disconnects, ending the discovery process
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
master_addressnull192.168.1.10:6379192.168.1.10:6379 (failed)192.168.1.11:6379192.168.1.11:6379
Key Moments - 2 Insights
Why does the client ask Sentinel for the master address again after a failover?
Because the original master failed and Sentinel elected a new master, so the client must get the updated address to connect to the correct server (see execution_table step 2 and 3).
What happens if the client stops querying Sentinel after a failover?
The client may stay connected to the old master address, which is no longer valid, causing errors or stale data (see execution_table step 5).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what master address does the client connect to at Step 1?
A192.168.1.10:6379
B192.168.1.11:6379
C127.0.0.1:6379
DNo connection yet
💡 Hint
Check the 'Sentinel Response' and 'Client Action' columns in Step 1.
At which step does the client receive the new master address after failover?
AStep 2
BStep 3
CStep 1
DStep 5
💡 Hint
Look for when the client gets a new address from Sentinel in the table.
If the client never queries Sentinel again after Step 1, what is the likely outcome?
AClient connects to new master automatically
BSentinel pushes new master info to client
CClient stays connected to old master even if it fails
DClient disconnects immediately
💡 Hint
Refer to Step 5 in the execution_table and variable_tracker for stale connection.
Concept Snapshot
Client discovery through Sentinel:
- Client asks Sentinel for master address using 'SENTINEL get-master-addr-by-name <name>'.
- Sentinel replies with current master IP and port.
- Client connects to that master.
- On failover, Sentinel elects new master.
- Client queries Sentinel again to get updated master address.
- Repeat to maintain connection to correct master.
Full Transcript
Client discovery through Sentinel means the client asks Sentinel for the current master server address. The client sends the command 'SENTINEL get-master-addr-by-name' with the master name. Sentinel responds with the IP and port of the master. The client then connects to that master. If the master fails, Sentinel chooses a new master. The client must ask Sentinel again to get the new master's address and connect to it. This process repeats to keep the client connected to the right master. If the client stops asking Sentinel, it might stay connected to an old master that no longer works.