In distributed systems, the lack of a shared clock and a shared memory space makes it difficult to know if a remote node is functioning correctly. Heartbeats and Leases are two complementary patterns used to manage node presence and resource authority.
A Heartbeat is a periodic signal sent from one node to another (usually a leader or monitor) to indicate that it is still operational.
Heartbeats are prone to false positives caused by network jitter or heavy CPU load. Modern systems use the Phi Accrual Failure Detector to provide a probabilistic suspicion level instead of a binary Up/Down status.
A Lease is a time-bound grant of authority over a shared resource. It is essentially a "lock with an expiration date."
Traditional locks are dangerous in distributed systems. If a node acquires a lock on a database row and then crashes, the resource remains locked forever.
| Feature | Heartbeat | Lease |
|---|---|---|
| Primary Goal | Failure detection. | Resource coordination (Mutual Exclusion). |
| Mechanism | "I am alive" signal. | "I have the right to act" contract. |
| Authority | No rights granted. | Exclusive rights granted for a window. |
| Direction | Node \to Monitor. | Client \leftrightarrow Lock Manager. |
Most production systems (etcd, ZooKeeper) combine these patterns: