Skip to main content
Lexicon
Lexicon

Chandy-Lamport Distributed Snapshot Algorithm

Difficulty: Advanced
3 min read

In plain English

Plain definition

A way to take a coherent 'photograph' of every process and every message currently travelling between processes in a distributed system, even though nothing stops running while the photo is taken. Each process notes its own state and passes along a special marker; messages caught mid-flight are recorded too, so the resulting snapshot never shows a message being received without it having been sent.

The algorithm operates on the assumption of FIFO, reliable, point-to-point channels between processes in a system modeled as a directed graph. A snapshot is initiated when one or more processes record their own local state and immediately send a special marker on every outgoing channel before any further application message, then start recording on their incoming channels. The core invariant being enforced is that the resulting global state is a valid consistent cut — meaning that if the snapshot records a message as received, it must also record it as sent. A message sent but not yet received is not an inconsistency but a message in transit, which the algorithm records in its channel’s state rather than losing.

Each process follows a simple rule set upon marker arrival: on receiving the first marker on any incoming channel, a process immediately records its own local state, records the state of that channel as empty, sends a marker on each of its outgoing channels before sending any further application messages on it, and starts recording on all of its other incoming channels. For each of those channels, the recorded channel state is the sequence of application messages received after the process recorded its state and before the marker arrives on that channel. This is the mechanism that captures messages in transit at the moment of the logical cut: messages sent before the sender recorded its state but received after the receiver recorded its own. Without it, those messages would appear in neither process’s state, so the global state would be incomplete (money in transit between two accounts would vanish from the total). A receive with no corresponding send is ruled out separately: on a FIFO channel, any message sent after the sender’s snapshot arrives behind the marker, after the receiver has recorded its state.

Key properties and edge cases engineers must account for:

  • Non-blocking: processes never pause to wait for the snapshot to complete; they interleave marker handling with normal execution, which is why this scales to production systems rather than requiring stop-the-world coordination.
  • Termination detection is a separate concern — a coordinator (or diffusion-based completion protocol) must detect when every process has recorded its state and every channel’s marker has been processed, since there’s no global clock to signal ‘snapshot complete.’
  • Channel ordering dependency: the algorithm’s correctness collapses if channels are not FIFO; message reordering can produce cuts that violate causal consistency (a receive without its corresponding send).
  • Multiple concurrent initiators are supported — if several processes trigger snapshots independently, the algorithm still converges on one consistent global cut, because each process records its state only once, on the first marker it receives, and later markers only close recording on their channels.

In modern infrastructure, this algorithm underlies distributed checkpointing mechanisms in stream processing engines — Apache Flink’s asynchronous barrier snapshotting is a direct descendant, using barriers (markers) injected into data streams to align exactly-once state checkpoints across parallel operators without pausing the pipeline. It’s also foundational to deadlock detection in distributed databases and to constructing globally consistent views for distributed garbage collection. The core architectural lesson it encodes — that a ‘global state’ in an asynchronous system is not a single instant but a causally-consistent cut reconstructed from local observations plus channel history — informs how engineers reason about consistency in any system lacking synchronized clocks.

About this page

Credited to

Dates

Published

Corrections

  • : Corrected during a review of published articles. Details

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

More from KBY that goes with this term.

What Is Chandy-Lamport Distributed Snapshot Algorithm?