Try
↑ ↓ move↵ openesc close

Interview prep / LSM trees

Mid · LSM trees · System design interview question

Compare leveled and tiered compaction. Which suits a write-heavy ingest workload?

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

A strong answer

Leveled compaction keeps one sorted run per level, and each level is a fixed multiple larger than the one above. A merge pushes a level down into the next. Reads check few runs and stale data is removed quickly, and each entry is rewritten about once per level, or more.

Tiered compaction lets several runs of similar size accumulate and merges them together when there are enough. Each entry is rewritten about once per level, so writes are cheaper. Reads check more runs and space use is higher because old versions linger.

For write-heavy ingest where reads are rare or filtered, tiered fits. For read-heavy loads, or when disk space is tight, leveled fits. Say what you would measure to decide.

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