23
Client-centric consistency models Ensar Basri Kahveci

Client-centric Consistency Models

Embed Size (px)

Citation preview

Page 1: Client-centric Consistency Models

Client-centric consistency models

Ensar Basri Kahveci

Page 2: Client-centric Consistency Models

Data-centric Consistency Models- Maintains a globally-accessible and

globally-consistent data store.- Linearizability, sequential consistency, …

Page 3: Client-centric Consistency Models

Client-centric Consistency Models- Instead of a globally-consistent view,

maintains consistent views for individual clients.

- Easier to deal with inconsistencies.- Eventual consistency, monotonic reads, monotonic

writes, read your writes, writes following reads… [1], [5]

Page 4: Client-centric Consistency Models

Monotonic reads (MR)- If a client reads a data entry X, any successive

read of X by the same client returns the same value or a more recent value.

Page 5: Client-centric Consistency Models

Monotonic WRITES (MW)- If a client first performs Write1 then Write2,

Write1 is ordered and executed before Write2 on all copies of the data.

Page 6: Client-centric Consistency Models

Writes Following Reads (WFR)- The client makes a write operation: Write1. Then, it eventually

observes result of Write1 with a ReadX, which is not necessarily the successive operation of Write1. After ReadX, the client makes a new write: Write2.

- On all copies of the entry, Write1 is ordered and executed before Write2.- Happens-before relationship …

Page 7: Client-centric Consistency Models

Read Your Writes (RYW)- The effect of a write operation by a client on a

data entry X will always be seen by a successive read operation on X by the same client.

Page 8: Client-centric Consistency Models

Session Guarantees for Weakly Consistent Replicated Data [1]- Defines MR, MW, WFR and RYW guarantees using sessions.- A client connects to the system and operates within the

boundaries of a session.- It can talk to a single server or a set of servers, and it can

behave like a server. - Consistency guarantees are either ensured by the session

manager in the client during the session, or the client learns that the guarantees cannot be continued, which means that the session has ended.

Page 9: Client-centric Consistency Models

Read Your Writes (RYW)

Page 10: Client-centric Consistency Models

Highly Available Transactions: Virtues and Limitations [2] - In the presence of arbitrary, indefinitely-long network

partitions … - High availability: If a client can contact to a non-failing server,

it eventually receives a response.- Sticky availability: If a client’s transactions is executed against

a copy of the database that reflects all of its prior operations, the client eventually receives a response.

- Any guarantee achievable in a highly-available system is also achievable in a sticky-available system, but not vice-versa.

Page 11: Client-centric Consistency Models

Aphyr’s consistency models tree [2], [3]

Page 12: Client-centric Consistency Models

What does it mean?- You can get linearizability and sequential consistency in

a CP system.- You can get MR, MW, WFR in an AP system.- If you have sticky sessions, you can get RYW in an AP

system. Otherwise, you need a CP system for it. - MR + MW + RYW = PRAM consistency- PRAM + WFR = Causal consistency

Page 13: Client-centric Consistency Models

How does it work?- RYW against MR, MW and WFR- Delaying visibility of writes in MR, MW and WFR [2], [4]

Page 14: Client-centric Consistency Models

How TO map these models to hazelcast?- In a Hazelcast cluster:

- Each partition has a single owner and possibly multiple backups.

- All operations are executed on the partition owner.

- Partition operations are linearizable in a stable Hazelcast cluster.

Page 15: Client-centric Consistency Models

DETECTING INCONSISTENCY CASES IN HAzELCAST- Can we detect if there is a possibility of data inconsistency on

failures?- A hypothetical ConsistencyLostListener implementation

- For the following examples, a single partition with 2 replicas is considered. Additionally, lets assume partition operations return partition version in responses and our proxy classes can track them.

Page 16: Client-centric Consistency Models

EXAMPLE #1: MR is lost

Page 17: Client-centric Consistency Models

EXAMPLE #2: RYW is lost

Page 18: Client-centric Consistency Models

EXAMPLE #3: RYW - Vector clocks NEEDED

Page 19: Client-centric Consistency Models

EXAMPLE #4: RYW with Vector clocks

Page 20: Client-centric Consistency Models

EXAMPLE #5: MW is lost. We need a Dirty flag. Same for WFR

Page 21: Client-centric Consistency Models

RECAP- Linearizability and sequential consistency is achievable in CP

systems.- Hazelcast already provides linearizability on partition level in a stable

cluster (e.g., no network partitioning or partition owner crash). - In AP systems, causal consistency is achievable with sticky

sessions.- Hazelcast proxies already are already as they talk to partition owners.

- Hazelcast proxies can detect the possibility of inconsistency situations.

- On partition owner failure, they can check if they continue the current session or not.

Page 22: Client-centric Consistency Models

REFERENCES[1] Terry, Douglas B., et al. "Session guarantees for weakly consistent replicated data." Parallel and Distributed Information Systems, 1994., Proceedings of the Third International Conference on. IEEE, 1994.

[2] Bailis, Peter, et al. "Highly available transactions: Virtues and limitations." Proceedings of the VLDB Endowment 7.3 (2013): 181-192.

[3] https://aphyr.com/posts/313-strong-consistency-models[4] http://www.bailis.org/blog/stickiness-and-client-server-session-guarantees/[5] http://www.allthingsdistributed.com/2008/12/eventually_consistent.html

Page 23: Client-centric Consistency Models

THANKS!Any questions?