Loading in 5 sec....

Consistency and ReplicationPowerPoint Presentation

Consistency and Replication

- By
**howe** - Follow User

- 125 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' Consistency and Replication' - howe

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Reasons for Replication

- Reliability:
- Mask failures
- Mask corrupted data

- Performance:
- Scalability (size and geographical)

- Examples:
- Web caching
- Horizontal server distribution
- Object distribution

Example – Object Replication (1)

- Organization of a distributed remote object shared by two different clients.

Example – Object Replication (2)

- A remote object capable of handling concurrent invocations on its own.
- A remote object for which an object adapter is required to handle concurrent invocations

Example – Object Replication (3)

- A distributed system for replication-aware distributed objects.
- A distributed system responsible for replica management

Cost of Replication

?

- Replicas must be kept consistent
- Dilemma:
- Replicate data for better performance
- Modification on one copy triggers modifications on all other replicas
- Propagating each modification to each replica can degrade performance
- When and how the modifications are made = consistency model
- Weak versus strong consistency model

Consistency Issues – Access/Update Ratio

Lost Updates

User accesses to the page

…

Updates to the Web page

time

Consistency Models

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

Framework for Consistency Partial and Total Orders

- Let S be a set, and R S S
- R is anti-reflexive if x S, (x,x) R
- R is transitive if x, y, z S, if (x,y) R and (y,z) R then (x,z) R
- A PO is an anti-reflexive, transitive relation
- A PO is denoted by (S,R)
- xRy means (x,y) R
- A TO is a PO (S,R) such that x, y S x y, either xRy or yRx

Framework for Consistency Operations and Data Items

- Operations are either writes or reads (other operations are possible)
- A write is denoted wp(x)v
- A read is denoted rp(x)v
- A read-write data item is the set of all sequences <o1, o2, … on> such that
- Each oi is either a read or a write
- Each read returns the same value written by the most recent preceding write in the sequence

Framework for Consistency Operations and Processes

- Each operation can be decomposed into two components:
- Invocation and response

- wp(x)v: invocation = wp(x)v; response = empty
- rp(x)v: invocation = rp(x)?; response = v
- A process is a sequence of operation invocations
- A process computation is a sequence of operations obtained by augmenting each invocation in the process by its response

Framework for Consistency Multiprocess Systems

- A (multiprocess) system (P,D) is a set of processes, P, and a set of data items, D, such that all operation invocations of processes in P are applied to items in D
- A (multiporcess) system (P,D) computation is a collection of process computations one for each process in P

Framework for Consistency Example

Program p:

x = y

Program q:

y = x

System (P,D):

P = {p,q}

D = {x,y}

Process p:

r(y)v?

w(x)v?

Process q:

r(x)v?

w(y)v?

System (P,D) Computation:

p: r(y)5 w(x)5

q: r(x)0 w(y)0

Process p

Comp:

r(y)5

w(x)5

Process q

Comp:

r(x)0

w(y)0

Framework for Consistency Program Order

Program p:

x = y

Program q:

y = x

- rp(y)5 <po wp(x)5
- rq(x)0 <po wq(y)0
- All of program order for the exmple

Process p:

r(y)v?

w(x)v?

Process q:

r(x)v?

w(y)v?

Process p

Comp:

r(y)5

w(x)5

Process q

Comp:

r(x)0

w(y)0

- Define program order, dnoted (O, <po), by o1<po o2 iff o2 follows o1 in p’s computation

Framework for Consistency Consistency Models

- A consistency model is a set of constraints on system computations
- A system computation of (P,D) satisfies a consistency model CM if the computation meets all the constraints in CM
- For two consistency models CM1 and CM2 CM1 is stronger than CM2 if the constraints of CM1 imply those of CM2
- CM2 is weaker than CM1

Framework for Consistency – Validity

- Given a set of operations O
- O|w indicates all the write operations in O
- O|r indicates all the read operations in O
- O|p is the subset of O containing p’s operations, for some process p
- O|x is the subset of O containing operations on x, for some data item p
- Let (O,<) be a total order of O
- (O,<) is valid if for each data item x, the subsequence (O|x,<) is valid for x.

