Database / Apache Cassandra Intermediate and Advanced interview questions
When would you choose Leveled Compaction Strategy over Size-Tiered Compaction Strategy?
The choice comes down to whether your workload is more sensitive to read latency or to compaction overhead.
- Choose LCS when reads dominate and you need predictable, low-latency lookups — LCS guarantees a row exists in at most one SSTable per level (aside from level 0), so a read touches far fewer files than under STCS once data has spread across many SSTables.
- Choose LCS for tables with frequent updates to the same rows, since STCS can leave many overlapping versions of a row scattered across differently-sized SSTables, hurting read amplification.
- Avoid LCS on very write-heavy, high-throughput tables, because LCS does significantly more disk I/O for compaction (constantly rewriting to maintain level ordering), which can bottleneck nodes with limited disk throughput.
ALTER TABLE user_profiles WITH compaction = {'class': 'LeveledCompactionStrategy', 'sstable_size_in_mb': 160};
A practical signal: if nodetool cfstats shows a high "SSTables per read count" under STCS, that is a strong indicator the table would benefit from switching to LCS.
More Related questions...