Storage durability
Compaction Foundry
Pour writes into an LSM-tree and watch the disk rewrite your data, level by level.
How to read this lab
Every write first lands in memory, then flushes to disk as a small file, then gets rewritten again and again as compaction merges files together. Switch strategy and run the identical workload through both: leveled compaction rewrites your data more times (higher write amplification) but keeps less stale data around (lower space amplification); size-tiered is the opposite trade.
Controls
- Compaction strategy
- Leveled merges overlapping files into clean, non-overlapping levels — more rewriting, less wasted space. Size-tiered merges same-sized files together less eagerly — less rewriting, more stale data survives longer.
- Write burst (N keys)
- Writes a batch of keys — some repeats, some deletes — into the in-memory memtable.
- Flush memtable to L0
- Forces the current memtable to disk as a new Level-0 file, even if it hasn't hit its size threshold yet.
- Run compaction pass
- Triggers one merge step — the lowest over-budget level gets folded into the next one down.
What to watch for
- Run the same sequence of write bursts and compaction passes under Leveled, note Write amplification, then switch to Size-tiered and repeat — leveled's number is consistently higher.
- Compare Space amplification the same way — size-tiered's is higher.
- If you flush repeatedly without compacting, the L0 SSTables count grows until the lane's label turns red — a real read/write stall condition.
Why it happens
Leveled compaction keeps each level's key ranges non-overlapping, which means a key gets rewritten every time it cascades one level deeper — more total bytes written per logical byte, but old or duplicate versions get cleaned up quickly. Size-tiered only merges same-sized files together and tolerates overlapping ranges for longer, so a key is rewritten less often (lower write amplification) but stale versions of it can survive on disk much longer (higher space amplification). Neither is 'better' — it's the same tradeoff RocksDB, Cassandra, and every other LSM-based store expose as a tuning knob.
Try this first — Click Write burst five times, then Run compaction pass repeatedly until it stops changing anything, and compare the two amplification numbers.
Waiting for writes
Nothing has been written yet — click "Write burst" to add keys to the memtable, then flush and compact to see write and space amplification build up.
- SSTable (size ∝ area)
- Just-merged level
- L0 stall (too many tables)
Compaction strategy
Workload
Write a burst, flush it to L0, then run compaction passes to watch levels fill and merge.
Write amplification
0.00×
Bytes rewritten per logical byte written
Space amplification
0.00×
Bytes on disk per live byte
L0 SSTables
0
Below stall threshold
Compaction passes
0
0 flushes total