Framework for Consistency Valid Total Orders

Valid for x: rq(x)0 wq(y)5 wp(x)5 rq(x)5 rp(y)5

Valid for y: rq(x)0 wq(y)5 wp(x)5 rq(x)5 rp(y)5

Computation:

p: w(x)5 r(y)5

q: r(x)0 w(y)5 r(x)5

x and y are initially 0

Valid Total Order: rq(x)0 wq(y)5 wp(x)5 rq(x)5 rp(y)5

Invalid Total Order: wp(x)5 rq(x)0 wq(y)5 rq(x)5 rp(y)5

Sequential Consistency (SC) [Lamport]

- “the result of any execution is the same as if the operations of all the processes were executed in some sequential order, and the operations of each indvidual process appear in this sequece in the order specified by its program”
- Let O be the set of all the operations of a computation C of a system (P,D). Then, C satisfies SC if there is a valid total order (O,<) such that (O,<po) (O,<)

SC – Intuition

…

process

process

process

FIFO

Channels

Switch (e.g. bus, token)

All Data Items ( the set D)

Sequential Consistency – Examples

p: w(x)1 r(x)2

q: r(x)1 w(x)2

p: w(x)1 r(x)2

q: w(x)2 r(x)1

p: w(x)1 w(y)2

q: r(y)2 r(x)0

C1

C2

C3

C1 satisfies SC

(O,<) = <wp(x)1, rq(x)1, wq(x)2, rp(x)2>

(O,<po) = { (wp(x)1, rp(x)2), (rq(x)1, wq(x)2) }

C2 does not satisfy SC

(O, <po) = { (wp(x)1, rp(x)2), (wq(x)2, rq(x)1) }

<wp(x)1, rq(x)1, wq(x)2, rp(x)2> (violates PO)

<wp(x)1, wq(x)2, rp(x)2, rq(x)1> (is not valid)

Cycle: wp(x)1 wq(x)2 & wq(x)2 wp(x)1

Exercise: Does C3 satisfy SC?

(x and y are initially 0)

Coherence [Goodman]

- SC per data item
- Let O be the set of all the operations of a computation C of a system (P,D). Then, C satisfies Coherence if for each x D there is a valid total order (O|x,<x) such that (O|x,<po) (O|x,<x)

Coherence – Intuition

…

process

process

process

FIFO

Channels

…

One

Data Item

One

Data Item

One

Data Item

Coherence – Examples

p: w(x)1 r(x)2

q: r(x)1 w(x)2

p: w(x)1 w(x)2

q: w(x)2 r(x)1

p: w(x)1 w(y)2

q: r(y)2 r(x)0

p: w(x)3 w(x)2 r(y)3

q: w(y)3 w(y)1 r(x)3

C1

C2

C3

C4

C1 satisfies Coherence

(O|x,<x) = <wp(x)1, rq(x)1, wq(x)2, rp(x)2>

C2 does not satisfy Coherence

C3 satisfies Coherence but not SC

Does C4 satisfy Coherence? SC?

SC versus Coherence

C3

All Computations satisfying consistency model CM = C(CM)

C(Coherence)

- If Computation C satisfies SC, then it satisfies Coherence
- Proof: exercise

- If a Computation C satisfies Coherence, then it does not necessarily satisfy SC
- Proof: Computation C3 is a counter example

C(SC)

Pipelined Random Access Machine (P-RAM) [Lipton & Sandberg]

- Let O be the set of all the operations of a computation C of a system (P,D). Then, C satisfies Coherence if for each p P there is a valid total order (O|p O|w,<p) such that (O|p O|w,<po) (O|p O|w,<p)

P-RAM – Intuition

process

process

process

process

All Data

Items (D)

All Data

Items (D)

All Data

Items (D)

All Data

Items (D)

FIFO

Channels

P-RAM – Examples

p: w(x)1 r(x)2

q: r(x)1 w(x)2

p: w(x)1 w(x)2

q: w(x)2 r(x)1

p: w(x)1 w(y)2

