Database Reference
In-Depth Information
Using the ALL consistency for both reading and writing, however, is an overkill in virtu-
ally all cases. If we write the data at the ALL consistency, then we can subsequently read it
with ONE consistency because we know all of the replicas have the most recent copy of
the data. Conversely, if we are reading with the ALL consistency, we will have immediate
consistency even if the profile was updated with ONE consistency. At least one of the rep-
licas has the most recent version of the data, and since we're reading all the copies, we're
guaranteed to get the latest version back in one of them.
The downside of the ALL consistency is that, when we use it, we have no tolerance for
failure. If any one of the machines that should store alice 's user profile is unavailable,
the request at the ALL consistency will fail. Queries at the ALL consistency also have un-
pleasant performance characteristics. Since Cassandra must wait for all interested replicas
to respond, the overall performance of the request is bounded by the response time of the
slowest replica.
Fortunately, there is a middle ground that allows us to have immediate consistency
without completely sacrificing performance and resilience to failure.
Fault-tolerant immediate consistency with QUORUM
If we consider a request successful once it's been fulfilled by a single replica, we're very
resilient to node failure, but we have to be willing to accept eventual consistency. If we re-
quire that every replica respond to a request before that request can complete, we have im-
mediate consistency at the cost of making every replica a single point of failure. But we
can achieve both immediate consistency and failure tolerance by defining a successful re-
quest as one that's fulfilled by just enough replicas.
This is the QUORUM consistency level, and just enough is precisely defined as the strict
majority of replicas. For our replication factor of three, QUORUM requires that two nodes
fulfill the request. Let's explore how the QUORUM consistency gives us the best of both
worlds.
Returning to our email update scenario, let's send the query to change alice 's email us-
ing the QUORUM consistency. Immediately after the UPDATE query completes, the worst-
case scenario is as follows:
• Replica 1 is one of the replicas that acknowledged the write request. By defini-
tion, it has the up-to-date email address.
Search WWH ::




Custom Search