0% found this document useful (0 votes)
20 views8 pages

Consistency and Replication

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views8 pages

Consistency and Replication

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Consistency and Replication

An important issue in distributed systems is the replication of data. Data


are generally replicated to enhance reliability or improve performance.
One of the major problems is keeping replicas consistent. Informally, this
means that when one copy is updated, we need to ensure that the other
copies are updated as well; otherwise, the replicas will no longer be the
same. Main questions here are “why replication is useful? and how it
relates to scalability? what consistency actually means”. First, we start
with concentrating on managing replicas, which considers not only the
placement of replica servers, but also how content is distributed to these
servers. The second issue is how replicas are kept consistent. In most
cases, applications require a strong form of consistency. Informally, this
means that updates are to be propagated more or less immediately
between replicas.
Replication
Why replicate
Assume a simple model in which we make a copy of a specific part of a system
(meaning code and data).
Increase reliability: if one copy does not live up to specifications, switch over to the
other copy while repairing the failing one.
Performance: simply spread requests between different replicated parts to keep
load balanced, or to ensure quick responses by taking proximity into account.
The problem
Having multiple copies, means that when any copy changes, that change should
be made at all copies: replicas need to be kept the same, that is, be kept
consistent.
Performance and scalability
Main issue
To keep replicas consistent, we generally need to ensure that all
conflicting operations are done in the the same order everywhere
Conflicting operations: From the world of transactions
Read–write conflict: a read operation and a write operation act
concurrently
Write–write conflict: two concurrent write operations

Issue
Guaranteeing global ordering on conflicting operations may be a costly
operation, downgrading scalability. Solution: weaken consistency
requirements so that hopefully global synchronization can be avoided
Data-centric consistency models
Consistency model
A contract between a (distributed) data store and processes, in which the data
store specifies precisely what the results of read and write operations are in the
presence of concurrency.
Essential
A data store is a distributed collection of storages:
Sequential consistency
Definition
The result of any execution is the same as if the operations of all processes
were executed in some sequential order, and the operations of each individual
process appear in this sequence in the order specified by its program.

A sequentially consistent data store

A data store that is not sequentially consistent


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.

A violation of a causally-consistent store

A correct sequence of events in a causally-consistent store


Consistency models, serializability, transactions
Sequential Consistency
Overwhelming, but often already known
Again, from the world of transactions: can we order the execution of all operations
in a set of transactions in such a way that the final result matches a serial
execution of those transactions? The keyword is serializability.
BEGIN TRANSACTION BEGIN TRANSACTION BEGIN TRANSACTION
x =0 x =0 x =0
x =x +1 x =x +2 x =x +3
END TRANSACTION END TRANSACTION END TRANSACTION
Transaction T1 Transaction T2 Transaction T3

A number of schedules
Time − →

S1 x=0 x=x+1 x=0 x=x+2 x=0 x=x+3 Legal

S2 x=0 x=0 x=x+1 x=x+2 x=0 x=x+3 Legal

S3 x=0 x=0 x=x+1 x=0 x=x+2 x=x+3 Illegal

S4 x=0 x=0 x=x+3 x=0 x=x+1 x=x+2 Illegal


Eventual consistency WhatsApp

Definition
Consider a collection of data stores and (concurrent) write operations. The strores are
eventually consistent when in lack of updates from a certain moment, all updates to that point
are propagated in such a way that replicas will have the same data stored (until updates are
accepted again).
Srong eventual consistency
Basic idea: if there are conflicting updates, have a globally determined resolution mechanism
(for example, using NTP, simply let the “most recent” update win).
Network Time Protocol
Program consistency
P is a monotonic problem if for any input sets S and T , P(S) ⊆ P(T ). Observation: A program
solving a monotonic problem can start with incomplete information, but is guaranteed not to
have to roll back when missing information becomes available. Example: filling a shopping cart.
Important observation
In all cases, we are avoiding global synchronization.

You might also like