What is Redis Sentinel, and which problems does it solve for a Redis deployment?
answer
- Same binary, `--sentinel`, port 26379
- Monitor / notify / failover / config provider
- Control plane, never in the data path
- Replicas via INFO, Sentinels via `__sentinel__:hello`
- HA only — no sharding, no sync replication
basics
~20 sSentinel is a separate Redis process that watches a master and its replicas. It detects when the master is down, promotes a replica automatically, reconfigures the other replicas, and tells clients the current master address. Data never flows through it.
solid answer
~50 s**Sentinel is Redis's built-in high-availability supervisor** for a classic one-master/N-replica setup. You run several `redis-sentinel` processes (same binary, `--sentinel` mode) on separate hosts; each is told to monitor a master under a logical name such as `mymaster`. It does four things: - **Monitoring** — pings master and replicas, tracks their health via `PING`/`INFO`. - **Automatic failover** — when enough Sentinels agree the master is unreachable, they elect a leader Sentinel, pick the best replica, issue `REPLICAOF NO ONE`, and repoint the remaining replicas at the new master. - **Configuration provider / discovery** — clients ask Sentinel `SENTINEL get-master-addr-by-name mymaster` instead of hardcoding an IP, and subscribe to `+switch-master` to learn about changes. - **Notification** — events on Pub/Sub channels, plus optional notification scripts. What it is **not**: it is not a proxy (traffic goes straight to Redis), it does not shard data, and it does not make replication synchronous — a failover can still lose recent writes.
code
text · 6 linesport 26379
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
# 2 = quorum: how many Sentinels must agree the master is downgo deeper
Be able to say Sentinel is a separate watchdog process that promotes a replica when the master dies and tells clients the new address.
Name the four responsibilities (monitor, notify, failover, config provider), explain that replicas and other Sentinels are auto-discovered, and note that clients must be Sentinel-aware.
Add the operational picture: odd number of Sentinels on independent hosts, config-file rewriting as durable state, the asynchronous-replication data-loss window, and how clients drop stale connections on +switch-master.
Frame it as a choice of failure domain and control plane: Sentinel buys automatic recovery for a single-master dataset with no data-path cost, at the price of a lossy failover and no horizontal scale; compare against Cluster or a managed endpoint on those axes.
## The problem A plain Redis master with replicas gives you read scaling and a warm copy of the data, but nothing automatic happens when the master dies. Somebody has to notice, choose a replica, run `REPLICAOF NO ONE` on it, repoint the other replicas, and tell every application instance the new address. Sentinel is the component that does all of this without a human. ## What Sentinel is, concretely Sentinel is the *same binary* as the Redis server started in a different mode (`redis-sentinel sentinel.conf`, or `redis-server sentinel.conf --sentinel`). It speaks the normal Redis protocol on its own port (26379 by default) but serves a small command set (`SENTINEL ...`, `PING`, `SUBSCRIBE`, ...) instead of the data commands. **No application data ever passes through Sentinel** — it is a control plane, not a proxy. Clients still open connections directly to the Redis master. You run **several** Sentinels — three is the usual minimum — on hosts that fail independently. They form their own small distributed system so that a single Sentinel's opinion (or a single Sentinel's death) cannot trigger or block a failover. ## Topology and discovery You only configure the master: ``` sentinel monitor mymaster 10.0.0.10 6379 2 ``` From there Sentinel bootstraps the rest of the picture: - It runs `INFO` against the master every ~10 seconds; the reply lists the connected replicas, so **replicas are auto-discovered**. - Sentinels find *each other* by publishing to and subscribing to the `__sentinel__:hello` Pub/Sub channel on the monitored Redis instances. So you never list Sentinels in each other's config; they gossip through Redis itself. Sentinel **rewrites its own config file** as it learns replicas, other Sentinels, and after every failover (`sentinel monitor` line updated to the new master). This is normal and must not be prevented — the config file is Sentinel's persistent state. ## The four jobs 1. **Monitoring** — periodic `PING`, `INFO`, and hello messages to master, replicas, and other Sentinels. 2. **Notification** — every state change is published on Sentinel's Pub/Sub channels (`+sdown`, `+odown`, `+switch-master`, `+failover-end`, ...). `notification-script` can page a human. 3. **Automatic failover** — subjective down → objective down by quorum → leader election among Sentinels → replica promotion → reconfiguration of the surviving replicas and of the old master when it returns (it comes back as a replica of the new master). 4. **Configuration provider** — the client-facing part. An application asks any Sentinel `SENTINEL get-master-addr-by-name mymaster` and connects to whatever it returns; well-written clients also subscribe to `+switch-master` so they drop stale connections immediately. ## Client responsibility Sentinel only works end to end if clients are **Sentinel-aware**. Jedis/Lettuce/redis-py/go-redis all ship a Sentinel connection mode where you configure the *list of Sentinel addresses plus the master name* rather than the master's host. If you point your app at a fixed master IP, the failover will still happen and your app will still be broken — a very common production mistake. The alternative is a virtual IP or a DNS record updated by the `client-reconfig-script` hook Sentinel invokes on failover, but native Sentinel clients are the standard answer. ## What Sentinel deliberately does not do - **No sharding.** The whole dataset lives on one master; you get HA, not horizontal write scale or memory scale. That is Redis Cluster's job. - **No proxying or load balancing.** Sentinel does not sit in the data path, so it adds no latency and is not a throughput bottleneck — but it also cannot route reads for you. - **No strong durability.** Redis replication is asynchronous: writes acknowledged by the master may not have reached the promoted replica, so a failover can silently lose the last few milliseconds of writes. `min-replicas-to-write` / `min-replicas-max-lag` narrow this window by refusing writes when not enough replicas are keeping up, but never close it. - **No protection against a partitioned old master.** An isolated master keeps accepting writes from clients stuck on its side until it notices it has too few replicas; those writes are discarded when it rejoins as a replica. ## When you would choose it Sentinel is the right fit when a single master comfortably holds the dataset and the requirement is "survive a node loss without a human". If you need more memory or write throughput than one node provides, you want Cluster (which has its own failover built in and does not use Sentinel). Managed offerings usually hide one or the other behind an endpoint.
- Why must you run at least three Sentinels rather than one?A single Sentinel is itself a single point of failure and, worse, a single point of *false* failure: a network glitch on that one host would trigger a failover of a perfectly healthy master. Failover also requires a majority of the Sentinel set to elect a leader, so with one or two Sentinels you cannot tolerate losing one. Three Sentinels on independently failing hosts tolerate one loss and still form a majority.
- Does Sentinel help you scale writes or memory?No. Sentinel keeps a single-master topology; every write still goes to one node and the whole dataset must fit in that node's memory. It only automates recovery from node failure. Scaling writes or dataset size across nodes requires Redis Cluster or client-side sharding, which have their own failover mechanisms and do not use Sentinel.
- What happens to the old master when it comes back online?Sentinel reconfigures it as a replica of the new master, so it does not become a second writable master. Any writes it accepted while partitioned and not yet replicated are lost when it resynchronizes. This is why applications must reconnect through Sentinel rather than pinning the old address.
Sentinel is the on-call electrician for a building with one main generator and spare units: it doesn't carry the current, it just watches, flips the changeover switch when the main dies, and updates the sign telling everyone which generator is live.
saying these in an interview costs you the question
- Saying Sentinel is a proxy or that clients connect through it — it never touches the data path.
- Claiming Sentinel shards data or scales writes; it manages exactly one master's worth of data.
- Running a single Sentinel, or all Sentinels on the same host as the master.
- Assuming failover is lossless because "the replica had the data" — replication is asynchronous.
- Pointing the application at a hardcoded master IP and expecting failover to be transparent.