EECS 498 Introduction to Distributed Systems Fall 2017

Slides:



Advertisements
Similar presentations
Time, Clocks, and the Ordering of Events in a Distributed System
Advertisements

Last Class: Clock 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.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Logical Clocks and Global State.
Distributed Systems Spring 2009
Ordering and Consistent Cuts Presented By Biswanath Panda.
Lecture 13 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Last quiz Max: 69 / Median: 52 / Min: 24 In a box outside.
Time, Clocks and the Ordering of Events in a Distributed System - by Leslie Lamport.
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 12 Synchronization. EECE 411: Design of Distributed Software Applications Summary so far … A distributed system is: a collection of independent.
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.
Distributed Systems Foundations Lecture 1. Main Characteristics of Distributed Systems Independent processors, sites, processes Message passing No shared.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Fall 2003 URL: Logical Clocks and Global State.
Logical Clocks (2). Topics r Logical clocks r Totally-Ordered Multicasting r Vector timestamps.
Chapter 5.
Distributed Mutex EE324 Lecture 11.
Logical Clocks n event ordering, happened-before relation (review) n logical clocks conditions n scalar clocks condition implementation limitation n vector.
Page 1 Logical Clocks Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation is.
Synchronization. Why we need synchronization? It is important that multiple processes do not access shared resources simultaneously. Synchronization in.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
Lamport’s Logical Clocks & Totally Ordered Multicasting.
“Virtual Time and Global States of Distributed Systems”
Synchronization Chapter 5.
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
Distributed Coordination. Turing Award r The Turing Award is recognized as the Nobel Prize of computing r Earlier this term the 2013 Turing Award went.
D u k e S y s t e m s Asynchronous Replicated State Machines (Causal Multicast and All That) Jeff Chase Duke University.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
Feb 15, 2001CSCI {4,6}900: Ubiquitous Computing1 Announcements.
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.
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 1: Logical and Physical Time with some Applications Anish Arora CSE 6333 Notes include material from Dr. Jeff Brumfield.
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
CS533 Concepts of Operating Systems Class 8 Time, Clocks, and the Ordering of Events in a Distributed System By Constantia Tryman.
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 6: Synchronyzation 3/5/20161 Distributed Systems - COMP 655.
6.2 Logical Clocks Kranthi Koya09/23/2015. Overview Introduction Lamport’s Logical Clocks Vector Clocks Research Areas Conclusion.
11-Jun-16CSE 542: Operating Systems1 Distributed systems Time, clocks, and the ordering of events in a distributed system Leslie Lamport. Communications.
Logical Clocks event ordering, happened-before relation (review) logical clocks conditions scalar clocks  condition  implementation  limitation vector.
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Greetings. Those of you who don't yet know me... Today is... and
Time and Clock Primary standard = rotation of earth
Time Synchronization and Logical Clocks
Vector Clocks and Distributed Snapshots
CSE 486/586 Distributed Systems Global States
CSC 8320 Advanced Operating System
Distributed Mutex EE324 Lecture 11.
Time Synchronization and Logical Clocks
Overview of Ordering and Logical Time
EECS 498 Introduction to Distributed Systems Fall 2017
Time and Clock.
EECS 498 Introduction to Distributed Systems Fall 2017
EECS 498 Introduction to Distributed Systems Fall 2017
EECS 498 Introduction to Distributed Systems Fall 2017
Time and Clock.
EECS 498 Introduction to Distributed Systems Fall 2017
Outline Theoretical Foundations - continued Vector clocks - review
EECS 498 Introduction to Distributed Systems Fall 2017
Time And Global Clocks CMPT 431.
Event Ordering.
Outline Theoretical Foundations
CS 425 / ECE 428  2013, I. Gupta, K. Nahrtstedt, S. Mitra, N. Vaidya, M. T. Harandi, J. Hou.
Chapter 5 (through section 5.4)
Distributed algorithms
CSE 542: Operating Systems
Last Class: Naming Name distribution: use hierarchies DNS
Outline Theoretical Foundations
Presentation transcript:

EECS 498 Introduction to Distributed Systems Fall 2017 Harsha V. Madhyastha

Replicated State Machine Clients September 13, 2017 EECS 498 – Lecture 3

Replicated State Machine All replicas must apply updates in same order Ordering updates based on time of receipt is hard because of clock skew and drift Challenge in synchronizing clocks: Unbounded network delay September 13, 2017 EECS 498 – Lecture 3

Idea: Logical clocks Landmark 1978 paper by Leslie Lamport Insight: Disregard precise clock time Only relationships between events matter Associate every event with “logical time” Preserve “happens before” relationships If a happens before b, then clock(a) < clock(b) September 13, 2017 EECS 498 – Lecture 3

Defining “happens-before” In same process, if a occurs before b, then a  b If c is a message receipt of b, then b  c If a  b and b  c, then a  c P1 P2 P3 Space time diagram a b c d Physical time ↓ e September 13, 2017 EECS 498 – Lecture 3

Back to RSMs … How do we use “happens before” to ensure consistent ordering of updates in an RSM? September 13, 2017 EECS 498 – Lecture 3

Lamport clock: Objective Associate any event a with a clock time C(a) Clock condition: If a  b, then C(a) < C(b) Order events at all nodes based on clock time September 13, 2017 EECS 498 – Lecture 3

The Lamport Clock algorithm Each process Pi maintains a local clock Ci P1 C1=0 P2 C2=0 P3 C3=0 a b c Physical time ↓ September 13, 2017 EECS 498 – Lecture 3

The Lamport Clock algorithm Before executing an event, Ci  Ci + 1 P1 C1=1 P2 C2=0 P3 C3=0 C(a) = 1 a b c Physical time ↓ September 13, 2017 EECS 498 – Lecture 3

The Lamport Clock algorithm Before executing an event, Ci  Ci + 1 P1 C1=2 P2 C2=0 P3 C3=0 C(a) = 1 a C(b) = 2 b c Physical time ↓ September 13, 2017 EECS 498 – Lecture 3

The Lamport Clock algorithm Before executing an event, Ci  Ci + 1 Send the local clock in the message m P1 C1=2 P2 C2=0 P3 C3=0 C(a) = 1 a C(b) = 2 b c Physical time ↓ C(m) = 2 September 13, 2017 EECS 498 – Lecture 3

The Lamport Clock algorithm On process Pj receiving a message m: What time to set for receive event? C(m) + 1? P1 C1=2 P2 C2=3 P3 C3=0 C(a) = 1 a C(b) = 2 C(c) = 3? b c Physical time ↓ C(m) = 2 September 13, 2017 EECS 498 – Lecture 3

The Lamport Clock algorithm On process Pj receiving a message m: What time to set for receive event? C(m) + 1? P1 C1=2 P2 C2=3 P3 C3=2 C(d) = 1 C(a) = 1 d C(f) = 3 a C(b) = 2 f e C(e) = 2 b c Physical time ↓ C(m) = 2 C(c) = 3? September 13, 2017 EECS 498 – Lecture 3

The Lamport Clock algorithm On process Pj receiving a message m: Set Cj and time of receive event to 1 + max{ Cj, C(m) } P1 C1=2 P2 C2=4 P3 C3=1 C(d) = 1 C(a) = 1 d C(f) = 3 a C(b) = 2 f e C(e) = 2 b c Physical time ↓ C(m) = 2 C(c) = 4 September 13, 2017 EECS 498 – Lecture 3

Lamport clock Associate any event a with a clock time C(a) Clock condition: If a  b, then C(a) < C(b) If a causally leads to b, then C(a) < C(b) September 13, 2017 EECS 498 – Lecture 3

Ordering all events C = 1 2 3 4 a b c d e f P1 P2 P3 d a f e b c C1=2 September 13, 2017 EECS 498 – Lecture 3

