Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
114 views
8 pages
Physical Vs Logical Clock
Uploaded by
Ranjan
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save physical vs logical clock For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
114 views
8 pages
Physical Vs Logical Clock
Uploaded by
Ranjan
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save physical vs logical clock For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save physical vs logical clock For Later
You are on page 1
/ 8
Search
Fullscreen
5118/2020, Distributed Systems: Physical, Logical, and Vector Clocks Distributed Systems: Physical, Logical, and Vector Clocks €é Joe Honour Dec 29, 2018 «7 min read : f ™~ a P2 Interactions within a Distributed System between 2 processes, P1 and P2, Distributed systems offer us the ability to solve problems we couldn't possibly solve with asingle machine, However, I have recently become painfully aware that every solution toa problem brings with it a series of new problems and considerations to be made. Within the realm of distributed systems, one of the largest problems we gain over a single machine system is attempting to keep a correct timeline of events. This is needed for a variety of reasons — one of the most crucial is understanding the ordering and causality of events within your system. This is what allows analysis to be performed when evaluating why your system executed a specific action. For instance, if you want to know why a particular value was written to your database, you may search for the series of events leading up to the point of the ivserr request being created. You can then place these events in chronological order using their timestamp, traversing from latest > oldest in order to understand the causality of actions leading up to the final value being written [Figure 1]. hitpsfevelup.gltconnected, comidietributed-systems-physica-ogieal-and-vector-clockt-7ea98015(780 ve5118/2020, Distributed Systems: Physical, Logical, and Vector Clocks E2: 12:31:35 Vi=0 v=5 Pt ES: 12:31:45 E4: 12:32:01 v V=6 — = EVENT TIME P1 = Single process of execution Figure 1 : this shows a series of events by a single process [P!], leading up to 2 database INSERT request being made. You can see that using timestamps allow the events to be placed in chronological order, showing haw the variable V ended up assuming the value 6 when sent to the database. When we have a single machine, a timeline of events is relatively easy to create, even if we have multiple processes (threads) creating events. This is due to all the events, across processes, sharing the same Physical Clock. When each one of those events logs the time in which it executed, we can guarantee when constructing a timeline that all events will be placed in the correct order with respect to each other. This is due to the same Physical Clock being used for all timestamps, providing a single global view of time [Figure 2]. Database INSERT E5:12:91:45 7: 12:9152 _sent v=6 Ve7 Pt E2: 12:31:26 EB: 12:92:01 va4 V=7 P2 E1: 12:90:20 E4: 12:81:36 56: 12:31:48 Ve ———- TIME © =evenT P1 = Single process of execution Figure 2: this shows 2 processes sending messages between each other affecting the variable V You can see that the timestamps still work as they are both on the same machine with the same single view of time. hitpsfevelup.gltconnected, comidietributed-systems-physica-ogieal-and-vector-clockt-7ea98015(780 285118/2020, Distributed Systems: Physical, Logical, and Vector Clocks Thus, we can order the events and determine what caused V to be equal to 7 when it was sent to the database. However, when we move to a distributed system we cannot rely on this property anymore. Let’s take our previous example to prove this. If we have events leading up to an INSERT now happening across multiple machines, each with their own local clock, and we use timestamps to place events in chronological order, we now have to guarantee that every machines clock has the exact same time. This is known as having a Global Clock, and is not easily achieved in a distributed system [Figure 3]. Database INSERT sent E3:12:31:95 65: 12:31:45 E: 12:31:52 v=0 v=5 v Vv Pt 2: 12:31:26 E68: 12:32:01 v V=7 P2 TIME © =EVENT P1 = Single process of execution on an individual machine Figure 3: the above diagram shows the inconsistent states we can get into if there is no global clock. You can see the clocks within P1 ane P2 differ enough for us to get incorrect ordering of events. We think E4 happens after E5 (blue) based on the timestamps only, We also see that E6 was sent after it arrives in P1 at E7 (red). This makes the system impossible to draw causelity from when investigating the database INSERT event. Instead, a distributed system really has an approximation of the Physical Time across all its machines. An approximation may be good enough if events happen infrequently, as you will always be able to place events into the correct chronological order as long as the clocks of every machine stay synchronized within some acceptable threshold. Though, in most distributed systems this is not a good enough guarantee. Therefore, we have to hitpsfevelup.gltconnected, comidietributed-systems-physica-ogieal-and-vector-clockt-7ea98015(780 ses1872020 Distributed Systems: Physical, Logical, and Vector Clocks look to a virtual way of expressing time between machines, so we can keep the ability to place events into an accurate timeline. This is the notion of Logical Clocks. Logical Clocks refer to implementing a protocol on all machines within your distributed system, so that the machines are able to maintain consistent ordering of events within some virtual timespan. This is more formally specified as a way of placing events in some timespan so the following property will always be true: Given 2 events (e1, e2) where one is caused by the other (e1 contributes to e2 occurring). Then the timestamp of the ‘caused by’ event (1) is less than the other event (e2). To provide this functionality any Logical Clock must provide 2 rules: Rule 1: this determines how a local process updates its own clock when an event occurs. Ruile 2: determines how a local process updates its awn clock when it receives a message from another process. This can be described as how the process brings its local clock inline with information about the global time. The simplest implementation of this is Scalar Time. In this representation each process keeps a local clock which is initially set to 0. It then provides the following implementation of the 2 rules: Rule 7: before executing an event (excluding the event of receiving a message) increment the local clock by 1. local_clock = local_clock + 1 Rule 2: when receiving a message (the message must include the senders local clock value) set your local clock to the maximum of the received clock value and the local clock value, After this, increment your local clock by 1 [Figure 4], 1, local_clock = max(local_clock, received_clock) 2, local_clock = local_clock + 1 hitpsfevelup.gltconnected, comiditributed-systems-physica-ogieal-and-vector-clockt-7ea98015(780 485118/2020, Distributed Systems: Physical, Logical, and Vector Clocks 3. message becomes available. 2 3 6 7 PIL 1 2 5 P2 — 1 3 4 5 TIME © =EVENT P1 = Single process of execution on an individual machine Figure 4: the above diagram shows how using Scalar Time, the 2 pracesses (P1 and P2) update their local clocks based on the messages they receive, We can see that Scalar Time provides an eventually consistent state of time. This means there may be places where the recorded time differs between processes but, given a finite amount of time, the processes will converge on a single view of the correct time. Causing this is the fact that internal events in a process (that apply Rule 1) loose consistency with regards to concurrent events on another process (red events in Figure 4). This is due to the use of a single number for both our global and local clocks across processes, \n order to become causally consistent we need a way of representing local time and global time separately. Thi: Vector Clocks expand upon Scalar Time to provide a causally consistent view of the world. This means, by looking at the clock, we can see if one event contributed (caused) another event. With this approach, each process keeps a vector (a list of integers) with an integer for each local clock of every process within the system. If there are N processes, there will be a vector of N size maintained by each process. Given a process (Pi) with a vector (v), Vector Clocks implement the Logical Clock rules as follows: hitpsfevelup.gltconnected, comidietributed-systems-physica-ogieal-and-vector-clockt-7ea98015(780 se5118/2020, Distributed Systems: Physical, Logical, and Vector Clocks Rule 1: before executing an event (excluding the event of receiving a message) process Pi increments the value v[i] within its local vector by 1. This is the element in the vector that refers to Processor(i)’s local clock. | tocal_vectorfi] = local_vectorfi] + 1 Rule 2: when receiving a message (the message must include the senders vector) loop through each element in the vector sent and compare it to the local vector, updating the local vector to be the maximum of each element. Then increment your local clock within the vector by 1 [Figure 5]. 1. for k = 1 to N: local_vector[k] = max(local_vector[k], sent_vector[k]) 2, local_vector[i] = local_vector[i] + 1 3. message becomes available, [2, 0, 0} (30,0) [44,1] (5,4, 1] PL [1, 0, 0) (2, 0, 0} [2, 3, 1] P2 [0, 1,0] [22,0] 2,4, 1] (2.5, 1] P3 (0, 0, 1] (0,0, 2} ——_—> TIME © =EVENT EXECUTING RULE 1 © =EVENT EXECUTING RULE 2 Figure 5: the above diagram shows how the vector clacks are updated when executing internal events, sending events and receiving events. It also shows the values of the vectors sent between processes, hitpsfevelup.gltconnected, comidietributed-systems-physica-ogieal-and-vector-clockt-7ea98015(780 oes1872020 Distributed Systems: Physical, Logical, and Vector Clocks Vector Clocks provide a causally consistent ordering of events, however this does come ata price. You can see that we need to send the entire Vector to each process for every message sent, in order to keep the vector clocks in sync. When there are a large number of processes this technique can become extremely expensive, as the vector sent is extremely large. There have been many improvements over the initial Vector Clock implementation mentioned, most notably: * Singhal-Kshemkalyané’s differential technique [1]: This approach improves the message passing mechanism by only sending updates to the vector clock that have occurred since the last message sent from Process(i) > Process(j). This drastically reduces the message size being sent, but does require O(n?) storage. This is due to each node now needing to remember, for each other process, the state of the vector at the last message sent. This also requires FIFO message passing between processes, as it relies upon the guarantee of knowing what the last message sent is, and if messages arrive out of order this would not be possible. © Fowler-Zwaenepoel direct-dependency technique [2]: This technique further reduces the message size by only sending the single clock value of the sending process with a message. However, this means processes cannot know their transitive dependencies when looking at the causality of events. In order to gain a full view of all dependencies that lead to a specific event, an offline search must be made across processes. In conclusion, we can see that when we go to a distributed system maintaining order becomes a difficult problem. In order to solve this we have to create an artificial view of time, known as Logical Time, There are many solutions that provide an implementation of Logical Time. Scalar Clocks provide a naive solution to the problem, giving an eventually consistent ordering of events. Vector Clocks then build upon this technique by separating local and global clocks of processes, meaning event ordering can be made causally consistent. Furthermore, improvements are made upon Vector Clocks to improve their performance at the cost of needing greater storage space or requiring analysis of causality to be performed offline. hitpsfevelup.gltconnected, comidietributed-systems-physica-ogieal-and-vector-clockt-7ea98015(780 1811872020 Distrbuted Systems: Physical, Logical and Vector Cocks This article was based on the book “Distributed Computing: Principles, Algorithms and Systems” [3], which I highly recommend reading. hope you enjoyed the read. :} Joe Honour - Software Engineer - BJSS | Linkedin profile on LinkedIn, 5 jobs listed on world's largest professional View Joe Honour's community. Joe h wwwilinkedin.com References: [1]: Singhal, M. and Kshemkalyani, A.D., 1992. An efficient implementation of vector clocks. Information Processing Letters, 43(1), pp.47-52. [2]: Fowler, J. and Zwaenepoel, W., 1990, May. Causal distributed breakpoints. In Distributed Computing Systems, 1990. Proceedings., 10th International Conference on (pp. 134-141). IFEE. [3]: Kshemkalyani, A.D. and Singhal, M., 2011. Distributed computing: principles, algorithms, and systems. Cambridge University Press, ec Systems Software Development Software Engineering Consistency Programming Dis eee aod hitpsfevelup.gltconnected, comidietributed-systems-physica-ogieal-and-vector-clockt-7ea98015(780 8
You might also like
The Chess Course
PDF
74% (39)
The Chess Course
632 pages
Distributed Computing Second Edition: Sunita Mahajan Seema Shah
PDF
100% (1)
Distributed Computing Second Edition: Sunita Mahajan Seema Shah
39 pages
Distributed Computing Second Edition: Sunita Mahajan Seema Shah
PDF
100% (1)
Distributed Computing Second Edition: Sunita Mahajan Seema Shah
39 pages
Module 2
PDF
No ratings yet
Module 2
67 pages
Chap2 Ds
PDF
100% (1)
Chap2 Ds
58 pages
CS3551 Distributed Computing Unit2
PDF
No ratings yet
CS3551 Distributed Computing Unit2
24 pages
Clocks-And Event Ordering-II
PDF
No ratings yet
Clocks-And Event Ordering-II
35 pages
UCS1701 - Distributed Systems
PDF
No ratings yet
UCS1701 - Distributed Systems
11 pages
Praful Zaveri - The Chess Course-4. Advanced-I (2013) PDF
PDF
No ratings yet
Praful Zaveri - The Chess Course-4. Advanced-I (2013) PDF
109 pages
DS 2
PDF
No ratings yet
DS 2
68 pages
Chap 7 Slides - Synchronization - Coordination
PDF
No ratings yet
Chap 7 Slides - Synchronization - Coordination
13 pages
Vector Clocks
PDF
No ratings yet
Vector Clocks
4 pages
Chapter 14
PDF
No ratings yet
Chapter 14
45 pages
Lecture10 LogicalClock
PDF
No ratings yet
Lecture10 LogicalClock
43 pages
Time and Global States PDF
PDF
No ratings yet
Time and Global States PDF
18 pages
DS Module-2
PDF
No ratings yet
DS Module-2
5 pages
DS 3
PDF
No ratings yet
DS 3
7 pages
3 Synchronization
PDF
No ratings yet
3 Synchronization
93 pages
Logical Time: (Scalar Time, Vector Time, and Matrix Time)
PDF
No ratings yet
Logical Time: (Scalar Time, Vector Time, and Matrix Time)
81 pages
DS Mod 2
PDF
No ratings yet
DS Mod 2
72 pages
Explanation
PDF
No ratings yet
Explanation
4 pages
Casuality and Time in Distributed Systems
PDF
No ratings yet
Casuality and Time in Distributed Systems
44 pages
Distributed System TYPED NOTES
PDF
No ratings yet
Distributed System TYPED NOTES
40 pages
6clock Synchronization
PDF
No ratings yet
6clock Synchronization
31 pages
2016 DistributedSystems 1B L4
PDF
No ratings yet
2016 DistributedSystems 1B L4
24 pages
1
PDF
No ratings yet
1
34 pages
Distributed Systems: Logical Time and Logical Clocks
PDF
No ratings yet
Distributed Systems: Logical Time and Logical Clocks
12 pages
cs3551 Unit II Notes None
PDF
No ratings yet
cs3551 Unit II Notes None
35 pages
Distributed Synchronization
PDF
No ratings yet
Distributed Synchronization
46 pages
BCSM-F21-050 7A Assignment #3
PDF
No ratings yet
BCSM-F21-050 7A Assignment #3
8 pages
DS 3
PDF
No ratings yet
DS 3
29 pages
LM10
PDF
No ratings yet
LM10
43 pages
Unit 2 Part 1
PDF
No ratings yet
Unit 2 Part 1
34 pages
Clock Synchronizationin Distributed Systems
PDF
No ratings yet
Clock Synchronizationin Distributed Systems
20 pages
Department of Artificial Intelligence & Data Science
PDF
No ratings yet
Department of Artificial Intelligence & Data Science
23 pages
3 Synchronisation and Coordination
PDF
No ratings yet
3 Synchronisation and Coordination
119 pages
Consistent Global States of Distributed Systems: Fundamental Concepts and Mechanisms
PDF
No ratings yet
Consistent Global States of Distributed Systems: Fundamental Concepts and Mechanisms
33 pages
Synchronization in Distributed Systems
PDF
No ratings yet
Synchronization in Distributed Systems
51 pages
Module 4
PDF
No ratings yet
Module 4
38 pages
CS8603-Distributed Systems QA
PDF
No ratings yet
CS8603-Distributed Systems QA
57 pages
1 Removed
PDF
No ratings yet
1 Removed
24 pages
Distributed System
PDF
No ratings yet
Distributed System
30 pages
Unit 1
PDF
No ratings yet
Unit 1
21 pages
DC - Unit II
PDF
No ratings yet
DC - Unit II
43 pages
Kaku - Time and Global State Seminar
PDF
No ratings yet
Kaku - Time and Global State Seminar
8 pages
DisSys Lec5
PDF
No ratings yet
DisSys Lec5
14 pages
Coordination: CE32204 - Distributed System Presented By: Eka Stephani Sinambela Institut Teknologi Del
PDF
No ratings yet
Coordination: CE32204 - Distributed System Presented By: Eka Stephani Sinambela Institut Teknologi Del
16 pages
DC Unit II Notes
PDF
No ratings yet
DC Unit II Notes
27 pages
Zaveri Praful - Mastermind Chess I (2008, Francis ITI Printing Press)
PDF
100% (2)
Zaveri Praful - Mastermind Chess I (2008, Francis ITI Printing Press)
119 pages
D S (Comp9243)
PDF
No ratings yet
D S (Comp9243)
13 pages
Unit 1
PDF
No ratings yet
Unit 1
19 pages
Chapter 5 TimeState
PDF
No ratings yet
Chapter 5 TimeState
9 pages
Rohini 39764868099
PDF
No ratings yet
Rohini 39764868099
6 pages
Lecture Notes: Distributed OS Theories
PDF
No ratings yet
Lecture Notes: Distributed OS Theories
14 pages
Clocks and Global State
PDF
No ratings yet
Clocks and Global State
55 pages
Logical Clocks in Distributed Systems
PDF
No ratings yet
Logical Clocks in Distributed Systems
68 pages
Synchronization in Distributed Systems
PDF
No ratings yet
Synchronization in Distributed Systems
55 pages
Chapter 5 - Theoretical Foundations
PDF
No ratings yet
Chapter 5 - Theoretical Foundations
36 pages
ch4 2-Fall08
PDF
No ratings yet
ch4 2-Fall08
30 pages
311 Session27Ardavan2
PDF
No ratings yet
311 Session27Ardavan2
41 pages
K Nearest Neighbor Classification
PDF
0% (1)
K Nearest Neighbor Classification
32 pages
Chapter 3: Logical Time: Ajay Kshemkalyani and Mukesh Singhal
PDF
No ratings yet
Chapter 3: Logical Time: Ajay Kshemkalyani and Mukesh Singhal
67 pages
Logical Clock Implementation in The Distributed System: ISSN: 2454-132X Impact Factor: 4.295
PDF
No ratings yet
Logical Clock Implementation in The Distributed System: ISSN: 2454-132X Impact Factor: 4.295
6 pages
Chapter 3
PDF
No ratings yet
Chapter 3
5 pages
Clocks DOS
PDF
No ratings yet
Clocks DOS
9 pages
Certificate PDF
PDF
No ratings yet
Certificate PDF
1 page
DSND Certificate PDF
PDF
No ratings yet
DSND Certificate PDF
1 page
General formula for AM x (t) m Given: E E m = = = = = E sin (2π f t) + E sin (2 π f m t) sin (2 π f c t) 2cos (2π f c t) + 0.5cos (2 π f m t) cos (2 π f c t) E / E
PDF
No ratings yet
General formula for AM x (t) m Given: E E m = = = = = E sin (2π f t) + E sin (2 π f m t) sin (2 π f c t) 2cos (2π f c t) + 0.5cos (2 π f m t) cos (2 π f c t) E / E
45 pages
Downloadudacity PDF
PDF
No ratings yet
Downloadudacity PDF
1 page
Lecture 4 Compatibility Mode
PDF
No ratings yet
Lecture 4 Compatibility Mode
15 pages
Lamport
PDF
No ratings yet
Lamport
3 pages
Clocks in Distributed System
PDF
No ratings yet
Clocks in Distributed System
34 pages
CSE543: Machine Learning: Lecture 2: August 6, 2014
PDF
No ratings yet
CSE543: Machine Learning: Lecture 2: August 6, 2014
27 pages
Applications For Public-Key Cryptosystems
PDF
No ratings yet
Applications For Public-Key Cryptosystems
25 pages
Playing SNES in The Retro Learning Environment
PDF
No ratings yet
Playing SNES in The Retro Learning Environment
11 pages
LECTURE NOTE-1 - P0uO32a7WI
PDF
No ratings yet
LECTURE NOTE-1 - P0uO32a7WI
9 pages
Computer Architecture Assignment 1
PDF
No ratings yet
Computer Architecture Assignment 1
8 pages
Assignment No. 2 Assignment No. 2: 16 July 2020
PDF
No ratings yet
Assignment No. 2 Assignment No. 2: 16 July 2020
1 page
Information & System Security Assignment - II
PDF
No ratings yet
Information & System Security Assignment - II
1 page
Information & System Security Assignment - I
PDF
No ratings yet
Information & System Security Assignment - I
1 page
Assignment No. 1 Assignment No. 1
PDF
No ratings yet
Assignment No. 1 Assignment No. 1
1 page
Information & System Security Assignment - III
PDF
No ratings yet
Information & System Security Assignment - III
1 page