Try
↑ ↓ move↵ openesc close
In this lesson · topic 2 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 2

Heartbeats, timeouts and suspicion

5 min read

The monitor’s view

The monitored node sends a heartbeat at a fixed interval. The monitor records the arrival time of each one and keeps a short window of the gaps between arrivals. That window, plus the current silence, is everything a detector has. Step through a pause and a crash below and watch what the monitor can and cannot see.

A pause and a crash, seen from outside

Step 1 / 5
300 ms timeoutnownode: alive · silence 30 ms · fixed says alive · φ 0.0lines: heartbeats at the monitor · shaded: silence since the lasta regular stream: one heartbeat about every 100 ms.
mean gap
100 ms
spread
12 ms
  1. Heartbeats arrive

    The monitored node sends a heartbeat every 100 ms. The monitor records when each one arrives and keeps a window of the gaps between arrivals. The phi detector fits a mean and a spread to that window.

Fixed timeout

The simplest rule compares the current silence with a constant. Silence above the timeout means suspected. The next heartbeat clears it. Detection time for a crash is the timeout minus whatever part of it had already run down between the last heartbeat and the crash, because the node never sends again. The false alarm rate is how often a live node is silent longer than the timeout, which depends on the network’s delay spread and on the node’s pauses.

Nothing in the rule knows about either. Tune it for a quiet network and it fires constantly on a noisy one. Tune it for the noisy one and it is slow everywhere.

Phi accrual

The phi accrual detector, from Hayashibara and colleagues, replaces the constant with a question: given the gaps I have seen, how unlikely is the current silence? It fits a mean and a spread to the window and reports the probability that a heartbeat would arrive this late, on a log scale. Phi of 1 means about a one in ten chance, phi of 2 one in a hundred, phi of 8 one in a hundred million.

The application picks a threshold on phi instead of a timeout in milliseconds. The useful property is that the threshold is relative. On a regular stream the spread is small and the same threshold fires after a short silence. On a jittery stream the spread is large and the detector waits longer by itself.

What a suspicion is for

Chandra and Toueg described detectors by two properties. Completeness: every crashed node is eventually suspected. Accuracy: live nodes are not suspected, in weaker and stronger forms. No detector in an asynchronous network can have both perfectly, and their result is that consensus does not need one that does. It is enough that eventually some live node stops being wrongly suspected.

The practical reading of that is the rule the rest of this module follows. A suspicion may trigger an action, but the action must stay correct if the suspicion was wrong. Raft’s terms and leases with fencing tokens are both ways of making actions safe under false alarms.

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