Database Reference
In-Depth Information
Table7-2.Write consistency levels
Consistency
level
Implication
The write operation will return immediately to the client before the write is recorded; the write
will happen asynchronously in a background thread, and there are no guarantees of success.
ZERO
Ensure that the value is written to a minimum of one node, allowing hints to count as a write.
ANY
Ensure that the value is written to the commit log and memtable of at least one node before re-
turning to the client.
ONE
Ensure that the write was received by at least a majority of replicas (( replication factor / 2) +
1).
QUORUM
Ensure that the number of nodes specified by replication factor received the write before re-
turning to the client. If even one replica is unresponsive to the write operation, fail the opera-
tion.
ALL
The most notable consistency level for writes is the ANY level. This level means that the write is
guaranteed to reach at least one node, but itallowsahinttocountasasuccessfulwrite. That is,
if you perform a write operation and the node that the operation targets for that value is down,
the server will make a note to itself, called a hint, which it will store until that node comes back
up. Once the node is up, the server will detect this, look to see whether it has any writes that it
saved for later in the form of a hint, and then write the value to the revived node. In many cases,
the node that makes the hint actually isn'tthe node that stores it; instead, it sends it of to one of
the nonreplica neighbors of the node that is down.
Using the consistency level of ONE on writes means that the write operation will be written to
both the commit log and the memtable. That means that writes at CL.ONE are durable, so this
level is the minimum level to use to achieve fast performance and durability. If this node goes
down immediately after the write operation, the value will have been written to the commit log,
which can be replayed when the server is brought back up to ensure that it still has the value.
For both reads and writes, the consistency levels of ZERO , ANY , and ONE are considered weak,
whereas QUORUM and ALL are considered strong. Consistency is tuneable in Cassandra because
clients can specify the desired consistency level on both reads and writes. There is an equation
that is popularly used to represent the way to achieve strong consistency in Cassandra: R+W>
N=strongconsistency. In this equation, R, W, and Nare the read replica count, the write rep-
lica count, and the replication factor, respectively; all client reads will see the most recent write
in this scenario, and you will have strong consistency.
Search WWH ::




Custom Search