Consistency and Replication Chapter 6. 6.1 Concepts Reasons for Replication Reliability Earthquake, flood Misoperation Performance Place copies of data.

Slides:



Advertisements
Similar presentations
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 7: Consistency 4/13/20151Distributed Systems - COMP 655.
Advertisements

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
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 Systems1 Chapter 8: Replication and Consistency  Replication: A key to providing good performance, high availability and fault tolerance in.
Consistency And Replication
Consistency and Replication
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.
CS 582 / CMPE 481 Distributed Systems
Consistency and Replication. Why Replicate Data? Enhance reliability. Improve performance. But: if there are many replicas of the same thing, how do we.
Consistency and Replication Chapter 6. Reasons for Replication Data replication is a common technique in distributed systems. There are two reasons for.
Computer Science Lecture 14, page 1 CS677: Distributed OS Consistency and Replication Introduction Consistency models –Data-centric consistency models.
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.
Computer Science Lecture 16, page 1 CS677: Distributed OS Last Class:Consistency Semantics Consistency models –Data-centric consistency models –Client-centric.
1 Consistency and Replication Reasons for Replication Reliability Performance –Scaling with respect to size of geographic area Negative Points Having multiple.
Consistency and Replication Chapter 7
Consistency & Replication Chapter No. 6
1 6.4 Distribution Protocols Different ways of propagating/distributing updates to replicas, independent of the consistency model. First design issue.
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.
Consistency and Replication Chapter 7. n Most of the lecture notes are based on slides by Prof. Jalal Y. Kawash at Univ. of Calgary n Some notes are based.
CIS 720 Lecture 16. Client-Centric Consistency Intended to address the issues in eventual consistency for mobile clients. –Consistent for a single.
ICS362 – Distributed Systems Dr. Ken Cosh Lecture 7.
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.
Outline Introduction (what’s it all about) Data-centric consistency Client-centric consistency Replica management Consistency protocols.
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.
第5讲 一致性与复制 §5.1 副本管理 Replica Management §5.2 一致性模型 Consistency Models
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.
Distributed Systems CS Consistency and Replication – Part IV Lecture 21, Nov 10, 2014 Mohammad Hammoud.
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.
Shyh-In Hwang in Yuan Ze University1 Chapter 6 Consistency and Replication.
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.
Distributed Systems CS Consistency and Replication – Part IV Lecture 13, Oct 23, 2013 Mohammad Hammoud.
Client-Centric Consistency Models
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.
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.
OS2 –Sem 1, Rasool Jalili Consistency and Replication Chapter 6.
Consistency and Replication (1). Topics Why Replication? Consistency Models – How do we reason about the consistency of the “global state”? u Data-centric.
CS6320 – Performance L. Grewe.
Consistency and Replication
Consistency and Replication
Consistency Models.
Consistency and Replication
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Replica Placement Model: We consider objects (and don’t worry whether they contain just data or code, or both) Distinguish different processes: A process.
Last Class: Web Caching
Consistency and Replication
Presentation transcript:

Consistency and Replication Chapter 6

6.1 Concepts Reasons for Replication Reliability Earthquake, flood Misoperation Performance Place copies of data close to the processes using them Web cache Difficulty Keep all replicas up-to-date

Object Replication Distributed remote objects Simultaneous access Protected by itself Protected by the server it resides Solve inconsistency problem replication-aware objects system’s responsibility

Object Replication (1) Organization of a distributed remote object shared by two different clients.

Object Replication (2) a)A remote object capable of handling concurrent invocations on its own. b)A remote object for which an object adapter is required to handle concurrent invocations

Object Replication (3) a)A distributed system for replication-aware distributed objects. b)A distributed system responsible for replica management

Object Replication Replication? normally improve performance but not always, it depends on the access-to- update ratio P accesses a local replica N times per sec; The replica is updated M times per sec; If N << M, then many updated versions of the local replica will never be accessed by P; Rendering a lot of useless network communication.

6.2 Data-centric Consistency Models Terminology Data store: data that is physically distributed across multiple machines. Consistency model: a contract between processes and the data store. If processes agree to obey certain rules, the store promises to work correctly.

Data-Centric Consistency Models The general organization of a logical data store, physically distributed and replicated across multiple processes.

Strict Consistency Any read on a data item x returns a value corresponding to the result of the most recent write on x. Notation: W i (x)a: a write by process P i to data item x with the value a; R i (x)b : a read by process P i to data item x with the value b;

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

Strict Consistency Counterexample x is a data item on machine B a process on machine A reads x at T 1 by sending a message to B to get the value of x a process on machine B writes x at T 2 T 2 - T 1 = 1 ns distance(A, B)= 3 meters

