Try
↑ ↓ move↵ openesc close

Interview prep / LSM trees

Junior · LSM trees · System design interview question

When would you choose an LSM-based store over a B-tree based one?

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

A strong answer

Pick an LSM tree when the workload is write heavy and the data is much larger than memory. Writes are sequential, so a disk absorbs a high rate of inserts, and compaction can pack data densely.

Pick a B-tree when reads, especially range scans and point reads with a tight latency target, matter most, or when you want predictable latency. A B-tree reads one place per level and has no background merging that competes for I/O.

A good answer names the trade-off both ways. An LSM tree has background work and read cost that varies. A B-tree pays random page writes.

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