Cassandra's Tunable Consistency

Cassandra's Tunable Consistency

Cassandra is an AP (Available and partition tolerant) system. But it also provides tunable consistency. Consistency can be defined as the same data available on all the replica nodes even concurrent updates are done. High consistency gives low availability.
For read queries consistency is given as the number of replica nodes must respond for that particular read.
For write queries consistency is given as number of replica nodes must write the data.
There are types of consistency levels in Cassandra. They are:
  1. One : One of the replica node must respond to the query.
  2. Two: Two of the replica nodes must respond to the query.
  3. Quorum: These many nodes ("(RF/2)+1") must respond from the cluster. where RF is the replication factor. For example if we have RF = 3 then two nodes must respond to the query. 
  4. Each_Quorum: Simply, must read from the maximum number of replica nodes from each data center.
  5. Local_Quorum: Must read from the maximum number of replica nodes from that particular data center. If we use this consistency level we can afford to loose one data center.
  6. ALL: Each and every node must respond to the query. It is not used in the production deployment. Because higher the consistency, lower the availability.
The recommended consistency level for production deployment is read and write at "Quorum". There is also an equation which is used in Cassandra in order to get strong consistency.
                                                                    
                                     R + W > RF
               where,
                             R = Read Replica Count
                             W = Write Replica Count
                             RF = Replication Factor

According to the above equation if the replication factor is greater than the sum of read replica count and write replica count then the system will have strong consistency.

Comments

Popular posts from this blog

Cassandra Reaper Configuration

Authorization in Cassandra

Authentication in Cassandra