Databases 6 min read

Understanding Redis Sentinel: Discovery, Failover Detection, and Gossip Protocol

This article explains Redis Sentinel's role in providing high availability by detailing how Sentinels discover each other, detect master failures, elect a new master, and communicate state using the gossip protocol, offering a clear conceptual overview for database practitioners.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Understanding Redis Sentinel: Discovery, Failover Detection, and Gossip Protocol

Author: Yue Mingqiang, DBA team member at iKangsheng Beijing, responsible for database management platform operations and MySQL troubleshooting.

What is Sentinel

Redis is a popular NoSQL database known for high performance, high availability, scalability, and rich data structures. Sentinel provides Redis high‑availability by automatically promoting a replica when the master fails, and this article explains its underlying principles.

Sentinel Discovery

When configuring a Sentinel cluster, each Sentinel only knows the master’s address; they discover each other by periodically publishing a _sentinel_:hello message to the master’s Pub/Sub channel every 2 seconds and subscribing to it. New Sentinels are added to the cluster as soon as they are detected.

Detecting Master Down

At least three odd‑numbered Sentinels form a quorum. Every SENTINEL_PING_PERIOD (1000 ms) each Sentinel sends a PING to the master. If no reply is received within is‑master‑down‑after‑milliseconds , the Sentinel marks the master as subjectively down (s_down). Only after a majority of Sentinels agree (quorum) is the master marked objectively down (o_down) and a failover may proceed.

Selecting a New Master

When a master is deemed down, remaining replicas are evaluated. A replica is eligible if it is not in S_DOWN, O_DOWN, or DISCONNECTED state, responds promptly to PING/INFO, has reasonable replication offset, and its priority is non‑zero. Eligible replicas are ordered by lower priority, larger replication offset, smaller runid, and higher command count, and the best candidate is promoted.

The Gossip Protocol

Sentinel nodes exchange state information using a gossip protocol: each node randomly forwards its own status and the information it has received to a few other nodes, propagating updates until all nodes have a consistent view. This same mechanism is also used by Redis Cluster for internal communication.

Conclusion

The article provides a conceptual overview of Redis Sentinel, covering master‑down detection, replica election, failover workflow, and the gossip communication mechanism.

DatabaseHigh AvailabilityRedissentinelfailovergossip protocol
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.