Try
↑ ↓ move↵ openesc close

Interview prep / LSM trees

Junior · LSM trees · System design interview question

Describe how a write moves through an LSM tree.

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

A strong answer

The write is appended to a log for durability and inserted into the memtable, a sorted table in memory. When the memtable is full, it is written to disk in one sequential pass as an immutable sorted file, an SSTable.

Over time files pile up. A background process, compaction, merges them into larger sorted files and drops old versions of keys.

The write itself never changes an existing file. That is what makes writes fast and sequential, and why reads have to look in more than one place.

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