Database / Apache Cassandra Intermediate and Advanced interview questions
What role does the Paxos protocol play in Cassandra's lightweight transactions?
Cassandra implements a variant of the Paxos consensus algorithm to make LWTs linearizable across replicas without needing a single elected leader.
- Prepare/Promise: the coordinator asks replicas to promise not to accept any older proposal, establishing a ballot number higher than anything seen before.
- Read: the current value is read (and the condition, like
IF balance = 100, is evaluated) to decide whether the write should proceed. - Propose/Accept: if a quorum promised, the coordinator proposes the actual mutation, and replicas accept it if they haven't promised a newer ballot in the meantime.
- Commit/Acknowledge: once a quorum accepts, the coordinator tells replicas to commit the value, making it durable and visible.
This ballot-based approach lets any node coordinate an LWT and still reach agreement safely, even if multiple nodes try to propose conflicting updates at the same time — competing proposals simply retry with higher ballots until one wins. It's this mechanism, not the normal write path, that gives LWTs their strong linearizable consistency guarantee.
More Related questions...