q: r(y)2 r(x)0

p: w(x)3 w(x)1 w(y)2

q: r(y)2 r(x)3

C1

C2

C3

C5

C1 satisfies P-RAM (also SC and Coherence)

(O|p O|w,<p) = <wp(x)1, wq(x)2, rp(x)2>

(O|q O|w,<q) = <wp(x)1, rq(x)1, wq(x)2>

C2 satisfies P-RAM but not Coherence

C3 satisfies Coherence but not SC nor P-RAM

Does C4 satisfy P-RAM?

Does C5 satisfy Coherence? P-RAM? SC?

SC versus P-RAM

C4

C(P-RAM)

- If Computation C satisfies SC, then it satisfies P-RAM
- Proof: exercise

- If a Computation C satisfies P-RAM, then it does not necessarily satisfy SC
- Proof: Computation C4 is a counter example

C(SC)

Coherence versus P-RAM

C: satisfies P-RAM and Coherence,

but not SC

C(P-RAM)

C(Coherence)

C(SC)

- If Computation C satisfies Coherence, then it does not necessarily satisfy P-RAM
- Proof: Computation C5 is a counter example

- If a Computation C satisfies P-RAM, then it does not necessarily satisfy Coherence
- Proof: Computation C2 is a counter example

- There are computations that satisfy both Coherence and P-RAM, but not SC
- Proof: find a computation C

Causal Consistency (CC) [Ahamad et al.]

- Define the write-before-read order, (O,<wbr), by o1 <wbr o2, if o1 is w(x)v and o2 is r(x)v for some x and v.
- Define the Causal order order (O,<co) = ((O,<wbr) (O,<po))+
- Let O be the set of all the operations of a computation C of a system (P,D). Then, C satisfies CC if for each p P there is a valid total order (O|p O|w,<p) such that (O|p O|w,<co) (O|p O|w,<p)

CC – Intuition

process

process

process

process

FIFO

Channels

All Data

Items (D)

All Data

Items (D)

All Data

Items (D)

All Data

Items (D)

p:

q:

s:

w(x)0

w(x)1

r(x)1

w(y)2

r(y)2

r(x)0

- Allowed in P-RAM
- If s sees wq(y)2 which was performed after rq(x)1, which sees
- wp(x)1 performed after wp(x)0, it must be the case that rs(x)0 also
- sees wp(x)1

CC – Examples (1)

p: w(x)1 w(x)2

q: w(x)2 r(x)1

p: w(x)1 r(y)2

q: w(y)2 r(x)0

p: w(x)3 w(x)1 w(y)2

q: r(y)2 r(x)3

p: w(x)3 w(x)2 r(y)3

q: w(y)3 w(y)1 r(x)3

C2

C7

C5

C4

C1 satisfies CC (also SC, Coherence, P-RAM ), exercise

C2 satisfies CC and P-RAM but not Coherence

C7 satisfies CC, P-RAM, and

Coherence but not SC

C4 satisfies CC, P-RAM, and

Coherence, but not SC.

C5 satisfies Coherence, but not CC,

P-RAM, or SC?

CC – Examples (2)

p: w(x)3 w(x)1

q: r(x)1 w(y)1

s: r(y)1 r(x)3

C6

C6 satisfies P-RAM, Coherence,

but not CC (neither SC)

- (O,<wbr) = {(wp(x)3,rs(x)3), (wp(x)1,rq(x)1), (wq(y)1,rs(y)1)}
- Since wp(x)3 <po wp(x)1 and wp(x)1 <wbr rq(x)1, then wp(x)3 <co wp(x)1<co rq(x)1
- But rq(x)1 <po wq(y)1 and wq(y)1 <wbr rs(y)1, then
- wp(x)3 <co wp(x)1<co rq(x)1 <co rs(y)1
- Finally, rs(y)1 <po rs(x)3, therefore
- wp(x)3 <co wp(x)1<co rq(x)1 <co rs(y)1 <co rs(x)3, which is invalid

Comparison of read-write models

CC

C(P-RAM)

C(Coherence)

C(SC)

