Try
↑ ↓ move↵ openesc close
In this lesson · topic 6 of 7
  1. 1. Silence is all you get
  2. 2. Heartbeats, timeouts and suspicion
  3. 3. Slide one detector along its curve
  4. 4. When a 600 ms pause beats the detector
  5. 5. Watching three hundred nodes without three hundred heartbeats each
  6. 6. Adding up a failover, and the storm a false alarm can start
  7. 7. Check the ten-second timeout

Topic 6

Adding up a failover, and the storm a false alarm can start

7 min read

Detection is only the first line

A timeout does not tell you how long users are down. Take a primary and replica database with an external monitor. Heartbeats go out every 1 s and the timeout is 5 s. The primary crashes just after sending one.

  • Detection: the monitor’s clock started at the last heartbeat, so it notices after about 5 s.
  • Promotion: the replica must confirm the primary is fenced off, replay what it has not applied, and open for writes. Say 3 s.
  • Rerouting: clients hold connections to the old primary and retry with backoff. Say a cap of 4 s.

That is 5 + 3 + 4 = 12 s of unavailable writes. Halving the timeout saves 2.5 s, about a fifth of the outage. Making the client retry faster would save as much. A detector is not always where the time is.

The false alarm bill

Now count the other side. Suppose the same timeout fires wrongly once per 500 node-hours. A 100-node fleet has 2,400 node-hours a day, so the expected number of false failovers is 2,400 / 500 = 4.8 a day. If each one costs the 12 s outage plus a cold cache, that is about a minute of avoidable downtime a day spread over the fleet, and 4.8 chances for a promotion bug to bite.

Raising the timeout to 10 s might cut false alarms to nearly zero but adds 5 s to every real failure. Which is better depends on which happens more often and what each costs. Write both numbers down before choosing, as the senior interview question asks.

Predict first

A failover takes 5 s to detect, 3 s to promote and 4 s for clients to reroute. You cut the detection timeout from 5 s to 2 s. Roughly how much shorter is the outage?

A burst of suspicions

False alarms are not independent. A congested switch, a noisy neighbour on shared hosts, or a deploy that makes many processes pause at once all raise latency across many nodes together. The detector sees many silences at the same moment.

Suppose 100 nodes run at 70% load. A switch fault makes the monitor suspect 20 of them. If the system reacts by moving their traffic to the other 80, each survivor now carries 100 x 70 / 80 = 87.5% load. Response times rise. Heartbeats on those nodes get slower, because they share the same CPU and network, and the detector starts suspecting more of them. Each wave of failover makes the next one more likely.

The countermeasures are all about limiting the reaction, not tuning the detector:

  • Cap concurrent failovers. Allow at most a few at a time, so the survivors absorb them gradually.
  • Treat a large fraction of suspects as a network problem. If a quarter of the fleet goes silent at once, the probable fault is the monitor’s own view, so freeze and alert instead of acting.
  • Add hysteresis. Require a node to be healthy for a while before it returns to rotation, so a flapping node does not bounce in and out.
  • Make failover cheap to undo. If the suspected node comes back, it should rejoin without a full resync.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms