Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views6 pages

Vector Clocking in Distributed Systems

The document discusses the importance of clock synchronization in distributed systems to ensure efficient communication and resource sharing among CPUs. It outlines various synchronization algorithms such as Cristian's Algorithm, Berkeley Algorithm, Network Time Protocol, Lamport's Clock, Vector Clock, and election algorithms like Bully and Ring, highlighting their mechanisms and applications. The study emphasizes the challenges posed by clock discrepancies and the need for effective synchronization methods to maintain system integrity and coordination.

Uploaded by

mescholar12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Vector Clocking in Distributed Systems

The document discusses the importance of clock synchronization in distributed systems to ensure efficient communication and resource sharing among CPUs. It outlines various synchronization algorithms such as Cristian's Algorithm, Berkeley Algorithm, Network Time Protocol, Lamport's Clock, Vector Clock, and election algorithms like Bully and Ring, highlighting their mechanisms and applications. The study emphasizes the challenges posed by clock discrepancies and the need for effective synchronization methods to maintain system integrity and coordination.

Uploaded by

mescholar12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Clock Synchronization in Distributed Systems

Amey Thakur1 , Mega Satish2


1-2Department of Computer Engineering, University of Mumbai, Mumbai, MH, India

[email protected], [email protected]

---------------------------------------------------------------------***---------------------------------------------------------------------
Abstract — Clock discrepancies are troublesome in a printer or scanner. However, resources are finite
distributed systems and pose major difficulties. To avoid and can be distributed in either collaborative or
mistakes, the clocks of separate CPUs must be synced. This competitive forms. Resources like a printer and
is to ensure that communication and resource sharing are scanner cannot be used by multiple processes
as efficient as possible. As a result, the clocks must be simultaneously, so they must wait for one process
constantly monitored and adjusted. Otherwise, the clocks to complete and then give a chance to the next
drift apart. Clock skew causes a disparity in the time values process. Another instance is producer-consumer
of two clocks. Both of these issues must be solved in order as well as client-server operations that operate in
to make effective use of distributed system characteristics. extensive cooperation.
In this study, we briefly explored the features of distributed
systems and its algorithms. 1.2 Need to resynchronize the clocks

Keywords — Clock Synchronization, Distributed Systems, So there is a need for proper allocation of available
Physical Clock, Logical Clock, Cristian Algorithm, Berkeley resources, to preserve the state of resources and
Algorithm, Network Time Protocol (NTP), Lamport’s Clock, coordination between processes. Clock synchronization [2]
Vector Clock, Bully Algorithm, Ring Algorithm. is critical for resolving these problems. Clock
synchronization can be implemented by using the physical
1. INTRODUCTION clock and logical clock.

1.1 Distributed systems and its types 1.3 Issues in Clock Synchronization

Distributed System (DS) is a collection of computers A basic technique of clock synchronization [2][3] is for each
connected via a high-speed communication network [1]. A node to submit a time query message to the real-time
distributed system is one in which interconnected server. The node gets a reply message with the value of time
hardware and software interact and coordinate their 't'. This method has the following issues:
operations only through exchanging messages. - Every node's capacity to read the clock value of
another node. This can raise errors due to delays in
There are two types of Distributed Systems: message communication between nodes. The time
1. Homogeneous Distributed Systems: required to prepare, deliver, and get a blank
- It is a distributed system such that all nodes have message because of the lack of transmission
identical hardware, the same type of architecture, problems and system load can be used to calculate
and operating system. delay.
- Time should never be reversed since it might lead
2. Heterogeneous Distributed Systems: to the recurrence of events or transactions, causing
- It is a distributed system such that each node has chaos in the system. Time going backwards is only
its own operating system and machine a notion; it does not literally travel backwards.
architecture. Each node in a distributed system can
share its resources, e.g., the producer-consumer
processes and the client-server processes, sharing

