Consistency and Replication (1). Topics Why Replication? Consistency Models – How do we reason about the consistency of the “global state”? u Data-centric.

Slides:



Advertisements
Similar presentations
Global States.
Advertisements

COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 7: Consistency 4/13/20151Distributed Systems - COMP 655.
Relaxed Consistency Models. Outline Lazy Release Consistency TreadMarks DSM system.
Linearizability Linearizability is a correctness criterion for concurrent object (Herlihy & Wing ACM TOPLAS 1990). It provides the illusion that each operation.
Replication. Topics r Why Replication? r System Model r Consistency Models r One approach to consistency management and dealing with failures.
Consistency and Replication Chapter 7 Part II Replica Management & Consistency Protocols.
Consistency and Replication Chapter Introduction: replication and scalability 6.2 Data-Centric Consistency Models 6.3 Client-Centric Consistency.
Consistency and Replication Chapter Topics Reasons for Replication Models of Consistency –Data-centric consistency models: strict, linearizable,
Principles and Paradigms Consistency and Replication
Consistency and Replication
Time and Global States Part 3 ECEN5053 Software Engineering of Distributed Systems University of Colorado, Boulder.
Consistency and Replication (3). Topics Consistency protocols.
Consistency and Replication Chapter 6. Object Replication (1) Organization of a distributed remote object shared by two different clients.
Replication and Consistency Chapter 6. Data-Centric Consistency Models The general organization of a logical data store, physically distributed and replicated.
Consistency Models Based on Tanenbaum/van Steen’s “Distributed Systems”, Ch. 6, section 6.2.
Consistency and Replication. Replication of data Why? To enhance reliability To improve performance in a large scale system Replicas must be consistent.
Computer Science Lecture 14, page 1 CS677: Distributed OS Consistency and Replication Today: –Introduction –Consistency models Data-centric consistency.
Distributed Systems CS Consistency and Replication – Part II Lecture 11, Oct 10, 2011 Majd F. Sakr, Vinay Kolar, Mohammad Hammoud.
Distributed Systems Spring 2009
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Computer Science Lecture 14, page 1 CS677: Distributed OS Consistency and Replication Today: –Introduction –Consistency models Data-centric consistency.
Computer Science Lecture 16, page 1 CS677: Distributed OS Last Class: Web Caching Use web caching as an illustrative example Distribution protocols –Invalidate.
Group Communications Group communication: one source process sending a message to a group of processes: Destination is a group rather than a single process.
CS 582 / CMPE 481 Distributed Systems
Distributed Systems Fall 2009 Replication Fall 20095DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
Computer Science Lecture 14, page 1 CS677: Distributed OS Consistency and Replication Introduction Consistency models –Data-centric consistency models.
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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Client-Centric.
Logical Clocks (2). Topics r Logical clocks r Totally-Ordered Multicasting r Vector timestamps.
Distributed Deadlocks and Transaction Recovery.
Consistency and Replication CSCI 4780/6780. Chapter Outline Why replication? –Relations to reliability and scalability How to maintain consistency of.
Consistency and Replication
Consistency And Replication
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Consistency.
CIS 720 Lecture 16. Client-Centric Consistency Intended to address the issues in eventual consistency for mobile clients. –Consistent for a single.
Consistency and Replication Chapter 6. Release Consistency (1) A valid event sequence for release consistency. Use acquire/release operations to denote.
Consistency and Replication. Replication of data Why? To enhance reliability To improve performance in a large scale system Replicas must be consistent.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Consistency and Replication Distributed Software Systems.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Consistency.
Replication (1). Topics r Why Replication? r Consistency Models – How do we reason about the consistency of the “global state”? m Data-centric consistency.
IM NTU Distributed Information Systems 2004 Replication Management -- 1 Replication Management Yih-Kuen Tsay Dept. of Information Management National Taiwan.
第5讲 一致性与复制 §5.1 副本管理 Replica Management §5.2 一致性模型 Consistency Models
Shared Memory Consistency Models. SMP systems support shared memory abstraction: all processors see the whole memory and can perform memory operations.
Consistency and Replication Chapter 6 Presenter: Yang Jie RTMM Lab Kyung Hee University.
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.
Distributed Systems Replication. Why Replication Replication is Maintenance of copies at multiple sites Enhancing Services by replicating data Performance.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Consistency and Replication Chapter 6. Topics Reasons for Replication Models of Consistency –Data-centric consistency models –Client-centric consistency.
Distributed Systems CS Consistency and Replication – Part I Lecture 10, September 30, 2013 Mohammad Hammoud.
12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation.
Replication (1). Topics r Why Replication? r System Model r Consistency Models r One approach to consistency management and dealing with failures.
Consistency and Replication. Outline Introduction (what’s it all about) Data-centric consistency Client-centric consistency Replica management Consistency.
Client-Centric Consistency Models
Hwajung Lee.  Improves reliability  Improves availability ( What good is a reliable system if it is not available?)  Replication must be transparent.
Replication Improves reliability Improves availability ( What good is a reliable system if it is not available?) Replication must be transparent and create.
Consistency and Replication Chapter 6 Presenter: Yang Jie RTMM Lab Kyung Hee University.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Consistency and Replication CSCI 6900/4900. FIFO Consistency Relaxes the constraints of the causal consistency “Writes done by a single process are seen.
CS6320 – Performance L. Grewe.
Consistency and Replication
Consistency and Replication
Consistency Models.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Distributed Systems CS
Replica Placement Model: We consider objects (and don’t worry whether they contain just data or code, or both) Distinguish different processes: A process.
Consistency and Replication
CSE 486/586 Distributed Systems Consistency --- 1
Presentation transcript:

Consistency and Replication (1)

Topics Why Replication? Consistency Models – How do we reason about the consistency of the “global state”? u Data-centric consistency u Client-centric consistency Update propagation – How does an update to one copy of an item get propagated to other copies? Replication protocols – What is the algorithm that takes on update propagation method and enforces a given consistency model.

Readings Van Steen and Tanenbaum: 6.1, 6.2 and 6.3 Coulouris: 14

Why Replicate? Common approach used in distributed systems Reliability u If one replica is unavailable or crashes, use another u Avoid single points of failure Performance u Placing copies of data close to the processes using them can improve performance through reduction of access time. u If there is only one copy, then the server could become overloaded.

Why Not Replicate? Multiple copies may lead to consistency problems. Whenever a copy is modified, that copy becomes different from the rest. Modifications have to be carried out on all copies to ensure consistency. Exactly when and how those modifications need to be carried out determines the price of replication.

Why Not Replicate? Example: u To improve performance, web browsers often locally store a copy of a previously fetched web page. This is referred to as caching a web page. u User may perceive access time as excellent. u However, if the user always wants to have the latest version of a page, they may be in for bad luck. u What if the page has been modified and those modification have not been propagated (yet) to cached copies?

Why Not Replicate Solutions: u Don’t allow caches – poor access times u Let the web server invalidate or update cached copy – requires the server to keep track of all caches and send them messages. Could degrade performance of server.

Performance and Scalability Tradeoff: Keeping copies current may require more network bandwidth. Consider a process P that accesses a local replica N times per second, whereas the replica itself is updated M times per second. If N << M, we have the situation where many updated versions of the local replica will never be accessed by P, rendering the network communication for those versions useless.

Performance and Scalability Keeping multiple copies consistent may be subject to scalability problems. A collection of copies is consistent when the copies are always the same. This means that a read operation performed at any copy will always return the same result. When an update propagation is performed on one copy, the update should be propagated to all copies before a subsequent operation takes place. This is referred to as tight consistency.

Performance and Scalability To keep replicas tightly consistent, we generally need to ensure that all conflicting operations are done in the same order everywhere. Conflicting operations are defined as follows: u Read-write conflict: A read operation and a write operation act concurrently on the same data item. u Write-write conflicts: Two concurrent write operations on the same data item. Guaranteeing global ordering on conflicting operations is costly in terms of performance. This potentially downgrades the usefulness of replication. Consistency requirements must be weakened. This means that copies may not always be the same everywhere.

Data-Centric Consistency Models A consistency model is a contract between a distributed store and processes, in which the data store specifies precisely what the results of read and write operations are in the presence of concurrency. A data store is a distributed collection of storages accessible to clients.

Data-Centric Consistency Models

Notation To study consistency in detail, we will give numerous examples. Special notation is used. The symbol W i (x)a indicates a write by process P i to data item x with the value a The symbol R i (x)b indicates a read from the item x by P i returning b. It is assumed that each data item is initially NILL.

Strict Consistency Strict consistency is defined as follows: Any read to a shared data item X returns the value stored by the most recent write operation on X. You get strict consistency in the normal sequential case, where your program does not interfere with other programs.

Strict Consistency Behavior of two processes, operating on the same data item. A strictly consistent store. (a) A store that is not strictly consistent. (b)

Strict Consistency Suppose x is a data item stored only on machine B. Imagine that a process on A reads x at time T 1 which means that a message is sent to B to get x. Slightly later, at T 2, a process on B does a write to x. If strict consistency holds, the read should always return the old value regardless of where the machines are and how close T 2 is to T 1

Strict Consistency If T 2 -T 1 is 1 nanosecond and the machines are three meters apart, then to propagate the read request from A to B to get there before the write, the signal would have to travel the speed of light. When a data store is strictly consistent, all writes are instantaneously visible to all processes. The laws of physics are not with us on this. Is it reasonable to have strict consistency?

Sequential Consistency Two criteria must be satisfied: u The result of any execution is the same as if the (read and write) operations by all processes on the data store were executed in some sequential order u The operations of each individual process appear in this sequence in the order specified by its program. u Nothing is said about most recent write We are talking about interleaved executions: there is some total ordering for all operations taken together. Read operations are local, but write operations are applied everywhere. Linearizable: Sequential plus operations are ordered according to a global timestamp.

Sequential Consistency x = 1; print (y, z); y = 1; print (x, z); z = 1; print (x, y); Prints: (a) x = 1; y = 1; print (x,z); print(y, z); z = 1; print (x, y); Prints: (b) y = 1; z = 1; print (x, y); print (x, z); x = 1; print (y, z); Prints: (c) y = 1; x = 1; z = 1; print (x, z); print (y, z); print (x, y); Prints: (d) Process P1Process P2Process P3 x = 1; print ( y, z); y = 1; print (x, z); z = 1; print (x, y);

Sequential Consistency a) A sequentially consistent data store. b) A data store that is not sequentially consistent.

Sequential Consistency One possible implementation u Remember Lamport’s algorithm for total order

Causal Consistency Definition: Writes that are potentially causally related must be seen by all processes in the same order. Concurrent writes may be seen in a different order by different processes. Example u Suppose that process P 1 writes a variable x. u P 2 reads x and writes y u The reading of x and the writing of y are potentially causally related if the computation of y may have depended on the value of x read by P 2

Casual Consistency This sequence is allowed with a casually-consistent store, but not with sequential or strictly consistent store: W 2 (x)b and W 1 (x)c are concurrent.

Casual Consistency a) A violation of a casually-consistent store. b) A correct sequence of events in a casually-consistent store. In (a) we have W 2 (x)b potentially depending on W 1 (x)a because the b may be a result of a computation involving the value read by R 2 (x)a; In (b ) the read has been removed and thus W 1 (x)a and W 2 (x)b are concurrent.

Causal Consistency Possible Implementation u Use vector timestamps. u More on this later.

FIFO Consistency Definition: Writes done by a single process are received by all other processes in the order in which they were issued, but writes from different processes may be seen in a different order by different processes. Basically this is saying that there are no guarantees about the order in which different processes see writes, except that two or more writes from a single source must arrive in order.

FIFO Consistency A valid sequence of events of FIFO consistency

FIFO Consistency Easy to implement u Tag each write operation with a (process, sequence number). u Perform writes per process in the order of their sequence number.

Weak Consistency It is not always necessary that all writes are seen. Consider the case of a process inside a critical section writing records to a replicated database. u The important thing is that the final results are sent everywhere. u There shouldn’t be too much worrying about propagation of intermediate results

Weak Consistency Need synchronization variables. Accesses to synchronization variables associated with a data store are sequentially consistent u All processes see them in the same order No operation on a synchronization variable is allowed to be performed until all previous writes have been completed everywhere

Eventual Consistency There are examples in which concurrency appears only in a restricted form. Example: u In database systems, most processes hardly ever perform update operations but only read data from the database. u Relatively few processes perform update operations. Question: How fast should updates be made available to only reading processes?

Eventual Consistency Example: Consider DNS u DNS name space is partitioned into domains, where each domain is assigned to a naming authority, which acts as owner of that domain. u Only that authority is allowed to update its part of the name space. u Thus, conflicts resulting from two operations that both want to perform an update on the same data never occur. u It is often possible to propagate an update in a lazy fashion which means that a reading process will see an update only after some time has passed since the update took place.

Eventual Consistency Example: WWW u Web pages are updated by a single authority, such as a webmaster or the actual owner of the pages. u No write-write conflicts to resolve. u Browsers cache u It is possible that the cached page that is returned to the requesting client is an older version compared to the one available at the actual web server. u Is this really a big deal? The examples provided show that there are applications that can tolerate a relatively high degree of inconsistency. They have in common that if no updates take place for a long time, all replicas will gradually become consistent. This is known as eventual consistency.

Eventual Consistency Data stores that are eventually consistent thus have the property that in the absence of updates, all replicas converge toward identical copies of each other. Eventual consistency requires only that updates are guaranteed to propagate to all replicas. However…… u Problems arise when different replicas are accessed. u See example of mobile user.

Eventual Consistency The principle of a mobile user accessing different replicas of a distributed database.

Eventual Consistency The mobile user accesses the database by connecting to one of the replicas in a transparent way. The application running on the user’s portable computer is unaware (ideally) on which replica it is actually operating. Assume the user performs several update operations and then disconnects again. Later the user accesses the database again, possibly after moving to a different location or by using a different access device. The user may be connected to a different replica. What if the updates have not propagated? Could be confusing to the user.

Eventual Consistency The example of the mobile users is typical and is caused by the fact that users may sometimes operate on different replicas. Client-centric consistency is needed. Client-centric consistency provides guarantees for a single client concerning the consistency of accesses to a data store by that client. No guarantees are given concerning concurrent accesses by different clients. Goal: Concentrate on what specific clients want, instead of what should be maintained by servers.

Monotonic Reads If a process reads the value of a data item x, any successive read operation on x by that process will always return that same value or a more recent value. Example: Consider a distributed database In such a database, each user’s mailbox may be distributed and replicated across multiple machines. Mail can be inserted in a mailbox at any location. Updates are propagated in a lazy (i.e., on demand) fashion. Assume that reads don’t change the mailbox. Suppose a user reads their in Vancouver and then flies to Toronto and reads their . A monotonic read guarantees that the messages that were in the mailbox in Vancouver will also be in the mailbox in Toronto.

Monotonic Writes A write operation by a process on a data item x is completed before any successive write operation on x by the same process. This is especially needed in those cases where a write may affect only part of the state of a data item. Example: Updating a software library u Update may consist of replacing one or more functions resulting in a new version. u Updates performed on a copy of the library should be able to assume that all proceeding updates have been performed first. This is similar to data-centric FIFO consistency.

Read Your Writes The effect of a write operation by a process on data item x will always be seen by a successive read operation on x by the same process. The absence of this consistency is seen in the following examples. Example: Updating Web HTML pages u Cached web pages are still read even though that web page has been updated. Example: Password updates for digital library u This may occur at one site, but not immediately propagated to a site where the account/password is actually needed

Writes Follow Reads A write operation by a process on a data item x following a previous read operation on x by the same process, is guaranteed to take place on the same or a more recent value of x that was read. In other words, any successive write operation by a process on a data item x will be performed on a copy of x that is up to date with the value most recently read by that process. This can be used to guarantee that a user of a network newsgroup see a posting of a reaction to an article only after they have seen the original article.

Implementing Client-Centric Models Globally unique ID per write operation u Assigned by the initiating server u Global IDs can be generated locally. For each client, we keep track of two sets of write identifiers: u Read set n Write IDs relevant to client’s read operations u Write set n IDs of writes performed by client Major performance issue: u Size of read/write sets

Implementing Client-Centric Models The global identifier could include the identifier of a server where the operation was initiated. A server is required to log the write operation so that it can be replayed at another server.

Implementing Client-Centric Models Monotonic read: u When a client issues a read, the server is given the client’s read set to check whether all the identified writes have taken place locally n If not, the server contacts others to ensure that it is brought up-to-date u After the read, the client’s read set is updated with the server’s “relevant” writes Monotonic write: u When a client issues a write, the server is given the client’s write set n … to ensure that all specified writes have been applied (in-order) u The write operation’s ID is appended to client’s write set

Implementing Client-Centric Models Read-your-writes: u Before serving a read request, the server fetches (from other servers) all writes in the client’s write set Writes-follow-reads: u Server is brought up-to-date with the writes in the client’s read set u After write, the new ID is added to the client’s write set, along with the IDs in the read set n … as these have become “relevant” for the write just performed

Implementing Client-Centric Models Using vector timestamps for improving efficiency: u When server S i accepts a write operation, it assigns to it a globally unique WID and a timestamp ts(WID) u Each server maintains vector RCVD(i) n RCVD(i)[j] := timestamp of the latest write initiated at server S j that has been received & processed at S i Server returns its current vector timestamp with its responses to read/write requests Client adjusts the timestamp for its own read/write set (how this is done is described next).

Implementing Client-Centric Models When a client issues a request to perform a read/write operation at a specific server, the server returns its current timestamp along with the results of the operation. Read and write sets are subsequently represented by vector timestamps. For any such set A, the client constructs VT(A) with VT(A)[i] set equal to the maximum timestamp of all operations in A that were initiated at server S i

Implementing Client-Centric Models Efficient representation of read/write set A: u VT(A): vector timestamp n VT(A)[i] := max. timestamp of all operations in A that were initiated at server S i u Union of 2 sets of write IDs: n VT(A+B)[i] := max{ VT(A)[i], VT(B)[i] } u Efficient way to check if A is contained in B: n VT(A)[i] <= VT[B](i)

Implementing Client-Centric Models When a server passes its current timestamp back to a client, the client adjusts the vector timestamp of its own read or write set, depending on the operation that was performed.

Implementing Client-Centric Models Consider monotonic-read consistency u The client is returned the vector timestamp RCVD(i) from server S i u If the timestamp of the client’s read set is VT(Rset), then for each j, VT(Rset)[j] is set equal to max(VT(Rset)[j],RCVD(i)[j]). The client’s read set will thus reflect the latest write operations it has seen. The corresponding vector timestamp will be sent along with the next read operation that the client issues.