Consistency
Explore the concept of Tunable Consistency in Apache Cassandra, which allows users to select an appropriate consistency level for read and write operations to balance data consistency, availability, and performance.
With data replicated across multiple nodes, the number of replicas read for a read operation or the number of replica acknowledgments awaited for a write operation affects latency, data accuracy, and availability. This replica count is configurable in Cassandra and defined as Consistency Level (CL), specified for each read and write operation. Thus, based on the requirements Cassandra allows the client to decide the consistency level, providing great flexibility.
Read consistency
For a read operation, the consistency level specifies the minimum number of replica nodes required to respond with the data before the coordinator can send the data back to the client.
If CL cannot be reached for the read operation, the operation fails.
The above diagram illustrates the spectrum of read consistency levels offered by Apache Cassandra. Read consistency levels range from ALL
to LOCAL_ONE
, each offering a different balance between availability and data accuracy. ALL
provides the highest data accuracy by requiring responses from all replicas, but it has the lowest availability, as a replica failure will cause the operation to fail. EACH_QUORUM
provides strong accuracy across multiple datacenters by requiring a quorum/majority from each datacenter, but it reduces availability as the operation fails if any datacenter cannot achieve a quorum. QUORUM
improves availability while still ensuring strong accuracy by requiring a majority of replicas to respond. LOCAL_QUORUM
optimizes for low latency and strong data accuracy within a single datacenter, ensuring local consistency while ...