Try
↑ ↓ move↵ openesc close

Interview prep / LSM trees

Senior · LSM trees · System design interview question

An LSM store has fine average write latency but sometimes stalls writes for seconds. What is happening, and what do you do?

Sketch your own answer first, then compare it with the one below.

A strong answer

Compaction has fallen behind ingest. Files are piling up faster than they merge, so the store slows or stops writes to let compaction catch up, rather than let read cost and disk use grow without bound. The memtable may also be full while the previous one is still flushing.

Possible fixes are to give compaction more I/O bandwidth, to add parallel compaction threads, to switch to a policy that rewrites less, to smooth ingest with a queue upstream, or to leave headroom so a burst does not outrun the merge. Limiting the rate of compaction I/O so it does not starve reads is the other side of the same trade.

A good answer treats the stall as a signal that sustained write rate is above what the compaction policy can merge, not as a random glitch.

Sources

Learn it by running it

The lsm trees and compaction lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms