Database / Apache Cassandra Intermediate and Advanced interview questions
How does Cassandra achieve tunable consistency?
Cassandra lets you pick a consistency level (CL) independently for every read and every write, instead of hard-coding one global guarantee. The CL just says how many replicas out of the replication factor (N) must acknowledge before the coordinator replies to the client.
- Writes go to all N replicas in parallel, but the coordinator only waits for the CL you asked for (e.g. ONE, QUORUM, ALL).
- Reads query enough replicas to satisfy the CL, then compare timestamps and pick the freshest value.
- If R + W > N (read replicas + write replicas exceeds replication factor), you get strong consistency because the read and write sets are guaranteed to overlap by at least one node.
This is what makes Cassandra tunable rather than fixed: a shopping-cart write can use CL ONE for speed, while a financial balance update can use QUORUM or ALL for stronger guarantees, all in the same cluster and even the same table.
The trade-off is the classic CAP one: pushing CL toward ALL improves consistency but sacrifices availability, since more replicas must be up and reachable for the request to succeed.
More Related questions...