Cassandra, as a NOSQL database, selects AP in the CAP principle, which can be used for sex and partition tolerance, and is guaranteed by final consistency in data consistency, using an extension of final consistency--tunable consistency. For any read-write operation, the client application determines the level of conformance for the requested data, Cassandra then responds to the request based on the requested consistency level.
Write consistency
If you write data to Cassandra, the consistency level specifies how many replicas must be written to succeed and then return to the client application. Write can use the following consistency level, any is the lowest consistency (but the highest availability), all is the highest consistency (but the lowest availability), quorum is the middle to ensure strong consistency, can tolerate a certain degree of failure.
Any |
At least one node responds to the write operation. If all the replica nodes corresponding to the requested row key are stopped, the node receiving the request logs the hint message and the request data, and then responds to the write success. All read row key fails until at least one of all replica nodes corresponding to the row key is started. And the hint message remains for a period of time, and if all replica nodes are not available during that time, the data is lost. |
One |
At least 1 replica nodes in the cluster were successfully written. |
Two |
At least 2 replica nodes in the cluster were successfully written. |
THREE |
At least 3 replica nodes in the cluster were successfully written. |
QUORUM |
At least one of the quorum replica nodes in the cluster was successfully written. quorum= (the sum of the data Center replica factor)/2 + 1, if 2 data centers, 1 of the replica factors in the data center 3,1 the copy factor of the datacenter is 2,quorum= (3+2)/2 + 1 = 3 |
Local_quorum |
At least quorum replica nodes in the cluster with 1 data centers are successfully written. quorum= (this data center replica factor)/2 + 1, quorum= (2)/2 + 1 = 2 If the node that accepts the request has a copy factor of 2 in the data center. |
Each_quorum |
At least one quorum replica node in each datacenter in the cluster was successfully written. QUORUM calculated with Local_quorum. |
All |
All replica nodes in the cluster were successfully written. |
Read consistency
If you are reading data to Cassandra, the consistency level specifies how many copies must be responded to and then returned to the client application results.
One |
Returns the response of the most recent copy of the cluster (determined by snitch). |
Two |
Returns the latest data from the 2 most recent replicas in the cluster. |
THREE |
Returns the latest data from the 3 most recent replicas in the cluster. |
QUORUM |
Returns the most recent data in a quorum replica in a cluster. Quorum= (the sum of each data center replica factor)/2 + 1, if 2 data centers, the replica factor in 1 data 3,1 the copy factor of the data center is 2,quorum= (3+2)/2 + 1 = 3 |
Local_quorum |
Returns the most recent data in a quorum copy of the current datacenter in the cluster. quorum= (this data center replica factor)/2 + 1, quorum= (2)/2 + 1 = 2 If the node that accepts the request has a copy factor of 2 in the data center. |
Each_quorum |
Returns the latest data in at least quorum replicas in each datacenter in a cluster. QUORUM calculated with Local_quorum. |
All |
Returns the most recent data in all replicas in the cluster. |
Note: Local_quorum,each_quorum is used for rack-sensing strategies (such as networktopologystrategy) for multiple data centers.
Reference: About data consistency,about hinted handoff writes