Cassandra Consistency Levels
Per-query consistency, replication factor, and the quorum arithmetic that decides what a read is guaranteed to see.
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
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.
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).