3 minutes
Cassandra : Consistency Levels List
Typical values of consistency levels are -
Note - Write operation consists of writing to commit log and memtable.
Level | Write | Read | Usage |
---|---|---|---|
ALL | A write must be on all replica nodes in the cluster for that partition. | Returns the record after all replicas. The read operation will fail if a replica does not respond. | Provides the highest consistency and the lowest availability of any other level. |
EACH_QUORUM | A write must be on a quorum of replica nodes in each datacenter. | Not supported for reads. | Strong consistency. Used in multiple datacenter clusters to strictly maintain consistency at the same level in each datacenter. For example, choose this level if you want a write to fail when a datacenter is down and the QUORUM cannot be reached on that datacenter. |
QUORUM | A write must be on a quorum of replica nodes across all datacenters. | Returns the record after a quorum of replicas from all datacenters has responded. | Used in either single or multiple datacenter clusters to maintain strong consistency across the cluster. Use if you can tolerate some level of failure. |
LOCAL_QUORUM | A write must be on a quorum of replica nodes in the same datacenter as the coordinator. | Returns the record after a quorum of replicas in the current datacenter as the coordinator has reported. | Strong consistency. Avoids latency of inter-datacenter communication. Used in multiple datacenter clusters with a rack-aware replica placement strategy, such as NetworkTopologyStrategy, and a properly configured snitch. Use to maintain consistency locally (within the single datacenter). Can be used with SimpleStrategy. |
ONE | A write must be at least one replica node. | Returns a response from the closest replica, as determined by the snitch. By default, a read repair runs in the background to make the other replicas consistent. | Satisfies the needs of most users because consistency requirements are not stringent. |
TWO | A write must be at least two replica nodes. | Returns the most recent data from two of the closest replicas. | Similar to ONE. |
THREE | A write must be at least three replica nodes. | Returns the most recent data from three of the closest replicas. | Similar to TWO. |
LOCAL_ONE | A write must be sent to, and successfully acknowledged by, at least one replica node in the local datacenter. | Returns a response from the closest replica in the local datacenter. | In a multiple datacenter clusters, a consistency level of ONE is often desirable, but cross-DC traffic is not. LOCAL_ONE accomplishes this. For security and quality reasons, you can use this consistency level in an offline datacenter to prevent automatic connection to online nodes in other datacenters if an offline node goes down. |
SERIAL | Not supported | Allows reading the current (and possibly uncommitted) state of data without proposing a new addition or update. If a SERIAL read finds an uncommitted transaction in progress, it will commit the transaction as part of the read. Similar to QUORUM. | To read the latest value of a column after a user has invoked a lightweight transaction to write to the column, use SERIAL. Cassandra then checks the inflight lightweight transaction for updates and, if found, returns the latest data. |
LOCAL_SERIAL | Not supported | Same as SERIAL, but confined to the datacenter. Similar to LOCAL_QUORUM. | Used to achieve linearizable consistency for lightweight transactions. |
ANY | A write must be written to at least one node. If all replica nodes for the given partition key are down, the write can still succeed after a hinted handoff has been written. If all replica nodes are down at write time, an ANY write is not readable until the replica nodes for that partition have recovered. | Not supported | Provides low latency and a guarantee that a write never fails. Delivers the lowest consistency and highest availability. |
Read other posts
comments powered by Disqus