Try
↑ ↓ move↵ openesc close

Interview prep / LSM trees

Mid · LSM trees · System design interview question

Define write, read and space amplification for an LSM tree, and say why you cannot minimise all three.

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

A strong answer

Write amplification is the bytes written to disk per byte the application wrote, mostly from compaction rewriting data. Read amplification is the number of files, or the amount of data, a read must examine. Space amplification is the bytes stored per byte of live data, caused by old versions that have not been merged away.

They pull against each other. Merging more eagerly keeps few files and few old versions, so reads and space are good, and the data is rewritten many times. Merging lazily saves write work, and leaves more files and more stale data.

A good answer says that the compaction policy is a choice of which cost to pay, based on the workload.

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