Understanding Redis Sentinel, Replication, and Cluster: High Availability and Data Replication
This article explains how Redis Sentinel provides automated failover, details the replication process that keeps master and slave data synchronized, and compares the roles of master‑slave replication, Sentinel, and Redis Cluster in achieving high availability and horizontal scalability.
Sentinel
Sentinel is a crucial component in Redis cluster architecture that automates failover when master‑slave replication encounters faults, eliminating the need for manual intervention.
Redis Sentinel main functions
(1) Cluster monitoring : monitors the health of Redis master and slave processes.
(2) Notification : sends alerts to administrators when a Redis instance fails.
(3) Failover : automatically promotes a slave to master when the master node goes down.
(4) Configuration provider : informs clients of the new master address after a failover.
High availability mechanism
When a master fails, Sentinel discovers the failure, performs a coordinated election, and notifies applications of the new master, achieving high availability.
Sentinel creates multiple sentinel nodes (processes) that jointly monitor the health of data nodes.
Sentinel nodes communicate with each other, exchanging monitoring status of master and slave nodes.
Every second each sentinel sends a PING to the entire cluster (master, slaves, and other sentinels) as a heartbeat check.
Sentinel uses the concepts of subjective down and objective down to decide node health.
1. Subjective down : a single sentinel judges the master as down.
2. Objective down : when a majority of sentinels agree the master is down, the master is considered objectively down.
3. Principle : the first sentinel that determines objective down initiates a Raft‑style election; the elected leader performs the master‑slave switch.
Redis Replication
Redis replicates data to multiple slave nodes to provide redundancy, improve reliability, and achieve high availability.
Replication steps
1. The slave sends a SYNC command to the master.
2. The master creates a snapshot and generates an RDB file.
3. The master sends the RDB file to the slave, which loads it.
4. The master streams buffered write commands to the slave.
5. After synchronization, every subsequent write on the master is sent to the slave.
Note: Since Redis 2.8, after a disconnection, replication resumes incrementally based on the last command offset.
Differences among Master‑Slave Replication, Sentinel, and Cluster
Master‑slave replication provides data backup and load balancing; Sentinel adds automatic failover for high availability; Cluster distributes data across multiple nodes to overcome single‑instance capacity limits and increase concurrency.
1. Master‑slave : data backup, read/write separation, one master with multiple slaves.
2. Sentinel : monitoring and automatic master election when the current master fails.
3. Cluster : sharding data across many machines, removing single‑node memory/QPS limits and enabling horizontal scaling.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Mike Chen's Internet Architecture
Over ten years of BAT architecture experience, shared generously!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