Strict Consistency Summary: Ideal, but impossible to be implemented in a DS. All writes are instantaneously visible to all processes. An absolute global time order is maintained.

Sequential Consistency 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 and the operations of each individual process appear in this sequence in the order specified by its program.

Sequential Consistency Explanation Any valid interleaving of read and write operations is acceptable behavior, but all processes see the same interleaving of operations. Nothing about time and no reference to the “most recent” word.

Sequential Consistency (1) a)A sequentially consistent data store. b)A data store that is not sequentially consistent. R(x)a R(x)b (c) c) A sequentially consistent data store.

Linearizable Consistency 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 and the operations of each individual process appear in this sequence in the order specified by its program. In addition, if ts op1 (x) < ts op2 (y), then operation OP1(x) should precede OP2(y) in this sequence. ts op (x): a timestamp assigned to operation OP that is performed on data item x.

Linearizability and Sequential Consistency Three concurrently executing processes. Process P1Process P2Process P3 x = 1; print ( y, z); y = 1; print (x, z); z = 1; print (x, y); Trivial question : how many valid interleaved execution sequences based on possible program order?

Linearizability and Sequential Consistency Four valid execution sequences for the processes of the previous slide. The vertical axis is time. x = 1; print (y, z); y = 1; print (x, z); z = 1; print (x, y); Prints: Signature: (a) x = 1; y = 1; print (x,z); print(y, z); z = 1; print (x, y); Prints: Signature: (b) y = 1; z = 1; print (x, y); print (x, z); x = 1; print (y, z); Prints: Signature: (c) y = 1; x = 1; z = 1; print (x, z); print (y, z); print (x, y); Prints: Signature: (d) Is signature allowed?

Casual Consistency Causality If event B is caused or influenced by an earlier event A, then the causality requires that everyone else first see A, then see B. Example: Process P 1 writes a variable x, then process P 2 reads x and writes y. It’s possible that the computation of y may have depended on the value of x read by P 2 (i.e., the value written by P 1 ).

Casual Consistency (1) Writes that are potentially casually related must be seen by all processes in the same order. Concurrent writes may be seen in a different order on different machines.

Casual Consistency (2) This sequence is allowed with a casually-consistent store, but not with sequentially or strictly consistent store.

Casual Consistency (3) a)A violation of a casually-consistent store. b)A correct sequence of events in a casually-consistent store. R(x)a R(x)b (c)

FIFO Consistency (1) Writes done by a single process are seen 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.

FIFO Consistency (2) A valid sequence of events of FIFO consistency

FIFO Consistency (3) Statement execution as seen by the three processes from the previous slide. The statements in bold are the ones that generate the output shown. x = 1; print (y, z); y = 1; print(x, z); z = 1; print (x, y); Prints: 00 (a) x = 1; y = 1; print(x, z); print ( y, z); z = 1; print (x, y); Prints: 10 (b) y = 1; print (x, z); z = 1; print (x, y); x = 1; print (y, z); Prints: 01 (c) Signature: which is not allowed in sequential consistency

FIFO Consistency (4) Two concurrent processes. Process P1Process P2 x = 1; if (y == 0) kill (P2); y = 1; if (x == 0) kill (P1); P 1 is killed P 2 is killed Neither is killed Both are killed ?

Weak Consistency Synchronization Variable (S) A process P performs operations only on its locally available copy of the data store. When the data store is synchronized, all local writes by process P are propagated to the other copies, whereas writes by other processes are brought in to P’s copy. synchronize(S) synchronizes all local copies of the data store.

Weak Consistency (1) Accesses to synchronization variables associated with a data store are sequentially consistent No operation on a synchronization variable is allowed to be performed until all previous writes have been completed everywhere No read or write operation on data items are allowed to be performed until all previous operations to synchronization variables have been performed.

Weak Consistency (2) A program fragment in which some variables may be kept in registers. int a, b, c, d, e, x, y;/* variables */ int *p, *q;/* pointers */ int f( int *p, int *q);/* function prototype */ a = x * x;/* a stored in register */ b = y * y;/* b as well */ c = a*a*a + b*b + a * b;/* used later */ d = a * a * c;/* used later */ p = &a;/* p gets address of a */ q = &b/* q gets address of b */ e = f(p, q)/* function call */

Weak Consistency (3) a)A valid sequence of events for weak consistency. b)An invalid sequence for weak consistency.

Release Consistency (1) A valid event sequence for release consistency.

Release Consistency (2) Before a read or write operation on shared data is performed, all previous acquires done by the process must have completed successfully. Before a release is allowed to be performed, all previous reads and writes by the process must have completed Accesses to synchronization variables are FIFO consistent (sequential consistency is not required).

