Scrivio Interview library
DesignAdvanced6 min read · updated 13 November 2026

A team runs a Redis Cluster of six primaries and six replicas across three availability zones in one cloud region. A zone outage took the cluster down for 20 minutes even though half of the nodes were still healthy.

How does Redis Cluster decide to fail over, why can a single-zone loss stop it, and how would you lay out and size the cluster so it survives losing any one zone?

A replica is promoted only after a majority of primaries agree its primary has failed and vote for it, so if one zone holds most of the primaries, losing that zone leaves no majority, no failover happens and the cluster stays down. We spread primaries evenly across the three zones, put each replica in a different zone from its primary, plan for the degraded state after a zone loss, alert on placement drift, and keep memory headroom so syncs and failovers fit.

Why this question is asked

Running across three availability zones is supposed to make a zone outage survivable, and the nodes were indeed spread across zones. What went wrong was which nodes sat where: Redis Cluster decides failovers by a vote among primaries, and placement decides whether a vote can still be won. Interviewers ask this design question to see whether we can connect the failover protocol to physical layout and size a cluster for a zone loss. In this answer, we will recap how cluster failover works, replay the outage, design the layout, plan the state after a zone loss, add placement checks and size the nodes.

1A Quick Recap of Cluster Failover

Nodes in a Redis Cluster ping each other constantly. If a node does not answer for cluster-node-timeout, 15 seconds by default, a node that noticed marks it PFAIL, possibly failing. When a majority of primaries report the same node as failing, it becomes FAIL, and that news spreads. Then the failed primary's replicas ask for promotion, and a replica needs votes from a majority of primaries to win. Both steps count primaries, and both need more than half of all primaries in the cluster, reachable or not.

This is what keeps a minority partition from promoting its own primaries and creating two owners for the same slots.

2Replaying the Outage

The cluster had six primaries and six replicas, but the layout had drifted so that four primaries ran in zone A. When zone A failed, two primaries remained, two of six, not a majority. They could not mark the four lost primaries as FAIL, and no replica could gather the four votes it needed, so the slots of four shards had no owner. With full coverage required, the whole cluster refused queries for 20 minutes until zone A came back, even though half of the nodes, including replicas of the lost primaries, were healthy.

The layout that failed
ZonePrimariesReplicasAfter zone A fails
AP1, P2, P3, P4R5, R6all gone
BP5R1, R21 primary left
CP6R3, R41 primary left: 2 of 6, no majority

3A Layout That Survives Any One Zone

Spread the primaries evenly: two per zone. Then put each replica in a different zone from its own primary. Losing any zone now removes two of six primaries; four remain, a majority. They mark the lost primaries as FAIL, the replicas of those two primaries, which live in the other zones, win their votes and are promoted, and all slots are covered again. The time to recover is roughly cluster-node-timeout plus a few seconds for the vote and for clients to refresh their slot maps, so about 15 to 20 seconds with the defaults.

Text
# rule: replica Rn never lives in the same zone as its primary Pn
zone A: P1, P2, R3, R5
zone B: P3, P4, R1, R6
zone C: P5, P6, R2, R4
Step throughZone B fails in the even layout
P1, P2 (zone A)P5, P6 (zone C)R3 (zone A)R4 (zone C)
no pings from P3, P4 for 15 s: PFAIL
P3, P4 failing too
majority 4 of 6: FAIL P3, P4
vote for me to replace P3
votes
vote for me to replace P4
votes
promoted, owns P3's slots

8 messages in order. Play them, or step through them one at a time.

4Planning for the State After a Zone Loss

Surviving the loss is half the design. Afterwards, zone B's former replicas R1 and R6 are gone, so P1 and P6 have no replica, and the promoted R3 and R4 are primaries without replicas too. The cluster runs with no redundancy for four shards until zone B returns. When it does, the old P3 and P4 rejoin as replicas of their promoted replacements, and everything resyncs.

The layout is now different from the plan: zone A holds three primaries. A second zone loss of the wrong zone would again leave no majority. So after recovery we restore the intended layout deliberately, by running CLUSTER FAILOVER on the replica that should be primary again, one shard at a time, during a quiet period.

5Keeping the Layout True Over Time

This outage happened because the layout drifted. Repairs, scale-outs and automation that places nodes wherever there is capacity do not preserve zone placement on their own, and managed tooling may not either. So we add a check that reads CLUSTER NODES, maps each node to its zone, and alerts whenever a primary and its replica share a zone, or a single zone holds half or more of the primaries. It runs every few minutes, and after every scaling or repair job.

6Sizing Nodes for Failover

Memory per node should stay well below its limit, for example under 60 to 70 percent of available RAM. A full sync after the zone returns forks the primary, and copy-on-write plus replication buffers can add a large fraction of the dataset. A promoted replica also takes on its primary's full write load. Finally, test the design: simulate a zone loss under realistic load, measure the time until all slots are covered and clients recover, and repeat after every major change.

7Follow-up questions

How many zones would you need if each primary had two replicas?

Three zones are still enough to survive the loss of one zone, as long as primaries are spread evenly and each primary's two replicas are in the two other zones. Every shard then keeps two copies after a zone loss, which protects against a second node failure. To survive the loss of two zones at once, though, the surviving primaries would still need a majority, which requires spreading primaries over at least five zones, so extra replicas alone do not buy that.

Why not count replicas in the vote?

Only primaries vote because they own slots and carry the authoritative configuration. Replicas take part in detection gossip but not in authorising a failover.

Could cluster-require-full-coverage no have helped?

It would have let P5 and P6 keep serving their own slots during the outage, so a third of the keys would have worked. It does not create a majority, so the four shards would still have stayed down.

8Conclusion

In this answer, we saw that Redis Cluster fails over only when a majority of primaries agree and vote, so a zone holding four of six primaries took the majority with it. We spread primaries two per zone with each replica in another zone, which recovers from any single zone loss in about cluster-node-timeout plus a few seconds, planned the degraded state and the later CLUSTER FAILOVER to restore the layout, added a continuous placement check, and kept memory per node well below its limit, verified by zone-loss tests.

What to say in the interviewAbout 100 seconds aloud

Open with

Redis Cluster fails over by vote among primaries. When a node stops answering for cluster-node-timeout, 15 seconds by default, others mark it as possibly failed, and it becomes failed only when a majority of primaries agree; then one of its replicas must collect votes from a majority of primaries to be promoted.

Then, if they want more

In our cluster four of the six primaries had ended up in one zone, so when that zone failed only two of six were left. Two is not a majority, so no failure was confirmed, no replica was promoted, slots stayed uncovered and the whole cluster was down, even with half the nodes healthy.

My layout puts two primaries in each of the three zones and every replica in a different zone from its own primary.

Losing any zone then removes a third of the primaries, the remaining four are a majority, the lost primaries' replicas in the other zones are promoted, and all slots are covered again within about the node timeout plus a few seconds.

I would also plan for the aftermath: some shards run without replicas until the zone returns, and the layout must be restored with CLUSTER FAILOVER on the right replicas. Because automation and repairs drift placement, I add an alert whenever a primary and its replica share a zone or one zone holds half the primaries.

Finally I keep memory per node below about 60 to 70 percent so full syncs and failovers fit, and test a zone loss under load.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Redis documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "How does Redis Cluster decide to fail over, why can a single-zone loss stop it, and how...": https://scrivio-interview-library.netlify.app/databases/redis-scaling/241ae1d594/