Database Reference
In-Depth Information
• Replica 2 is the other replica that acknowledged the write request, so it also has
the up-to-date email address.
• Replica 3 has not yet received the updated email address.
By the contract of the
QUORUM
consistency level, we are assured that at least two of the
three replicas have persisted
alice
's new email address. If we then read
alice
's user
profile, also at
QUORUM
consistency, Cassandra will wait to receive at least two copies of
the profile from two replicas. In the above scenario, at least one of the copies must come
from Replica 1 or Replica 2; we're guaranteed that Cassandra will see the most recent ver-
sion of the user profile before returning it to us.
This observation generalizes to quorums at any replication factor: as long as data is writ-
ten to a strict majority of nodes and read from a strict majority of nodes, we know that
there is
some
replica that was involved in both the write and the subsequent read. So,
we're guaranteed immediate consistency.
Note
Note that we are only guaranteed immediate consistency if data is written and read at the
QUORUM
consistency. This is in contrast to the
ALL
consistency, which guarantees imme-
diate consistency if it's used for either writing or reading.
The
QUORUM
consistency is also resilient to failure: if one of the three nodes holding a
copy of
alice
's user profile is unavailable, Cassandra can still successfully fulfill re-
quests using the other two nodes.
QUORUM
is not an entirely free lunch, however; opera-
tions at the
ONE
consistency level can handle a failure of any two nodes, whereas the
QUORUM
consistency can only handle a single node failure.
QUORUM
performance is also a middle ground between
ONE
and
ALL
:
QUORUM
opera-
tions are bounded by the median response time of the interested replicas. This is a big ad-
vantage over the
ALL
consistency, if one replica happens to be under especially heavy
load. But is not as speedy as
ONE
, which will be as responsive as the fastest node.