What are Redis Sentinel and Redis Cluster?

Redis Sentinel is a set of separate monitoring processes that watch an ordinary primary/replica group. When enough Sentinels agree (a configured quorum) that the primary is unreachable, one of them is elected to promote a replica, repoint the remaining replicas, and report the new primary's address to clients that ask for it. The Redis servers themselves run in their normal mode and are unaware of any sharding.

Redis Cluster is a different server mode. The keyspace is divided into 16384 hash slots, and those slots are spread across several primaries, each with its own replicas. No external monitor is involved. The nodes gossip with each other, detect failures, and promote replicas themselves.

They solve different problems. Sentinel provides automatic failover for a dataset that fits on one primary. Cluster provides failover and also adds sharding, for when memory or write throughput outgrows a single node.

For a backend cache, high availability has two purposes. The first is protecting the origin: if a cache node dies and its replacement starts empty, every miss falls through to the database at once, causing a cold-cache stampede. Promoting a warm replica prevents this. The second is predictable latency, because a failover that completes within seconds causes a short spike rather than a sustained period of misses.

Redis Sentinel Redis Cluster
Topology One primary, N replicas, plus separate Sentinel processes Multiple primaries, each with replicas
Sharding None; full dataset on each node Keys mapped to 16384 slots across primaries
Failover coordinator Sentinel processes, by quorum and leader election Cluster nodes, by majority of primaries
Client requirements Must ask Sentinels for the current primary Must track the slot map and follow MOVED/ASK redirects
Multi-key operations Unrestricted Only when all keys hash to the same slot
Logical databases Supported (SELECT) Database 0 only
Minimum for real HA 1 primary, 1 replica, 3 Sentinels 3 primaries, each with 1 replica (6 nodes)

How do Sentinel and Cluster work?

Both build on standard Redis replication. A replica connects to its primary and, on first sync, receives a full snapshot of the dataset. After that, the primary streams every write command to the replica. If the link drops briefly, the replica can try a partial resynchronization from the primary's replication backlog instead of copying the whole dataset again. Replication is asynchronous. The primary acknowledges a write to the client without waiting for replicas, which is why any failover can lose recent writes.

How Sentinel works

You configure each Sentinel with only the primary's address and a name for the group. Sentinels discover everything else on their own. They learn about replicas from the primary's INFO output, and they find each other by publishing and reading announcements on a pub/sub channel on the monitored Redis instances. Each Sentinel then keeps monitoring the primary, its replicas, and the other Sentinels. When a failover happens, the Sentinels rewrite their own configuration files to record the new primary, so the change survives a Sentinel restart.

Sentinel is not in the data path. Clients use it only as a service-discovery endpoint: they ask which node is the primary, then connect to that node directly and send commands to it. If all Sentinels are down, existing client connections keep working, but no failover can happen and new clients cannot discover the primary.

How Cluster works

Every key maps to a slot computed as CRC16 of the key, modulo 16384. If the key contains a hash tag ({...}), only the tag is hashed. Each primary owns a set of slots, and every node knows the full slot-to-node map. Nodes talk to each other over a separate cluster bus port, which by default is the data port plus 10000. They use it for gossip about node state, failure detection, and failover votes.

A client sends a command to any node. If that node owns the key's slot, it executes the command. If it doesn't, it replies with a redirect naming the owner. Data moves between primaries one slot at a time during resharding. Keys in a migrating slot can briefly live on either node, which is what the ASK redirect handles.

How does failover work in Sentinel and in Cluster?

Sentinel

Each Sentinel pings the primary. If no valid reply arrives within down-after-milliseconds, that Sentinel marks the primary SDOWN (subjectively down). This is one Sentinel's opinion only. When enough Sentinels report SDOWN to meet the quorum set in sentinel monitor, the primary becomes ODOWN (objectively down). Quorum only triggers detection. To act, a Sentinel must be elected leader by a majority of all Sentinels, so a minority partition cannot start a failover. The leader promotes the best replica and reconfigures the remaining replicas to follow it. failover-timeout bounds how long each attempt may take. Clients learn the new address by querying Sentinel or subscribing to its +switch-master event.

Cluster

Nodes exchange gossip over the cluster bus. If a node gets no reply from a primary within cluster-node-timeout, it flags that primary PFAIL. Once a majority of primaries report it unreachable, it becomes FAIL. A replica of the failed primary then requests votes from the primaries and promotes itself if it wins a majority. Clients find the new owner through MOVED redirects or by refreshing the slot map.

 Sentinel                          Cluster
 [S1] [S2] [S3]                    P1 slots 0-5460      -> R1
    \  |  /                        P2 slots 5461-10922  -> R2
   [Primary] -> R1, R2             P3 slots 10923-16383 -> R3

Failover takes time

