Skip to main content
KBY Technologies Logo
cd ../lexicon
sys/docs/lexicon/phi-accrual-failure-detector.md
Lexicon Entry

Phi Accrual Failure Detector

A failure detection algorithm that outputs a continuous suspicion level (phi), derived from the statistical distribution of historical heartbeat inter-arrival times, rather than a binary alive/dead verdict based on a fixed timeout.

Practical example

Akka Cluster computes phi per peer from a sliding window of heartbeat intervals and marks a node unreachable once phi exceeds a configured threshold (typically 8-12), rather than after a fixed number of missed pings.

Classical failure detectors operate on a fixed timeout: if no heartbeat arrives within T milliseconds, the node is declared dead. This is brittle under real-world network conditions where inter-arrival times are not constant but follow some distribution (often approximated as normal or exponential once GC pauses and network queuing are factored in). The Phi Accrual Failure Detector, introduced in the Hayashibara et al. paper and popularized by Akka and Cassandra’s gossip subsystem, instead maintains a sliding window of recent heartbeat inter-arrival intervals and computes a suspicion level φ(t) at any query time t based on how anomalous the current silence duration is relative to that historical distribution.

Mechanically, each node maintains a HeartbeatHistory buffer (bounded, e.g. last 1000 samples) per monitored peer. On each query, the detector computes the mean μ and standard deviation σ of the sampled intervals, then evaluates the probability P(now - t_last > Δ) that a heartbeat would still be legitimately late given the observed distribution. Phi is defined as φ = -log10(P). A phi value of 1 corresponds to roughly a 10% chance of a false positive; a phi of 8 corresponds to roughly a 1 in 100,000,000 chance. Consumers set a threshold (commonly 8-12 in Akka Cluster) above which the peer is marked unreachable, rather than the algorithm hard-coding a binary cutoff itself.

  • Self-tuning under jitter: On a congested network, the interval distribution widens naturally, so phi rises more slowly for the same absolute silence duration, suppressing false suspicions without operator intervention.
  • Cold-start problem: With an empty or sparse history buffer, variance estimates are unreliable; most implementations seed the buffer with a conservative bootstrap mean/stddev or clamp minimum standard deviation to avoid phi exploding to infinity on the first missed beat.
  • Non-stationarity: The algorithm assumes the recent past is representative of the near future. A sudden, permanent shift in network topology (e.g., a peer moved to a higher-latency AZ) causes a transient burst of false suspicions until the sliding window flushes stale samples.
  • Composability with quorum systems: Phi accrual output is typically fed into a higher-level membership protocol (SWIM-style dissemination, gossip convergence) rather than used to directly trigger STONITH or leader eviction, since a single node’s local phi computation is not itself agreed-upon cluster state.

The architectural payoff is that failure suspicion becomes a first-class, tunable signal rather than a hard binary, letting operators trade detection latency against false-positive rate via a single dimensionless threshold instead of re-tuning millisecond timeouts per deployment environment. The cost is interpretability: debugging why a node was marked unreachable requires inspecting the historical interval distribution at the time of the event, not just a single missed-deadline log line, which pushes observability requirements onto whatever heartbeat history buffer the implementation exposes.