Illustration: Apache Cassandra Consistency Levels
Explore the main consistency levels in Apache Cassandra and how they impact read and write operations on clusters with varying node counts. Learn to evaluate query success based on consistency settings and replication factors through practical demonstrations in both single-node and multi-node environments.
We'll cover the following...
For easy reference, the main Apache Cassandra consistency levels are listed in the table below, ordered by strongest to weakest consistency.
CL | Replica(s) contacted for read/write | Availability vs. Data Accuracy |
| Every replica in the cluster |
|
| Majority (51%) replicas in each datacenter. Heavy operation. Rarely used |
|
| Majority (51%) of replicas across all datacenters ((RF1+RF2+..RFn) /2) +1 |
|
| Closest 51% replicas in the same datacenter (RF/2)+1 |
|
| 3 replicas closest to coordinator |
|
| 2 replicas closest to coordinator |
|
| 1 replica closest to coordinator |
|
| Closest replica to coordinator in the same datacenter |
|
| For write operations only. No acknowledgement required. Hint is stored by coordinator & write succeeds even if all replicas are down |
|
In this lesson, we will demonstrate each consistency level with a read and write query. To display how consistency level and the cluster node count affect query success, the INSERT and SELECT statements are executed on two configurations: a three-node Cassandra cluster and a one-node Cassandra cluster. Records are written to and read from courses_by_category table, Cassandra partition in the VideoCourses keyspace with a RF of 2.
The INSERT and SELECT statements executed for each consistency demonstration are listed below. Please note that the value of the title column in the INSERT statement will be set to ...