SkillSprout
Chapter 18 · Lesson 2
Intermediate
4 min read

Push, Pull, Gossip and Adaptive Detection

Overview

Heartbeats can be sent by the node or requested by the monitor, and big clusters need smarter ways than "everyone watches everyone." This lesson covers push versus pull, gossip, and adaptive timeouts.

It also shows how health checks and leases are the same idea in everyday tools.

Detailed Notes

What are the heartbeat styles

  • Push: the node sends "I'm alive" to the monitor on a schedule.
  • Pull: the monitor asks the node "are you OK?" and waits for a reply. This is how a load balancer health check works.
  • Gossip: every node periodically shares what it knows about others with a few random peers.

The problem it solves

With 3 nodes, everyone can heartbeat everyone. With 1,000 nodes, "all-to-all" means about a million messages per round (N times N), which drowns the network. Also, a fixed timeout like 10 seconds is wrong when network delay changes between calm and busy periods. These styles fix those two scaling problems.

How it works

Push vs pull

PushPull
Who startsNodeMonitor
Good whenNodes are behind firewalls or come and go oftenYou want to test a real endpoint (a deep check)
DrawbackA node can send beats while its real work is brokenMonitor must know every node and reach it

Gossip. Each node keeps a table of "node: heartbeat counter." Regularly it bumps its own counter and sends the table to a few random peers. Peers merge tables by keeping the higher counter for each node. If a node's counter stops growing everywhere, it is suspected. Traffic per node stays constant, and news spreads to everyone in roughly log N rounds, like a rumour. To avoid blaming a node for one bad link, a suspecting node can ask a third node to probe the suspect indirectly; if anyone reaches it, it is alive.

Adaptive (phi-accrual) detection. Instead of a fixed timeout and a yes/no answer, the detector learns how heartbeats normally arrive and outputs a suspicion score (phi) that rises as silence becomes unusual. You act above a threshold. If the network is jittery, the detector learns to tolerate longer gaps, so fewer false alarms.

Health checks. Real systems use two flavours:

  • Liveness: "is the process alive?" If not, restart it.
  • Readiness: "can it serve requests right now?" If not, stop sending it traffic but do not restart it (it may just be warming up).

Leases. A lease is a claim that lasts for a limited time and must be renewed by heartbeat. If the holder dies and stops renewing, the lease expires on its own and others can take over. Nobody has to prove the holder is dead.

A simple example

A parent gives a child a phone and says "text me every hour." If the child has been quiet for a while, the parent compares it to normal. At a theme park with poor signal, long gaps are normal; at home, the same gap is alarming. That is adaptive detection. The agreement "this room is yours until 5 p.m. unless you renew it" is a lease.

System design example

A cache cluster of 500 nodes uses gossip so no central monitor is a bottleneck. Meanwhile, on each application server, a web container exposes a readiness check: during start-up it reports "not ready," so the load balancer withholds traffic until warm. In a job system, a worker holds a lease on a task and renews it every 10 seconds; if the worker crashes, the lease expires and another worker picks the task up.

Summary

  • Push: node reports in. Pull: monitor asks. Pick pull for deep checks, push for nodes behind firewalls.
  • All-to-all heartbeats do not scale; gossip spreads liveness with constant traffic per node.
  • Adaptive detectors turn silence into a suspicion score that fits current network conditions.
  • Liveness restarts, readiness controls traffic; a lease is a time-limited claim renewed by heartbeat.

Architecture Diagram

Gossip failure detection
Architecture
Nodeheartbeat counter

Peers

Peer 1
Peer 2
Phi detectorsuspicion score

Counters spread through random peers; a detector turns silence into suspicion.

  1. 1Each node increments its own heartbeat counter regularly.
  2. 2It gossips its table to a few random peers.
  3. 3Peers merge by keeping the highest counters.
  4. 4A detector turns long silence into a suspicion score and acts above a threshold.

Common Interview Questions

Chapter quiz

Heartbeats · 5 questions

  1. 1.What does a failure detector actually observe?

  2. 2.A very short timeout mainly risks:

  3. 3.Why avoid all-to-all heartbeats in huge clusters?

  4. 4.How does gossip merge two tables?

  5. 5.What is a lease?

0 of 5 answered

Finished this lesson?

0 of 91 lessons done · 0% of the course