| Page 1
1.4 Reasons for Delay in Synchronization integrated circuit. They are not flawless, but they
are relatively precise, reliable, and accurate. This
As discussed above, there are many reasons [3][4] for a implies that the clocks will differ from the correct
communication delay that needs to be minimized to time. Every timer is different in terms of
minimize delay and get a nearby accurate time. characteristics — characteristics that might
1. Communication Link Failure: For example, when change with time, temperature. Thus, each
sending a request message, the communication system's time will drift away from the true time at
link is working properly and the message reaches a different rate — and perhaps in a different
the server. If at the time of receiving a message, the direction (slow or fast).
communication link may fail due to some break. - It is feasible to coordinate physical clocks across
And the client may not be able to get a reply several systems, but it will never be accurate. The
message. After recovery, the reply reaches the drifting away from the real-time from each clock is
client which contains a false time value. something that happens in a distributed system.
2. Fault Tolerance: If any failure happens during
exchanging messages, the clock time may be 2. Logical Clock:
incorrectly interpreted. So the system should be - Logical clocks mean creating a protocol on all
fault-tolerant so that it can work in a faulty computers in a distributed system so that the
situation and minimize the clock drift value. computers can keep a uniform ordering of
3. Propagation Time: Due to heavy traffic or happenings inside some virtual time range.
congestion in the network, it may cause a large - In a distributed system, a logical clock is a
propagation time from server to client. It may technique for recording temporal and causative
cause the inaccurate reading of the clock value in links. Because distributed systems may lack a
the reply. physically synchronized global clock, a logical
4. Non-Receipt of Acknowledgement: It may be clock provides for the global ordering of
possible that due to the above reasons client will occurrences from various processes in certain
not get a reply within a round trip time and systems.
therefore it sends multiple requests to the server
for synchronization. 3. Clock Synchronization Algorithms
5. The Bandwidth of Communication Link: Due to the
low bandwidth of communication links, congestion 3.1 Cristian Algorithm
may occur in the network. As a result, requests for
time will be unable to reach the server and reply Cristian’s Algorithm is a centralized clock synchronization
messages will be unable to get to the client, algorithm used to synchronize time with a time server by
affecting clock synchronization. client processes. This algorithm works well with a low
latency network where the round-trip time — time
2. Clocks in Synchronization duration between the start of request and end of
corresponding response — is short as compared to the
In synchronization [2], there are two types of clocks. accuracy. It is an approach in which the client approaches
the server.
1. Physical Clock:
- Time isn't a big issue in traditional centralized
systems, where one or more CPUs share a common
bus. The entire system shares the same
understanding of time, right or wrong, it is
consistent.
- In distributed systems, this is not the case. Every
system, though, has its own timer that keeps the
clock running. These clocks are based on the
oscillation of a piezoelectric crystal or a similar Figure 1: Cristian’s Algorithm Workflow

| Page 2
A client sends a request to a time server for its current value
of the UTC time (𝑇s). The client records the time its request
was submitted (𝑇0) and the time it got the response (𝑇1).
Then, the client changes its current time at 𝑇1 with the
value received from the server plus its estimate of the delay
in obtaining this value, resulting in the total time required
to submit the query and get the response, which is
(𝑇1−𝑇0)/2. The new time value is thus 𝑇s+(𝑇1−𝑇0)/2.

Figure 3: Berkeley’s Algorithm Workflow

Here the time server has prior knowledge of the


approximate time required for the propagation of the
message which is used to readjust the message. The time
server then takes the average of all clock values of all the
computers. All clocks should be readjusted to the current
time which is the calculated average. The time server
readjusts its own clock value to this value and instead of
sending the current time to other computers, it sends the
Figure 2: Cristian’s Algorithm Working amount of time each computer needs for readjustment. The
value may be positive or negative.
Algorithm:
- Let S be the time server and Ts be its time.
- Process P requests the time from S.
- After receiving the request from P, S prepares a
response and appends time Ts from its own clock
and then sends it back to P.

3.2 Berkeley Algorithm

The Berkeley Algorithm is a centralized clock


