Strong consistency
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.
linearizability
Bounded Staleness
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.
Updates inside the staleness window - when there is a single write region
Updates inside the staleness window - when there are multiple write regions
Bounded staleness garantees
How to implement bounded staleness
Session (Intuition)
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.
Monotonic writes
Writes are propagated after writes that
logically precede them.
Write-follows-reads
A write is propagated always after the
read updates.
Read your writes
a read always reflects the writes executed
in the session.
Guarantees
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 to implement session
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).
Consistent prefix (intuition)
The client sees a prefix of the updates from every region, but
might miss recent updates from different regions.
Guarantees (Consistent prefix)
How to implement?
Eventual consistency
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.
Optimal solution for most applications
Session?
What if stronger consistency is needed?
select bounded staleness. Bounded staleness is almost as good as strong
consistency if the bound is small, but reads can be processed
locally.
What if your application requires eventual consistency?
it is recommended that you use consistent prefix consistency
level – provide better guarantee with similar cost.
What if your application requires eventual consistency?
it is recommended that you use consistent prefix consistency
level – provide better guarantee with similar cost.
Types of conflicts
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.
Confit resolution policies
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.
Durability
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.