- If Computation C satisfies CC, then it satisfies P-RAM
- Proof: follows from CC definition

- If a Computation C satisfies P-RAM, then it does not necessarily satisfy CC
- Proof: Computation C6 is a counter example

- Coherence and CC are incomparable (exercise)
- SC is stronger than CC (exercise)

Synchronization Operations

- In addition to reads and writes, introduce synchp() operation
- O|s denotes the subset of O containing synch operations
- Define the weak program order order, (O,<wpo), by o1 <wpo o2 if o1 <po o2 and
- o1 and o2 are on the same data item,
- o1 or o2 is a synchronization operation, or
- There is o’ st o1 <wpo o’ and o’ <wpo o2

Weak Consistency (WC) [Dubios et al.]

- Let O be the set of all the operations of a computation C of a system (P,D). Then, C satisfies WC if for each p P there is a valid total order (O|p O|w,<p) such that
- (O|p O|w O|s,<wpo) (O|p O|w O|s,<p)
- q P, (O|s,<p) = (O|s,<q)

WC – Intuition

…

process

process

process

S1 S3 S2

S1 S3 S2

S1 S3 S2

}

S1

S3

Reads and

writes

Synchronization

Points

S2

WC – Example

p: w(x)3 s()

q: r(x)0 s() w(y)1 s’() r(x)3

m: w(x)5 s() r(y)1 r(x)3

C7

- All of p, q, and m must agree on a total order of synch operations consistent with program order; for example:
- <sq(), sp(), sm(), s’q()>
- (O|p O|w, <p) = < wm(x)5,sq(), wp(x)3, sp(), wq(y)1, sm(), s’q() >
- (O|q O|w, <q) =
- < rq(x)0,wm(x)5,wp(x)3,sq(), sp(), wq(y)1, sm(), s’q(), rq(x)3>
- (O|m O|w, <m) =
- < wm(x)5,sq(), wp(x)3, sp(), wq(y)1, rm(y)1, sm(), s’q(), rm(x)3 >
- Exercise: construct a computation that does not satisfy WC

More Synchronization Operations

- In addition to reads and writes, introduce relp(l) and acqp(l) operation (O|s)
- relp(l): p releases lock l
- acqp(l): p acquires lock l

- Define the acquire-release order order, (O,<aro), by o1 <aro o2 if o1 <po o2 and
- o1 and o2 are on the same data item,
- o1 is acquire and o2 is a read or write,
- o1 is a read or write and o2 is a release, or
- There is o’ st o1 <wpo o’ and o’ <wpo o2

Release Consistency (RC) [Gharachorloo et al.]

- Let O be the set of all the operations of a computation C of a system (P,D). Then, C satisfies RCsc if for each p P there is a valid total order (O|p O|w O|s,<p) such that
- (O|p O|w O|s,<aro) (O|p O|w O|s,<p)
- q P, (O|s,<p) = (O|s,<q)
- (O|s,<po) (O|s,<p) [SC]

Timed Operations

- When there is a global time in the system, invocation and responses of operations are time stamped
- Define the time-order order, (O,<to), by o1 <to o2 iff invocation(o2).ts < response(o1).ts

Linearizability (Lin) [Herlihy & Wing]

- Let O be the set of all the operations of a computation C of a system (P,D). Then, C satisfies Lin if there is a valid total order (O,<) such that:
- (O,<po) (O,<)
- (O,<to) (O,<)

Linearizability versus SC

p:

q:

response

w(x)1

w(x)2

r(x)3

Invocation

r(x)2

w(x)3

time

Linearizable

w(x)1

w(x)2

r(x)3

p:

r(x)2

w(x)3

q:

time

SC but not Linearizable

Lazy Consistency Models

- When updates are scarce
- When updates are not conflicting
- Examples: DNS and WWW

- Eventual Consistency (EC): Lazy propagation of updates to all replicas
- If no updates take place for a long time, all replicas will become consistent

- Cheap to implement
- If a client always accesses the same replica, EC is trivial

Eventual Consistency

- Read-any/write any replication scheme with a mobile client

Download Presentation

Connecting to Server..