The Chandy–Lamport algorithm is a snapshot algorithm that is used in distributed systems for recording a consistent global state of an asynchronous system. It was developed by and named after Leslie Lamport and K. Mani Chandy.[1]
According to Leslie Lamport's website, the snapshot algorithm was described when they visited Chandy, who was at the University of Texas (Austin). He posed the problem over dinner, but they had too much wine to think about it. The next morning, while Lamport was in the shower, he came up with the solution. When he arrived at Chandy's office, he was waiting for him with the same solution. They considered the algorithm to be the straightfoward application from the basic ideas of article 27, titled "Time, Clocks and the Ordering of Events in a Distributed System". [2]
The assumptions of the algorithm are as follows:
The algorithm works using marker messages. Each process that wants to initiate a snapshot records its local state and sends a marker on each of its outgoing channels. All the other processes, upon receiving a marker, record their local state, the state of the channel from which the marker just came as empty, and send marker messages on all of their outgoing channels. If a process receives a marker after having recorded its local state, it records the state of the incoming channel from which the marker came as carrying all the messages received since it first recorded its local state.
Some of the assumptions of the algorithm can be facilitated using a more reliable communication protocol such as TCP/IP. The algorithm can be adapted so that there could be multiple snapshots occurring simultaneously.
The Chandy–Lamport algorithm works like this:
From this, the observer builds up a complete snapshot: a saved state for each process and all messages “in the ether” are saved.