HomeAlgorithms & AILSM Tree: How Cassandra, RocksDB, and LevelDB Write Fast

🪵 LSM Tree: How Cassandra, RocksDB, and LevelDB Write Fast

Explore the Log-Structured Merge Tree, the write-optimized storage engine behind Cassandra, RocksDB, LevelDB, and HBase. See how memtables, SSTables, bloom filters, and compaction trade read speed for write throughput.

Algorithms & AI3DModerate60 FPS
lsm-tree-lab ↗ Open standalone

This simulation demonstrates how an LSM tree routes writes through an in-memory memtable into immutable on-disk SSTables, how reads must search the memtable and then SSTables from newest to oldest, how bloom filters let reads skip files that cannot contain a key, and how background compaction merges SSTables to bound read cost and reclaim space from overwritten or deleted keys.

🔬 What It Demonstrates

This simulation demonstrates how an LSM tree routes writes through an in-memory memtable into immutable on-disk SSTables, how reads must search the memtable and then SSTables from newest to oldest, how bloom filters let reads skip files that cannot contain a key, and how background compaction merges SSTables to bound read cost and reclaim space from overwritten or deleted keys.

🎮 How to Use

Add writes to fill the memtable and watch it flush into a new SSTable on disk. Issue reads for different keys and observe the search order: memtable first, then SSTables from newest to oldest, with bloom filters shown skipping files that cannot contain the key. Trigger compaction to merge SSTables and see the file count drop, stale versions and tombstones disappear, and subsequent reads become cheaper.

💡 Did You Know?

Did you know that Google's original Bigtable paper introduced the SSTable and popularized the LSM tree design, and that the same core idea now powers Cassandra, HBase, RocksDB, LevelDB, and even parts of modern versions of MySQL's storage layer through engines like MyRocks?

⚙ Under the hood

Explore the Log-Structured Merge Tree, the write-optimized storage engine behind Cassandra, RocksDB, LevelDB, and HBase. See how memtables, SSTables, bloom filters, and compaction trade read speed for write throughput.

lsm-treedatabasesstorage-enginescassandrarocksdbcompactiondata-structuresdistributed-systems

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)