The outage window is the detection timeout plus promotion time plus client rediscovery. Applications need short timeouts and retries with backoff to ride it out. Lowering the timeouts shortens the window, but a GC pause or a brief network blip can then trigger unnecessary failovers. These can flap the primary back and forth and lose writes acknowledged by the old primary.

sentinel monitor mymaster 10.0.0.10 6379 2

sentinel down-after-milliseconds mymaster 5000

sentinel failover-timeout mymaster 60000

sentinel parallel-syncs mymaster 1

cluster-enabled yes

cluster-node-timeout 5000

Minimal Sentinel and Cluster settings that control failure detection and failover timing. Lowering down-after-milliseconds or cluster-node-timeout shortens the outage window but makes spurious failovers more likely.

When does a single primary stop being enough? Sharding as the dividing line

Sentinel adds failover, not capacity. Every write still lands on one primary, and the whole dataset has to fit in that primary's memory. Adding replicas scales reads only. Replication is asynchronous, so a replica can return a value the primary has already overwritten or deleted. Redis Cluster splits the keyspace into hash slots and spreads those slots across several primaries, so both memory and write load are divided.

Illustrative estimate

Assumed inputs:

  • Cache size: 150 million keys, averaging 350 bytes of key plus value.
  • Per-key overhead: 70 bytes for internal structures. Measure your own with sampled keys.
  • Node memory: 64 GB.
  • Headroom: 50% reserved for fragmentation, replication and client output buffers, and copy-on-write during a persistence fork.

That gives 150M × 420 B ≈ 63 GB of data. Only about 32 GB per node is usable, so one primary tops out near 76 million keys at this key size. The full dataset needs 63 / 32 ≈ 2 primaries. Plan for 3 to leave room for growth.

Writes follow the same logic. Assume one primary sustains 80k writes/s on your hardware and peak load is 200k writes/s. That is 2.5 primaries' worth, so you need 3, assuming keys spread evenly.

That assumption is the catch. Sharding distributes keys, not the traffic on any one key. A single hot key, such as a global counter or a popular session, lives in one slot on one node. A Cluster can still bottleneck there while the other primaries sit idle.

What do clients need to support Sentinel or Cluster?

Topology is only half the setup. The client library has to understand it too, because neither Sentinel nor Cluster hides failover or sharding from the client.

Sentinel-aware clients

Configure a Sentinel client with a list of Sentinel addresses and a master name, never a primary's IP. On connect, it asks a Sentinel for the current primary. You can do the same by hand with redis-cli -p 26379 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster, which returns the primary's IP and port. After a failover, the client must detect the change and reconnect to the new primary. It finds out either from connection errors or by subscribing to Sentinel's notifications.

A client with a hardcoded address fails in one of two ways:

  • The old primary is gone. The client hits connection errors and timeouts against an address that no longer answers.
  • The old primary came back as a replica. The client keeps writing to it and gets READONLY errors.

Either way, the failover worked but the application didn't follow it.

Cluster-aware clients

A Cluster client keeps a map of the 16384 hash slots to nodes and sends each command straight to the node that owns the key's slot. When the map is stale, the node replies with a redirection:

  • MOVED means the slot has a new owner. The client retries there and refreshes its topology.
  • ASK is a one-off redirect used during slot migration. The client retries there once without updating its map.

You can see the difference in redis-cli. Without -c, a request for a key on another node returns (error) MOVED 3999 10.0.0.12:6379. With redis-cli -c, the tool follows the redirect and prints -> Redirected to slot [3999] instead.

An unaware client behaves like redis-cli without -c. It works only for keys that happen to live on the node it connected to, and it surfaces MOVED errors for everything else.

Before you pick a topology, check what your client libraries and any proxies in the path actually support. Do this for every language in your stack. That check often settles the choice outright, and it is much cheaper than finding the gap mid-migration.

redis-cli -h 10.0.0.21 -p 26379 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster
redis-cli -h 10.0.0.10 -p 6379 CLUSTER KEYSLOT foo
redis-cli -h 10.0.0.10 -p 6379 SET foo bar
redis-cli -c -h 10.0.0.10 -p 6379 SET foo bar
redis-cli -h 10.0.0.10 -p 6379 CLUSTER SHARDS

This shows how to query Sentinel for the current primary, and how a Cluster MOVED redirection looks with and without redis-cli's -c flag (the IP addresses are placeholders and the output is illustrative).

What does Redis Cluster restrict, and how do hash tags help?

Cluster splits the keyspace into 16,384 hash slots, and a single node owns each slot. Any command that touches several keys therefore works only when all of them hash to the same slot. That covers MGET, MSET, SUNION, MULTI/EXEC blocks and Lua scripts. If the keys land in different slots, the request fails with a CROSSSLOT error. No node can execute it atomically, so Cluster refuses it.

Hash tags let you choose which keys share a slot. When a key contains {...}, only the text inside the braces is hashed. That means {user:42}:profile and {user:42}:cart land on the same slot, and a transaction or script can touch both. To confirm, run CLUSTER KEYSLOT on each key and check that the numbers match.

Use hash tags sparingly. A tag that groups too much data puts all of it on one node, which bounds its memory and CPU. A tag like {global} or {tenant:big} creates a hot slot that adding nodes cannot fix, because you cannot split a slot.

Other limits that matter for caches:

  • Only database 0 exists. You cannot use SELECT to separate tenants or environments, so use key prefixes or separate clusters instead.
  • Classic pub/sub is broadcast. Every published message is forwarded to every node, so bandwidth cost grows as the cluster grows.

A Sentinel-managed deployment has none of these restrictions. Moving to Cluster means real engineering work. You need to redesign key naming, refactor scripts so every key passes through KEYS, and add tests that exercise cross-slot cases before they surface in production.

#!/usr/bin/env bash
CLI="redis-cli -c -h cache-node-1.internal -p 7000"

$CLI CLUSTER KEYSLOT user:42:profile
$CLI CLUSTER KEYSLOT user:42:cart

$CLI MSET user:42:profile '{"name":"Ada"}' user:42:cart '[]'

$CLI CLUSTER KEYSLOT '{user:42}:profile'
$CLI CLUSTER KEYSLOT '{user:42}:cart'

$CLI MSET '{user:42}:profile' '{"name":"Ada"}' '{user:42}:cart' '[]'
$CLI MGET '{user:42}:profile' '{user:42}:cart'

$CLI EVAL "redis.call('EXPIRE', KEYS[1], ARGV[1]); return redis.call('EXPIRE', KEYS[2], ARGV[1])" \
  2 '{user:42}:profile' '{user:42}:cart' 300

$CLI SELECT 1

Uses CLUSTER KEYSLOT to show that keys without hash tags can trigger CROSSSLOT errors, while keys sharing a {user:42} tag map to one slot and work with MSET, MGET and Lua scripts that receive their keys through KEYS.

How should you deploy Sentinel and Cluster across availability zones?

A Sentinel deployment needs at least three Sentinel processes in separate failure domains. The quorum decides when the primary counts as down, but a majority of all Sentinels must still agree before a failover is authorized. With two Sentinels, losing one zone means no majority can form. Cluster needs at least three primaries, because a majority of primaries must vote to promote a replica. Each primary also needs at least one replica, or there is nothing to promote.

Option Minimum nodes Zone placement Related config
Sentinel 3 Sentinels, 1 primary, 1+ replica One Sentinel per zone; replica in a different zone from the primary sentinel monitor <name> <host> <port> 2
Cluster 3 primaries, 3 replicas Primaries spread across zones; each replica in a zone other than its primary's cluster-require-full-coverage yes (default)

Placement mistakes cause specific failures. If Sentinels sit only in the primary's zone, losing that zone also removes the voters, so no failover happens. If Sentinels are isolated from a healthy primary, they can trigger a false failover. In Cluster, losing a primary together with all of its replicas leaves that primary's slots unserved. By default the whole cluster then rejects queries. Setting cluster-require-full-coverage no lets the remaining slots keep serving, but some keys will be unreachable.

Replication is asynchronous, so a failover can lose writes the client already saw acknowledged. A partitioned primary can also keep accepting writes that are discarded when it rejoins as a replica. Setting min-replicas-to-write 1 and min-replicas-max-lag 10 makes the primary refuse writes when no replica has acknowledged it within that window. This bounds how many writes you can lose, but it does not bring the loss to zero. For a cache, that is usually acceptable, because a lost write becomes a miss and the value is reloaded from the source of truth.

port 26379
sentinel monitor cache-primary 10.0.1.10 6379 2
sentinel down-after-milliseconds cache-primary 5000
sentinel failover-timeout cache-primary 60000
sentinel parallel-syncs cache-primary 1

port 6379
min-replicas-to-write 1
min-replicas-max-lag 10
port 6379
cluster-enabled yes
cluster-config-file nodes-6379.conf
cluster-node-timeout 5000
cluster-require-full-coverage yes
min-replicas-to-write 1
min-replicas-max-lag 10

These are minimal Sentinel and Cluster configs for a three-zone deployment: a Sentinel quorum of 2, write-lag bounds on the primaries, and the full-coverage setting that decides whether the cluster keeps serving after it loses a slot.

Who should use Sentinel or Cluster?

Redis HA is aimed at teams running Redis themselves, on virtual machines, bare metal, or Kubernetes, who own failover and on-call for the cache. If a managed service already handles failover for you, most of the configuration above is the provider's job. You still need to understand the topology, because it determines client configuration and which commands you can use.

