rocksdb
Installation
SKILL.md
RocksDB
RocksDB is an embedded (in-process, no server) persistent key-value store from Meta, based on a log-structured merge-tree (LSM-tree). It is a C++ library forked from LevelDB, optimized for fast storage (SSD/NVMe) and high write throughput. It is the storage engine behind TiKV, CockroachDB, Kafka Streams, Ceph, and many others. Apply these conventions when embedding RocksDB via Rust or Node.js bindings.
Architecture (why behavior is what it is)
- Write path: writes go to the WAL (durability) and an in-memory memtable. When the memtable fills, it is flushed to an immutable SST file at level 0. Background compaction merges SSTs down the level hierarchy (L0→L1→…).
- LSM tradeoffs: excellent write throughput and sequential I/O, but reads may touch multiple levels (read amplification) and compaction consumes CPU/IO (write amplification). Tuning is about balancing space/read/write amplification for your workload.
- Ordered keys: keys are stored sorted by byte order; range scans and prefix iteration are cheap. There is no secondary indexing — model your keys for the access pattern.
- Single-process ownership: one process opens the DB read-write (a lock file enforces this). Use a secondary instance or checkpoints for read-only sharing.