rust-rocksdb
Idiomatic Rust bindings and wrapper for Facebook's RocksDB embedded key-value store.
Repository Health
Technical Analysis
rust-rocksdb (published to crates.io as rocksdb) is a Rust wrapper around Facebook’s RocksDB, a high-performance embedded key-value store built on an LSM-tree. It statically links and builds the C++ RocksDB library via the companion librocksdb-sys FFI crate and exposes a safe, idiomatic Rust API on top: opening databases with configurable Options, column families, transactions (both pessimistic TransactionDB and OptimisticTransactionDB), snapshots, checkpoints, backups, merge operators, and compaction filters.
With over 50 million cumulative downloads, it is the de facto standard way to embed RocksDB in a Rust application, and is used as the storage engine underneath several production databases and blockchain/state-storage systems written in Rust. The crate tracks upstream RocksDB releases closely and exposes most of RocksDB’s advanced tuning knobs (compression, write buffers, bloom filters, io_uring, jemalloc) as opt-in Cargo features rather than hard dependencies, keeping default builds lean.
What You Get
- A
DBtype withopen,open_cf_descriptors,put,get,delete, and iterator APIs for basic key-value operations - Column family support for partitioning data within a single database instance
- Pessimistic (
TransactionDB) and optimistic (OptimisticTransactionDB) transaction support - Snapshots, checkpoints, and backup/restore APIs for point-in-time consistency and disaster recovery
- Merge operators and compaction filters for custom read-time and compaction-time data transformations
- Cargo feature flags for optional compression codecs (snappy, lz4, zstd, zlib, bzip2), jemalloc, and io_uring
Common Use Cases
- Embedding a fast, persistent local key-value store in a Rust service without running a separate database process
- Building a custom storage engine for a database, blockchain, or state-machine-replication system on top of RocksDB’s LSM-tree
- Using column families to logically partition different data types (e.g. indexes vs. raw records) within one RocksDB instance
- Taking consistent backups or snapshots of an embedded store for replication or point-in-time recovery
Under The Hood
Architecture — The crate is split into a safe wrapper (this rocksdb crate, under src/) and a separate librocksdb-sys FFI crate (declared as a workspace member) that vendors and statically builds the upstream C++ RocksDB source via build.rs; the wrapper’s src/db.rs, src/db_options.rs, src/column_family.rs, and src/transactions/ modules layer safe, ownership-checked Rust types (DB, Options, ColumnFamilyDescriptor) over raw FFI calls, with src/raw_ptr.rs and src/ffi_util.rs centralizing unsafe pointer handling so the rest of the crate can stay safe Rust. Tech Stack — Rust 2021 edition (rust-version 1.85+), depending on libc and the sibling librocksdb-sys crate for the vendored C++ RocksDB build, with optional serde support behind a feature flag and dev-dependencies on tempfile, trybuild, and pretty_assertions for testing. Code Quality — The tests/ directory contains 20+ integration test files covering column families, transactions, backups, checkpoints, iterators, compaction filters, comparators, and multithreaded access, reflecting the correctness bar expected of a storage-engine binding; CI builds against the vendored RocksDB source to catch upstream breakage early. API Design — The API mirrors RocksDB’s own C++ surface closely (Options, ColumnFamilyDescriptor, WriteBatch) rather than inventing a novel Rust-idiomatic key-value trait, which keeps it familiar to anyone who has used RocksDB in another language but means newcomers benefit from reading upstream RocksDB docs alongside the crate’s own rustdoc.
Used by 5 apps in this directory
Convex Backend
Developer Tools · Databases
Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.
Murr
Databases
A RocksDB-based NVMe/S3 cache purpose-built for AI inference workloads — a faster Redis replacement optimized for batch, low-latency, zero-copy reads and writes between data pipelines and inference apps.
PostHog
Analytics · Monitoring · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
Sonic
Databases · Search
Fast, lightweight, schema-less search backend in Rust — microsecond queries, 30MB RAM, no document storage required.
Stalwart
Collaboration
All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.