---
title: "LSM-tree storage engine"
description: "How a log-structured merge tree buffers writes in memory, flushes sorted files, reads across them, and why compaction and tombstones carry the cost."
canonical_url: "https://fanout.sh/system/archive/lsm-tree-storage-engine"
md_url: "https://fanout.sh/system/archive/lsm-tree-storage-engine.md"
last_updated: "2026-11-07"
access: "pro-preview"
---

# LSM-tree storage engine

How a log-structured merge tree buffers writes in memory, flushes sorted files, reads across them, and why compaction and tombstones carry the cost.

- Access: Fanout Pro (public preview)

## The core idea

Bitcask keeps a current location for every key in memory.

A log-structured merge tree, or LSM tree, instead buffers recent writes and organizes older keys in sorted files.

## In this lesson

- From a write buffer to sorted files
- Watch three keys fill a buffer
- Replay the same states
- What a complete merge can remove
- Reading without visiting every record
- The work moves into maintenance

## Continue reading

Pro unlocks video lessons, visual walkthroughs, full notes, diagrams, case studies, and implementations across the System Design archive.

---
This representation contains public Fanout content only. Protected Pro lessons, account data, billing, checkout, and pricing are not included.

Browse the public content map: https://fanout.sh/sitemap.md
