Chapter 14 · Consistency Levels, Quorums, Availability, and Client Guarantees
ANY, ONE, TWO, THREE, QUORUM, ALL, LOCAL_QUORUM, EACH_QUORUM, and LOCAL_ONE Semantics
Derive every regular consistency level from replication factor, datacenter scope, operation type, and replica availability.
Learning outcomes
AtlasMart has one team using ONE everywhere for
speed, another using ALL everywhere for “safety,”
and a third copying EACH_QUORUM from a multi-DC
article into a single-DC service. The result is inconsistent
business guarantees and avoidable outages. This lesson replaces
names with response arithmetic.
Compute the replica acknowledgments required by ANY, ONE, TWO, THREE, QUORUM, ALL, LOCAL_QUORUM, EACH_QUORUM, and LOCAL_ONE.
Explain why ANY is write-only and why a hint can satisfy it without a target replica acknowledging the mutation.
Distinguish global QUORUM from LOCAL_QUORUM and EACH_QUORUM by RF and DC scope.
Observe success, unavailable errors, and read rejection under controlled replica loss.
Explain what each successful CL proves and what it does not prove about durability, freshness, repair, or tenant locality.
The mandatory single-DC labs use Apache Cassandra
5.0.9 in the pinned Docker image
cassandra:5.0.9, Java 17 inside the image,
cluster atlasmart-course, network
atlasmart-cassandra, nodes
atlasmart-cass-1..3, datacenter dc1,
racks rack1..rack3, 16 virtual nodes per node,
NetworkTopologyStrategy, replication factor (RF)
3, and explicit per-request consistency levels (CLs). New
tables use UnifiedCompactionStrategy (UCS), no default Time To
Live (TTL), and the Cassandra default
gc_grace_seconds unless a lesson states
otherwise. Authentication, client Transport Layer Security
(TLS), internode TLS, and remote Java Management Extensions
(JMX) are disabled only inside the isolated local learning
network. The optional application example uses Apache
Cassandra Java Driver 4.19.3. Windows learners
should use Docker Desktop/WSL-style Linux containers; commands
run inside containers unless labeled host-side.
docker network inspect atlasmart-cassandra >/dev/null 2>&1 || docker network create atlasmart-cassandradocker volume create atlasmart-cass-1-datadocker volume create atlasmart-cass-2-datadocker volume create atlasmart-cass-3-datadocker inspect atlasmart-cass-1 >/dev/null 2>&1 || docker run -d --name atlasmart-cass-1 --hostname atlasmart-cass-1 --network atlasmart-cassandra -e CASSANDRA_CLUSTER_NAME=atlasmart-course -e CASSANDRA_DC=dc1 -e CASSANDRA_RACK=rack1 -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_NUM_TOKENS=16 -v atlasmart-cass-1-data:/var/lib/cassandra cassandra:5.0.9# Wait until node 1 reports UN before starting peers.docker exec atlasmart-cass-1 nodetool statusdocker inspect atlasmart-cass-2 >/dev/null 2>&1 || docker run -d --name atlasmart-cass-2 --hostname atlasmart-cass-2 --network atlasmart-cassandra -e CASSANDRA_CLUSTER_NAME=atlasmart-course -e CASSANDRA_DC=dc1 -e CASSANDRA_RACK=rack2 -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_NUM_TOKENS=16 -e CASSANDRA_SEEDS=atlasmart-cass-1 -v atlasmart-cass-2-data:/var/lib/cassandra cassandra:5.0.9docker inspect atlasmart-cass-3 >/dev/null 2>&1 || docker run -d --name atlasmart-cass-3 --hostname atlasmart-cass-3 --network atlasmart-cassandra -e CASSANDRA_CLUSTER_NAME=atlasmart-course -e CASSANDRA_DC=dc1 -e CASSANDRA_RACK=rack3 -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_NUM_TOKENS=16 -e CASSANDRA_SEEDS=atlasmart-cass-1 -v atlasmart-cass-3-data:/var/lib/cassandra cassandra:5.0.9# Continue only after all three nodes are UN.docker exec atlasmart-cass-1 nodetool statusdocker exec atlasmart-cass-1 nodetool versiondocker exec atlasmart-cass-1 java -versiondocker exec atlasmart-cass-1 cqlsh -e "SHOW VERSION"
CREATE KEYSPACE IF NOT EXISTS atlasmart_consistencyWITH replication = {'class':'NetworkTopologyStrategy','dc1':3};CREATE TABLE IF NOT EXISTS atlasmart_consistency.order_status_by_id ( order_id text PRIMARY KEY, status text, version int, updated_at timestamp) WITH compaction = {'class':'UnifiedCompactionStrategy'};CREATE TABLE IF NOT EXISTS atlasmart_consistency.inventory_reservation_by_product ( product_id text, reservation_id text, customer_id text, state text, created_at timestamp, PRIMARY KEY (product_id, reservation_id)) WITH compaction = {'class':'UnifiedCompactionStrategy'};CONSISTENCY LOCAL_QUORUM;INSERT INTO atlasmart_consistency.order_status_by_id(order_id,status,version,updated_at)VALUES ('order-42','PAID',1,toTimestamp(now()));DESCRIBE KEYSPACE atlasmart_consistency;
Run commands only against the disposable Apache Cassandra course lab or another explicitly approved non-production environment. Confirm node, keyspace, table, container, volume, path, and datacenter targets before destructive, failure-injection, cleanup, repair, restore, security, or topology operations. Capture current state and expected rollback/recovery evidence first; output and timings can differ by host, operating system, Java runtime, Docker/runtime, driver, and Cassandra configuration.
Core terms used throughout this chapter
Replication factor (RF) is the number of
replicas Cassandra is configured to keep for each partition in a
datacenter. A replica stores a copy of a
partition; the coordinator is the node handling
one client request and is not a permanent leader. A
consistency level (CL) is the per-request rule
that says how many and which replicas must acknowledge a write
or satisfy a read before the coordinator can return success. A
datacenter (DC) is Cassandra's logical
locality/failure-domain grouping; a rack is a
smaller placement grouping within a DC. A
quorum is a majority, calculated as
floor(RF/2)+1 for the relevant replica scope.
CQL means Cassandra Query Language;
cqlsh is its shell. A
Lightweight Transaction (LWT) is a conditional
CQL operation using Paxos consensus; it has a serial phase and a
regular learn/data phase. Availability here
means whether enough replicas are alive/responding for the
requested CL—not whether the cluster has any node alive.
Staleness means a read can return an older
replica version because the requested read CL did not
necessarily intersect the replicas that acknowledged a prior
write.
1. The consistency menu is arithmetic over a replica scope
For RF=3 in one DC, ONE/LOCAL_ONE need
one replica response, TWO needs two, and
THREE/QUORUM/LOCAL_QUORUM/ALL
all require three, two, two, and three respectively according to
their definitions. The names only become different when RF or
topology changes. Cassandra still sends ordinary writes to all
natural replicas; CL controls how many acknowledgments the
coordinator must wait for before returning success.
| CL | Operation | RF=3, one DC | Multi-DC scope | Important boundary |
|---|---|---|---|---|
ANY |
write only | 1 replica ack OR a stored hint | not a read level | success can occur before any target replica stores the mutation |
ONE |
read/write | 1 replica | any eligible replica | weak intersection can expose stale reads |
TWO |
read/write | 2 replicas | two replicas globally | invalid if total RF < 2 |
THREE |
read/write | 3 replicas | three replicas globally | invalid if total RF < 3 |
QUORUM |
read/write | 2 of 3 | majority of total RF across DCs | remote replicas can become part of latency/availability |
ALL |
read/write | 3 of 3 | all replicas | one failed replica makes the operation unavailable |
LOCAL_QUORUM |
read/write | 2 of local 3 | majority only in coordinator local DC | requires RF in local DC |
EACH_QUORUM |
read/write | same as local quorum in one DC | majority in every DC | a remote-DC outage can make request unavailable |
LOCAL_ONE |
read/write | 1 local replica | one local replica; reads stay local | locality is not authorization/isolation |
2. Controlled one-replica failure
Pause one disposable replica. With RF=3,
LOCAL_QUORUM and QUORUM still have two
live replicas and should succeed. ALL and
THREE cannot satisfy their response requirement and
should fail with an unavailable-style error once failure
detection knows the node is down. Exact error text/timing
depends on failure detection and cqlsh/server versions.
docker pause atlasmart-cass-3# Give gossip/failure detection time to mark the endpoint down, then inspect.docker exec atlasmart-cass-1 nodetool status
CONSISTENCY LOCAL_QUORUM;UPDATE atlasmart_consistency.order_status_by_id SET status='PACKING', version=2, updated_at=toTimestamp(now()) WHERE order_id='order-42';SELECT * FROM atlasmart_consistency.order_status_by_id WHERE order_id='order-42';CONSISTENCY ALL;SELECT * FROM atlasmart_consistency.order_status_by_id WHERE order_id='order-42';CONSISTENCY ONE;SELECT * FROM atlasmart_consistency.order_status_by_id WHERE order_id='order-42';
docker unpause atlasmart-cass-3# Wait until all three nodes are UN again.docker exec atlasmart-cass-1 nodetool status
3. ANY is a write-specific escape hatch, not “consistency zero”
ANY can acknowledge a mutation when either a
replica responds or the coordinator durably stores a hint for a
temporarily unavailable target replica. That is why it can offer
very high write availability but cannot serve a read: a hint is
not queryable application data. cqlsh/native protocol should
reject using ANY for a SELECT. To observe hint-only success
requires a live coordinator that is not one of the unavailable
target replicas; the three-node RF=3 baseline has every node as
a replica, so the safer deterministic lab below verifies the
write-only boundary and defers a hint-only topology to Chapter
15.
CONSISTENCY ANY;UPDATE atlasmart_consistency.order_status_by_id SET status='SHIPPED', version=3, updated_at=toTimestamp(now()) WHERE order_id='order-42';-- Expected: SELECT at ANY is rejected because ANY is accepted only for writes.SELECT * FROM atlasmart_consistency.order_status_by_id WHERE order_id='order-42';CONSISTENCY LOCAL_QUORUM;SELECT * FROM atlasmart_consistency.order_status_by_id WHERE order_id='order-42';
ALL means all replicas required by RF
acknowledged this request. It does not replace
commit-log/storage durability configuration, disk reliability,
repair, backup, disaster recovery, or protection against later
operator/application deletion. CL is a response/visibility
contract, not an immortality guarantee.
4. Verification and reset
- All three nodes return
UN. - The keyspace shows RF=3 in
dc1. -
The learner can compute quorum as
floor(3/2)+1=2. - ANY is described and observed as write-only.
- Unavailable and timeout are not conflated.
CONSISTENCY LOCAL_QUORUM;UPDATE atlasmart_consistency.order_status_by_id SET status='PAID', version=10, updated_at=toTimestamp(now()) WHERE order_id='order-42';SELECT * FROM atlasmart_consistency.order_status_by_id WHERE order_id='order-42';
Check your understanding
- For RF=3 in dc1, how many acknowledgments does LOCAL_QUORUM need?
- Why can ANY succeed when no target replica acknowledges?
- Can ANY be used for SELECT?
- What does ALL prove?
- Is LOCAL_ONE a tenant-isolation control?
Review the answers
1. Two local replica responses.
2. A live coordinator may store a hint; the hint counts for ANY write acknowledgment and is replayed later.
3. No. It is write-only.
4. That all replicas required by RF acknowledged this operation; it does not prove permanent durability or future recoverability.
5. No. It is a replica-locality/response rule; security and tenant isolation require authentication, authorization, schema/application boundaries, and network controls.
Production judgment
Choose consistency from a business invariant, topology, RF, and failure budget—not from a cluster-wide slogan. Record which reads must observe which writes, whether the invariant is local to one DC or global, whether conditional uniqueness/compare-and-set is required, and what latency/availability degradation is acceptable when replicas or a whole DC are unavailable. Then test that contract with the real driver, routing policy, request timeout, retry/speculative-execution policy, idempotency classification, and representative network latency.
Consistency level does not replace durable commit-log/storage
design, repair, backup/restore, security isolation,
schema/partition design, compaction/tombstone management, or
application-level idempotency. ALL is not
“permanent durability”; LOCAL_ONE is not tenant
isolation; a timeout is not proof that a write failed; and a
successful weak write does not promise a subsequent weak read
will be fresh. Storage-Attached Indexing (SAI) or vector search
can add read work but do not redefine RF/CL arithmetic. Managed
Cassandra services may restrict topology visibility or CL
choices; verify provider semantics rather than assuming Apache
Cassandra behavior is exposed unchanged. Lesson 2 extends the
arithmetic to two datacenters and shows why LOCAL_QUORUM is
usually the latency/availability-aware choice for DC-local
application traffic.
Summary and next bridge
A consistency level is a per-request replica-response rule. Its meaning comes from RF, DC scope, operation type, and current replica availability. Next, derive the same rules in a real multi-DC layout where global QUORUM and EACH_QUORUM behave differently from LOCAL_QUORUM.
Authoritative references
Re-check these version-sensitive sources when regenerating this course.