CSE 486/586 CSE 486/586 Distributed Systems Time and Synchronization Steve Ko Computer Sciences and Engineering University at Buffalo.

Slides:



Advertisements
Similar presentations
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Leader Election Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
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
L-8 Synchronizing Physical Clocks 1 Announcements Proj1 checkpoint – due midnight tonight HW1 checkpoint – due 2/12 2.
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.
© 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.
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.
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.
Lecture 2-1 CS 425/ECE 428 Distributed Systems Lecture 2 Time & Synchronization Reading: 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.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Mutual Exclusion 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.
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 ( )
CSE 486/586 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
1 Time (and Global State). 3 Time – basics zWe want to know when something happened - Physical and logical clocks. zAlgorithms may depend upon clock.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Global States Steve Ko Computer Sciences and Engineering University at Buffalo.
1 Clock Synchronization & Mutual Exclusion in Distributed Operating Systems Brett O’Neill CSE 8343 – Group A6.
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.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Mutual Exclusion & Leader Election Steve Ko Computer Sciences and Engineering University.
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.
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 CS Synchronization – Part I Lecture 8, Sep 23, 2013 Mohammad Hammoud.
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.
CSE 486/586 CSE 486/586 Distributed Systems Global States Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586 CSE 486/586 Distributed Systems Leader Election Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
Distributed Web Systems Time and Global State Lecturer Department University.
CSE 486/586 Distributed Systems Leader Election
Distributed Computing
Time and Synchronization
CSE 486/586 Distributed Systems Logical Time
Time and Global States Ali Fanian Isfahan University of Technology
CSE 486/586 Distributed Systems Global States
Lecture 5 Time and synchronization
CSE 486/586 Distributed Systems Time and Synchronization
Time and Synchronization
CSE 486/586 Distributed Systems Logical Time
Logical time (Lamport)
湖南大学-信息科学与工程学院-计算机与科学系
Lecture 12: Time and Ordering
CSE 486/586 Distributed Systems Leader Election
Distributed Systems CS
Physical clock synchronization
CDK: Sections 11.1 – 11.4 TVS: Sections 6.1 – 6.2
Logical time (Lamport)
Logical time (Lamport)
CSE 486/586 Distributed Systems Global States
CSE 486/586 Distributed Systems Logical Time
CSE 486/586 Distributed Systems Time and Synchronization
Logical time (Lamport)
CSE 486/586 Distributed Systems Leader Election
Presentation transcript:

CSE 486/586 CSE 486/586 Distributed Systems Time and Synchronization Steve Ko Computer Sciences and Engineering University at Buffalo

CSE 486/586 Last Time Models of Distributed Systems –Synchronous systems –Asynchronous systems Failure detectors---why? –Because things do fail. Failure detectors---what? –Properties: completeness & accuracy –Metrics: bandwidth, detection time, scale, accuracy Failure detectors---how? –Two processes: Heartbeating and Ping –Multiple processes: Centralized, ring, all-to-all 2

CSE 486/586 Today’s Question The topic of time –Today and next time Why? –Need to know when things happen What? –Ideally, we’d like to know when exactly something happened. How? –Let’s see! 3

CSE 486/586 Today’s Question Servers in the cloud need to timestamp events Server A and server B in the cloud have different clock values –You buy an airline ticket online via the cloud –It’s the last airline ticket available on that flight –Server A timestamps your purchase at 9h:15m:32.45s –What if someone else also bought the last ticket (via server B) at 9h:20m:22.76s? –What if Server A was > 10 minutes ahead of server B? Behind? –How would you know what the difference was at those times? 4

CSE 486/586 Physical Clocks & Synchronization Some definitions: Clock Skew versus Drift Clock Skew = Relative Difference in clock values of two processes Clock Drift = Relative Difference in clock frequencies (rates) of two processes A non-zero clock drift will cause skew to continuously increase. Real-life examples –Ever had “make: warning: Clock skew detected. Your build may be incomplete.”? –It’s reported that in the worst case, there’s 1 sec/day drift in modern HW. –Almost all physical clocks experience this. 5

CSE 486/586 Synchronizing Physical Clocks C i (t): the reading of the software clock at process i when the real time is t. External synchronization: For a synchronization bound D>0, and for source S of UTC time, for i=1,2,...,N and for all real times t. Clocks C i are accurate to 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. External synchronization with D  Internal synchronization with 2D Internal synchronization with D  External synchronization with ?? 6

