The Chandy-Lamport algorithm allows processes in a distributed system to consistently capture a global snapshot of the system state. Any process can initiate the snapshot by sending a marker message along outgoing communication channels. When a process receives a marker, it records its local state and the state of incoming channels before sending markers on other outgoing channels. This propagation of markers throughout the system allows each process to consistently record its state and the state of all communication channels, providing an accurate view of the global system state at a single point in time.
❖ In aDistributed system, more processes may be
running on different physical servers. These processes
communicate with each other via communication channels
using text messaging.
❖ These processes neither have a shared memory nor a
common physical clock, so determining the global state of a
distributed system is very difficult.
❖ But a process could record its own local state at a given
time but a message that is in transit (on its way to be
delivered) will not be included in the recorded state and hence
the actual state of the system/process is incorrect after the
transit message is delivered.
3.
As shown inthe below diagram, if we record only the local states of the
process S1 and S2 and omit the communication channels, then Rs.500will not
be tallied in both accounts A and B as that deliveringmessage is in transit
between both accounts while taking snapshot
FOR EXAMPLE
4.
GLOBAL SNAPSHOT:
Global Snapshot= Global State = Collection of
individual states of each process in the distributed
system
+
individual state of each communication channel
in the distributed system
SNAPSHOT:
❖ Is a photograph of a process taken or record it
quickly.
6.
What is theneed for taking snapshots or recording
the global state of the system?
CHECK POINTING:
❖ Snapshot will use as a checkpoint, to restart the
application in case of failure.
COLLECTING GARBAGE:
❖ Use to remove objects that don't have any
references
DETECTING DEADLOCKS:
❖ Use to examine the current application state
CHANDY LAMPORT ALGORITHM
❖This algorithm always captures the consistent
global state of a distributed system
❖ The main idea behind the proposed algorithm is
that if we know that all messages that have been sent
by one process and they have been received by
another process, then we can record the global state
of the system.
12.
❖ Any processin the distributed system can
initiate this global state recording algorithm using a
special message called MARKER.
❖ This marker traverse the distributed system
across all communication channel and cause each
process to record its own state.
❖ In the end, the state of entire system (Global state)
is recorded.
❖ This algorithm does not interfere with normal
execution of processes.
13.
How it works
❖This algorithm can be initiated by any process by
executing the "Marker Sending Rule" records its local
state and sends a marker on each outgoing channel.
❖ The receiving process executes the "Marker
Receiving Rule" once received the marker. If incase,
the process has not yet recorded its local state, it sets
the state of the incoming channel on which the marker
has been received as EMPTY or NULL
14.
❖ The incomingchannel on which the marker has
been received is set as empty in order to block any
other messages coming on this channel while
recording is being done.
❖ Then the receiving process executes the
"Marker Sending Rule" to record its own local state
+ record the state of other incoming channels i.e
except the channel on which the MARKER is
received.
15.
Let us assume,
Twoprocesses P1 & P2 are running two channels
are C12, C21
❖Now, P1 tellsP2 to change its state variable x2 to 4.
❖This is an another global snapshot of this distributed
system - No: 2
18.
❖ Now P2receives the message sent by p1 through
the channel C12. So the channel C12 becomes empty
now.
❖ Global snapshot of this distributed system No: 3
19.
❖ P2 changesits state variable x2 to 4.
❖ Global snapshot of the distributed system - No: 4
20.
❖ Now, theProcess P1 initiates the recording process.
i.e P1 is the initiator.
❖ So, P1 sends a MARKER message to P2 and begins recording
its local state and recording all messages on inbound
channels.
❖ Meanwhile, P2 also sent a message to P1
21.
❖ P2 receivesthe MARKER message for the first
time, so records its local state.
❖ Meanwhile P1 also receives the message M1, sent by p2
❖ Now, P2 sends a MARKER message to P1
22.
Now the statueis, P1 has already sent a
MARKER message to P2, so it records all
messages it received on inbound channels to the
appropriate channel's state
23.
Now, Both processeshave recorded
their states and also the states of their all
incoming channels
24.
❖Each process hasreceived a MARKER
on all of its incoming channels. i.e both
processes have recorded their local states.
❖Since only two processes running in this
distributed system, the algorithm terminates
here.
❖The collection of these two local snapshots,
determine the global state of the distributed
system.