Try
↑ ↓ move↵ openesc close

Interview prep / Failure detection

Junior · Failure detection · System design interview question

A service sends a heartbeat every 1 second and the monitor declares it dead after 1.5 seconds of silence. Why is this configuration fragile, and what would you change?

Sketch your own answer first, then compare it with the one below.

A strong answer

One late or lost heartbeat is enough to cross the line. If a packet is dropped, the next one arrives 2 seconds after the previous, which is already past 1.5 seconds, so a healthy node gets declared dead because of a single bad packet.

The timeout should span several heartbeat intervals so that it takes a run of missed messages, not one, to cause a verdict. Three to five intervals is a common starting point. With a 1 second interval that suggests a timeout around 3 to 5 seconds, or an interval of 300 to 500 ms if you want to keep 1.5 seconds.

Shortening the interval is not free, since heartbeats cost traffic and CPU on both sides, and a short interval does nothing for a node that is paused rather than slow. The detection time after a crash is still about the timeout, so the interval is a lever on how much slack a timeout has, not on how fast you see real failures.

Sources

Learn it by running it

The failure detection lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

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