Entry Consistency (1) An acquire access of a synchronization variable is not allowed to perform with respect to a process until all updates to the guarded shared data have been performed with respect to that process. Before an exclusive mode access to a synchronization variable by a process is allowed to perform with respect to that process, no other process may hold the synchronization variable, not even in nonexclusive mode. After an exclusive mode access to a synchronization variable has been performed, any other process's next nonexclusive mode access to that synchronization variable may not be performed until it has performed with respect to that variable's owner.

Entry Consistency (2) A valid event sequence for entry consistency.

Summary of Consistency Models a)Consistency models not using synchronization operations. b)Models with synchronization operations. ConsistencyDescription StrictAbsolute time ordering of all shared accesses matters. Linearizability All processes must see all shared accesses in the same order. Accesses are furthermore ordered according to a (nonunique) global timestamp Sequential All processes see all shared accesses in the same order. Accesses are not ordered in time CausalAll processes see causally-related shared accesses in the same order. FIFO All processes see writes from each other in the order they were used. Writes from different processes may not always be seen in that order (a) ConsistencyDescription WeakShared data can be counted on to be consistent only after a synchronization is done ReleaseShared data are made consistent when a critical region is exited EntryShared data pertaining to a critical region are made consistent when a critical region is entered. (b)

6.3 Client-centric Consistency Models 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.

Eventual Consistency If no updates take place for a long time, all replicas will gradually become consistent. Example: WWW –web pages are updated by a single one –no write-write conflicts –out-of-date local cache –but, acceptable inconsistency Eventual consistent data store work fine as long as clients always access the same replica.

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

Notations x i [t]: the version of date item x at local copy L i at time t. WS(x i [t]): a series of write operations to x at L i that took place since initialization, till time the version x i [t]. WS(x i [t 1 ]; x j [t 2 ]): If operations in WS(x i [t 1 ]) have also been performed at local copy L j at a later time t 2. The time index will be omitted if the timing is clear from the context.

(1) Monotonic Reads A data store is said to provide monotonic-read consistency if the following condition holds: 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. If a process has seen a value of x at time t, it will never see an older version of x at a later time

(1) Monotonic Reads The read operations performed by a single process P at two different local copies of the same data store. a)A monotonic-read consistent data store b)A data store that does not provide monotonic reads.

(2) Monotonic Writes In a monotonic-write consistency store, the following condition holds: A write operation by a process on a data item x is completed before any successive write operation on x by the same process. A write operation on a copy of data item x is performed only if that copy has been brought up to date by means of any preceding write operation, which may have taken place on other copies of x.

(2) Monotonic Writes The write operations performed by a single process P at two different local copies of the same data store a)A monotonic-write consistent data store. b)A data store that does not provide monotonic-write consistency.

(3) Read Your Writes A data store is said to provide read- your-writes consistency, if the following condition holds: 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. A write operation is always completed before a successive read operation by the same process, no matter where that read operation takes place.

(3) Read Your Writes a)A data store that provides read-your-writes consistency. b)A data store that does not.

(4) Writes Follow Reads A data store is said to provide writes-follow-reads consistency, if the following condition holds: 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. 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.

(4) Writes Follow Reads a)A writes-follow-reads consistent data store b)A data store that does not provide writes-follow-reads consistency

(4) Writes Follow Reads Example of a network newsgroup –A user first reads an article A; –Then he reacts by posting a response B; –B will be written to any copy of the newsgroup only after A has been written as well. The writes-follows-reads consistency assures that reactions to articles are stored at a local copy only if the original is stored there as well.

6.4 Distribution Protocols Replica Placement –Permanent Replicas Mirroring sites –Server-Initiated Replicas push caches Some servers dynamically replicate files to other servers close to demanding clients. –Client-initiated Replicas Client caches

Replica Placement The logical organization of different kinds of copies of a data store into three concentric rings.

Server-Initiated Replicas Specific files on a server can be migrated or replicated to servers placed in the proximity of clients that issue many requests for those files.

Server-Initiated Replicas Counting access requests from different clients. cnt Q (P, F): access count from P for the file F at server Q, where P is the same “closest” server for C 1 and C 2.

Server-Initiated Replicas Each server keeps track of access counts per file, and where access requests come from. When the number of requests for a specific file F at server S drops below a deletion threshold del(S, F), that file can be removed from S. A replication threshold rep(S, F) indicates that the number of requests for a specific file is so high that it may be worthwhile replicating it on another server. If for some server P, cnt Q (P, F) exceeds more than half of the total requests for F at Q, server Q will attempt to migrate F to P.

