A Deep Dive into Redis Sentinel and Redis Cluster
Published: 2026-04-03
URL: https://thecodinggopher.substack.com/p/why-scaling-redis-is-harder-than
A technical breakdown of high availability, horizontal sharding, and algorithmic data distribution. A single Redis instance is a powerhouse, capable of processing hundreds of thousands of operations per second.
But relying on a single node introduces two critical engineering bottlenecks: The Single Point of Failure (SPOF). If the server dies, your application loses its cache, its session state, or its job queues.
The Physical Memory Limit. You can only scale vertically so much. Eventually, a 500GB dataset simply won’t fit on a single standard machine without astronomical costs. Priming the cache (or "cache warming") in Redis is the process of proactively loading frequently accessed or critical data into the Redis in-memory data store before the application actually requests it. Instead of waiting for a "cache miss" (where the application queries the database, then populates Redis), the cache is pre-filled, ensuring that initial user requests are served instantly from memory.
To solve these problems, Redis provides two distinct distributed topologies: Redis Sentinel and Redis Cluster. While they are often confused, they solve fundamentally different problems. Sentinel is built for High Availability (HA), while Cluster is built for Horizontal Scalability.
Here is how they work under the hood.
- Redis Sentinel. The Distributed Watchdog (High Availability)
If your dataset easily fits within the RAM of a single server, but you cannot afford a single second of downtime, you need Redis Sentinel. In a standard primary-replica setup, all writes go to a “Master” node, which asynchronously replicates its data to one or more “Replica” nodes. If the Master crashes, a human operator traditionally has to manually promote a Replica to become the new Master and update the application’s configuration. Redis Sentinel automates this entire process.
It is a separate distributed system (usually running as a cluster of at least three Sentinel processes) that strictly monitors your Redis nodes. The Sentinel Failover Process Monitoring. Sentinels constantly ping the Master and Replicas. Subjective Down (SDOWN). If one Sentinel doesn’t receive a reply from the Master, it flags it as “Subjectively Down.” However, it doesn’t trigger a failover yet, preventing false positives from isolated network blips. Objective Down (ODOWN). If a configured quorum (a majority) of Sentinels agree that the Master is unreachable, the state is upgraded to “Objectively Down.” Automatic Failover.
The Sentinels elect a leader among themselves to perform the failover. The leader selects the healthiest, most up-to-date Replica and promotes it to Master. Configuration Provider. Finally, the Sentinels act as a service discovery mechanism.
When the application needs to connect, it asks the Sentinel, “Who is the current Master?” Sentinel provides the new IP address, ensuring seamless recovery. 𝐋𝐞𝐚𝐫𝐧 𝐭𝐨 𝐛𝐮𝐢𝐥𝐝 𝐆𝐢𝐭, 𝐃𝐨𝐜𝐤𝐞𝐫, 𝐑𝐞𝐝𝐢𝐬, 𝐇𝐓𝐓𝐏 𝐬𝐞𝐫𝐯𝐞𝐫𝐬, 𝐚𝐧𝐝 𝐜𝐨𝐦𝐩𝐢𝐥𝐞𝐫𝐬, 𝐟𝐫𝐨𝐦 𝐬𝐜𝐫𝐚𝐭𝐜𝐡. Get 40% OFF CodeCrafters: https://app.codecrafters.io/join?via=the-coding-gopher This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.
- Redis Cluster. The Sharding Heavyweight (Horizontal Scaling)
What happens when your dataset grows to 2 Terabytes? No single machine can efficiently handle that in RAM. You need to split the data across multiple machines. This is called sharding, and it is exactly what Redis Cluster is built for. Unlike Sentinel, which manages a single Master, Redis Cluster is a true multi-master architecture. Algorithmic Routing.
The Magic of 16,384 Hash Slots How does a cluster know which node should store the key user:1042:profile? Instead of using complex mapping tables or standard consistent hashing, Redis Cluster uses a concept called Hash Slots.
The entire cluster’s memory space is logically divided into exactly 16,384 Hash Slots. When you send a command to the cluster, Redis runs a mathematical formula on the key: CRC16(key) mod 16384. The result is a number between 0 and 16,383. Node A might hold slots 0 to 5,500. Node B holds 5,501 to 11,000. Node C holds 11,001 to 16,383. CRC16 (Cyclic Redundancy Check 16) is the hashing algorithm used in Redis Cluster mode to determine which master node a specific key should be stored on.
This mechanism ensures that keys are automatically sharded across the cluster. If the formula outputs 12000, the cluster instantly knows the data belongs on Node C. This algorithmic approach means data is routed with zero lookup overhead.
The cluster's key space is split into 16384 slots, effectively setting an upper limit for the cluster size of 16384 master nodes (however, the suggested max size of nodes is on the order of ~ 1000 nodes).
Each master node in a cluster handles a subset of the 16384 hash slots. The Gossip Protocol Unlike Sentinel, Cluster doesn’t rely on separate monitoring processes. The Redis nodes themselves talk to each other using a Gossip Protocol. They constantly exchange pings to share their state, the hash slots they control, and the health of their peers. If a Master node in the cluster fails, the other nodes will use this gossip network to detect the failure and promote that specific Master’s Replica to take over its assigned hash slots.
The Verdict. Which should you choose? Choosing between the two comes down to understanding your system’s constraints. Ultimately, both architectures highlight Redis’s flexibility. It can act as a simple, highly available cache or be transformed into a massive, distributed data grid powering enterprise-scale infrastructure.
This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber. Thanks for reading! This post is public so feel free to share it. Share