Figure 4: Berkeley’s Algorithm Working
synchronization mechanism in a distributed system that
implies no computer has a precise timing source. The
3.3 Network Time Protocol
algorithm was developed by Gusella and Zatti at the
University of California, Berkeley in 1989. Network Time Protocol is a standard followed by
synchronization clocks on the internet. It is a decentralized
This algorithm is an example of an active time server algorithm.
approach: the time server periodically sends a message to
all the computers in the group. When the message is The Network Time Protocol (NTP) is a commonly employed
received, each computer then sends back its own clock Internet Engineering Task Force (IETF) standard (RFC
value to the time server. It is an approach in which the 1305). (RFC 1305). The main servers are directly linked to
server approaches the client. a precise and dependable UTC time source. They are the
foundations of hierarchical time service, with additional
servers becoming operational as we go away from the
roots. The common configuration includes UTC time
servers at big government institutions at stratum 1,
institutional time servers or Internet service providers'
time servers at stratum 2, and most users linking to
academic time servers at stratum 3.

| Page 3
NTP may synchronize computers in three modes: first is the In a distributed system, Lamport Clocks [5] are a basic
client-server mode, the second is the multicast mode, and mechanism for identifying the sequence of events. It gives a
the last is the symmetrical (peer) mode. In the client-server "Happened-Before" sequencing of occurrences. If there is
mode, the client makes queries to the server upon startup no “happened-before” relationship, then the events are
and on a regular basis thereafter. In a way similar to considered concurrent.
Cristian's technique, it tracks the time at which the request
and response are delivered and received in order to factor Algorithm:
out network latency as much as feasible. Because the server The “Happened before” relation between a and b is a -> b,
multicasts its time value on a regular basis, the multicast which means ‘a’ happened before ‘b’.
mode is frequently more efficient. On a local area network The criteria for logical clocks are:
with multicast capabilities, time resynchronization can be - Clock 1: Ci (a) < Ci(b), Ci -> Logical Clock, if ‘a’
accomplished in a single message rather than two messages happened before ‘b’, then the time of ‘a’ will be less
per client (e.g., Ethernet). However, in order to assess the than ‘b’ in a particular process.
network latency and adjust for it, the clients must first - Clock 2: Ci(a) < Cj(b), Clock value of Ci(a) is less
conduct a few client-server queries. However, if the than Cj(b).
network parameters change over time, the multicast
mode's accuracy will be inferior to that of the client-server 3.5 Vector Clock
mode.
In Lamport’s clock, if x -> y, then T(x)<T(y). But this does
The Simple Network Time Protocol (RFC 2030) is a not tell about the relationship between events x and y.
Network Time Protocol adaptation that supports operation That’s because Lamport’s clock do not capture causality.
in a stateless remote procedure call mode or multicast The causal relationship between messages is captured
mode. It is designed for use in contexts where a complete through vector clocks.
NTP implementation is neither required nor warranted.
SNTP is intended to be utilized at the endpoints of the Vector Clock [9] is an algorithm that creates a partial
synchronization subnet (high stratum) rather than for time ordering of occurrences and identifies causality breaches in
server synchronization. a distributed system. Such clocks extend on vector time to
provide for a logically coherent picture of the distributed
system; they identify if a contributed activity has triggered
another activity. It essentially captures all the causal
relationships. This approach assists in labelling each
process within the system with a vector (a list of numbers)
including an integer for each local clock. As a result, for
every N process, there will be a vector of size N.

Algorithm:
- All of the clocks are initialized to zero.
- When an internal event happens in a process, the
Figure 5: Architecture of Network Working Protocol number of the process's logical clock in the vector
is increased by one.
- Also, every time a process sends a message, the
3.4 Lamport’s Clock
value of the process's logical clock in the vector is
In a distributed system, it is not necessary for the clocks to incremented by one.
be absolutely synchronized. If two processes do not interact - Every time a process receives a message, the value
with each other, it is not necessary that their clocks need to of the process's logical clock in the vector is
be synchronized because the lack of synchronization would incremented by one, and moreover, each element
not matter. It is not important for all processes to agree on is adjusted by calculating the maximum value of
what the current time is but they should agree on the order the vector clock and the vector value in the
in which events occur. incoming message.

| Page 4
3.6 Election Algorithms

Algorithms used in distributed systems necessitate the


usage of a coordinator who performs duties required by
other processes in the system. Election algorithms [7] are
meant to select a coordinator.

Election algorithms choose a process from a group of


processors to act as a coordinator. If the coordinator
process fails for whatever reason, another processor
chooses a new coordinator. The election algorithm decides
where a new copy of the coordinator should be begun.

