Compaction
The background process in an LSM tree that merges several SSTables into fewer, removes overshadowed old versions, and physically deletes tombstones. Crucial for keeping read performance and disk usage in check.
Why: since SSTables are immutable and only appended, over time many files accumulate where the same key exists in several versions. Compaction reads them together, keeps the latest value, discards old ones and tombstones, and writes out fewer, cleaner SSTables. Strategies: leveled compaction (RocksDB — low space/read amplification, high write amplification), tiered/size-tiered (Cassandra — the opposite), and universal. The trade-off directly governs the RUM balance (read/write/space amplification). Compaction is resource-intensive (I/O + CPU) and its timing/control is a central tuning question; bad compaction causes latency spikes. The heart of how LSM databases stay healthy. Related to SSTable and write amplification.