Sentinel fits teams that:

  • run a cache whose dataset and write rate fit comfortably on one node
  • depend on multi-key commands, transactions, or Lua scripts over arbitrary keys
  • use several logical databases, or have clients that cannot handle slot routing
  • want automatic failover with the fewest changes to existing application code

Cluster fits teams that:

  • have outgrown, or will soon outgrow, one node's memory or write capacity
  • can design key names around hash tags, or whose access pattern is mostly single-key GET/SET
  • have cluster-aware client libraries for every service that talks to the cache
  • can take on resharding and slot-balance monitoring as ongoing operational work

Neither is a good fit for teams whose cache is small, cheap to rebuild, and protected by origin fallback and request coalescing, or whose service can tolerate a brief cache outage. For those teams the extra processes and failure modes cost more than they save.

Should you use Sentinel, Cluster, or no HA at all for your cache?

Start from data size and client constraints, not from how much availability feels necessary.

Use a single primary with Sentinel when the dataset and write load fit on one node with clear headroom. You keep multi-key commands, Lua scripts across arbitrary keys, and multiple logical databases, which Cluster does not support. Avoid it when growth will clearly exceed one node. Migrating to Cluster later means changing clients and key design under pressure.

Use Cluster when memory or write throughput must scale horizontally, and when your clients and key layout can live with slot routing and hash tags. Avoid it for small datasets, for workloads built on cross-key logic, or when any important client lacks cluster support. In those cases you take on its constraints and gain nothing from sharding.

Skip HA entirely if the cache can be rebuilt from the origin. A single instance, or a managed equivalent, can be enough if you have three things in place:

  • fallback to the origin on miss or connection error
  • request coalescing, so that one caller refills a key while the others wait
  • graceful degradation, such as shorter timeouts, serving stale data, or shedding non-critical reads

The real risk is a stampede against the origin after a restart. Coalescing addresses that risk more directly than replicas do.

No HA Sentinel Cluster
Minimum nodes 1 1 primary, 1+ replicas, 3 Sentinels 3 primaries, plus replicas
Operational tasks Restarts, origin capacity Sentinel quorum, failover drills Resharding, live slot migration with redirects and latency on large keys
Code changes Fallback and coalescing Sentinel-aware client Cluster client, hash-tagged keys
On-call burden Low Moderate Highest

What are the alternatives to Sentinel and Cluster?

Sentinel and Cluster are not the only ways to make a cache resilient or to scale it past one node. Each of the following trades something different.

  • Replication with manual failover. Run a primary and a replica without Sentinel, and promote the replica by hand (REPLICAOF NO ONE) when the primary fails. You avoid the Sentinel processes and their tuning, but recovery depends on a person or your own automation. Clients also need a way to find the new primary, such as a DNS record or a virtual IP that you repoint.
  • Client-side sharding across independent instances. The application hashes each key, usually with consistent hashing, and picks one of several standalone Redis instances. This scales memory and writes without Cluster's server-side constraints. However, there is no automatic failover or resharding, adding a node remaps part of the keyspace, and every client must use the same hashing scheme. For a cache, a remapped key is just a miss, which makes this approach more tolerable than it would be for primary data.
  • A proxy layer. A proxy in front of several Redis instances handles sharding and routing, so applications talk to it like a single server. This keeps client code simple, but the proxy adds a network hop, its own availability problem, and its own limits on which commands it supports.
  • A managed Redis-compatible service. Cloud providers offer hosted Redis-compatible caches with built-in failover, and many also offer a sharded mode. You trade control and some cost for not running the failover machinery yourself. The same client concerns apply: a sharded managed offering still has cluster-style key and command restrictions.
  • An in-process cache in front of, or instead of, Redis. A small local cache in each application instance absorbs the hottest keys and keeps serving them during a Redis failover. This also helps with the hot-key problem that sharding cannot fix. The cost is staleness across instances and memory used in every process.
  • No HA, with origin protection. As described above, a single instance plus fallback, request coalescing, and graceful degradation is a legitimate design for caches that are cheap to rebuild.

These options can be combined. A common pattern is a small in-process cache for hot keys in front of a Sentinel-managed primary, which handles hot-key load and node failure without moving to Cluster.

How OneEnv can help

Disclosure: OneEnv is the product behind this blog.

OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.

Applied to redis sentinel vs cluster, this is where it helps:

Saves time

  • Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
  • One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
  • Reviewers see the exact diff and the list of affected services up front, so approval is a decision rather than an investigation.

Saves cost

  • Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
  • Less duplicated configuration to maintain: one shared definition inherited by many services.
  • Per-service approve/reject means a bad shared value can be refused where it would break something, before it is live.
  • OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.

These are qualitative benefits, not measured results — how much you save depends on how many services share the value.

Want to try it? Start at oneenv.io.