Question: How can one scale Redis using Sentinel?


Redis Sentinel provides high availability for Redis. In practical terms, this means that using Sentinel you can create a Redis deployment that resists certain kinds of failures.

Scaling Redis with Sentinel mainly involves adding more Sentinels and Redis instances (either masters or slaves) to the system. However, scaling requires careful planning and understanding of how Sentinel works.

Here is a basic guide on how to do it:

  1. Adding More Sentinels

    More Sentinels means higher reliability. The minimum recommended number of Sentinels is three because having an odd number prevents "split-brain" scenarios in which the Sentinels cannot agree on whether a master is down. To add a new Sentinel, start it as you would any other, and give it the address of any existing Redis instance that's already monitored by the current Sentinel cluster.

    redis-sentinel /path/to/sentinel.conf
  2. Adding More Slaves

    Adding more slave instances can help distribute read load. Slaves connect to a master and replicate all its data. In the event of master failure, one of the slaves will be promoted to be the new master by Sentinel.

    To add a new slave, first start a new Redis instance, then use the following command, replacing master_host and master_port with the appropriate values:

    redis-cli SLAVEOF master_host master_port
  3. Sharding

    If you need to handle more write operations than a single Redis master can process, you may need to shard your data across multiple masters. This means splitting your data into parts and storing each part on a different master. Redis does not provide built-in support for sharding, so you'll have to implement this in your application code. Each shard should have its own set of slaves and be monitored by the same set of Sentinels.

Remember, scaling is not just about adding more resources but also configuring them properly to work in unison. Always thoroughly test any changes in a separate environment before deploying them to production.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.