consistency and replication. outline introduction (what’s it all about) data-centric consistency...

Download Consistency and Replication. Outline Introduction (what’s it all about) Data-centric consistency Client-centric consistency Replica management Consistency

Post on 21-Jan-2016

219 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • Consistency and Replication

  • Outline Introduction (whats it all about) Data-centric consistency Client-centric consistency Replica management Consistency protocols

  • Why Replicate?ReliabilityIf one goes down, the others can stay up.Corrupted data

    PerformanceDivide the work (single server vs multiple servers)Place data closer to place it is used.

    What is the challenge?Consistency (when updates are needed)Consider a web cache in your browser.

  • CostsAs a scaling technique (for performance problem)Trade-off: keep copies up to date require bandwidth. PAccess replica N times per secondUpdate replica M times per secondAs a scaling technique, may not always be applicable. What if N
  • Assume synchronous replicationA dilemma:Scalability can be alleviated by replication and caching.Keep copies consistent is scaling problem (and require bandwidth too)E.g, consistency requires global synchronization!real solution is to relax consistency requirements.

  • Recap on SynchronizationDo some synch mechanisms apply here? Prefect clock synch?Message ordering? Total ordered multicastCausal relationship?

    Mutual exclusionCentralized or decentrilized?Distributed A leader or multiple leaders

  • Outline Introduction (whats it all about) Data-centric consistency Client-centric consistency Replica management Consistency protocols

  • Consistency ModelsEnforcing absolute ordering is too expensive, especially with replication and caching.

    So we need to allow for mis-ordering.We could just do it casually. Tell programmers, Well, you always see things in exact order.They would say, What do you mean?

    So we need an exact, very precise way of specifying the kinds of inconsistencies that the application might see.

    That is the purpose and point of having consistency models.

  • Data StoresConsistency is viewed as read/write ops on shared data.A consistency model is a contract between the processes and the data store (Shared memory, database, file systems).A read operation on a data item returns a value of last write. (nothing can claim as a best solution)

  • Example:A warehouse data itemDistributed reads/writes.

    A middleware provide a function call that ensures the consistency model

  • Outline Data-centric consistencyContinuous ConsistencySequential ConsistencyCausal ConsistencyGrouping Operations

  • Continuous Consistency (1)A 3 ops, B 2 ops A not see 1 Bs op, the value is 5 B not see 3 As op, the MAX value is 6

  • So application decides the consistency or tolerate level of inconsistency

  • Continuous Consistency (2) Choosing the appropriate granularity for a conit. e.g, two replica can differ in one item(a) Two updates lead to update propagation.

  • Continuous Consistency (3)But here (b), no update propagation is needed (yet).

  • Outline Data-centric consistencyContinuous ConsistencySequential ConsistencyCausal ConsistencyGrouping Operations

  • NotationProcesses execute to the right as time progresses.The notation W1(x)a means that the process wrote the value a to the variable x.The notation R2(x)a means that the process read the value a from the variable x.The subscript is often dropped.

  • Sequential ConsistencyThe 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.

    There is some global order.

    Were talking about interleaved executions: there is some total ordering for all operations taken together. not time

  • no

  • Sequential Consistency (3)Write b happened before write a -- sequentialWrite b happened before write a -- not sequential

  • Sequential Consistency (4)6! = 720 possible execution sequence. 90 valid

  • Sequential Consistency (5)Figure 7-7. Four valid execution sequences for the processes of Fig. 7-6. The vertical axis is time.Four sample valid interleaving. Reorder with signature: p1, p2, p364 of them (not all are allowed) under sequence consistency The contract says: given the program, these many outputs are correct.

  • Causal ConsistencyFor a data store to be considered causally consistent, it is necessary that the store obeys the following condition:

    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 on different machines.causally related: If event b is caused by event a, then a must be first, then b Concurrent - not casually relatedWeaker than sequential consistencyDeal with writes

  • Causal Consistency (2)W2(x)b and W1(x)c are concurrentThis sequence is allowed with a causally-consistent store, but not with a sequentially consistent store.

  • Causal ConsistencyCausally consistent?a and b are related, so incorrect a and b are not related, so correct W1(x)a and W2(x)b causally related

  • Recap slides (next 3)

  • Consistency ModelsConsistency is viewed as read/write ops on shared data.

    An exact, very precise way of specifying the kinds of inconsistencies that the application might see A consistency model is a contract between the processes and the data store (Shared memory, database, file systems).

    A middleware provide a function call that ensures the consistency model

  • What consistency models? W1a and W2b are related, not causal consistency W1a and W2b are not related, is causal consistency What about sequential consistency ?

  • Outline Data-centric consistencyContinuous ConsistencySequential ConsistencyCausal ConsistencyGrouping Operations

  • Grouping OperationsInstead of read and write ops, what about many operations that applications perform under control of synE.g, Mutual exclusion. How do we handle consistency in Multi Thread programs?Use locks.E.g, ENTER_CS and LEAVE_CS

    As viewed by an external, data-centric process, what do locks do?Many read and write: turn non-atomic operations into atomic ones (functionally).In other words, they group them.

  • Synchronization VariablesOperations are grouped via synchronization variables (locks).Each sync var protects an associated data.Each kind of sync var has some associated properties.

    Each sync var has a current owner,A non-owner needs to send msg to the owner for ownership (and data value)A sync var can be owned by many processors nonexclusively.

  • Grouping OperationsEntry Consistency: Necessary criteria for correct synchronization:An acquire access of a synchronization variable is not allowed to perform until all updates to guarded shared data have been performed with respect to that process. - Given up an ownership means finishing previous updates Before exclusive mode access to 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. - Writing must be exclusiveAfter exclusive mode access to a synchronization variable has been performed, any other process next nonexclusive mode access to that synchronization variable may not be performed until it has performed with respect to that variables owner. - otherwise, no guarantee on consistency if one does a nonexclusive mode

  • Grouping Operations (2)A valid event sequence for entry consistency.

  • SummaryData-centric consistencyContinues consistencyConsistent ordering of operationsSequential consistencyCausal consistencyGrouping operations

  • Outline Introduction (whats it all about) Data-centric consistency Client-centric consistencyEventual consistencyMonotonic readsMonotonic writesRead your writesWrites follow reads Replica management Consistency protocols

  • Weaker ModelsSometimes strong models are needed, if the result of race conditions are very bad.Banks

    Sometimes the result of races are just inefficiency, or inconvenience, etc.DNS, web caches,

    How strong is Orbitzs model?If it shows a ticket available, is it really?How does it prevent two people from reserving the same seat?

  • Eventual Consistency

    One kind of weaker model is eventual consistencyIt eventually becomes consistent if updates are not frequent. Updates eventually propagate to allWrite-write conflicts are relatively easy to solve (infrequent, by a small portion of nodes)Read-write conflicts are handled.

  • Mobile users (short time)How well does EC work for mobile clients? If replica is location related Client-centric is for this. Consistent for a single client.

  • Outline Data-centric consistency Client-centric consistencyGoal: perhaps avoid system wide consistency, by concentrating on what specific clients want, instead of what should be maintained by servers.Eventual ConsistencyMonotonic ReadsMonotonic WritesRead Your WritesWrites Follow Reads

  • Data StoresLocal read/writeEventually propagate to all

  • Notation xi[t] is the version of x at local copy Li at time t.Version xi[t] is the result of a series of write operations at Li that took place since initialization. This is WS(xi[t]).

    If operations in WS(xi[t]) have also been performed at local copy Lj at a later time t2, we write WS(xi[t1];xj[t2]).

  • Monotonic ReadsA 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.

  • Monotonic ReadsFor one pr

Recommended

View more >