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 styleWrite amplificationSpace useGood for
LeveledHigherLowestRead-heavy and mixed workloads
UniversalLowerUp to about double during compactionWrite-heavy workloads with spare disk
FIFOMinimalBounded by size limitTime 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.

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 nodeMachineDrives
Up to 700 GBBUSINESS-2 20242x 960 GB SSD NVMe, Soft RAID
Up to 1.4 TB, RAID 0 or separateBUSINESS-4 20242x 960 GB SSD NVMe, Soft RAID
Up to 2.5 TB, many coresENTERPRISE-a2 20262x 1.92 TB SSD NVMe
Heavy compaction, large cachesESSENTIAL-XL2x 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.

ModelProcessorCoresMemoryDrivesPortPer month
ESSENTIAL-MAMD Ryzen 9 9900X1264 GB2x 512 GB SSD NVMe1 Gbps unmetered$70.80
ESSENTIAL-XLAMD EPYC TURIN 945548128 GB2x 1.92 TB SSD NVMe1 Gbps unmetered$212.40
BUSINESS-2 2024AMD EPYC 4344P864 GB2x 960 GB SSD NVMe3 Gbps unmetered$109.80
BUSINESS-4 2024AMD EPYC 4584PX1664 GB2x 960 GB SSD NVMe3 Gbps unmetered$180.60
BUSINESS-4 2026AMD EPYC 4585PX1664 GB2x 960 GB SSD NVMe3 Gbps unmetered$212.40
ENTERPRISE-a2 2026AMD EPYC TURIN 925524128 GB2x 1.92 TB SSD NVMe5 Gbps unmetered$446.40

Pick NVMe capacity first, then cores for compaction and memory for cache.

See all servers and prices

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 more

Database servers

NVMe machines with large memory for PostgreSQL, MySQL, MariaDB and MongoDB, from a single primary to replicated pairs.

Read more

Software 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 more

NVMe 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 more

Questions 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.