What is Redis Sentinel?

Redis is an open-source, in-memory data structure store used to implement NoSQL key-value databases. Users who require their databases to be highly available can make use of Redis Sentinel. But what is Redis Sentinel exactly, and how does Redis Sentinel work?

What is Redis Sentinel?

The master-slave database architecture helps increase the scalability and performance of your enterprise database, offloading computation to the slave nodes and creating backups. However, this architecture can result in availability issues in the event that the master node goes down, causing the slave nodes to lose connection.

First released in 2012, Redis Sentinel is a high-availability solution for Redis. The Redis Sentinel platform performs several key functions to ensure high availability for your enterprise databases:

  • Monitoring your Redis deployment, including master and slave instances
  • Notifying you of important issues and changes in the Redis environment
  • Automatically handling failover events in the case that a master node is unavailable
  • Helping clients find the address of the current master node

By design, Redis Sentinel is a distributed system. Redis recommends that you have at least three instances of Redis Sentinel running simultaneously in order to improve the system’s availability and resiliency. This is for multiple reasons:

  • If a majority of Redis Sentinel instances agree that a master node is no longer available, then the system will perform failover handling. However, with a single Redis Sentinel instance, there is a small risk of false positives. Increasing the number of instances in the system, and requiring a majority vote, will reduce this risk.
  • Adding more instances of Redis Sentinel makes the entire system more robust. If one instance fails, the system can continue operating with the other instances.

Redis vs. Redis Sentinel vs. Redis Cluster

Redis Sentinel isn’t the only flavor of Redis that users can deploy. Redis Cluster is another version of Redis that also uses a master-slave architecture. So what’s the difference between Redis Sentinel and Redis Cluster?

For one, Redis Cluster first appeared in 2011, making it slightly older than Redis Sentinel. The use case of Redis Cluster is also different from Redis Sentinel. Redis Cluster performs data sharding, splitting database tables into smaller “shards” in order to improve scalability and availability. There are at least 3 master nodes and 3 slave nodes in every Redis Cluster deployment. In the event that one of the master nodes fails, the corresponding slave node is promoted to master.

How to run Redis Sentinel?

Running Redis Sentinel is fairly straightforward. After installing the redis-sentinel executable, you can launch Redis Sentinel with the following command:

redis-sentinel /path/to/sentinel.conf

where /path/to/sentinel.conf represents the Redis Sentinel configuration file. Below is an example of a Redis Sentinel configuration file:

sentinel monitor mymaster 6379 2
sentinel down-after-milliseconds mymaster 60000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1
sentinel monitor resque 6380 4
sentinel down-after-milliseconds resque 10000
sentinel failover-timeout resque 180000
sentinel parallel-syncs resque 5

These settings help Redis Sentinel determine when to start handling failover for the master node. For example, down-after-milliseconds determines the number of milliseconds after which the master node is considered unreachable (here 10,000 milliseconds, or 10 seconds).

Similar terms