Course contentsShow
← Cloud and Infrastructure
Lesson 2687 of 2,98958. Caching StrategiesFree lesson

Redis High Availability with Sentinel

Configure Redis Sentinel for automatic failover and monitoring of Redis instances.

Redis High Availability with Sentinel

You'll learn how to configure Redis Sentinel to automatically detect failures and promote replicas without manual intervention.

What is Redis Sentinel?

Redis Sentinel is a distributed system that monitors your Redis instances and automatically performs failover when the primary node fails. Think of Sentinel as a team of watchdogs: if one dog falls asleep, the others are still alert. Multiple Sentinel processes run independently, voting together to determine if a primary is truly down and which replica should be promoted.

Why You Need Sentinel

Without Sentinel, if your Redis primary crashes, applications lose cache access until you manually promote a replica. With Sentinel, this happens automatically in seconds. Your cache remains available, and applications reconnect to the new primary seamlessly.

Core Sentinel Responsibilities

Sentinel handles four critical tasks:

  1. Monitoring: Continuously checks if primary and replica instances are working
  2. Notification: Alerts you (via scripts or APIs) when something goes wrong
  3. Automatic Failover: Promotes a replica to primary if the original primary fails
  4. Configuration Provider: Tells clients the current primary address

Basic Configuration

Deploy at least three Sentinel instances (odd numbers help voting). Each Sentinel monitors the same Redis setup:

sentinel monitor mymaster 10.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 10000

The 2 in monitor means two Sentinels must agree the primary is down before triggering failover. This quorum prevents false positives from network hiccups.

How Failover Works

When enough Sentinels agree the primary is unreachable, they elect a leader Sentinel to orchestrate failover. That leader picks the healthiest replica, promotes it, and reconfigures other replicas to follow the new primary.

Key Takeaway: Redis Sentinel provides automatic failover and monitoring with a minimum of three Sentinel processes voting together, ensuring your cache remains available even when the primary node fails.