Client-Initiated Replicas A cache could be located on the client’s machine, or on a separate machine in the same LAN as the client. Caches work fine as long as the fetched data have not been modified in the meantime. –Data are generally kept in a cache for a limited amount time

Update Propagation What is actually to be propagated? –Propagate only a notification of an update Invalidation protocols Small read-to-write ratio Little network bandwidth –Transfer data from one copy to another High read-to-write ratio –Propagate the update operation to other copies Little network bandwidth

Pull versus Push Protocols Push-based approach(server-based approach) –Updates are propagated to other replicas without those replicas even asking for the updates. Pull-based approach(client-based approach) –A server or client requests another server to send it any updates it has at that moment.

Pull versus Push Protocols A comparison between push-based and pull-based protocols in the case of multiple client, single server systems. IssuePush-basedPull-based State of serverList of client replicas and cachesNone Messages sentUpdate (and possibly fetch update later)Poll and update Response time at client Immediate (or fetch-update time)Fetch-update time Consistency degree highlow Read-to-update ratio highlow

Epidemic Protocols Update Propagation Models –Terminology: infective: holds an update and is willing to spread it susceptible: has not been updated removed: is not willing or able to spread its update –Anti-entropy algorithm A server P picks another server Q at random and subsequently exchanges updates with Q. –P only pushes its own updates to Q –P only pulls in new updates from Q –P and Q send updates to each other (a push-pull approach)

Epidemic Protocols –Gossiping algorithm If server P has just been updated for data item x, it contacts an arbitrary other server Q and tries to push the update to Q. If Q was already updated by another server, P may lose interest in spreading the update any further. That is, it then becomes removed.

6.5 Consistency Protocols A consistency protocol describes an implementation of a specific consistency model –Primary-based Protocols Remote-write Protocols Local-write Protocols –Replicated-write Protocols Active Replication Quorum-based Protocols –Cache-coherence Protocols (omitted)

Remote-Write Protocols (1) Primary-based remote-write protocol with a fixed server to which all read and write operations are forwarded.

Remote-Write Protocols (2) The principle of primary- backup protocol.

Primary-based Protocols Primary-backup protocols provides a straightforward implementation of sequential consistency, as the primary can order all incoming writes.

Local-Write Protocols (1) Primary-based local-write protocol in which a single copy is migrated between processes.

Local-Write Protocols (2) Primary-backup protocol in which the primary migrates to the process wanting to perform an update.

Active Replication In replicated-write protocols, write operations can be carried out at multiple replicas instead of only one, as in the case of primary-based replicas. sequencer: a central coordinator. –totally-ordered multicasting: first forward each operation to the sequencer, which assign it a unique sequence number and subsequently forwards the operation to all replicas.

Active Replication (1) The problem of replicated invocations.

Active Replication (2) a)Forwarding an invocation request from a replicated object. b)Returning a reply to a replicated object.

Quorum-Based Protocols Suppose a file is replicated on N servers –Algorithm Whenever a client want to update a file, it needs to get permissions from at least (N/2 + 1) servers. If ok, then the client change the file and associate a new version number to the file. To read a file, a client get the file as well as the version number from at least (N/2 + 1) servers. If all version numbers agree, then it gets the most recent copy of the file.

Quorum-Based Protocols Suppose a file is replicated on N servers –Gifford’s Algorithm To read the file, a client needs to assemble a read quorum, an arbitrary collection of any N R servers, or more. To update the file, a client needs to assemble a write quorum, an arbitrary collection of at least N w servers. Constraints: –N R + N w > N => prevent read-write conflicts –N w > N/2 => prevent write-write conflicts

Quorum-Based Protocols Three examples of the voting algorithm: a)A correct choice of read and write set b)A choice that may lead to write-write conflicts c)A correct choice, known as ROWA (read one, write all)

Homework #3 due 12/24, 2pm Chapter 5 question 18, 7: Systems that use locking for concurrency control usually distinguish read locks from write locks. What should happen if a process has already acquired a read lock and now wants to change it into a write lock? What about changing a write lock into a read lock? In Fig (or page 31 of this slide) we have two ELECTION messages circulating simultaneously. While it does no harm to have two of them, it would be more elegant if one could be killed off. Devise an ( see the next page )

Homework #3 due 12/24, 2pm algorithm for doing this without affecting the operation of the basic election algorithm. Chapter 6 question 9, 10: In Fig. 6-7, is a legal output for a distributed shared memory that is only FIFO consistent? Explain your answer. In Fig. 6-8, is a legal output for a sequentially consistent memory? Explain your answer.