# Heartbeat

**In short:** Heartbeat is an availability tactic for spotting failures. One component sends a message at regular intervals and another listens. If the messages stop, the listener assumes the sender failed and triggers fault correction.

## Explanation

Heartbeat is a way to detect that a component has failed. It is one of the fault detection tactics (see the article "Fault Detection Tactic"). These tactics support availability, which is a system's ability to be working when needed.

**How it works.** One component, the monitored one, sends a small message at regular intervals. Another component listens for these messages. While they keep arriving, the listener assumes all is well. If the heartbeat stops, the listener assumes the sender has failed. It then notifies a fault correction component, which handles recovery.

**Who starts the exchange.** In a heartbeat, the monitored component starts the exchange. The listener only receives. This is the opposite of Ping/Echo. There, the monitor sends a ping and expects an echo from the monitored component within a set time.

**Where it sits among related tactics.** Exception detection works inside a single process. Heartbeat works across processes: one component watches another.

**The same idea in other catalogs.** Fowler's HeartBeat pattern has a server show it is available by periodically messaging the other servers. Enterprise Integration Patterns describes a heartbeat as a series of periodic messages showing that a component works well. An observer detects missing beats and raises alerts or takes corrective action.

**Choosing the timing.** Fowler advises setting the interval longer than the network round-trip time between the servers. The failure timeout is then a multiple of that interval.

**A contrast in practice.** Kubernetes liveness probes check whether a container is in a broken state. If it is, the kubelet restarts the container. The probe frequency is set with periodSeconds. A liveness probe is polling started by the kubelet, so it works like ping/echo, not like a heartbeat.

## Example

An order service and a monitoring component run on separate machines. Every few seconds the order service sends a short "I am alive" message to the monitor. The monitor allows a few intervals of silence. When the silence lasts longer than that, the monitor assumes the order service has failed. It then notifies the component that handles recovery, for example by starting a replacement.

## Trade-offs

The facts give one concrete timing rule. The interval should exceed the network round-trip time, and the failure timeout should be a multiple of the interval. Beyond that, the facts do not describe other costs or limits of heartbeat.

The monitored component sends heartbeats. When they stop, the listener notifies fault correction.

```mermaid
sequenceDiagram
    participant S as Monitored component
    participant M as Listener
    participant F as Fault correction
    S->>M: heartbeat
    S->>M: heartbeat
    Note over S,M: heartbeats stop
    M->>F: notify: component assumed failed
```

## Checks

- The document names which component sends the heartbeat and which component listens for it.
- The document states what happens when heartbeats stop: a fault correction component is notified.
- The heartbeat interval is longer than the network round-trip time, and the failure timeout is a multiple of the interval.
- The document distinguishes heartbeat (monitored side initiates) from ping/echo (monitor initiates).

## Related

- [Ping/Echo](https://arc.fuet.ch/concepts/tactics/ping-echo.md)
- [Fault Detection Tactic](https://arc.fuet.ch/concepts/tactics/availability-tactics-fault-detection.md)
- [Availability](https://arc.fuet.ch/concepts/quality-attributes/availability.md)
- [Availability Tactic](https://arc.fuet.ch/concepts/tactics/availability-tactics.md)
- [Exception Handling Tactic](https://arc.fuet.ch/concepts/tactics/exception-handling.md)
- [Fault Recovery Tactic](https://arc.fuet.ch/concepts/tactics/availability-tactics-fault-recovery.md)
- [Architectural Tactic](https://arc.fuet.ch/concepts/tactics/architectural-tactic.md)

## Sources

- [](https://people.ece.ubc.ca/matei/EECE417/BASS/ch05lev1sec2.html) — people.ece.ubc.ca, accessed 2026-11-08
- [HeartBeat](https://martinfowler.com/articles/patterns-of-distributed-systems/heartbeat.html) — martinfowler.com, accessed 2026-11-08
- [Heartbeat - Enterprise Integration Patterns 2](https://www.enterpriseintegrationpatterns.com/patterns/conversation/HeartBeat.html) — enterpriseintegrationpatterns.com, accessed 2026-11-08
- [Configure Liveness, Readiness and Startup Probes | Kubernetes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) — kubernetes.io, accessed 2026-11-08
