Lecture 12 Synchronization. EECE 411: Design of Distributed Software Applications Summary so far … A distributed system is: a collection of independent.

Slides:



Advertisements
Similar presentations
1 Process groups and message ordering If processes belong to groups, certain algorithms can be used that depend on group properties membership create (
Advertisements

Time, Clocks, and the Ordering of Events in a Distributed System
Time and Global States Part 3 ECEN5053 Software Engineering of Distributed Systems University of Colorado, Boulder.
Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
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.
Distributed Systems Spring 2009
CS 582 / CMPE 481 Distributed Systems
Ordering and Consistent Cuts Presented By Biswanath Panda.
EEC 688/788 Secure and Dependable Computing Lecture 12 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Distributed Systems CS Synchronization – Part II Lecture 8, Sep 28, 2011 Majd F. Sakr, Vinay Kolar, Mohammad Hammoud.
EEC 693/793 Special Topics in Electrical Engineering Secure and Dependable Computing Lecture 13 Wenbing Zhao Department of Electrical and Computer Engineering.
Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion.
SynchronizationCS-4513, D-Term Synchronization in Distributed Systems CS-4513 D-Term 2007 (Slides include materials from Operating System Concepts,
Lecture 13 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Last quiz Max: 69 / Median: 52 / Min: 24 In a box outside.
EEC 688/788 Secure and Dependable Computing Lecture 13 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Synchronization in Distributed Systems CS-4513 D-term Synchronization in Distributed Systems CS-4513 Distributed Computing Systems (Slides include.
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
Clock Synchronization and algorithm
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 14 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Project P01 deadline on Wednesday November 3 rd. Non-blocking.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Clock Synchronization Physical clocks Clock synchronization algorithms –Cristian’s.
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport (1978) Presented by: Yoav Kantor.
Synchronization Chapter 6 Part I Clock Synchronization & Logical clocks Part II Mutual Exclusion Part III Election Algorithms Part IV Transactions.
Logical Clocks (2). Topics r Logical clocks r Totally-Ordered Multicasting r Vector timestamps.
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.
CIS 720 Distributed algorithms. “Paint on the forehead” problem Each of you can see other’s forehead but not your own. I announce “some of you have paint.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Synchronization in Distributed Systems Chapter 6.
Logical Clocks n event ordering, happened-before relation (review) n logical clocks conditions n scalar clocks condition implementation limitation n vector.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
Synchronization Physical clocks Logical clocks. EECE 411: Design of Distributed Software Applications Summary so far … A distributed system is: a collection.
Lamport’s Logical Clocks & Totally Ordered Multicasting.
Synchronization Chapter 5.
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
Distributed Systems Principles and Paradigms Chapter 05 Synchronization.
Event Ordering Greg Bilodeau CS 5204 November 3, 2009.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
EEC 688/788 Secure and Dependable Computing Lecture 10 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
D u k e S y s t e m s Asynchronous Replicated State Machines (Causal Multicast and All That) Jeff Chase Duke University.
Physical clock synchronization Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down,
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Building Dependable Distributed Systems, Copyright Wenbing Zhao
Distributed Systems Topic 5: Time, Coordination and Agreement
CS 3471 CS 347: Parallel and Distributed Data Management Notes13: Time and Clocks.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Logical Clocks. Topics r Logical clocks r Totally-Ordered Multicasting.
Event Ordering. CS 5204 – Operating Systems2 Time and Ordering The two critical differences between centralized and distributed systems are: absence of.
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.
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 6: Synchronyzation 3/5/20161 Distributed Systems - COMP 655.
Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.
Logical Clocks event ordering, happened-before relation (review) logical clocks conditions scalar clocks  condition  implementation  limitation vector.
Prof. Leonardo Mostarda University of Camerino
Time and Clock.
Distributed Systems CS
Distributed Systems CS
Time and Clock.
Distributed Systems CS
Distributed Systems CS
Chapter 5 (through section 5.4)
Physical clock synchronization
Distributed Systems CS
Last Class: Naming Name distribution: use hierarchies DNS
Outline Theoretical Foundations
Presentation transcript:

Lecture 12 Synchronization

EECE 411: Design of Distributed Software Applications Summary so far … A distributed system is: a collection of independent computers that appears to its users as a single coherent system Components need to: Communicate Cooperate => support needed Naming – enables some resource sharing Synchronization

EECE 411: Design of Distributed Software Applications Last time Physical clocks Two applications Provide at-most-once semantics Global Positioning Systems ‘Logical clocks’ Where only ordering of events matters Other coordination primitives Leader election: How do I choose a coordinator? Mutual exclusion

EECE 411: Design of Distributed Software Applications Efficient at-most-once message delivery Issues 1: How long to maintain transaction data? 2: How to deal with server failures? (Minimize state that is persistently stored)

EECE 411: Design of Distributed Software Applications Efficient at-most-once message delivery (II) Issue1: How long to maintain transaction data? Solution: Client: Sends transaction id and physical timestamp Client (or network) may resend messages Server: Discards messages with duplicate id and messages that have been generates too far in the past Mechanism Maintains: G = T current - MaxLifeTime - MaxClockSkew Discards messages with timestamps older than G Ignores (or delays) message that arrive in the future (Maintains transaction data only for the interval G--T now

EECE 411: Design of Distributed Software Applications Issue 2: What to persistently store across server failures? Solution: Current Time (CT) is written to disk every ΔT At recovery G failure is recomputed after a crash from saved CT After recovery: discard messages with timestamp older than G failure + ΔT Process messages with timestamp newer than G failure + ΔT [Note: the formulas above ignore clock skew!] Efficient at-most-once message delivery (III)

EECE 411: Design of Distributed Software Applications Uses of (synchronized) physical clocks NTP Using physical clocks to implement at-most- once semantics Global Positioning Systems

EECE 411: Design of Distributed Software Applications GPS – Global Positioning Systems (1) Basic idea: Estimate signal propagation time between satellite and receiver to estimate distance Principle: Problem: Assumes that the clocks of the satellites and receiver are accurate and synchronized: The receiver’s clock is definitely out of synch with the satellite

EECE 411: Design of Distributed Software Applications GPS – Global Positioning Systems (2) X r, Y r, Z r, are unknown coordinates of the receiver. T i is the timestamp on a message from satellite i ∆I i = (T now – T i ) is the measured delay of the message sent by satellite i. Distance to satellite i can be estimated in two ways Propagation time: d i = c x ∆I i Real distance: 3 satellites  3 equations in 3 unknowns So far I assumed receiver clock is synchronized! What if it needs to be adjusted? ∆I = (T now – T i ) + ∆r collect one more measurement frm one more satellite!

EECE 411: Design of Distributed Software Applications Computing position in wired networks Observation: a node P needs at least k + 1 landmarks to compute its own position in a k-dimensional space. Consider two-dimensional case: Solution: P needs to solve three equations in two unknowns (x P,y P ):

EECE 411: Design of Distributed Software Applications Computing Position (…cont) Problems : measured latencies to landmarks fluctuate computed distances will not even be consistent Solution: Measure latencies to L landmarks and let each node P minimize where denotes the actual distance to landmark b i, given a computed coordinate for P.

EECE 411: Design of Distributed Software Applications Logical clocks -- Time Revisited What’s important? What precise time an event occurred? The order in which events occur?

EECE 411: Design of Distributed Software Applications “Happens-before” relation Problem: We first need to introduce a notion of ordering before we can order anything. The happened-before relation on the set of events in a distributed system: if a and b in the same process, and a occurs before b, then a → b if a is an event of sending a message by a process, and b receiving same message by another process then a → b Property: transitive Notation: a → b, when all participants agree that b occurs after a. Two events are concurrent if nothing can be said about the order in which they happened (partial order)

EECE 411: Design of Distributed Software Applications Logical clocks Problem: How do we maintain a global view on the system’s behavior that is consistent with the ‘happened-before’ relation? Solution: attach a timestamp C(e) to each event e, satisfying the following properties: P1: If a and b are two events in the same process, and a → b, then we demand that C(a) < C(b). P2: If a corresponds to sending a message m, and b to the receipt of that message, then also C(a) < C(b). Note: C must only increase Problem: Need to attach timestamps to all events in the system (consistent with the rules above) when there’s no global clock maintain a consistent set of logical clocks, one per process.

EECE 411: Design of Distributed Software Applications Logical clocks (cont) -- Lamport’s Approach Solution: Each process P i maintains a local counter C i and adjusts this counter according to the following rules: (1) For any two successive events that take place within process P i, the counter C i is incremented by 1. (2) Each time a message m is sent by process P i the message receives a timestamp ts(m) = C i (3) Whenever a message m is received by a process P j, P j adjusts its local counter C j to max{C j, ts(m)}; then executes step 1 before passing m to the application. Property P1 is satisfied by (1); Property P2 by (2) and (3). Note: it can still occur that two events happen at the same time. Avoid this by breaking ties through process IDs.

EECE 411: Design of Distributed Software Applications Example

EECE 411: Design of Distributed Software Applications Architectural view Middleware layer in charge of: Stamping messages with clock times, reading timestamps Local management of logical clocks Message ordering (if necessary)

EECE 411: Design of Distributed Software Applications Totally ordered group communication Example Initial state: $100 account balance Update 1: add $100 Update 2: add 1% monthly interest Q: What’s the result if updates are performed in different order at the two replica?

EECE 411: Design of Distributed Software Applications Totally ordered group communication (cont) Solution: Each message is timestamped with local logical time then multicasted When multicasted, also message logically sent to the sender and queued using timestamp order When receiving, the middleware layer Adds message to queue Acknowledges (using multicst) the message Delivers from queue to application only when all acks are received

EECE 411: Design of Distributed Software Applications Totally Ordered Multicast – Algorithm Process P i sends timestamped message msg i to all others. The message itself is put in a local queue queue i. Any incoming message at P k is queued in queue k, according to its timestamp, and acknowledged to every other process. P k passes a message msg i to its application if: msg i is at the head of queue k for each process P x, there is a message msg x in queue k with a larger timestamp. Note: We are assuming that communication is reliable and FIFO ordered. Guarantee: all multicasted messages in the same order at all destination. Nothing is guaranteed about the actual order!

EECE 411: Design of Distributed Software Applications So far … Physical clocks Two applications Provide at-most-once semantics Global Positioning Systems ‘Logical clocks’ Where only ordering of events matters