Consistency models Flashcards

1
Q

Strong consistency

A

Strong consistency gives the illusion that there is a single
database (despite the fact that the implementation is replicated
and partitioned).

Strong consistency offers linearizability.
1. A read is guaranteed to return the most recently committed
version of an item.
2. A client never sees an uncommitted or partial write.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

linearizability

A
  1. A read is guaranteed to return the most recently committed
    version of an item.
  2. A client never sees an uncommitted or partial write.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Bounded Staleness

A

The database state evolves by applying all updates in a total order – all
updates outside the staleness window are applied in the same total order in
all replica.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Updates inside the staleness window - when there is a single write region

A
  • For clients in that region, updates are totally order immediately
    (equivalent to strong consistency)
  • For clients in other regions, clients may miss updates inside the staleness
    window, but they will see them in order (leading to consistent prefix)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Updates inside the staleness window - when there are multiple write regions

A
  • For clients writing to a single region, clients will observe those updates
    updates in order (equivalent to consistent prefix)
  • When client write to different regions, updates are applied locally but
    may be reorder later (leading to eventual consistency)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Bounded staleness garantees

A
  1. Reads observe a consistent-prefix, i.e., all updates are
    totally ordered except within the “staleness window”.
  2. Monotonic read, meaning that clients observe a version
    that is later that the previously read. Why is this interesting?
  3. A read might return an old value of the data item, configured
    as:
    * The number of versions (K) behind the current version that the
    read can return;
    E.g. with K = 5, the client knows that it might miss up to 5 writes.
    * The time interval (T) for which it might miss a write.
    E.g. with T = 10ms, the client knows that it might miss updates
    executed in the last 10 ms.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to implement bounded staleness

A
  • Master region orders and propagates updates to other regions.
  • A region can receive operations that propagate to the master
    region to be ordered – while the order is not established by
    the master, these updates are visible out-of-order in the local
    region.
  • Read can be performed in the local region, given that the
    bounded conditions can be established locally – e.g. from the
    last message received from the master, a replica know the
    potential staleness.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Session (Intuition)

A

The client has a session, where she sees the database evolving
as if it was a single replica. Updates from other clients/regions
are integrated in the view of the session.
Note: different clients with this consistency level may see
different database states.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Monotonic writes

A

Writes are propagated after writes that
logically precede them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Write-follows-reads

A

A write is propagated always after the
read updates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Read your writes

A

a read always reflects the writes executed
in the session.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Guarantees

A

Within a single client session, reads are guaranteed to
honor the consistent-prefix (assuming a single “writer”
session), monotonic reads, monotonic writes, read-yourwrites, and write-follows-reads guarantees

Clients outside of the session performing writes will see:
* Clients in the same region (either reading only or writing) will see
updates in order (leading to consistent prefix)
* Clients in other regions, with updates performed in a single region,
will see update in order (leading to Consistent prefix)
* For client writing in other regions, they may see their update being
reorder in relation to the writes of other regions (leading to Eventual
consistency)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to implement session

A

Client maintains version vector (token, context) with a
summary of the operations observed;
* Reads request a state that is at least as recent as the vector;
* Updates in each region are ordered and this order is
respected when applying them to other replicas).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Consistent prefix (intuition)

A

The client sees a prefix of the updates from every region, but
might miss recent updates from different regions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Guarantees (Consistent prefix)

A
  1. Results that are returned contain some prefix of all the
    updates, with no gaps;
  2. Reads never see out-of-order writes from a region (i.e., it
    always observes updates executed in region in the same
    order).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to implement?

A
  • Region orders updates and propagates them to the replicas;
  • Reads sees the updates received by the master (in order)
    more local request.
17
Q

Eventual consistency

A

The client might see a state that reflects any subset of the
updates.
Under eventual consistency, there is no ordering guarantee for
reads. In the absence of any further writes, the replicas
eventually converge.

18
Q

Optimal solution for most applications

A

Session?

19
Q

What if stronger consistency is needed?

A

select bounded staleness. Bounded staleness is almost as good as strong
consistency if the bound is small, but reads can be processed
locally.

20
Q

What if your application requires eventual consistency?

A

it is recommended that you use consistent prefix consistency
level – provide better guarantee with similar cost.

21
Q

What if your application requires eventual consistency?

A

it is recommended that you use consistent prefix consistency
level – provide better guarantee with similar cost.

22
Q

Types of conflicts

A

Insert conflicts: These conflicts can occur when an
application simultaneously inserts two or more items with the
same unique index in two or more regions.
Replace conflicts: These conflicts can occur when an
application updates the same item simultaneously in two or
more regions.
Delete conflicts: These conflicts can occur when an
application simultaneously deletes an item in one region and
updates it in another region.

23
Q

Confit resolution policies

A

Last-Write-Wins (LWW): uses a system-defined timestamp
to select which version to keep.
Application-defined (Custom): possible to define a merge
procedure to solve conflicts. These procedures get invoked
upon detection of the write-write conflicts – the procedure
executes exactly-once.

24
Q

Durability

A

Recovery time objective (RTO) is the time until an
application recover from a disruptive event.
Recovery point objective (RPO) is the period of time for
which updates might get lost in a failure.

25
Q

Pricing

A

The cost of the throughput provisioned and the storage
consumed on an hourly basis.
* Not cheap if you are not using it.
The request unit is based on the number and type of
operations and the data transferred.