Heartbeats
When to Use Heartbeats
In Practice
How Heartbeats Comes Up in Interviews
Scenario
Your service mesh needs to detect when a pod has died (not just slow) so the load balancer stops routing to it. The standard mechanism is a periodic 'I'm alive' ping; missing N in a row marks the peer dead. What's the name?
Heartbeats are the foundational failure-detection primitive. Leases are built on top (a lease is essentially a heartbeat with ownership semantics) but the question is about plain liveness detection.
Heartbeats are the foundational failure-detection primitive in any distributed system, a periodic 'I'm alive' ping with a 'missed N in a row = dead' threshold. Kubernetes kubelets send heartbeats to the control plane; ZooKeeper ephemeral nodes are heartbeat-tied; Cassandra gossip and Redis Sentinel are heartbeat-based; Raft uses heartbeat-disguised AppendEntries to maintain leadership. The hard problem is distinguishing slow from dead: a 100ms heartbeat interval with 3 misses gives 300ms detection latency but can false-positive on a hiccup. SWIM gossip (used by HashiCorp Serf, Consul) makes failure detection probabilistic and constant-cost at scale, which is why it's preferred over O(n) ping-everything-from-the-leader designs.