1DT066 D ISTRIBUTED I NFORMATION S YSTEM Time, Coordination and Agreement 1.

Slides:



Advertisements
Similar presentations
Chapter 12 Message Ordering. Causal Ordering A single message should not be overtaken by a sequence of messages Stronger than FIFO Example of FIFO but.
Advertisements

Synchronization.
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.
Time and Global States Ali Fanian Isfahan University of Technology
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.
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.
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.
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.
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.
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.
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 ( )
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.
1 Clock Synchronization & Mutual Exclusion in Distributed Operating Systems Brett O’Neill CSE 8343 – Group A6.
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.
Real-Time & MultiMedia Lab Synchronization Distributed System Jin-Seung,KIM.
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.
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 Systems CS
Distributed Computing
Distributed Systems CS
Time and Synchronization
Time and Clock Primary standard = rotation of earth
Time and Global States Ali Fanian Isfahan University of Technology
CSE 486/586 Distributed Systems Time and Synchronization
Time and Clock.
Logical time (Lamport)
Distributed Systems CS
Distributed Systems CS
Time and Clock.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Distributed Systems CS
Distributed Systems CS
Chapter 5 (through section 5.4)
Exercises for Chapter 11: TIME AND GLOBAL STATES
Physical clock synchronization
CDK: Sections 11.1 – 11.4 TVS: Sections 6.1 – 6.2
Distributed Synchronization
Logical time (Lamport)
Logical time (Lamport)
Jenhui Chen Office number:
CSE 486/586 Distributed Systems Time and Synchronization
Logical time (Lamport)
Last Class: Naming Name distribution: use hierarchies DNS
Presentation transcript:

1DT066 D ISTRIBUTED I NFORMATION S YSTEM Time, Coordination and Agreement 1

O UTLINE Time Physical time Logical time Coordination and agreement Multicast communication Summary 2

1 T IME The notation of time External synchronization Internal synchronization Physical clocks and their synchronization Logical time and logical clocks 3

1.1 S YNCHRONIZING P HYSICAL C LOCKS Computer each contains its physical clock. Physical clock is limited by its resolution - the period between updates of the clock register. Clock drift often happens to physical clocks. To compensate for clock drifts, computers are synchronized to a time service, e.g., UTC - Coordinated universal time. Several other algorithms for synchronization. 4

1.1 C RISTIAN S C LOCK S YNCHRONIZATION A process P can record the total round-trip time T round taken to send the request m r and receive the reply m t. A simple estimate of the time to which P should set its clock is t + T round / 2. 5

1.1 T HE B ERKELEY A LGORITHM A coordinator computer is chosen to act as the master. Master periodically polls to slaves whose clocks are to be synchronized. The master estimates their local clock times by observing the round-trip times, and it averages the values obtained. The master takes a fault-tolerant average. Should the master fail, then another can be elected to take over. 6

1.1 T HE N ETWORK T IME P ROTOCOL NTP distributes time information to provide: a service to synchronize clients in Internet a reliable service that survives loss of connection a frequent resynchronization for clients clock drift protection against interference with time server NTP service is provided by various servers: Primary servers, secondary servers, and servers of other levels (called strata ). Synchronization subnet: the servers which are connected in a logical hierarchy. 7

1.2 L OGICAL T IME AND L OGICAL C LOCKS The order of the events two events occurred in the order they appear in a process. event of sending occurred before event of receiving. happened-before relation, denoted by HB1 : If process p: x p y, then x y. HB2 : For any message m, send ( m ) rcv ( m ), HB3 : If x, y and z are events such that x y and y z, then x z. 8

1.2 L OGICAL T IMESTAMPS E XAMPLE Events occurring at three processes 9

1.2 L AMPORT L OGICAL T IMESTAMPS Logical clock - a monotonically increasing software counter. C p : logical clock for process p; C p ( a ): timestamp of event a at p ; C ( b ): timestamp of event b LC1 : event issued at process p: C p := C p + 1 LC2 : a) p sends message m to q with value t = C p b) C q := max( C q,t ) and applies LC1 to rcv ( m ). If a b then C ( a ) < C ( b ), but not visa versa! Total order logical clock and vector clock. 10

1.2 L AMPORT T IMESTAMPS E XAMPLE Events occurring at three processes => 7 11

1.3 V ECTOR C LOCKS Vector clock A vector clock of N processes is an array of N integers Each process keeps its own vector clock V i, which it uses to timestamp a local event 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. Taking the component-wise maximum of two vector timestamps in this way is known as a merge operation. 12

1.3 V ECTOR C LOCKS E XAMPLE Events occurring at three processes (1,0,0)(2,0,0) (0,0,1) (2,1,0)(2,2,0) (2,2,2) (2,2,3) (3,2,3)

1.4 C OMPARISON In Lamports clock, C(e)<C(e) does not imply e e; while in Vector timestamp, V(e)<V(e) implies e e. Vector timestamps take up an amount of storage and message payload that is proportional to N, the number of process; while Lamports clock does not. 14

1.5 L AMPORT T IMESTAMPS E XERCISE 15

1.5 L AMPORT T IMESTAMPS A NSWER

1.5 V ECTOR C LOCKS E XERCISE 17