Concurrent events Physical time ↓ Not all events are related by “happens before” a, d not related by  so concurrent, written as a || d P1 C1=2 P2 C2=4 P3 C3=2 d a f e b c Physical time ↓ September 13, 2017 EECS 498 – Lecture 3

Ordering all events How to ensure total ordering at all replicas? Can two events at same process have same clock value? a b c d e f a d b e f c d a e b f c C = 1 C = 2 September 13, 2017 EECS 498 – Lecture 3

Ordering all events Break ties by appending the process number to each event: Process Pi timestamps event e with Ci(e).i C(a).i < C(b).j when: C(a) < C(b), or C(a) = C(b) and i < j Now, for any two events a and b, C(a) < C(b) or C(b) < C(a) Total ordering of events September 13, 2017 EECS 498 – Lecture 3

Announcements Friday’s discussion section: Come prepared with questions about project 1 Homework questions posted on web page Reminder: Group declaration due in a week September 13, 2017 EECS 498 – Lecture 3

Making concurrent updates consistent Recall multi-site database replication: San Francisco (P1) deposited $100: New York (P2) paid 1% interest: Applying updates in different order made replicas inconsistent All replicas apply updates in Lamport clock order $ % September 13, 2017 EECS 498 – Lecture 3

RSMs with Lamport Clocks 7.2 2.1 P1 $ 3.1 % 8.2 % 8.2 3.1 $ 9.1 9.2 $ $ 10.2 % 10.1 11.2 % September 13, 2017 EECS 498 – Lecture 3

Consistent Ordering of Updates Key idea: Place events into a local queue Sorted by increasing C(x) How to tell if update at head of queue can be applied? Ping other nodes and check if they have earlier updates Application Application Ordered Updates Server1 Server2 Replicated State Machine Replicated State Machine Updates Updates September 13, 2017 EECS 498 – Lecture 3

RSMs with Lamport Clocks 7.2 2.1 P1 $ 3.1 % 8.2 % 8.2 3.1 $ 9.1 9.2 $ $ 10.2 % 10.1 11.2 % September 13, 2017 EECS 498 – Lecture 3

Reducing Waiting How to reduce time between receiving an update and applying it? Periodically ping all other nodes to sync clock Tolerate temporary inconsistency Apply update immediately upon receipt But, maintain log of updates in order to rollback September 13, 2017 EECS 498 – Lecture 3

Causal ordering Ordering all updates at all replicas may be unnecessary Example: Replication of Facebook posts Causal ordering suffices Show comments only if post visible to user With Lamport clock, a  b implies C(a) < C(b) But, converse is not necessarily true C(a) < C(b) does not imply a  b (possibly, a || b) September 13, 2017 EECS 498 – Lecture 3

Vector clock (VC) Label each event e with a vector V(e) = [c1, c2 …, cn] No. of components = No. of processes Semantic interpretation: ci is a count of events in process i that causally precede e September 13, 2017 EECS 498 – Lecture 3

Updating vector clocks Initially, all vectors are [0, 0, …, 0] Two rules for updating For each local event on process i, increment local entry ci If process j receives message with vector [d1, d2, …, dn]: Set each local entry ck = max{ck, dk} Increment local entry cj September 13, 2017 EECS 498 – Lecture 3

Vector clock: Example All counters start at [0, 0, 0] Applying local update rule Applying message rule Local vector clock piggybacks on inter-process messages P1 P2 P3 a [1,0,0] e [0,0,1] [2,0,0] b [2,0,0] [2,1,0] c [2,2,0] d [2,2,0] [2,2,2] f Physical time ↓ September 13, 2017 EECS 498 – Lecture 3

Vector clocks can establish causality Rule for comparing vector clocks: V(a) = V(b) when ak = bk for all k V(a) < V(b) when ak ≤ bk for all k and V(a) ≠ V(b) How to tell if two events are concurrent? a || b if ai < bi and aj > bj, some i, j V(a) < V(z) if and only if there is a chain of events linked by  between a and z September 13, 2017 EECS 498 – Lecture 3