Redis › Redis Sentinel & High Availability
How does an application discover the current primary Redis instance when using Sentinel, especially after a failover has occurred?
IntermediateAnswer
Rather than connecting directly to a specific server address, a Sentinel aware client library asks one of the Sentinel instances for the current address of the primary, and after a failover happens, subsequent queries to Sentinel automatically return the new primary's address, letting the application always connect to the correct, currently active primary.
-- Client asks Sentinel for the current primary address
SENTINEL get-master-addr-by-name mymasterReal-world example An application configured with a Sentinel aware client library automatically reconnects to the newly promoted primary after a failover, since it always asks Sentinel for the current address rather than hardcoding a specific server.