Why it matters

LSM-trees dominate modern write-heavy databases. Understanding shapes storage design.

Advertisement

The architecture

Memtable: in-memory sorted structure. Writes go here first.

SSTable: sorted immutable file on disk. Flushed from memtable.

LSM-tree opsMemtablein-memory writesSSTable flushsorted fileCompactionmerge sorted runsTrade-off: write-optimized at cost of read amplification (multiple SSTables per query)
LSM operations.
Advertisement

How it works end to end

Read path: check memtable + all SSTables (with bloom filter to skip).

Compaction: merge SSTables to reduce count + reclaim tombstoned space.

Level-based (LevelDB) vs size-tiered (Cassandra) compaction strategies.

Trade-off: write amplification (multiple rewrites) vs read amplification (multiple files per query).