Skip to content
Navigation

Type at least two characters. Search covers page titles, headings, tags and database names.

↑ ↓ to navigateEnter to openEsc to close0 pages
Cassandraintermediate

Cassandra Consistency Levels

Per-query consistency, replication factor, and the quorum arithmetic that decides what a read is guaranteed to see.

3 min readIntermediateUpdated Edit this page

Cassandra sets consistency per query, not per cluster. This is its most useful feature and the one most often left at a default nobody chose.

Replication Factor

The replication factor is set per keyspace and per datacenter:

CREATE KEYSPACE shop
WITH replication = {
  'class': 'NetworkTopologyStrategy',
  'eu-central': 3,
  'us-east': 3
};

NetworkTopologyStrategy places replicas in distinct racks where the topology allows. Always use it, even for a single datacenter — SimpleStrategy ignores topology and is unsuitable for production.

RF = 3 per datacenter is the usual choice: it tolerates one node loss while still allowing quorum operations. RF = 1 means any node loss makes data unavailable and unrecoverable if the disk is lost.

Consistency levels

LevelReplicas that must respond
ONE, TWO, THREEThat number of replicas, any datacenter
LOCAL_ONEOne replica in the local datacenter
QUORUMA majority across all datacenters
LOCAL_QUORUMA majority within the local datacenter
EACH_QUORUMA majority in every datacenter (writes only)
ALLEvery replica
ANYWrite only; a hint counts as success
CONSISTENCY LOCAL_QUORUM;
SELECT * FROM events_by_user WHERE user_id = ? AND bucket = ?;

Drivers set it per statement, which is where it belongs — the application knows which operations matter.

Quorum

A quorum is floor(RF / 2) + 1. With RF = 3 that is 2.

The guarantee comes from overlap: if R + W > RF, the read set and the write set share at least one replica, so the read observes the latest acknowledged write.

RFWROverlapTolerates
3QUORUM (2)QUORUM (2)YesOne node down
3ONEONENoTwo nodes down, stale reads
3ALL (3)ONEYesNo node down for writes
3ONEALL (3)YesNo node down for reads

Lightweight transactions

For compare-and-set within one partition:

INSERT INTO users (email, user_id) VALUES ('a@example.com', ?) IF NOT EXISTS;
UPDATE accounts SET balance = 900 WHERE id = ? IF balance = 1000;

These use Paxos and take four round trips instead of one. They are correct and they are slow — use them for genuinely contended uniqueness or state transitions, not as a general pattern. Their consistency is controlled separately by SERIAL CONSISTENCY (SERIAL or LOCAL_SERIAL).