1.5 V ECTOR C LOCKS A NSWER (1,0,0) (2,2,1)(3,2,1) (0,1,1) (0,2,1) (1,3,1)(1,4,1) (0,0,1)(3,2,2)(3,4,3) 18

2 C OORDINATION Distributed processes need to coordinate their activities. Distributed mutual exclusion is required for safety, liveness, and ordering properties. Election algorithms: methods for choosing a unique process for a particular role. 19

2.1 D ISTRIBUTED M UTUAL E XCLUSION The basic requirements for mutual exclusion: ME1 (safety): At most one process may execute in the critical section (CS) at a time. ME2 (liveness): A process requesting entry to the CS is eventually granted. ME3 (ordering): Entry to the CS should be granted in happened-before order. The central server algorithm. A ring-based algorithm. A distributed algorithm using logical clocks. 20

2.2 E LECTIONS An election is a procedure carried out to choose a process from a group. A ring-based election algorithm. The bully algorithm. 21

2.2.1 R ING -B ASED E LECTION A LGORITHM Each process P(i) has a communication channel to the next process P(i+1) mod N. Messages are sent clockwise. The goal is to elect a single process called the coordinator, which is the process with the largest identifier. 22

2.2.1 R ING -B ASED A LGORITHM Process numberstatus 1Non-participant Non-participant 34Non-participant Direction of message flow

2.2.1 R ING -B ASED A LGORITHM Every process can begin an election A process begins an election by marking itself as a participant, and sends an election message to its neighbor by placing its identifier Suppose process 7 now begins the election Process numberstatus Election message Participant Non-participant Participant Non-participant Participant Non-participant Participant Non-participant Participant Non-participant Elected Coordinator is 34 Non-participant Participant Non-participant 24

2.2.2 B ULLY A LGORITHM The processes themselves are synchronous. I.e. they use timeouts to detect a process failure. Unlike the ring-based algorithm in which processes only know their neighbors, bully algorithm allows processes to know those processes with a higher identifier. There are three types of message: Election Answer Coordinator Coordinator is now 13, because it has the highest identifier 25

2.2.2 B ULLY A LGORITHM The election begins when a process notices that the coordinator is failed. Several processes may discover this concurrently A process which detects the failure will send an election message to those with a higher identifier When a process receives an election message, it sends back an answer message and begins another election Election message Answer Message Election message Coordinator Process 12 will know that it is the highest identifier now as all its higher identifier process (i.e. process 13) have failed, this process will then send back the coordinator message to all its lower identifier process. 26

3 M ULTICAST C OMMUNICATION Group (multicast) communication requires coordination and agreement. One multicast operation is much better than multiple send operation in terms of efficiency and delivery guarantees. Basic multicast: guarantees a correct process will eventually deliver the message. Reliable multicast: requires that all correct processes in the group must receive a message if any of them does. 27

3.1 O PEN AND C LOSED G ROUPS 28

3 B ULLETIN B OARD E XAMPLE 29

3.2 C ONSISTENCY AND R EQUEST O RDERING Criteria: correctness vs. expenses. Total, causal, and FIFO ordering requirements. Implementing request ordering. Implementing total ordering. Implementing causal ordering with vector timestamps. 30

3.2.1 T OTAL, FIFO, C AUSAL O RDERING Let m 1 and m 2 be messages delivered to the group. Total ordering: Either m 1 is delivered before m 2 or m 2 is delivered before m 1, at all processes. Causal ordering: If m 1 happened-before m 2 then m 1 is delivered before m 2 at all processes. FIFO ordering: If m 1 is issued before m 2 then m 1 is delivered before m 2 at all processes. 31

3.2.1 O RDERING OF M ULTICAST M ESSAGES Totally ordered messages T 1,T 2 and F 1, FIFO-related messages F 1 and F 2 ; C 1 and C 2 Causally related messages C 1 and C 3 (assuming C 3 is a reply to C 1 at P 3 ) 32

3.2.2 I MPLEMENTING M ESSAGE O RDERING Hold-back: A received message is not delivered until ordering constraints can be met. Stable message: all prior messages processed. Hold-back queue vs. delivery queue. Safety property: no message will be delivered out of order by being prematurely transferred. Liveness property: no message should wait on the hold-back queue forever. 33

3.2.2 T HE H OLD -B ACK Q UEUE 34

3.2.3 I MPLEMENTING T OTAL O RDERING Basic approach: assign totally ordered sequence to messages. Sequencer Distributed agreement in assigning sequence Message 2 Proposed Seq P 2 P 3 P 1 P 4 3 Agreed Seq

3.2.4 I MPLEMENTING C AUSAL O RDERING Vector timestamp: a list of counts of update events, one for each of the processes. Merging vector timestamps: choose the largest values from the two vectors, component-wise. P3P3 P2P2 P1P1 P1P1 P2P2 P3P3 P2P2 P2P2 P3P3 P1P1 P2P2 P3P3 … 36

3.3 M ULTICAST C OMMUNICATION Sample multicasting operation void Multicast (in orderType order, in groupId group, in msg m, in int nReplies, out msgSeq replies) raises (…); Order types: unordered total ordering causal ordering sync-ordering 37

4 S UMMARY Timing issues Synchronizing physical clocks. Logical time and logical clocks. Distributed coordination and mutual exclusions. Coordination. Elections Ring-based algorithm Bully algorithm Multicast communication. Read textbook Chapters 14 and