Time and global states Chapter 11. Outline Introduction Clocks, events and process states Synchronizing physical clocks Logical time and logical clocks.

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.
CS6223: Distributed Systems Distributed Time and Clock Synchronization (1) Physical Time.
Computer Science 425 Distributed Systems CS 425 / ECE 428  2013, I. Gupta, K. Nahrtstedt, S. Mitra, N. Vaidya, M. T. Harandi, J. Hou.
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
From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Exercises for Chapter 14: TIME.
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.
Slides for Chapter 10: Time and Global State
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.
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.
Logical Time and Logical Clocks
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.
CS542: Topics in Distributed Systems Diganta Goswami.
EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.
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.
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.
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.
TIME AND GLOBAL STATES Đàm Vĩnh Tường ( ) Nguyễn Lê Anh Đào ( ) Trần Viễn Phúc ( )
Chapter 10: Time and Global States
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.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
Lecture 5-1 Computer Science 425 Distributed Systems CS 425 / ECE 428 Fall 2013 Indranil Gupta (Indy) September 10, 2013 Lecture 5 Time and Synchronization.
Distributed Systems Concepts and Design Chapter 11: Time and Global States Steve Wallis, Raymond Ho, Bruce Hammer.
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.
6 SYNCHRONIZATION. introduction processes synchronize –exclusive access. –agree on the ordering of events much more difficult compared to synchronization.
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 Synchronization
Time and Global States Ali Fanian Isfahan University of Technology
Logical time (Lamport)
Distributed Systems CS
Distributed Systems CS
Exercises for Chapter 11: TIME AND GLOBAL STATES
CDK: Sections 11.1 – 11.4 TVS: Sections 6.1 – 6.2
Slides for Chapter 11: Time and Global State
Distributed Synchronization
Logical time (Lamport)
Logical time (Lamport)
Slides for Chapter 14: Time and Global States
Logical time (Lamport)
Last Class: Naming Name distribution: use hierarchies DNS
Presentation transcript:

Time and global states Chapter 11

Outline Introduction Clocks, events and process states Synchronizing physical clocks Logical time and logical clocks

introduction The importance of time: Time is a quantity we often want to measure accurately.(e.g. e-commerce) Algorithms that depend upon clock synchronization have been developed for several problems in distribution: 1. Maintaining the consistency of distributed data 2. Checking the authenticity of request sent to server 3. Eliminating the processing of duplicate updates

Important facts : Two events that are judged to be simultaneous in one frame of reference are not necessarily simultaneous according to observers in other frames of references that are moving relative to it. The relative order of two events can even be reversed for two different observers. But this cannot happen if one event could have caused the other to occur. The notion of physical time is also problematic in a DS because of the limitation in our ability to timestamp events at different nodes sufficiently accurately to know the order in which any pair of events occurred, or whether they occurred simultaneously introduction

£ A collection of N processes p i, i = 1,2,.. N s i The state of p i E.g. variables Actions of p i Operations that transform p i ’s state Send or receive message between p j Clocks, events and process states

