Skip to main content
RocksDB provides extensive configuration options to tune performance for different workloads. This guide covers the most important configuration settings.

Basic Configuration

DBOptions vs ColumnFamilyOptions

RocksDB has two main option classes:
  • DBOptions: Database-wide settings (threads, WAL, compaction)
  • ColumnFamilyOptions: Per-column family settings (memtable, compaction style, compression)
  • Options: Combines both DBOptions and ColumnFamilyOptions

Essential Settings

Create Database if Missing

Set this to true to automatically create a new database if it doesn’t exist.

Parallelism

Increase background threads for better performance on multi-core systems:
IncreaseParallelism() sets max_background_jobs to the number of CPU cores and is recommended for most workloads.

Compaction Style

RocksDB offers multiple compaction strategies:

Level-Style Compaction

  • Better space amplification
  • Predictable performance
  • Default choice for most workloads

Universal-Style Compaction

  • Lower write amplification
  • Higher space amplification
  • Good for read-heavy workloads

Memory Configuration

Write Buffer

The write buffer (memtable) holds recent writes in memory:
Memory usage calculation:
Larger write buffers improve write performance but increase memory usage and recovery time after crashes.

Block Cache

The block cache caches uncompressed data blocks:

Compression

Configure compression for different levels:
  • Fast compression/decompression
  • Moderate compression ratio
  • Recommended for most levels

Write Options

Synchronous Writes

Control durability vs performance tradeoff:
With sync = false, recent writes may be lost in case of a system crash. Use sync = true for critical data or implement periodic manual syncing with DB::SyncWAL().

Disable WAL

For ephemeral data or when durability is not required:

Read Options

Read Caching

Snapshot Reads

Performance Tuning

File Opening

Compaction Triggers

Rate Limiting

Control I/O rate for compaction and flush:

Configuration Templates

High Write Throughput

Low Latency Reads

Small Database (< 1GB)

Configuration Best Practices

1

Start with defaults

Use IncreaseParallelism() and OptimizeLevelStyleCompaction() for good initial performance.
2

Measure performance

Use db_bench or your application’s workload to establish baseline performance.
3

Tune incrementally

Change one setting at a time and measure the impact.
4

Monitor resources

Watch memory usage, CPU utilization, and I/O patterns.

Next Steps

Performance Tuning

Deep dive into performance optimization techniques

Basic Operations

Learn basic CRUD operations