When Writes Outrun Merges
An LSM engine accepts writes quickly, but flushing and compaction run in the background and have limited throughput. If clients write faster than compaction can drain, files accumulate at level zero and unmerged runs grow.
The Danger
Too many overlapping files at level zero make reads scan more files, and unbounded growth threatens to exhaust disk space. To protect itself the engine applies back pressure called a write stall.
- A slowdown trigger throttles writers when level zero file count crosses a soft limit.
- A stop trigger pauses writers entirely when a hard limit is reached, until compaction catches up.
What Causes It
- Bursts of writes that outpace background work.
- Compaction threads that are too few or starved of input output.
- Large memtables flushing many files at once.
Mitigations
Tuning the number of compaction threads, raising the level zero thresholds, rate limiting clients, or using faster storage all reduce stalls. The aim is to keep compaction roughly matched to ingest.
Key idea
A write stall is intentional back pressure that throttles or pauses writers when compaction cannot keep up, protecting read speed and disk space.