e Event: occurrence of a single action  i occur before in p i, e.g. e  i e` Total order of events in p i history(p i ) = h i h i = Clocks, events and process states

A device that count oscillations occurring in a crystal at a definite frequency Hardware time: H i (t) The counts of oscillation since an original point Software time: C i (t) =  H i (t)+  Timestamp of an event Clock in computer  Successive events will correspond to different timestamps only if the clock resolution is smaller than the time interval between successive events.  The rate at which events occur depends on such factor as the length of the processor instruction cycle

Clock drift Crystal oscillate at different rate Clock drift can not be avoided Clock skew The instantaneous difference between the readings of any two clocks Clock skew and clock drift

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005 Figure 11.1 Skew between computer clocks in a distributed system

Rotation of earth on its axis and about the Sun Days, Years, etc Second is 1/86400 astronomical time Standard second Atomic oscillator Drift rate: one part in Astronomical Time &International Atomic Time

shift between astronomical time and atomic time The period of the Earth’s rotation about its axis is gradually getting longer Tidal friction, atmospheric effects, etc Leap second Atomic time which is inserted a leap second occasionally to keep in step with astronomical time Broadcast UTC to the World E.g., by GPS or WWV Coordinated Universal Time (UTC)

C i : p i ’s clock I: an interval of real time External synchronization For a synchronization bound D > 0, and for a source S of UTC time, |S(t)-C i (t)| < D, for i = 1, 2, … N and for all real times t in I Clocks C i are accurate to within the bound D Synchronizing physical clocks

Internal synchronization For a synchronization bound D > 0, |C i (t)-C j (t)| < D for i, j =1,2, … N, and for all real times t in I Clocks C i agree within the bound D If the system is externally synchronized with a bound D, then the system is internally synchronized with a bound 2D Synchronizing physical clocks

Correctness of a hardware clock H A bounded drift rate , e.g seconds/second,t and t’ are real time (1 -  )(t’ - t) <= H(t’) - H(t) <= ( 1 +  )( t’ - t) Correctness of a software clock Monotonicity: t’ > t  C(t’) > C(t) Set clock back Errors in the make process Change the clock rate General synchronization issues <= ( 1 +  ) H(t’) - H(t) (t’ - t) (1 -  ) <=

Clock failures Crash failure: stop ticking Arbitrary failure, e.g. Y2K bug General synchronization issues (2)

Protocol Sender: send M(t) Receiver: set time to t + T trans Bounds are know in synchronous system  min < T trans < max (constant) So, set T trans = (min+max) / 2 Receiver’s clock = t + (min+max) / 2 Synchronization in a synchronous system

Clock skew between sender and receiver  (max – min ) / 2 Synchronization in a synchronous system(2) t t+maxt +T trans t + min

Applying circumstance C/S Round-trip time is short compared with the required accuracy Protocol m r, m t (t), T round Estimated time: t in m t + T round /2 Cristian’s method of synchronizing clocks

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005 Figure 11.2 Clock synchronization using a time server m r m t p Time server,S

Accuracy analysis If the minimum delay of a message transmission is min, then accuracy:  (T round /2 – min) Cristian’s method of synchronizing clocks (2) t t +T round -min t +T round /2 t + min t +T round

Internal synchronization 1. The master polls the slaves’ clocks 2. The master estimates the slaves’ clocks by round-trip time Similar to Christian’s algorithm 3. The master averages the slaves’ clock values Cancel out the individual clock’s tendencies to run fast or slow The Berkeley algorithms

4. The master sends back to the slaves the amount that the slaves’ clocks should adjust by Positive or negative value Avoid further uncertainty due to the message transmission time Slave adjust its clock The Berkeley algorithms (2)

External synchronization Enable clients across the Internet to be synchronized accurately to UTC Reliability Can survive lengthy losses of connectivity Redundant server & redundant path between servers Design aims of Network Time Protocol

Scalability Enable clients to resynchronize sufficiently frequently to offset the rates of drift found in most computers Security Protect against interference with the time service Design aims of Network Time Protocol (2)

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005 Figure 11.3 An example synchronization subnet in an NTP implementation Note: Arrows denote synchronization control, numbers denote strata.

Multicast mode Intend for use on a high speed LAN Assuming a small delay Low accuracy but efficient Procedure-call mode Similar to Christian’s Higher accuracy than multicast Symmetric mode The highest accuracy Synchronization measures

Symmetric mode synchronization Assumming t, t’: actual transmission time of m, m’; o: actual B’s clock skew relative to A We have T i-2 = T i-3 + t + o, T i = T i-1 + t’ – o T i T i-1 T i-2 T i-3 Server B Server A Time mm' Time

Symmetric mode synchronization (2) T i-2 = T i-3 + t + o, T i = T i-1 + t’ – o Then addition : d i = t + t’ = T i-2 –T i-3 + T i – T i-1 subtraction : o = (T i-2 –T i-3 + T i-1 –T i + t’-t )/2 where o i = (T i-2 –T i-3 + T i-1 –T i ) /2 we have o= o i + (t’-t ) /2

Symmetric mode synchronization (2) we have o= o i + (t’-t ) /2 Accuracy analysis Due t, t’ >=0, then o i – (t’+t) /2 <= o <= o i + (t’+t) /2 Then o i - d i /2 <= o <= o i + d i /2 o i is the estimated time d i is the measure of the accuracy

NTP servers retain 8 most recent pairs The value o i of that corresponds to the minimum value d i is chosen to estimate o A NTP server exchanges with several peers in addition to with parent Peers with lower stratum numbers are favoured Peers with the lowest synchronization dispersion are favoured Symmetric mode sync. implementation

Happen-before relation  HB1: If  process p i : e  i e`, then e  e` HB2: For any message m, send(m)  receive(m) HB3: IF e, e`and e`` are events such that e  e` and e`  e``, then e  e`` Causal ordering Logical time & logical clocks

Example a || e Shortcomings Not suitable to processes collaboration that does not involve messages transmission Capture potential causal ordering Happen-before relation

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005 Figure 11.5 Events occurring at three processes

LC1 L i is incremented before each event is issued at process p i : L i :=L i +1 LC2: (a) When a process p i sends a message m, it piggybacks on m the value t = L i (b) On receiving (m,t), a process P j computes L j := max(L j, t) and then applies LC1 before timestamping the event receive(m) Lamport timestamps algorithm

e  e`  L(e) < L(e`) L(e) < L(e`)  e  e` or e||e` Lamport timestamps algorithm (2)

Useful in some applications Totally ordered logical clocks Assumption T i : local timestamp of e that is an event occurring at p i T j : local timestamp of e` that is an event occurring at p j Define the timestamps of e, e` are (T i, i), (T j, j) Define < (T i, i) < (T j, j) if T i < T j, or T i = T j and i < j

Each process p i keeps a vector clock V i VC1: Initially, V i [j]=0, for i, j = 1,2…, N VC2: Just before p i timestamps an event, it sets V i [i] := V i [i] +1 VC3: p i includes the value t= V i in every message it sends VC4: When p i receives a timestamp t in a message, it sets V i [j] :=max(V i [j], t[j]), for j=1,2…,N Vector Clocks - algorithm

Compare vector timestamps V = V` iff V [j] = V`[j] for j = 1,2…, N V <= V` iff V [j]<=V`[j] for j = 1,2…, N V < V` iff V [j]< V`[j] for j = 1,2…, N Otherwise V<> V` V(e) V(e`)  e||e` Vector Clocks - significance

Vector Clocks - example