AlgoViz

LSM tree

hard 28 min

A log-structured merge tree collects writes in memory, flushes them as sorted files and merges those files in the background.

Where it shows up

The same pattern appears across everyday software.

  • RocksDB

    An embedded engine with a skip list memtable, leveled compaction by default and many options. It is used inside other databases, such as TiKV.

  • Cassandra

    Commit log, memtables and SSTables on each node. Several compaction strategies can be chosen for each table.

  • ScyllaDB at Discord

    Discord described moving its messages from 177 Cassandra nodes to 72 ScyllaDB nodes. Falling behind on compaction was one of the problems it named.

  • CockroachDB

    Its storage layer is Pebble, an LSM engine written in Go and inspired by RocksDB, under a SQL database.

  • HBase and Bigtable

    Both follow the pattern of commit log, memory table and sorted files with minor and major compactions.

  • The B-tree side

    PostgreSQL, MySQL InnoDB and MongoDB indexes are B-trees. FoundationDB's ssd engines store data in B-trees too, and it also offers a RocksDB engine.