Database / Apache Cassandra Intermediate and Advanced interview questions
Why are lightweight transactions expensive in Cassandra?
Regular Cassandra writes are cheap precisely because they skip coordination: the coordinator just fires the mutation at all replicas and waits for the consistency-level count of acknowledgements. LWTs cannot take that shortcut, because they must guarantee only one outcome is agreed on across replicas.
- An LWT requires four round trips between the coordinator and replicas (Paxos Prepare/Promise, Propose/Accept, Commit/Acknowledge, plus an initial read to check the condition) instead of the single round trip a normal write uses.
- It must reach a quorum of the replicas responsible for the partition, regardless of the consistency level requested for other operations — there is no "LWT ONE" shortcut.
- Concurrent LWTs on the same partition serialize against each other; competing proposals cause retries, and heavy contention on one partition can create a queuing bottleneck.
Because of this overhead, LWTs are best reserved for genuinely conditional operations — unique constraint enforcement, leader election, distributed locks — not for general-purpose writes, where their throughput can be an order of magnitude lower than standard writes.
More Related questions...