Compaction Strategies: STCS, LCS, TWCS
Choose the right compaction strategy to balance read performance, write throughput, and space amplification for different workloads.
Because Cassandra's storage engine is an LSM-tree (Log-Structured Merge tree), writes accumulate as immutable SSTables on disk over time, and compaction is the background process that merges these SSTables together, discarding overwritten data and expired tombstones. The choice of compaction strategy has major implications for read latency, write amplification, and disk space usage.
STCS is like periodically merging piles of similarly-sized papers on your desk into one bigger pile. LCS is like maintaining strict alphabetized filing drawers where each drawer never has duplicate/overlapping labels. TWCS is like using a new labeled box for each week's mail and simply throwing out the entire box once its contents are no longer needed.