NotesSystem

RocksDB

Also: Rocks DB

An embeddable LSM key-value store from Facebook, forked from Google's LevelDB, that sits underneath many other databases. Its defining choice is to make every part of the [[LSM-Tree]] pluggable and tunable.

Design choices

  • LSM-Tree: writes go to a Write-Ahead Log and a skip-list Memtable (64 MB by default), flushed as SSTables with 4 KB blocks.
  • Compaction: leveled by default, levels 10× apart, sized from the bottom up since 8.4; universal (size-tiered) and FIFO are options.
  • Bloom Filter: one per SSTable, ~10 bits per key recommended for ≈1% false positives; Ribbon filters (production-ready since 6.22) save ~30% memory for more build CPU.
  • Column families: separate LSM-trees sharing one WAL, for atomic writes across them.
  • Write stalls: throttles, then stops, writes when L0 files or pending compaction bytes pile up.

Notable trade-offs

  • Leveled Write Amplification is often above 10×; dozens of options to tune it is both its power and its operational burden.
  • Embedded as a library: replication, sharding and SQL are the host system's job.

Used by

  • MyRocks (MySQL on RocksDB): Facebook's main user database moved to it from InnoDB in 2017 and halved its storage.
  • Kafka Streams and Apache Flink state stores, TiKV, and Instagram's Rocksandra engine for Cassandra.
  • CockroachDB used it until replacing it with Pebble, a RocksDB-inspired Go rewrite, in v20.2 (2020).