LSM Tree (Log-Structured Merge-Tree) 00:00:01 Accept a burst without updating a tree on disk A produce market records fruit-price changes as fast as customers buy. A log-structured merge tree appends recovery information and updates a sorted in-memory table. Different storage tiers absorb different parts of the job. Everything is empty. Each write is appended to the log and inserted into the memtable. The client gets its answer. No data file was touched. Three more. The memtable keeps them in key order. A fast acknowledgement is meaningful only under a stated log-sync policy. Distinguish a buffered update from a durable commit before comparing throughput figures. 00:00:40 Freeze one memtable and accept the next write Once the active table reaches its size budget, make it immutable and open a new one. The frozen contents can be written as a sorted disk file while newer updates continue. The full memtable is frozen. A new one takes writes, with a new part of the log. The entries are already in order, so this is one pass. The file is safe on disk, so the old records are not needed. Level 0 fills up. The ranges overlap. kiwi waits in the memtable. Install the completed file durably before retiring recovery information that covered it. A crash before publication should leave a valid recovery route through the earlier state. 00:01:20 Pay the merge bill in the background Several flushed files may contain versions of the same keys. Compaction reads sorted runs, resolves obsolete versions when safe, and writes new files with a smaller or better organized read path. Level 0 has four files. They may all hold the same key. All inputs are sorted, so each is read once. The newest version of a key stays. The new files take over in one step, then the inputs are removed. When level 1 is too large, part of it moves to level 2, which is ten times larger. Compaction converts extra storage and future read work into current I/O. Its workload is part of steady-state capacity, even when foreground writes initially appear cheap. 00:02:01 Delete without editing every old file A key can remain present in an older immutable file. A newer deletion marker tells readers the earlier value is obsolete. Simply dropping the key from memory would expose the old version again. cherry is in level 1. The marker goes to the log and the memtable like any write. After a flush the tombstone meets the old value. Nothing older lies below, so both go. cherry is gone, and the space is free. A tombstone can be removed only when the engine's snapshot and lower-level overlap rules make it safe. In replicated designs, include their repair and deletion propagation contract as well. 00:02:39 The sale outruns compaction At first the market absorbs the sale into memory and new files. Later, too many overlapping files slow reads and consume disk. Follow the backlog rather than judging the design by its first minute. Four files, then a merge. Reads are cheap. Writes triple. Level 0 grows faster than it is merged. At 36 files writes stop until compaction catches up. Limit the writers early, spread the load over more nodes, and give compaction more disk. Watch pending compaction bytes, write amplification, read latency and free space. Sustainable ingest is the rate at which the whole storage engine can absorb, flush and compact the stream.