Scrivio Interview library
ConceptFoundations6 min read · updated 13 November 2026

A failure detector decides when a node should be treated as dead. Most systems use heartbeats with timeouts, and some use adaptive detectors such as the phi accrual failure detector.

What trade-off does a heartbeat timeout make, and how does the phi accrual failure detector improve on a fixed timeout?

A heartbeat timeout trades detection speed against false alarms: a short timeout notices crashes quickly but convicts nodes that are only slow or briefly paused, causing needless failovers, while a long one avoids that but keeps sending requests to dead nodes. The phi accrual failure detector replaces the fixed timeout with a suspicion level, phi, computed from each peer's own history of heartbeat intervals, so it adapts to every link's normal jitter and convicts a peer when phi passes a threshold such as Cassandra's default of 8.

Why this question is asked

Every distributed system must decide when a silent node is dead, and that decision drives failovers, data movement and request routing. Interviewers ask this question because it shows whether we understand that failure detection is a guess, not a fact, and how adaptive detectors make that guess better. In this answer, we will look at what a timeout really trades off, why perfect detection is impossible, how phi accrual computes its suspicion level with a worked example, and why detection should be separated from the action taken.

1A Quick Recap of Heartbeats and Timeouts

The simplest failure detector is a heartbeat with a timeout. Each node sends a small message to its peers every second, and each peer remembers when it last heard from it. If the silence lasts longer than the timeout, say 5 seconds, the node is declared dead, and the system reacts: it stops routing requests there, elects a new leader or starts moving data to other replicas.

2The Trade-Off a Fixed Timeout Makes

Choosing the timeout is choosing between two kinds of mistakes. A short timeout, such as 2 seconds, detects a real crash quickly, but it also convicts nodes that are alive and merely slow: a garbage collection pause of 3 seconds, a burst of CPU throttling or a congested network link. Those false positives are expensive, because they trigger failovers and data movement that we then have to undo when the node comes back a second later. A long timeout, such as 30 seconds, avoids false alarms, but after a real crash we keep sending requests to a dead node for half a minute.

There is a deeper reason we cannot simply pick a perfect value. In an asynchronous network, where messages can be delayed by any amount, a slow node and a dead node look exactly the same from outside: in both cases, we hear nothing. No detector can tell them apart with certainty. Every detector is making a probabilistic judgement, and the question is only how well it makes it.

What the timeout value costs
TimeoutReal crash detected afterFalse positives from a 3 s pause
2 sabout 2 syes: needless failover
5 sabout 5 sno, but a 6 s pause still triggers one
30 sabout 30 srare, but 30 s of failed requests

3How the Phi Accrual Detector Works

The phi accrual failure detector, described by Hayashibara and colleagues, changes the question. Instead of asking "has the silence exceeded a fixed time?", it asks "how unlikely is this silence, given how this particular peer normally behaves?". For each peer, the node keeps a sliding window of recent intervals between heartbeats, for example the last 1,000. From those it estimates the distribution of intervals. When a heartbeat is late, it computes phi, defined as minus the base-10 logarithm of the probability that a heartbeat would arrive even later than now, if the peer were alive.

So phi is a suspicion level on a logarithmic scale. Phi = 1 means there is roughly a 10 percent chance that the peer is alive and the heartbeat is just late; phi = 2 means about 1 percent; phi = 8 means about one in 100 million. The node convicts the peer when phi crosses a threshold. The word accrual refers to the fact that suspicion accumulates continuously as the silence grows, rather than flipping from alive to dead at one instant.

Java
// Cassandra-style estimate: intervals modelled as exponential with the observed mean
double mean = window.mean(); // e.g. 1,000 ms between heartbeats
double phi(long sinceLastMs) {
return sinceLastMs / (mean * Math.log(10)); // = 0.434 * t / mean
}
phi(1_000); // 0.43 normal
phi(5_000); // 2.17 a little late
phi(18_500); // 8.03 convict with the default threshold of 8
// a peer on a noisy link with mean 1,600 ms reaches phi 8 only after about 29.5 s

The exact formula varies by implementation. Cassandra approximates the interval distribution with an exponential distribution based on the mean, as above, while Akka and Apache Pekko clusters model it as a normal distribution using the mean and standard deviation, plus a configurable acceptable heartbeat pause. Check your version's documentation for the details; the principle is the same.

