7.Distributed Systems-Consistancy Replication
7.Distributed Systems-Consistancy Replication
Replication
Distributed Systems
Introduction
• Reasons for replication
• Replication as scaling technique
Reason for Replication: Performance
and Scalability
Main issue: To keep replicas consistent, we generally need to ensure that all
conflicting operations are done in 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
Local Copy
Data-Centric Consistency Model:
Continuous Consistency
We can actually talk about a degree of consistency
• replicas may differ in their numerical value
• replicas may differ in their relative staleness
• there may be differences with respect to (number and order) of
performed update operations
⇒ order deviation = 3
• A has three pending operations
482)
Data-Centric Consistency Model:
Consistent Ordering Operations
Some Notations: Read and write operations
• Wi(x)a: Process Pi writes value a to data item x
• Ri(x)b: Process Pi reads value b from data item x
• All data items initially have value NIL
Possible behavior
We omit index when possible and draw according to time (x-axis):
P1: W(x)a
P2: R(x)NIL R(x)a
Data-Centric Consistency Model:
Consistent Ordering Operations:
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) A sequentially consistent data store. (b) A data store that is not
sequentially consistent
P1: W(x)a P1: W(x)a
• Basic idea: You don't care that reads and writes of a series of
operations are immediately known to other processes. You just want
the effect of the series itself to be known.
Data-Centric Consistency Model:
Consistent Ordering Operations:
Grouping
A Operations
valid event sequence for entry consistency
P1: L(x) W(x)a L(y) W(y)b U(x) U(y)
P2: L(x) R(x)a
R(y) NIL
P3: L(y)
R(y)b
Note: The only thing you really want is that the entries you updated and/or
read at A, are in B the way you left them in A. In that case, the database will
appear to be consistent to you.
Client-Centric Consistency
Architect
Model: BasicClient moves to other location and
(transparently) connects to other replica
ure
L1:
L2: W1(xW1)2(x1; x2) R1(x2) L1: W1(xW1) (x |x ) R (x )
2 1 2 1 2
L2: (b)
(a) your Web page and guaranteeing that your Web browser
Example: Updating
shows the newest version instead of its cached copy.
Client-Centric Consistency
Model: Writes follows Reads
• Definition
• 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.
(a) A writes-follow-reads consistent data store. (b) A data store that does not
provide writes-follow-reads consistency
L1: W1(x1) R2(x1) L1: W1(x1) R2(x1)
L2: W3(x1; W2(x2; x3) L2: W3(x1| W2(x2| x3)
x2) (a) x2) (b)
Example: See reactions to posted articles only if you have the original posting
(a read "pulls in" the corresponding write operation).
Replica Management
• Finding the best server location
• Content replication and placement
• Content distribution
• Managing replicated objects
Replica Management: Finding The
Best Server Location
Essence: Figure out what the best K places are out of N possible
locations.
• Select best location out of N −K for which the average distance to
clients is minimal. Then choose the next best server. (Note: The
first chosen location minimizes the average distance to all clients.)
Computationally expensive.
• Select the K-th largest autonomous system and place a server at the
best-connected host. Computationally expensive.
• Position nodes in a d-dimensional geometric space, where distance
reflects latency. Identify the K regions with the highest density
and place a server in every one. Computationally cheap.
Replica Management: Content
Replication and Placement
The logical organization of different kinds of copies of a data store into
three concentric rings
Replica Management: Content
Replication and Placement
Distinguish different processes: A process is capable of hosting a replica
of an object or data:
• Permanent replicas: Process/machine always having a replica
• Server-initiated replica: Process that can dynamically host a replica on
request of another server in the data store
• Client-initiated replica: Process that can dynamically host a replica on
request of a client (client cache)
Replica Management: Content
Replication and Placement: Server-
Initiated Replicas
• Keep track of access counts per Server without
C2
copy of file F
file, aggregated by
considering server closest to
requesting clients
∀W : val(W ) > 0
its value after a write operation W. Assume that
𝑣 = 𝑣𝑖𝑛𝑖𝑡 +
𝑡 𝑇𝑊[𝑘, 𝑘]
𝑘=1
Value vi of x at server Si
𝑣𝑖 = 𝑣𝑖𝑛𝑖𝑡 +
�
�
𝑇𝑊[𝑖, 𝑘]
𝑘=1
Consistency Protocol: Continuous
Consistency Bounding Numerical
Deviation:
•Problem: We needNumerical
to ensure that v(t)Errors
−vi < δi for every server Si.
•Approach: Let every server Sk maintain a view TWk[i, j] of what it
believes is the value of TW[i, j]. This information can be
gossiped when an update is propagated.
•Note: 0 ≤ TWk[i, j] ≤ TW[i, j] ≤ TW[j, j]
Consistency Protocol: Continuous
Consistency Bounding Numerical
Deviation:
• Solution: S sends Numerical Errors
operations from its log to S when it sees that TW [i,
k i k
k] is getting too far from TW[k, k], in particular, when TW[k, k] −
TWk[i, k] > δi /(N − 1)
• Push protocol
Consistency Protocol: Continuous
Consistency: Bounding staleness
deviations
•S keep a real-time vector clock RVC
k k
•RVCk[i] = ti means that Sk has seen all writes that have been submitted
to Si up to time ti, ti denotes the time local to Si.
•Server Sk notes that tk − RVCk[i] is about to exceed a specified limit,
pulling in writes that originated from Si with a timestamp later
than RVCk[i].
• Pull protocol
Consistency Protocol: Continuous
Consistency: Bounding ordering
deviations
• replica server tentatively applies updates to the local copy
• actual order in which they are to be applied to the local copy of x still
needs to be determined
• ordering deviation is bounded by specifying the maximal length of the
queue of tentative writes
Consistency Protocol: Sequential
Consistency: Primary-based Protocols:
Primary Backup Protocol: Remote-Write
Client
Primary server
E F G H E F G H E F G H
I J K L I J K L I J K L
NR = 3, NW = 10 NR = 7, NW = 6 NR = 1, NW = 12