RocksDB on dedicated NVMe servers
RocksDB is the storage engine inside many databases and stream processors. Its performance comes down to drive speed, compaction threads and memory for caches, all of which a dedicated machine gives in full.
What is RocksDB and where is it used?
An embedded key-value store built on a log-structured merge tree, written in C++ and widely used as the storage layer of other systems. Stream processors keep their state in it, distributed databases store their data in it, MySQL can use it through the MyRocks engine, and Ceph stores object metadata in it. If you run any of these, tuning RocksDB is tuning your system.
How does an LSM tree use the disks?
Writes land in an in-memory memtable and a write-ahead log. Full memtables are flushed as sorted files to level 0, and background compaction merges files into larger levels, discarding overwritten and deleted keys. Every byte is therefore written several times over its life, which is called write amplification, and reads may check several levels, which Bloom filters and the block cache keep cheap.
| Compaction style | Write amplification | Space use | Good for |
|---|---|---|---|
| Leveled | Higher | Lowest | Read-heavy and mixed workloads |
| Universal | Lower | Up to about double during compaction | Write-heavy workloads with spare disk |
| FIFO | Minimal | Bounded by size limit | Time series and caches that expire |
Which options matter most?
A handful cover most of the gain. Set them through your application's RocksDB options or the host system's configuration.
max_background_jobs: threads for flush and compaction; a quarter to half of the cores is a good start on a dedicated machine.write_buffer_sizeandmax_write_buffer_number: larger memtables mean fewer, larger flushes.level_compaction_dynamic_level_bytes = true: keeps level sizes in proportion and reduces space amplification.- Block cache size: a large share of free memory; the HyperClockCache scales better across many threads than the older LRU cache.
- Compression per level: LZ4 on upper levels for speed, Zstandard on the bottom level where most data lives.
- Bloom filters at about ten bits per key, or Ribbon filters to save memory.
use_direct_io_for_flush_and_compaction: keeps compaction from flushing your hot data out of the page cache.
How do I measure before changing anything?
With db_bench, which ships with RocksDB, and with the statistics your system already exports. Run a fill to reach realistic size, then the read and write mix you expect, and watch stalls and latency percentiles.
db_bench --db=/data/rdb-test --benchmarks=fillseq,readrandomwriterandom --num=300000000 --value_size=512 --readwritepercent=70 --threads=24 --max_background_jobs=16 --cache_size=34359738368 --bloom_bits=10 --compression_type=lz4 --bottommost_compression_type=zstd --statistics
Check rocksdb.stall.micros and the compaction statistics in the LOG file. Frequent write stalls mean compaction cannot keep up: add background jobs, enlarge memtables, or move to faster drives.
Which filesystem and RAID layout?
XFS or ext4 on NVMe, mounted with noatime. For a single node that holds the only copy, software RAID 1 across the two NVMe drives protects against a drive failure; Software RAID with mdadm shows the setup. For replicated systems where each node is one of three copies, two separate filesystems or RAID 0 give more throughput, and the replication handles failure. Keep at least 30 percent free space, since compaction needs room to write new files before deleting old ones.
Which machine fits?
Choose by data size on NVMe, then by cores for compaction, then by memory for cache.
| Data on each node | Machine | Drives |
|---|---|---|
| Up to 700 GB | BUSINESS-2 2024 | 2x 960 GB SSD NVMe, Soft RAID |
| Up to 1.4 TB, RAID 0 or separate | BUSINESS-4 2024 | 2x 960 GB SSD NVMe, Soft RAID |
| Up to 2.5 TB, many cores | ENTERPRISE-a2 2026 | 2x 1.92 TB SSD NVMe |
| Heavy compaction, large caches | ESSENTIAL-XL | 2x 1.92 TB SSD NVMe, Soft RAID |
ESSENTIAL-XL pairs 48 Zen 5 cores with 128 GB DDR5 and two 1.92 TB NVMe drives for $212.40 a month, a strong compaction host. Every model has ECC memory, which matters for a store that rewrites its data continuously.
How do I back up a RocksDB store?
Use checkpoints for a fast, consistent copy made of hard links, or the backup engine for incremental copies to another directory. Both can run while the database serves traffic. Copy the result to another machine; Ship database dumps to a second server shows a pattern. Our Speedb storage engine servers page covers a compatible engine worth benchmarking against the upstream one.
Machines for RocksDB workloads
Lowest monthly price of each model across its data centres; the model page shows the price in every location.
| Model | Processor | Cores | Memory | Drives | Port | Per month |
|---|---|---|---|---|---|---|
| ESSENTIAL-M | AMD Ryzen 9 9900X | 12 | 64 GB | 2x 512 GB SSD NVMe | 1 Gbps unmetered | $70.80 |
| ESSENTIAL-XL | AMD EPYC TURIN 9455 | 48 | 128 GB | 2x 1.92 TB SSD NVMe | 1 Gbps unmetered | $212.40 |
| BUSINESS-2 2024 | AMD EPYC 4344P | 8 | 64 GB | 2x 960 GB SSD NVMe | 3 Gbps unmetered | $109.80 |
| BUSINESS-4 2024 | AMD EPYC 4584PX | 16 | 64 GB | 2x 960 GB SSD NVMe | 3 Gbps unmetered | $180.60 |
| BUSINESS-4 2026 | AMD EPYC 4585PX | 16 | 64 GB | 2x 960 GB SSD NVMe | 3 Gbps unmetered | $212.40 |
| ENTERPRISE-a2 2026 | AMD EPYC TURIN 9255 | 24 | 128 GB | 2x 1.92 TB SSD NVMe | 5 Gbps unmetered | $446.40 |
Pick NVMe capacity first, then cores for compaction and memory for cache.
Related pages
Speedb storage engine servers
Evaluate Speedb, the RocksDB-compatible storage engine, on NVMe servers: what it changes, how to build and link it, and how to benchmark it fairly.
Read moreDatabase servers
NVMe machines with large memory for PostgreSQL, MySQL, MariaDB and MongoDB, from a single primary to replicated pairs.
Read moreSoftware RAID with mdadm
Read, create, monitor and tune Linux software RAID arrays with mdadm: status fields, email alerts, scrubs and the write-intent bitmap.
Read moreNVMe vs SATA SSD vs HDD
Throughput, latency and cost per terabyte of the three drive types in our machines, and which job suits each.
Read moreQuestions and answers
What is RocksDB?
An embedded key-value store based on a log-structured merge tree, used as the storage layer of many databases and stream processors.
Why does RocksDB write more bytes than my application sends?
The extra writing caused by compaction, which rewrites data as it merges levels. Faster NVMe drives and the right compaction style reduce its impact.
How many background jobs should RocksDB use?
On a dedicated server, start with a quarter to half of the cores for max_background_jobs, then adjust based on write stalls.
Should RocksDB run on RAID?
For a single copy of the data, RAID 1 on two NVMe drives protects it. For replicated systems, separate drives or RAID 0 give more throughput.
How do I back up a running RocksDB database?
Create a checkpoint or use the backup engine while it runs, then copy the result to another machine.