4Why Adapting to Each Link Helps

Because the history is kept per peer, the detector automatically adjusts to each link. A peer in the same rack whose heartbeats arrive every 1,000 ms with little variation is suspected quickly when it goes silent. A peer across zones whose heartbeats are often delayed by hundreds of milliseconds builds a history with a larger mean or spread, so the same silence produces a lower phi, and it is not convicted for ordinary jitter. A single fixed timeout would be too short for one link or too long for the other.

Cassandra exposes the threshold as phi_convict_threshold in cassandra.yaml, with a default of 8. On noisy cloud networks it is sometimes raised to 10 or 12, which tolerates more jitter at the cost of slower detection. The threshold is the one knob operators tune, instead of a timeout per link.

5Detection Is Only a Suspicion

A detector, however good, produces a suspicion, not a verdict. What we do with it should be a separate decision. Stopping sending new requests to a suspected node is cheap and easily undone, so it can happen immediately. Removing a member from the cluster, promoting a replica or rebuilding data is expensive, so it is better decided with more evidence: a longer period of suspicion, confirmation from other nodes, or a quorum agreeing that the node is unreachable. Separating the two keeps fast reactions cheap and expensive reactions rare.

Step throughFrom heartbeat to action
  1. Record heartbeat intervals per peersliding window of recent gaps
  2. Compute phi from current silencehow unlikely is this gap?
  3. phi above threshold?
    YesSuspect the peerNoTreat as alive
  4. Cheap action nowstop routing new requests
  5. Expensive action laterremove member or fail over with more evidence or a quorum

5 steps in order. Play them, or step through them one at a time.

6Follow-up questions

Does phi accrual eliminate false positives?

No. It reduces them by judging each link against its own history, but a long enough pause will still push phi over any threshold. No detector can tell a slow node from a dead one with certainty, so systems must still handle false suspicions safely.

What happens to the history when a node restarts?

The window for that peer is reset, since the old intervals no longer describe it. Implementations usually start with a default estimate until enough fresh heartbeats arrive, which is why detection right after a restart behaves a little differently.

Why is phi on a logarithmic scale?

Because the probabilities involved span many orders of magnitude. A logarithmic scale turns one in ten, one in a hundred and one in a hundred million into the simple numbers 1, 2 and 8, which makes thresholds easy to reason about and tune.

7Conclusion

In this answer, we saw that a fixed heartbeat timeout trades fast detection for false positives, and that no detector can be perfect because a slow node and a dead node look the same in an asynchronous network. The phi accrual detector computes a suspicion level from each peer's history of heartbeat intervals, so it adapts to every link's normal jitter, and convicts when phi passes a threshold such as Cassandra's phi_convict_threshold of 8, also used by Akka and Pekko clusters. Finally, we separated suspicion from action, keeping expensive reactions for stronger evidence.

What to say in the interviewAbout 90 seconds aloud

Open with

A heartbeat timeout trades speed against false alarms. Short timeouts catch crashes fast but convict nodes that are just slow, a GC pause or CPU throttling, which causes needless failovers and data movement.

Then, if they want more

Long timeouts avoid that but keep sending requests to a dead node for longer. And there's no perfect value, because in an asynchronous network a slow node and a dead node look the same: you just hear nothing. Phi accrual changes the question from 'has the silence exceeded a fixed time' to 'how unlikely is this silence for this peer'.

Each node keeps a sliding window of heartbeat intervals per peer, and computes phi as minus log ten of the probability that a heartbeat would arrive even later than now if the peer were alive. So phi one is roughly ten percent, phi eight is one in a hundred million. When phi passes a threshold, the peer is convicted.

Because the history is per peer, it adapts to each link: a noisy cross-zone link with lots of jitter needs a longer silence to reach the threshold than a quiet local link. Cassandra exposes it as phi_convict_threshold, default eight, sometimes raised to ten or twelve on noisy clouds, and Akka and Apache Pekko clusters use the same detector.

I'd also treat detection as only a suspicion: stop routing immediately, but remove members or fail over only with more evidence or a quorum.

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 official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
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 "What trade-off does a heartbeat timeout make, and how does the phi accrual failure...": https://scrivio-interview-library.netlify.app/architecture/distributed-systems/c719e518bb/