The election method is based on the assumption that each


active activity in the system has a distinct priority number.
As a new coordinator, the process with the utmost priority
will be picked. Hence, when a coordinator fails, this
algorithm elects that active process that has the highest
priority number. Then this number is sent to every active
process in the distributed system.

3.6.1 Bully Algorithm:

Bully Algorithm [7] was proposed by Garcia Molina. This


algorithm is planned on assumptions: a. Each process in a
situation has a process identifier that may be used to
identify it uniquely.
Figure 6: Working of Bully Algorithm
Each process should know the process numbers of all the
remaining processes. 3.6.2 Ring Algorithm:
The process with the highest process number is elated as
coordinator. The ring algorithm [8] is another example of an election
algorithm. This algorithm assumes that the processes are
Algorithm: arranged in a logical ring and each process knows the order
- A process P notices that the coordinator is no of the ring of processes. The processes are able to ‘skip’
longer responding, it will initiate an election. faulty systems - systems that don’t respond in a fixed
- P will send the election to all other processes with amount of time.
a higher process id than its. If no one responds, Algorithm:
process P becomes the coordinator. - Here, when the process notices that the
- If one of the higher processes answers, P’s job is coordinator is dead, it builds and sends an election
done and the higher process will take over. message to other processes.
- When process P gets a message from one of its - At every step, processes keep on adding their own
lowered id, it sends an OK message to the sender id at the end of this.
that it will take over and that the process is alive. - This stops when the initiator -- a process that
- Eventually, all processes will give up apart from started the election -- receives the message it sent.
one, which is the coordinator. The coordinator - After this, the process with the higher id is declared
finally wins and announces its victory by sending a to be a coordinator.
message to everyone. - The initiator then announces the coordinator by
sending the message to the nodes.

| Page 5
- Here the maximum number of initiators is 2.
REFERENCES

[1] Latha, C. A., and H. L. Shashidhara. "Clock


synchronization in distributed systems." In 2010 5th
International Conference on Industrial and Information
Systems, pp. 475-480. IEEE, 2010.
[2] Horauer, Martin. "Clock synchronization in distributed
systems." PhD diss., 2004.
[3] Sampath, Amritha, and C. Tripti. "Synchronization in
distributed systems." In Advances in Computing and
Information Technology, pp. 417-424. Springer, Berlin,
Heidelberg, 2012.
[4] Biradar, Shripad, Santosh Durugkar, and Subhash
Patil. "Handling Clock synchronization Anomalies in
Distributed System."
[5] Simons, Barbara. "An overview of clock
synchronization." Fault-Tolerant Distributed
Computing (1990): 84-96.
[6] Welch, Jennifer Lundelius, and Nancy Lynch. "A new
fault-tolerant algorithm for clock synchronization."
Information and computation 77, no. 1 (1988): 1-36.
[7] Arghavani, A., E. Ahmadi, and A. T. Haghighat.
"Improved bully election algorithm in distributed
systems." In ICIMU 2011: Proceedings of the 5th
international Conference on Information Technology &
Multimedia, pp. 1-6. IEEE, 2011.
[8] Soundarabai, Paulsingh & Thriveni, J. & Manjunatha, H.
& K R, Venugopal & Patnaik, Lalit. (2013). Message
Efficient Ring Leader Election in Distributed Systems.
[9] Baldoni, Roberto, and Michel Raynal. "Fundamentals of
Figure 7: Working of Ring Algorithm distributed computing: A practical tour of vector clock
systems." IEEE Distributed Systems Online 3, no. 2
(2002): 12.
CONCLUSION

Several synchronization algorithms in distributed systems


have been studied in this paper. In terms of algorithms, we
can conclude that for clock synchronization, both
centralized and distributed algorithms must account for the
propagation time of messages among each node. The
sequencing of processes and the preservation of resource
status requires clock synchronization. When it comes to the
concept of time in distributed systems, the most essential
element is to get the events in the right sequence. Events
can be positioned either in chronological order with
Physical Clocks or in a logical order with Lamport's Logical
Clocks and Vector Clocks along the execution timeline.
| Page 6

You might also like