Lecture 2-1 CS 425/ECE 428 Distributed Systems Lecture 2 Time & Synchronization Reading: 11.1-11.4 Klara Nahrstedt.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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
Distributed Systems Spring 2009
CS 582 / CMPE 481 Distributed Systems Synchronization.
Distributed Systems Fall 2010 Time and synchronization.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Time and Synchronization Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
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.
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.
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.
1 Synchronization Part 1 REK’s adaptation of Claypool’s adaptation of Tanenbaum’s Distributed Systems Chapter 5.
Synchronization Chapter 6 Part I Clock Synchronization & Logical clocks Part II Mutual Exclusion Part III Election Algorithms Part IV Transactions.
Lecture 3-1 Computer Science 425 Distributed Systems Lecture 3 Logical Clock and Global States/ Snapshots Reading: Chapter 11.4&11.5 Klara Nahrstedt.
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.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
CSE 486/586 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
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.
Physical clock synchronization Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down,
Time and global states Chapter 11. Outline Introduction Clocks, events and process states Synchronizing physical clocks Logical time and logical clocks.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Distributed Systems Topic 5: Time, Coordination and Agreement
6 SYNCHRONIZATION. introduction processes synchronize –exclusive access. –agree on the ordering of events much more difficult compared to 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.
Lecture 7- 1 CS 425/ECE 428/CSE424 Distributed Systems (Fall 2009) Lecture 7 Distributed Mutual Exclusion Section 12.2 Klara Nahrstedt.
Distributed Systems Lecture 5 Time and synchronization 1.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
Indranil Gupta (Indy) Topic: Time and Ordering Lecture A: Introduction and Basics Cloud Computing concepts All slides © IG.
CSE 486/586 CSE 486/586 Distributed Systems Time and Synchronization Steve Ko Computer Sciences and Engineering University at Buffalo.
Distributed Web Systems Time and Global State Lecturer Department University.
Proof of liveness: an example
Distributed Computing
Time and Synchronization
Time and Clock Primary standard = rotation of earth
CSE 486/586 Distributed Systems Logical Time
Time and Global States Ali Fanian Isfahan University of Technology
Lecture 5 Time and synchronization
CSE 486/586 Distributed Systems Time and Synchronization
Time and Synchronization
CSE 486/586 Distributed Systems Logical Time
Time and Clock.
Logical time (Lamport)
湖南大学-信息科学与工程学院-计算机与科学系
Lecture 12: Time and Ordering
Time and Clock.
CDK: Sections 11.1 – 11.4 TVS: Sections 6.1 – 6.2
Logical time (Lamport)
Logical time (Lamport)
CSE 486/586 Distributed Systems Logical Time
CSE 486/586 Distributed Systems Time and Synchronization
Logical time (Lamport)
Last Class: Naming Name distribution: use hierarchies DNS
Outline Theoretical Foundations
Presentation transcript:

Lecture 2-1 CS 425/ECE 428 Distributed Systems Lecture 2 Time & Synchronization Reading: Klara Nahrstedt

Lecture 2-2 Acknowledgement The slides during this semester are based on ideas and material from the following sources: –Slides prepared by Professors M. Harandi, J. Hou, I. Gupta, N. Vaidya, Y-Ch. Hu, S. Mitra. –Slides from Professor S. Gosh’s course at University o Iowa.

Lecture 2-3 Why synchronize clocks? You want to catch the 10 Gold West bus at the Illini Union stop at 6.05 pm, but your watch is off by 5 minutes –What if your watch is Faster by 5 minutes? –What if your watch is Late by 5 minutes? Two sharpshooters in a multiplayer online game kill the same target. Who gets the point? Object A is observed by S1 and S2 at local times t1 and t2. Which way is A moving? How fast? Synchronizing clocks helps us –Time-stamping events (provide ‘Fairness’) –Ordering events (provide ‘Correctness’)

Lecture 2-4 Plan for today Sources of time How to synchronize clocks? Can we define sequence of events without physical clocks?

Lecture 2-5 Time Sources De Facto Primary Standard – International Atomic Time (TAI) –Keeping of TAI started in 1955 –1 atomic second = 9,192,631,770 orbital transitions of Cs 133 (Caesium) –86400 atomic seconds = 1 solar day – 3 ms Coordinated Universal Time (UTC) – International Standard –Keeping of UTC started 1961 –Derived from TAI by adding leap seconds to keep it close to solar time –UTC source signals are synchronized –UTC time is re-transmitted by GPS satellites Local clocks are based on oscillators

Lecture 2-6 Terminology Distributed System (DS) consists of N processes p 1, p 2,.. p N Process p i, i є {1,…N} –State: values of local variables including time »C i (t): the reading of the local clock at process i when the real time is t –Actions: send message [send(m)], receive message [recv(m)], compute [comp] Occurrence of an action is called an event

Lecture 2-7 Terminology Events within process p i can be assigned timestamp and thus ordered Events across different processes in DS need to be ordered, but  Clocks in DS across processes are not synchronized –Process clocks can be different Need algorithms for either –time synchronization or –telling which event happened before which

