Lecture 9: Time & Clocks CDK4: Sections 11.1 – 11.4 CDK5: Sections 14.1 – 14.4 TVS: Sections 6.1 – 6.2 Topics: Synchronization Logical time (Lamport) Vector.

Slides:



Advertisements
Similar presentations
Time in Distributed Systems
Advertisements

Time and synchronization (“There’s never enough time…”)
Time and Clock Primary standard = rotation of earth De facto primary standard = atomic clock (1 atomic second = 9,192,631,770 orbital transitions of Cesium.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Time and Synchronization Steve Ko Computer Sciences and Engineering University at Buffalo.
Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428 Fall 2011 August 30, 2011 Lecture 3 Time and Synchronization Reading: Sections
Time and Global States Ali Fanian Isfahan University of Technology
L-8 Synchronizing Physical Clocks 1 Announcements Proj1 checkpoint – due midnight tonight HW1 checkpoint – due 2/12 2.
Distributed Systems Spring 2009
CS 582 / CMPE 481 Distributed Systems Synchronization.
Distributed Systems Fall 2010 Time and synchronization.
Teaching material based on Distributed Systems: Concepts and Design, Edition 3, Addison-Wesley Copyright © George Coulouris, Jean Dollimore, Tim.
Time and Global States Chapter 11. Why time? Time is an Important and interesting issue in distributes systems. One we can measure accurately. Can use.
Time in Distributed Systems Distributed Systems. Why Time is Important? If you work in the industry, you never have to worry about this You’ll rarely.
Teaching material based on Distributed Systems: Concepts and Design, Edition 3, Addison-Wesley Copyright © George Coulouris, Jean Dollimore, Tim.
© Chinese University, CSE Dept. Distributed Systems / Distributed Systems Topic 9: Time, Coordination and Replication Dr. Michael R. Lyu Computer.
Distributed Systems CS Synchronization – Part II Lecture 8, Sep 28, 2011 Majd F. Sakr, Vinay Kolar, Mohammad Hammoud.
1 Slides for Chapter 10: Time (and Global State) From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley.
Distribuerede systemer – 5. marts 2001 Presentation based on slides by Coulouris et al.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.
EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.
Distributed Systems Foundations Lecture 1. Main Characteristics of Distributed Systems Independent processors, sites, processes Message passing No shared.
Lecture 2-1 CS 425/ECE 428 Distributed Systems Lecture 2 Time & Synchronization Reading: Klara Nahrstedt.
PHYSICAL AND LOGICAL TIME EE324 Lecture 11 Last Time– RPC  Why remote procedure calls?  Simple way to pass control and data  Elegant transparent way.
1 Physical Clocks need for time in distributed systems physical clocks and their problems synchronizing physical clocks u coordinated universal time (UTC)
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
1DT066 D ISTRIBUTED I NFORMATION S YSTEM Time, Coordination and Agreement 1.
Distributed Mutex EE324 Lecture 11.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
Time and Coordination March 13, Time and Coordination What is time? :-)  Issue: How do you coordinate distributed computers if there is no global.
Parallel and Distributed Simulation Synchronizing Wallclock Time.
TIME AND GLOBAL STATES Đàm Vĩnh Tường ( ) Nguyễn Lê Anh Đào ( ) Trần Viễn Phúc ( )
Page 1 Logical Clocks Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation is.
Chapter 10: Time and Global States
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
1 Time (and Global State). 3 Time – basics zWe want to know when something happened - Physical and logical clocks. zAlgorithms may depend upon clock.
Synchronization Distributed System. Why synchronization? Two sharpshooters in a multiplayer online game kill the same target. Which one gets the points?
Lecture 9: Time and clocks (Chap 11) Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
Time This powerpoint presentation has been adapted from: 1) sApr20.ppt.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Lecture 9 – Time Synchronization
Distributed Systems Concepts and Design Chapter 11: Time and Global States Steve Wallis, Raymond Ho, Bruce Hammer.
Time and global states Chapter 11. Outline Introduction Clocks, events and process states Synchronizing physical clocks Logical time and logical clocks.
Distributed Systems CS Synchronization – Part I Lecture 8, Sep 23, 2013 Mohammad Hammoud.
Distributed Systems Topic 5: Time, Coordination and Agreement
CS 582 / CMPE 481 Distributed Systems Synchronization.
Hwajung Lee. Primary standard = rotation of earth De facto primary standard = atomic clock (1 atomic second = 9,192,631,770 orbital transitions of Cesium.
Distributed Systems Lecture 5 Time and synchronization 1.
CSE 486/586 CSE 486/586 Distributed Systems Time and Synchronization Steve Ko Computer Sciences and Engineering University at Buffalo.
Page 1 Clock Synchronization: Physical Clocks Minqi Zhou Distributed Systems Except as otherwise noted, the content of this presentation.
Distributed Web Systems Time and Global State Lecturer Department University.
Topic 7: Time and Global State Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Distributed Computing
Time and Global States Ali Fanian Isfahan University of Technology
Lecture 5 Time and synchronization
Distributed Mutex EE324 Lecture 11.
Time and Clock.
Logical time (Lamport)
Distributed Systems CS
Time and Clock.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
CDK: Sections 11.1 – 11.4 TVS: Sections 6.1 – 6.2
Distributed Synchronization
Logical time (Lamport)
Logical time (Lamport)
CSE 486/586 Distributed Systems Time and Synchronization
Logical time (Lamport)
Last Class: Naming Name distribution: use hierarchies DNS
Presentation transcript:

Lecture 9: Time & Clocks CDK4: Sections 11.1 – 11.4 CDK5: Sections 14.1 – 14.4 TVS: Sections 6.1 – 6.2 Topics: Synchronization Logical time (Lamport) Vector clocks We assume there are benefits from having different systems in a network able to agree the answers to time-related questions ….

8-Aug-15COMP28112 Lecture 92 Synchronization Two parts: –Difficulty of setting the same time –Clock drift – i.e. difficulty of maintaining synchronization once achieved

8-Aug-15COMP28112 Lecture 93 UTC (Coordinated Universal Time) International Atomic Time – derived from clocks with “atomic oscillators”, drift rate about 1 in 10^13 Astronomical time derived from stars, sun, etc. Slowing of earth’s rotation leads to divergence UTC based on atomic time, but with occasional insertion of leap seconds to keep it in step with astronomical time UTC broadcast by terrestrial radio and satellite (GPS)

8-Aug-15COMP28112 Lecture 94 Computer Time GPS receivers accurate to about 1 microsec. Receivers from terrestrial stations, or over dedicated telephone line – to a few millisec. In reality few computers in a network have either of these ways of setting the time And then there is drift (typically 1 in 10^6 for inexpensive crystal clocks)

8-Aug-15COMP28112 Lecture 95 TVS figure 6.6 – synchronizing clocks A’s offset from B: ( (T2 – T1) + (T4 – T3) ) /2

8-Aug-15COMP28112 Lecture 96 Cristian’s Clock Synchonization With a “time server”, clients set their own clocks by measuring the round-trip time to process their request, rtt, and adding half that to the time in the reply Assumes time-out = time-back, more likely to be true for short rtt If good estimate of min transmission time available can estimate accuracy

8-Aug-15COMP28112 Lecture 97 The Berkeley Algorithm 1 processor, the master, polls others (slaves) Slaves reply with their times Master estimates their local times using round-trip times (as above) Master averages all these (and own time) – eliminating any times with excessive rtt Also eliminates any clocks wrong wrt others

8-Aug-15COMP28112 Lecture 98 The Berkeley Algorithm (cont.) Rather than send back correct time, master sends back to each slave its own delta (+/-) If the master fails, a distributed election algorithm exists to elect one of the slaves as replacement Cristian’s algorithm & the Berkeley algorithm designed (primarily) for intranets

8-Aug-15COMP28112 Lecture 99 Network Time Protocol (NTP) Designed for larger scale internet Network of servers: –Primary (stratum 1)– with UTC clock –Secondary (stratum 2), synchronized with primary Can reconfigure – e.g. if UTC source fails primary can become secondary, etc.

8-Aug-15COMP28112 Lecture 910 NTP Synchronization Three methods of synchronization –Multicast mode –Procedure call mode –Symmetric mode Multicast mode used on high-speed LANs –Server sends time to all servers on LAN at once –Each reset clocks (assuming a small delay) –Not highly accurate

8-Aug-15COMP28112 Lecture 911 Procedure-call mode Procedure-call mode: –Effectively Cristian’s algorithm –Server accepts requests and replies with the time –Used when multicast not supported or higher accuracy required Symmetric mode –Used where highest accuracy is required –Messages exchanged, and data built up to improve accuracy of synchronization over time. –Each message sent contains timing info about the previous message received (time sent, time received) and time it is sent

8-Aug-15COMP28112 Lecture 912 CDK Figure 11.4 Messages exchanged between a pair of NTP peers T i T i-1 T i-2 T i-3 Server B Server A Time mm' Time

8-Aug-15COMP28112 Lecture 913 Using the information Use this information to estimate the offset between the two clocks, o, from the equations (where t, t’ are transmission times for m, m’ resp.), and a d, delay, total transmission time of the two messages. Hence:

8-Aug-15COMP28112 Lecture 914 Using the fact that t and t’ are both >= 0, leads to

8-Aug-15COMP28112 Lecture 915 Data filtering NTP servers filters successive (o,d) values to identify best (lowest d value), and measure the reliability of the other server Each server will interact with several peers identifying most reliable ones Achieves accuracies of 10s of millisec over internet paths

8-Aug-15COMP28112 Lecture 916 Logical Time (Lamport) In single processor, every event can be uniquely ordered in time using the local clock What we want is to be able to do this in a distributed system, where synchronization between clocks is not sufficiently good to use physical time

8-Aug-15COMP28112 Lecture 917 Simple principles If two events happen in the same process, they occur in the order given by that process If a message is sent from 1 process to another, the event of sending happens before the event of receiving These define a partial ordering of events, given by the happens-before relationship

8-Aug-15COMP28112 Lecture 918 CDK Figure 11.5 Events occurring at three processes

8-Aug-15COMP28112 Lecture 919 Logical clocks A logical clock is a monotonically increasing software counter Each process keeps its own, L, and uses it to timestamp events –L++ before each event –Each message sent contains current L (as t) –Each message received sets L = max(L,t)+1

8-Aug-15COMP28112 Lecture 920 Logical clocks (cont.) Now if event e1 happens-before e2, L(e1) < L(e2) Note that the converse is not true, i.e. we cannot deduce ordering from the timestamps

8-Aug-15COMP28112 Lecture 921 CDK Figure 11.6 Lamport timestamps for the events shown in CDK Figure 11.5

8-Aug-15COMP28112 Lecture 922 Totally ordered logical clocks Can make the ordering of events above total, so that there is an order between every pair of events, by using an ordering of process identifiers (using local timestamps) to resolve cases where logical clocks are the same in different processes This has no physical reality, but may be used to control entry to critical sections, etc.

8-Aug-15COMP28112 Lecture 923 Vector Clocks A vector clock in a system with n processes is an array of n integers Each process keeps its own Messages between processes contain the vector clock of the sender as a timestamp Each clock starts with all integers 0

8-Aug-15COMP28112 Lecture 924 Vector clocks (cont.) Events in process i increment the i’th element in its vector clock When process i receives a timestamp, t, in a message it resets each element in its clock V[j] = max(V[j], t[j] ) for j = 1 …n This operation is referred to as a merge

8-Aug-15COMP28112 Lecture 925 CDK Figure 11.7 Vector timestamps for the events shown in CDK Figure 11.5

8-Aug-15COMP28112 Lecture 926 Comparing Vector clocks V1 = V2 iff V1[j] = V2[j] for all j V1 <= V2 iff V1[j] <= V2[j] for all j V1 < V2 iff V1 <= V2 & V1 != V2 Now if event e1 happened-before event e2, V(e1) < V(e2) if V(e1) < V(e2), e1 happened-before e2

8-Aug-15COMP28112 Lecture 927 Advantages and Disadvantages We don’t end up with an arbitrary order when none is needed (e.g. between c and e in the figures: neither V(c) < V(e) nor V(e) < V(c) ) Cost is the extra amount of data in a timestamp. Lamport’s clocks do not capture causality, which can be captured by means of vector clocks.