In this lesson · topic 2 of 7
- 1. Silence is all you get
- 2. Heartbeats, timeouts and suspicion
- 3. Slide one detector along its curve
- 4. When a 600 ms pause beats the detector
- 5. Watching three hundred nodes without three hundred heartbeats each
- 6. Adding up a failover, and the storm a false alarm can start
- 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- mean gap
- 100 ms
- spread
- 12 ms
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.
A slow packet
One heartbeat is held up in the network. The silence reaches 180 ms. The fixed detector is nowhere near its 300 ms line. Phi reports how unlikely the silence is as a power of ten, and a gap this long is still an ordinary one.
A pause that looks like death
The node stops for a garbage collection pause. No heartbeat leaves it. At 300 ms of silence the fixed detector declares it dead. Phi climbs past 8, so a threshold of 8 would agree. Both are wrong, and nothing available to them could have told them so.
The pause ends
The node wakes and sends a heartbeat at once. Both detectors clear their suspicion. Whatever the system did during the false alarm, such as failing over or giving away a lock, has already happened.
A real crash
Now the node crashes. The silence grows exactly as it did in the pause. At 300 ms the fixed detector fires again, and this time it is right. The two situations produced the same evidence. Only the future told them apart.
- 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. mean gap: 100 ms; spread: 12 ms.
- A slow packet. One heartbeat is held up in the network. The silence reaches 180 ms. The fixed detector is nowhere near its 300 ms line. Phi reports how unlikely the silence is as a power of ten, and a gap this long is still an ordinary one. silence: 180 ms; φ: 10.9.
- A pause that looks like death. The node stops for a garbage collection pause. No heartbeat leaves it. At 300 ms of silence the fixed detector declares it dead. Phi climbs past 8, so a threshold of 8 would agree. Both are wrong, and nothing available to them could have told them so. silence: 340 ms; fixed 300 ms: suspects; φ: 29.2.
- The pause ends. The node wakes and sends a heartbeat at once. Both detectors clear their suspicion. Whatever the system did during the false alarm, such as failing over or giving away a lock, has already happened. silence: 30 ms; false alarms: 1.
- A real crash. Now the node crashes. The silence grows exactly as it did in the pause. At 300 ms the fixed detector fires again, and this time it is right. The two situations produced the same evidence. Only the future told them apart. silence: 340 ms; detection time: ~300 ms plus the gap to the last heartbeat.
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.