Ordering of events in Distributed Systems & Eventual Consistency Jinyang Li.

Slides:



Advertisements
Similar presentations
Relaxed Consistency Models. Outline Lazy Release Consistency TreadMarks DSM system.
Advertisements

Virtual Time “Virtual Time and Global States of Distributed Systems” Friedmann Mattern, 1989 The Model: An asynchronous distributed system = a set of processes.
Eventual Consistency Jinyang. Sequential consistency Sequential consistency properties: –Latest read must see latest write Handles caching –All writes.
D u k e S y s t e m s Time, clocks, and consistency and the JMM Jeff Chase Duke University.
Life after CAP Ali Ghodsi CAP conjecture [reminder] Can only have two of: – Consistency – Availability – Partition-tolerance Examples.
Replication Management. Motivations for Replication Performance enhancement Increased availability Fault tolerance.
Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
L-11 Consistency 1. Important Lessons Replication  good for performance/reliability  Key challenge  keeping replicas up-to-date Wide range of consistency.
CS 582 / CMPE 481 Distributed Systems
CPSC 668Set 12: Causality1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
1 ICS 214B: Transaction Processing and Distributed Data Management Replication Techniques.
Distributed Systems Fall 2009 Replication Fall 20095DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
Replication and Consistency CS-4513 D-term Replication and Consistency CS-4513 Distributed Computing Systems (Slides include materials from Operating.
G Robert Grimm New York University Bayou: A Weakly Connected Replicated Storage System.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Consistency.
Consistency. Consistency model: –A constraint on the system state observable by applications Examples: –Local/disk memory : –Database: What is consistency?
Lecture 12 Synchronization. EECE 411: Design of Distributed Software Applications Summary so far … A distributed system is: a collection of independent.
Managing Update Conflicts in Bayou, a Weakly Connected Replicated Storage System D. B. Terry, M. M. Theimer, K. Petersen, A. J. Demers, M. J. Spreitzer.
6.4 Data and File Replication Gang Shen. Why replicate  Performance  Reliability  Resource sharing  Network resource saving.
Distributed Shared Memory and Sequential Consistency.
Mobility in Distributed Computing With Special Emphasis on Data Mobility.
Replication and Consistency. Reference The Dangers of Replication and a Solution, Jim Gray, Pat Helland, Patrick O'Neil, and Dennis Shasha. In Proceedings.
D u k e S y s t e m s Asynchronous/Causal Replication in Bayou Jeff Chase Duke University.
EEC 688/788 Secure and Dependable Computing Lecture 9 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
CAP + Clocks Time keeps on slipping, slipping…. Logistics Last week’s slides online Sign up on Piazza now – No really, do it now Papers are loaded in.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Consistency.
“Virtual Time and Global States of Distributed Systems”
IM NTU Distributed Information Systems 2004 Replication Management -- 1 Replication Management Yih-Kuen Tsay Dept. of Information Management National Taiwan.
Shared Memory Consistency Models. SMP systems support shared memory abstraction: all processors see the whole memory and can perform memory operations.
Replication (1). Topics r Why Replication? r System Model r Consistency Models – How do we reason about the consistency of the “global state”? m Data-centric.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
D u k e S y s t e m s Asynchronous Replicated State Machines (Causal Multicast and All That) Jeff Chase Duke University.
CIS 720 Distributed Shared Memory. Shared Memory Shared memory programs are easier to write Multiprocessor systems Message passing systems: - no physically.
Chapter 4 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University Building Dependable Distributed Systems.
Consistency and Replication. Outline Introduction (what’s it all about) Data-centric consistency Client-centric consistency Replica management Consistency.
Asynchronous Replication client B Idea: build available/scalable information services with read-any-write-any replication and a weak consistency model.
CS533 Concepts of Operating Systems Jonathan Walpole.
Bayou: Replication with Weak Inter-Node Connectivity Brad Karp UCL Computer Science CS GZ03 / th November, 2007.
Consistency and Replication Chapter 6 Presenter: Yang Jie RTMM Lab Kyung Hee University.
Eventual Consistency Jinyang. Review: Sequential consistency Sequential consistency properties: –All read/write ops follow some total ordering –Read must.
EEC 688/788 Secure and Dependable Computing Lecture 9 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
, F’04 Lamport clocks Dave Eckhardt L36_Lamport.
Highly Available Services and Transactions with Replicated Data Jason Lenthe.
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 6: Synchronyzation 3/5/20161 Distributed Systems - COMP 655.
1 Lamport clocks Dave Eckhardt
Mobility Victoria Krafft CS /25/05. General Idea People and their machines move around Machines want to share data Networks and machines fail Network.
CS 347: Parallel and Distributed Data Management Notes07: Data Replication Hector Garcia-Molina CS 347 Notes07.
Nomadic File Systems Uri Moszkowicz 05/02/02.
Eventual Consistency: Bayou
Consistency and Replication
6.4 Data and File Replication
Consistency and Replication
Replication and Consistency
Replication and Consistency
EECS 498 Introduction to Distributed Systems Fall 2017
EECS 498 Introduction to Distributed Systems Fall 2017
IS 651: Distributed Systems Consistency
EEC 688/788 Secure and Dependable Computing
Fault-tolerance techniques RSM, Paxos
EEC 688/788 Secure and Dependable Computing
EEC 688/788 Secure and Dependable Computing
Distributed Shared Memory
EEC 688/788 Secure and Dependable Computing
Distributed Transactions
Atomic Commit and Concurrency Control
Distributed Systems CS
EEC 688/788 Secure and Dependable Computing
Lecture 9: Ordered Multicasting
EEC 688/788 Secure and Dependable Computing
Replication and Consistency
Presentation transcript:

Ordering of events in Distributed Systems & Eventual Consistency Jinyang Li

Consistency model: –A constraint on the system state observable by application operations Examples: –X86 memory: –Database: What is consistency? read x (should be 5)write x=5 time x:=x+1; y:=y-1assert(x+y==const) time

Consistency No right or wrong consistency models –Tradeoff between ease of programmability and efficiency Consistency is hard in (distributed) systems: –Data replication (caching) –Concurrency –Failures

Consistency challenges: example Each node has a local copy of state Read from local state Send writes to the other node, but do not wait

Consistency challenges: example W(x)1 W(y)1 x=1 If y==0 critical section y=1 If x==0 critical section

Does this work? R(y)0 W(x)1W(y)1 R(x)0 x=1 If y==0 critical section y=1 If x==0 critical section

What went wrong? W(x)1W(y)1 CPU0 sees: W(x)1 R(y)0 W(y)1 CPU1 sees: W(y)1 R(x)0 W(x)1 Diff CPUs see different event orders! R(y)0 R(x)0

Strict consistency Each operation is stamped with a global wall-clock time Rules: 1. Each read gets the latest write value 2. All operations at one CPU have time- stamps in execution order

No two CPUs in the critical section Proof: suppose mutual exclusion is violated CPU0: W(x)1 R(y)0 CPU1: W(y)1 R(x)0 Rule 1: read gets latest write CPU0: W(x)1 R(x)0 CPU1: W(y)1 R(x)0 Strict consistency gives “intuitive” results W must have timestamp later than R Contradicts rule 1: R must see W(x)1

Sequential consistency Strict consistency is not practical –No global wall-clock available Sequential consistency is the closest Rules: There is a total order of ops s.t. –All CPUs see results according to total order (i.e. reads see most recent writes) –Each CPUs’ ops appear in order

Lamport clock gives a total order Each CPU keeps a logical clock Each CPU updates its logical clock between successive events A sender includes its clock value in the message. A receiver advances its clock be greater than the message’s clock value. Lamport clocks define a total order. –Ties are broken based on CPU ids.

Fix the example W(x)1 W(y)1 CPU0 should see order W(x)1 W(y)1 CPU1 should see order W(x)1 W(y)1 ack R(y)0 R(x)1

Lamport clock: an example W(x)1 W(y)1 1,0 S: W(x)1 2,1 R: W(x)1 4,0 R: ack 2,0 R: W(y)1 1,1 S: W(y)1 4,1 R: ack 3,1 S: ack 3,0 S: ack 1,0 S W(x)1 1,1 S W(y)1 2,0 R W(y)1 2,1 R W(x)1 3,0 S ack 3,1 S ack 4,0 R ack 4,1 S ack Defines one possible total order: W(x)1 < W(y)1

Lamport clock: an example W(x)1 W(y)1 1,0 S: W(x)1 2,1 R: W(x)1 4,0 R: ack 2,0 R: W(y)1 1,1 S: W(y)1 4,1 R: ack 3,1 S: ack 3,0 S: ack 1,0 S W(x)1????? 1,0 S W(x)1 1,1 S W(y)1 2,0 R W(y)1 3,0 S ack 1,0 S W(x)1 1,1 S W(y)1 ??????1,1 S: W(x)1 1,0 S W(x)1 1,1 S W(y)1 2,1 R: W(x)1 3,1 S: ack 1,0 S W(x)1

Beyond Lamport clock Typical system obtains a total order differently –Use a single node to order all reads/writes E.g. the lock_server in Lab1 –Partition state over multiple nodes, each node orders reads/writes for its partition Invariant: exactly one is in charge of ordering  The ordering node must be online

Weakly consistent systems Sequential consistency –All read/writes are applied in total order –Reads must see most recent writes Eventual consistency (Bayou) –Writes are eventually applied in total order –Reads might not see most recent writes in total order

Why (not) eventual consistency? Support disconnected operations –Better to read a stale value than nothing –Better to save writes somewhere than nothing Potentially anomalous application behavior –Stale reads and conflicting writes…

Bayou Version Vector Write log 0:0 1:0 2:0 0:0 1:0 2:0 0:0 1:0 2:0 N0 N1 N2

Bayou propagation Version Vector Write log 0:3 1:0 2:0 N0 N1 N2 1:0 W(x) 2:0 W(y) 3:0 W(z) 0:0 1:1 2:0 0:0 1:0 2:0 1:1 W(x) 1:0 W(x) 2:0 W(y) 3:0 W(z) 0:3 1:0 2:0

Bayou propagation Version Vector Write log 0:3 1:0 2:0 N0 N1 N2 1:0 W(x) 2:0 W(y) 3:0 W(z) 0:3 1:4 2:0 0:0 1:0 2:0 1:0 W(x) 1:1 W(x) 2:0 W(y) 3:0 W(z) 1:1 W(x) 0:3 1:4 2:0

Bayou propagation Version Vector Write log N0 N1 N2 0:3 1:4 2:0 0:0 1:0 2:0 1:0 W(x) 1:1 W(x) 2:0 W(y) 3:0 W(z) 0:4 1:4 2:0 1:0 W(x) 1:1 W(x) 2:0 W(y) 3:0 W(z) Which portion of The log is stable?

Bayou propagation Version Vector Write log N0 N1 N2 0:3 1:4 2:0 1:0 W(x) 1:1 W(x) 2:0 W(y) 3:0 W(z) 0:4 1:4 2:0 1:0 W(x) 1:1 W(x) 2:0 W(y) 3:0 W(z) 0:3 1:4 2:5 1:0 W(x) 1:1 W(x) 2:0 W(y) 3:0 W(z)

Bayou propagation Version Vector Write log N0 N1 N2 0:3 1:6 2:5 1:0 W(x) 1:1 W(x) 2:0 W(y) 3:0 W(z) 0:4 1:4 2:0 1:0 W(x) 1:1 W(x) 2:0 W(y) 3:0 W(z) 0:4 1:4 2:5 1:0 W(x) 1:1 W(x) 2:0 W(y) 3:0 W(z) 0:3 1:4 2:5

Bayou uses a primary to commit a total order Why is it important to make log stable? –Stable writes can be committed –Stable portion of the log can be truncated Problem: If any node is offline, the stable portion of all logs stops growing Bayou’s solution: –A designated primary defines a total commit order –Primary assigns CSNs (commit-seq-no) –Any write with a known CSN is stable –All stable writes are ordered before tentative writes

Bayou propagation Version Vector Write log 0:3 1:0 2:0 N0 N1 N2 1:1:0 W(x) 2:2:0 W(y) 3:3:0 W(z) 0:0 1:1 2:0 0:0 1:0 2:0 ∞:1:1 W(x) 0:0 1:1 2:0

Bayou propagation Version Vector Write log 0:4 1:1 2:0 N0 N1 N2 1:1:0 W(x) 2:2:0 W(y) 3:3:0 W(z) 0:0 1:1 2:0 0:0 1:0 2:0 ∞:1:1 W(x) 4:1:1 W(x) 1:1:0 W(x) 2:2:0 W(y) 3:3:0 W(z) 4:1:1 W(x) 0:4 1:1 2:0

Bayou’s limitations Primary cannot fail Server creation & retirement makes nodeID grow arbitrarily long Anomalous behaviors for apps? –Calendar app