Software → Databases
LSM-Tree
A storage structure optimized for high write throughput using immutable sorted runs and compaction.
Motivation
An LSM-Tree solves the problem of making writes fast by batching and reorganizing data over time.
Where it fits
It belongs to databases and storage engines and is common in write-heavy systems.
Mental model
Writes first go to memory and logs, then are flushed and compacted into sorted files.
Important details
The tradeoff is excellent write throughput with read amplification and compaction complexity.
Common mistakes
- Assuming LSM-Trees are universally better than B-Trees.
- Forgetting compaction cost.