Lecture 2-8 Definitions Skew: –s(t) = C i (t) – C j (t) Maximum Drift Rate (MDR) ρ –|t – C i (t) | ≤ ρt –(1-ρ) ≤ dC i (t)/dt ≤ (1+ρ) Synchronization interval R and synchronization bound D –| C i (t) – C j (t) | ≤ 2ρt –| C i (R) – C j (R)| ≤ 2ρR ≤ D –R ≤ D/2ρ –This calculation ignored propagation delays MDR UTC clock Real time Clock time Clock 1 Clock 2 Real time Clock time R R

Lecture 2-9 Synchronizing Physical Clocks External synchronization: For a synchronization bound D > 0, and for source Source(t) of UTC time, for i=1,2,...,N and for all real times t. Clocks C i are accurate within the bound D. Internal synchronization: For a synchronization bound D>0, for i, j=1,2,...,N and for all real times t. Clocks C i agree within the bound D.

Lecture 2-10  Use elected leader process to ensure maximum skew is ρ among clients  Elected leader broadcasts to all machines for their time,  adjusts times received for transmission delay & latency,  averages times after removing outliers  tells each machine how to adjust.  In some systems multiple time leaders are used.  Averaging client’s clocks may cause the entire system to drift away from UTC over time  Failure of the leader requires some time for re-election, so accuracy cannot be guaranteed Internal Synchronization: Berkeley Algorithm

Lecture 2-11 External Synchronization: Cristian’s Method m r m t Client p i Time server S (keeps reference time) m r - message where client p i asks time server S for time m t - message where time server responds with its current time T Client p i uses T in m t to set its clock

Lecture 2-12 External Synchronization: Cristian’s Method RTT = t 1 – t 2 (Round Trip Time) Client sets its clock to T + RTT/2 Assumptions: –RTT measured accurately –Transmission and computation delays are symmetric –Server time-stamped the message at the last possible instant before sending it back

Lecture 2-13 External Synchronization: Cristian’s Method Suppose we know the minimum client-server one way transmission delay: min Then => actual time at client could be between [T + min, T + RTT - min] Accuracy: RTT/2 – min

Lecture 2-14 Secondry servers, synched by the primary server The Network Time Protocol (NTP) Primary server, direct synch. Strata 3, synched by the secondary servers  Provides UTC synchronization service across Internet  Uses time servers to sync. networked processes.  Time servers are connected by sync. subnet tree.  The root is adjusted directly.  Each node synchronizes its children nodes

Lecture 2-15 Messages Exchanged Between a Pair of NTP Peers (Connected Servers) T i T i-1 T i-2 T i-3 Server B Server A Time mm' Time Each message (e.g., m, m’ ) bears timestamps of recent message events: the local time when the previous NTP message (m) was sent (T i-3 ) and received (T i-2 ), and the local time when the current message (m’) was transmitted (T i-1 ).

Lecture 2-16 Theoretical Base for NTP T i T i-1 T i-2 T i-3 Server B Server A Time mm' Time o i : estimated skew o: true skew of clock at B relative to that at A = C A – C B t and t’: actual transmission times for m and m’ d i : estimate of accuracy of o i ; total transmission times for m and m’; d i =t+t’

Lecture 2-17 Summary on Physical Clocks Several algorithms for internal and external clock synchronization Accuracy depends on uncertainty in message delays We have not discussed failures –There are algorithms for synchronization with a fraction of failed clock (e.g., Lamport) Next: Logical Clocks

Lecture 2-18 Logical Clock Is it always necessary to give absolute time to events? Suppose we can assign relative time to events, in a way that does not violate their causality

Lecture 2-19 Happens-Before Relation on Events Define a relation  on the events as follows –On the same process : a  b iff time (a) < time (b) –If p 1 sends m to p 2 : send(m)  recv(m) –Transitivity: if a  b and b  c then a  c  is called the Happens-Before Relation Events a and b are concurrent if not (a  b or b  a)

Lecture 2-20 Events Occurring at Three Processes How to construct the happen-before relation in a distributed system?

Lecture 2-21 Lamport’s Logical Clock First proposed by Leslie Lamport in 70’s Lamport algorithm assigns logical timestamps to events Each process has a counter (logical clock) Initially logical clock is set to 0 Process increments its counter when a send or a computation (comp) step is performed Counter is assigned to event as its timestamp send(message) event carries its timestamp On recv(message) event, the counter is updated by max(local clock, message timestamp) + 1

Lecture 2-22 Lamport Timestamps

Lecture 2-23 Spot the Mistake p 1 p 2 p 3 p n Clock Value Message timestamp Physical Time

Lecture 2-24 Corrected Example: Lamport Logical Time p 1 p 2 p 3 p n Clock Value Message timestamp Physical Time

Lecture 2-25 logically concurrent events One thing to Notice … p 1 p 2 p 3 p n Clock Value Message timestamp Physical Time

Lecture 2-26 Summary Time synchronization for distributed systems –Berkeley algorithm –Cristian’s algorithm –NTP Relative order of events enough for practical purposes –Lamport’s logical clocks Next class: Logical Clock (Vector Clock) and Global States/Snapshots. –Reading: 11.4 and 11.5