CSE 486/586 Clock Synchronization Using a Time Server 7 m r m t p Time server,S

CSE 486/586 Cristian’s Algorithm Uses a time server to synchronize clocks Mainly designed for LAN Time server keeps the reference time (say UTC) A client asks the time server for time, the server responds with its current time T, and the client uses the received value T to set its clock But network round-trip time introduces an error. So what do we need to do? –Estimate one-way delay 8

CSE 486/586 Cristian’s Algorithm Let RTT = response-received-time – request-sent- time (measurable at client) Also, suppose we know –The minimum value min of the client-server one-way transmission time [Depends on what?] –That the server timestamped the message at the last possible instant before sending it back Then, the actual time could be between [T+min,T+RTT— min] 9 Request sent Response received RTT min T

CSE 486/586 Cristian’s Algorithm (From the previous slide), the accuracy is: +-(RTT/2 – min) Cristian’s algorithm –A client asks its time server. –The time server sends its time T. –The client estimates the one-way delay and sets its time. »It uses T + RTT/2 Want to improve accuracy? –Take multiple readings and use the minimum RTT  tighter bound –For unusually long RTTs, ignore them and repeat the request  removing outliers 10

CSE 486/586 CSE 486/586 Administrivia PA2 Part A is out. Please use Piazza; all announcements will go there. –If you want an invite, let me know. Please come to my office during the office hours! –Give feedback about the class, ask questions, etc. 11

CSE 486/586 The Network Time Protocol (NTP) Uses a network of time servers to synchronize all processes on a network. Designed for the Internet Why not Christian’s algo.? Time servers are connected by a synchronization subnet tree. The root is in touch with UTC. Each node synchronizes its children nodes. Why? 12 Secondry servers, sync’ed by the primary server Primary server, direct sync. Strata 3, sync’ed by the secondary servers

CSE 486/586 Messages Exchanged Between a Pair of NTP Peers (“Connected Servers”) Each message bears timestamps of recent message events: the local time when the previous NTP message was sent and received, and the local time when the current message was transmitted. 13 T i T i-1 T i-2 T i-3 Server B Server A Time mm' Time

CSE 486/586 The Protocol Compute round-trip delay: (T i – T i-3 ) – (T i-1 – T i-2 ) Take the half of the round-trip delay as the one-way estimate: ((T i – T i-3 ) – (T i-1 – T i-2 ))/2 14 T i T i-1 T i-2 T i-3 Server Client Time mm' Time

CSE 486/586 The Protocol Compute offset: T i-1 + (one-way estimate) - T i = ((T i-2 – T i-3 ) + (T i-1 – T i ))/2 Do this with not just one server, but multiple servers. Do some statistical analysis, remove outliers, and apply a data filtering algorithm. –Out of the scope of this lecture 15 T i T i-1 T i-2 T i-3 Server Client Time mm' Time

CSE 486/586 Theoretical Base for NTP o i : estimate of the actual offset between the two clocks d i : estimate of accuracy of o i ; total transmission times for m and m’; d i =t+t’ 16 T i T i-1 T i-2 T i-3 Server B Server A Time mm' Time

CSE 486/586 Theoretical Base for NTP 17 T i T i-1 T i-2 T i-3 Server B Server A Time mm' Time (with delay t)(with delay t’)

CSE 486/586 Then a Breakthrough… We cannot sync multiple clocks perfectly. Thus, if we want to order events happened at different processes (remember the ticket reservation example?), we cannot rely on physical clocks. Then came logical time. –First proposed by Leslie Lamport in the 70’s –Based on causality of events –Defined relative time, not absolute time Critical observation: time (ordering) only matters if two or more processes interact, i.e., send/receive messages. 18

CSE 486/586 Events Occurring at Three Processes 19

CSE 486/586 Summary Time synchronization important for distributed systems –Cristian’s algorithm –Berkeley algorithm –NTP Relative order of events enough for practical purposes –Lamport’s logical clocks Next: continue on logical clocks 20

CSE 486/ Acknowledgements These slides contain material developed and copyrighted by Indranil Gupta at UIUC.