CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.

Slides:



Advertisements
Similar presentations
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Consensus Steve Ko Computer Sciences and Engineering University at Buffalo.
Advertisements

CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Reliable Multicast Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
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
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
© 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.
Lecture 13 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Last quiz Max: 69 / Median: 52 / Min: 24 In a box outside.
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.
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport (1978) Presented by: Yoav Kantor.
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.
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)
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 Distributed Shared Memory 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.
Page 1 Logical Clocks Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation is.
CSE 486/586 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Global States Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
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.
Time and global states Chapter 11. Outline Introduction Clocks, events and process states Synchronizing physical clocks Logical time and logical clocks.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
Distributed Systems Topic 5: Time, Coordination and Agreement
CS 582 / CMPE 481 Distributed Systems Synchronization.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Replication Steve Ko Computer Sciences and Engineering University at Buffalo.
Hwajung Lee. Primary standard = rotation of earth De facto primary standard = atomic clock (1 atomic second = 9,192,631,770 orbital transitions of Cesium.
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
CSE 486/586 CSE 486/586 Distributed Systems Global States 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.
CSE 486/586 CSE 486/586 Distributed Systems Time and Synchronization Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Paxos Steve Ko Computer Sciences and Engineering University at Buffalo.
Distributed Web Systems Time and Global State Lecturer Department University.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Consistency Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586 Distributed Systems Reliable Multicast --- 1
Time and Synchronization
CSE 486/586 Distributed Systems Logical Time
CSE 486/586 Distributed Systems Global States
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
CS 425 / ECE 428  2013, I. Gupta, K. Nahrtstedt, S. Mitra, N. Vaidya, M. T. Harandi, J. Hou.
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 Reliable Multicast --- 2
CSE 486/586 Distributed Systems Logical Time
CSE 486/586 Distributed Systems Time and Synchronization
Logical time (Lamport)
Presentation transcript:

CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo

CSE 486/586, Spring 2012 Last Time Clock skews do happen External and internal synchronization –Cristian’s algorithm: external synchronization –Berkeley algorithm: internal synchronization –Both designed for LAN NTP (Network Time Protocol) –Hierarchy of time servers –Estimates the actual offset between two clocks –Designed for the Internet Logical time –For ordering events, relative time should suffice. –Will continue today 2

CSE 486/586, Spring 2012 Brief Recap: Cristian’s Algorithm 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 The correct time can be between [T + min, T + RTT – min] –Min one-way delay: min, max one-way delay: RTT – min The accuracy is: +-(RTT/2 – min) Natural next step: minimize inaccuracy –Take multiple readings and use the minimum RTT  tighter bound –For unusually long RTTs, ignore them and repeat the request  removing outliers 3

CSE 486/586, Spring 2012 Brief Recap: NTP The Internet –Arbitrary delays; hard to estimate one-way delay –Too many hosts; cannot rely on a few time servers –Thus, hard to apply Cristian’s algorithm The NTP –Doesn’t estimate one-way delay; instead estimate the actual offset between two clocks –Uses a hierarchy of servers  scales better How to estimate the actual offset 4

CSE 486/586, Spring 2012 Theoretical Base for NTP 5 T i T i-1 T i-2 T i-3 Server B Server A Time mm' Time Many NTP peers talk; apply a data filtering algo. then keep the 8 most recent pairs of, and selects the minimum d i (with delay t)(with delay t’)

CSE 486/586, Spring 2012 Ordering of Events Arises in many different contexts… 6

CSE 486/586, Spring 2012 Basics: State Machine State: a collection of values of variables Event: an occurrence of an action that changes the state, (i.e., instruction, send, and receive) As a program, –We can think of all possible execution paths. At runtime, –There’s only one path that the program takes. Equally applicable to –A single process –A distributed set of processes 7 S0 S1S2 S4S3 SF

CSE 486/586, Spring 2012 Events Occurring at Three Processes 8

CSE 486/586, Spring 2012 Lamport Timestamps 9

CSE 486/586, Spring 2012 Logical Clocks Lamport algorithm assigns logical timestamps: All processes use a counter (clock) with initial value of zero A process increments its counter when a send or an instruction happens at it. The counter is assigned to the event as its timestamp. A send (message) event carries its timestamp For a receive (message) event the counter is updated by max(local clock, message timestamp) + 1 Define a logical relation happened-before (  ) among events: On the same process: a  b, if time(a) < time(b) If p1 sends m to p2: send(m)  receive(m) (Transitivity) If a  b and b  c then a  c Shows causality of events 10

CSE 486/586, Spring 2012 Find the Mistake: Lamport Logical Time 11 p 1 p 2 p 3 p n Clock Value Message timestamp Physical Time 4

CSE 486/586, Spring 2012 Corrected Example: Lamport Logical Time 12 p 1 p 2 p 3 p n Clock Value Message timestamp Physical Time 8 3 and 7 are logically concurrent events

CSE 486/586, Spring 2012 Vector Timestamps With Lamport clock e “happened-before” f  timestamp(e) < timestamp (f), but timestamp(e) < timestamp (f)  e “happened-before” f 13 X

CSE 486/586, Spring 2012 Vector Logical Clocks Vector Logical time addresses the issue: All processes use a vector of counters (logical clocks), i th element is the clock value for process i, initially all zero. Each process i increments the i th element of its vector upon an instruction or send event. Vector value is timestamp of the event. A send(message) event carries its vector timestamp (counter vector) For a receive(message) event, V receiver [j] = Max(V receiver [j], V message [j]), if j is not self, V receiver [j] + 1, otherwise 14

CSE 486/586, Spring 2012 Find a Mistake: Vector Logical Time 15 p 1 p 2 p 3 p 4 0,0,0,0 Vector logical clock Message (vector timestamp) Physical Time 0,0,0,0 (1,0,0,0) 1,0,0,0 1,1,0,0 2,0,0,0 2,0,1,0 (2,0,0,0) 2,0,2,0 2,0,2,1 (2,0,2,0) 1,2,0,0 2,2,3,0 (1,2,0,0) 4,0,2,2 4,2,4,2 (4,0,2,2) 2,0,2,2 3,0,2,2 (2,0,2,2) 2,0,2,3 4,2,5,3 (2,0,2,3) n,m,p,q

CSE 486/586, Spring 2012 Comparing Vector Timestamps VT 1 = VT 2, iff VT 1 [i] = VT 2 [i], for all i = 1, …, n VT 1 <= VT 2, iff VT 1 [i] <= VT 2 [i], for all i = 1, …, n VT 1 < VT 2, iff VT 1 <= VT 2 &  j (1 <= j <= n & VT 1 [j] < VT 2 [j]) VT 1 is concurrent with VT 2 iff (not VT 1 <= VT 2 AND not VT 2 <= VT 1 ) 16

CSE 486/586, Spring 2012 The Use of Logical Clocks Is a design decision NTP error bound –Local: a few ms –Wide-area: 10’s of ms If your system doesn’t care about this inaccuracy, then NTP should be fine. Logical clocks impose an arbitrary order over concurrent events anyway –Breaking ties: process IDs, etc. 17

CSE 486/586, Spring 2012 CSE 486/586 Administrivia Project 0 deadline is 2/6/12 (Monday). –Please give feedback on project 0. –One server socket (one globally) vs. two server sockets (one each) Project 1 will be out next week (probably Wednesday). –Please form a project group of 5 people by next Wednesday. –By Sunday, if you cannot form a group of 5 people, post a public msg on Piazza, so that others can see and reply back to you. –By Wednesday, if you still cannot, then post a private msg on Piazza; the teaching staff will be match-makers. 18

CSE 486/586, Spring 2012 Summary Relative order of events enough for practical purposes –Lamport’s logical clocks –Vector clocks Global snapshot overview –Consistent cut –The “snapshot” algorithm Next: why the snapshot algorithm works & reliable multicast 19

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