Chapter 10 - PowerPoint PPT Presentation

chapter 10 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 10 PowerPoint Presentation
play fullscreen
1 / 90
Chapter 10
Download Presentation
Download Presentation

Chapter 10

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Chapter 10 Consistency And Replication

  2. Topics • Motivation • Data-centric consistency models • Client-centric consistency models • Distribution protocols • Consistency protocols

  3. Motivation • Make copies of services on multiple sites, improve … • Reliability(by redundancy) • If primary FS crashes, standby FS still works • Performance • Increase processing power • Reduce communication delays • Scalability • Prevent overloading a single server (size scalability) • Avoid communication latencies (geographic scale) • However, updates are more complex • When, who, where and how to propagate the updates?

  4. Concurrency Control on Remote Object • 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

  5. Object Replication • A distributed system for replication-aware distributed objects. • A distributed system responsible for replica management

  6. Distributed Data Store Clients point of view: Its data store is capable of storing an amount of data

  7. Distributed Data Store Data Store’s point of view: General organization of a logical data store, physically distributed and replicated across multiple tasks.

  8. Operations on A Data Store • Read:ri(x)bclient i or process Piperforms a read for data item x and it returns value b • Write: wi(x)aclient i or process Piperforms a write on data x setting it to the new value a • Operations not instantaneous • Time of issue (when request is sent by client) • Time of execution (when request is executed at a replica) • Time of completion (when reply is received by client)

  9. Example

  10. Consistency Models • Defines which interleaving of operations is valid (admissible) • Different levels of consistency • strong (strict, tight) • weak (loose) • Consistency model: • Concerned with the consistency of a data store • Specifies characteristics of valid ordering of operations • A data store that implements a particular consistency model will provide a total ordering of operations that is valid according to this model

  11. Consistency Models • Data-centric models • Described consistency experienced by all clients • Clients P1, P2, P3, … see same kind of orderings • Client centric models: • Described consistency only seen by clients who request it • Clients P1, P2, P3 may see different kinds of orderings

  12. Data-Centric Consistency Models • Strong ordering: • Strict consistency • Linear consistency • Sequential consistency • Causal consistency • FIFO consistency • Weak ordering: • Weak consistency • Release consistency • Entry consistency

  13. Strict Consistency • Definition: A DDS (distributed data store) is strict consistent if any read on a data item of the DDS returns the value corresponding to the result of the most recent write on x, regardless of the location of the processes doing read or write • Analysis: • 1. In a single processor system strict consistency is for nothing, that’s exact the behavior of local shard memory with atomic reads/writes • 2. However, it’s hard to establish a global time to determine what’s the most recent write • 3. Due to message transfer delays this model is not achievable

  14. Example • Behavior of two processes, operating on the same data item. • (a) A strictly consistent store. • (b) A store that is not strictly consistent.

  15. Strict Consistency Problems Assumption: y = 0 is stored on node 2, P1 and P2 are processes on node 1 and 2, Due to message delays, r(y) at t = t2 may result in 0 or 1 and at t = t4 may result in 0, 1 or 2 Furthermore: If y migrates to node 1 between t2 and t3 then r(y) issued at time t2 may even get value 2 (i.e. .back to the future.).

  16. Sequential Consistency (1) • Definition: A DDS offers sequential consistency, if all processes see the same order of accesses to the DDS, whereby reads/writes of individual processes occur in program order, and reads/writes of different ones are performed in some sequential order. • Analysis: • 1. Sequential consistency is weaker than strict consistency • 2. Each valid permutation of accesses is allowed iff all tasks see same permutation 2 runs of a distributed application may have different results • 3. No global timing ordering is required

  17. Example Each task sees all writes in the same order, even though not strict consistent.

  18. Non-Sequential Consistency

  19. Linear Consistency • Definition: A DDS is said to be linear consistent (linearizable) when each operation is time-stamped and the following holds: The result of each execution is the same as if the (read and write) operations by all processes on the DDS 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 TSOP1(x) < TSOP2(y), then operation OP1(x) should precede OP2(y) in this sequence

  20. Assumption • Each operation is assumed to receive a time stamp using a globally available clock, but with only finite precision, e.g. some loosely coupled synchronized local clocks. • Linear consistency is stricter than sequential one, i.e. a linear consistent DDS is also sequentially consistent. • With linear consistency no longer each valid interleaving of reads and writes is allowed, the ordering has also obey the order implied by the time-stamps of these operations.

  21. Causal Consistency (1) • Definition: A DDS is assumed to provide causal consistency if, the following condition holds: Writes that are potentially causally related* must be seen by all tasks in the same order. Concurrent writes may be seen in a different order on different machines. • * If event B is caused or influenced by an earlier event A, causality requires that everyone else also sees first A, and then B.

  22. Causal Consistency (2) • Definition: write2 is potentially dependent on write1, when there is a read between these 2 writes which may have influenced write2 • Corollary: If write2 is potential dependent on write1  the only correct sequence is: write1 write2.

  23. Causal Consistency: Example • This sequence is allowed with a casually-consistent store, but not with sequentially or strictly consistent store.

  24. Causal Consistency: Example • A violation of a casually-consistent store. • A correct sequence of events in a casually-consistent store.

  25. Implementation • Implementing causal consistency requires keeping track of which processes have seen which writes. • Construction and maintenance of a dependency graph, expressing which operations are causally related (using vector time stamps)

  26. FIFO or PRAM Consistency • Definition: DDS implements FIFO consistency, when all writes of one process are seen in the same order by all other processes, i.e. they are received by all other processes in the order they were issued. However, writes from different processes may be seen in a different order by different processes. • Corollary: Writes on different processors are concurrent • Implementation: Tag each write-operation of every process with: (PID, sequence number)

  27. Example Both writes are seen on processes P3 and P4 in a different order, they still obey FIFO-consistency, but not causal consistency because write 2 is dependent on write1.

  28. Example (2) Two concurrent processes with variable x,y = 0 • Possible results • A • B • Nil • AB? Process P1 Process P2 x=1; y=1; if ( y==0 ) print(“A”); if (x==0) print(“B”);

  29. Synchronization Variable • Background: not necessary to propagate intermediate writes. • Synchronization variable • Associated with one operation synchronize(S). • Synchronize all local copies of the data store.

  30. Compilation Optimization • 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 */

  31. Weak Consistency • Definition: DDS implements weak consistency, if the following hold: • Accesses to synchronization variablesobey sequential consistency • No access to a synchronization variable is allowed to be performed until all previous writes have completed everywhere • No data access (read or write) is allowed to be performed until all previous accesses to synchronization variables have been performed

  32. Interpretation • A synchronization variable S knows just one operation: synchronize(S) responsible for all local replicas of the data store • Whenever a process calls synchronize(S) its local updates will be updated on all replicas of the DDS and all updates of the other processes will be updated to its local replica of the DDS • All tasks see all accesses to synchronization-variables in the same order

  33. Interpretation (2) • No data access allowed until all previous accesses to synchronization-variables have been done • By doing a synch before reading shared data, a task can be sure of getting the “ up to date value” • Unlike previous consistency models “weak consistency” forces the programmer to collect critical operations all together

  34. Example Via synchronization you can enforce that you’ll get up-to-date values. Each process must synchronize if its writes should be seen by others. A process requesting a read without any synchronization measures may get out-of-date values.

  35. Non-weak Consistency

  36. Release Consistency • Problems with weak consistency: When a synch-variable is accessed, the DDS doesn’t know whether this is done because a process has finished writing the shared variables or whether it is about reading them. • It must take actions required in both cases, namely making sure that all locally initiated writes have been completed (i.e. propagated to all other machines), as well as gathering in all writes from other machines. • Provide two operations: acquire and release

  37. Details • Idea: • Distinguish between memory accesses in front of a critical section (acquire) and those behind of a critical section (release). • Implementation: • When a release is done, all the protected data that have been updated within the critical section will be propagated to all replicas.

  38. Definition • Definition: A DDS offers release consistency, if the following three conditions hold: • 1. Before a read or write operation on shared data is performed, all previous acquires done by the process must have completed successfully. • 2. Before a release is allowed to be performed, all previous reads and writes by the process must have been completed • 3. Accesses to synchronization variables are FIFO consistent.

  39. Example Valid event sequence for release consistency, even though P3 missed to use acquire and release. Remark: Acquire is more than a lock or enter_critical_section, it waits until all updates on protected data from other nodes are propagated to its local replicas, before it enters the critical section

  40. Lazy Release Consistency • Problems with “eager” release consistency: When a release is done, the process doing the release pushes out all the modified data to all processes that already have a copy and thus might potentially read them in the future. • There is no way to tell if all the target machines will ever use any of these updated values in the future  above solution is a bit inefficient, too much overhead.

  41. Details • With “lazy” release consistency nothing is done at a release. • However, at the next acquire the processor determines whether it already has all the data it needs. Only when it needs updated data, it needs to send messages to those places where the data have been changed in the past. • Time-stamps help to decide whether a data is out-dated.

  42. Entry Consistency • Unlike release consistency, entry consistency requires each ordinary shared variable to be protected by a synchronization variable. • When an acquire is done on a synchronization variable, only those ordinary shared variables guarded by that synchronization variable are made consistent. • A list of shared variables may be assigned to a synchronization variable (to reduce overhead).

  43. How to Synchronize? • Every synch-variable has a current owner • An owner may enter and leave critical sections protected by this synchronization variable as often as needed without sending any coordination message to the others. • A process wanting to get a synchronization-variable has to send a message to the current owner. • The current owner hands over the synch-variable all together with all updated values of its previous writes. • Multiple reads in the non-exclusive reads are possible.

  44. Example A valid event sequence for entry consistency

  45. Summary of Consistency Models • Consistency models not using synchronization operations. • Models with synchronization operations.

  46. Up to Now • System wide consistent view on DDS • Independent of number of involved processes • Mutual exclusive atomic operations on DDS • Processes access only local copies • Propagation of updates have to be made, whenever it is necessary to fulfill requirements of the consistency model • Are there still weaker consistency models?

  47. Client-Centric Consistency • Provide guarantees about ordering of operations only for a single client, i.e. • Effects of an operations depend on the client performing it • Effects also depend on the history of client’s operations • Applied only when requested by the client • No guarantees concerning concurrent accesses by different clients • Assumption: • Clients can access different replicas, e.g. mobile users

  48. Mobile Users • The principle of a mobile user accessing different replicas of a distributed database.

  49. Eventual Consistency • If updates do not occur for a long period of time, all replicas will gradually become consistent • Requirements: • Few read/write conflicts • No write/write conflicts • Clients can accept temporary inconsistency • Examples: • DNS: • No write/write conflicts • Updates slowly (1 – 2 days) propagating to all caches. • WWW: • Few write/write conflicts • Mirrors eventually updated • Cached copies (browser or Proxy) eventually replaced.

  50. Client Centric Consistency Models • Monotonic Reads • Monotonic Writes • Read Your Writes • Writes Follow Reads