|
| 1 | +--- |
| 2 | +title: 'RocksDB Backend Setup & Performance' |
| 3 | +description: 'Build and enable the RocksDB backend for seid to significantly improve iteration-heavy operations and traceBlock latency, especially on long-history RPC and archive nodes.' |
| 4 | +keywords: ['rocksdb', 'sei node', 'state store', 'performance', 'traceBlock', 'archive node', 'rpc'] |
| 5 | +--- |
| 6 | + |
| 7 | +import { ImageWithCaption } from '../../src/components'; |
| 8 | + |
| 9 | +import image1 from '../../public/assets/pebbledb-vs-rocksdb.png'; |
| 10 | + |
| 11 | +# RocksDB Backend Setup & Performance Guide |
| 12 | + |
| 13 | +## Overview |
| 14 | + |
| 15 | +As Sei nodes accumulate more history and state data, iteration-heavy operations—like those performed during `traceBlock` calls—can become significantly slower. This is especially true for archive or RPC nodes where the state store contains millions of versions. |
| 16 | + |
| 17 | +To address this, Sei supports **RocksDB** as an alternative backend to PebbleDB. RocksDB provides native **multi-version concurrency control (MVCC)** and **column family support**, which leads to substantial iteration performance improvements as history grows. |
| 18 | + |
| 19 | +## Why RocksDB? |
| 20 | + |
| 21 | +PebbleDB lacks native MVCC support, meaning Sei must manually encode versions into keys. This retrofit approach causes iteration time to grow linearly with the amount of stored history. As a result: |
| 22 | + |
| 23 | +- Archive nodes with large state stores experience **slower debug trace latency**. |
| 24 | +- Each key lookup may require scanning multiple key versions. |
| 25 | +- Iterations (e.g., over Oracle or EVM module keys) become increasingly expensive over time. |
| 26 | + |
| 27 | +By contrast, **RocksDB** supports native user-defined timestamps and optimized column families for versioned data access. This means: |
| 28 | + |
| 29 | +- Iterations over keys at a single version are **much faster**. |
| 30 | +- Historical data growth has **minimal effect on iteration cost**. |
| 31 | +- The performance advantage **amplifies with larger node history**. |
| 32 | + |
| 33 | +In Sei’s benchmarks, RocksDB achieved up to **10–30× faster traceBlock iteration times** compared to PebbleDB, with even greater benefits observed on archive nodes. |
| 34 | + |
| 35 | +## Example: TraceBlock Latency Comparison |
| 36 | + |
| 37 | +The following chart compares iteration (trace time) performance between **PebbleDB** and **RocksDB** over a 3 million block history: |
| 38 | + |
| 39 | +<ImageWithCaption img={image1} alt="PebbleDB vs RocksDB Trace Times" caption="Trace Times: Pebble vs Rocks (3M history): RocksDB shows a significantly flatter latency curve as state grows, while PebbleDB’s iteration times increase sharply for older blocks." /> |
| 40 | + |
| 41 | +## Setup Instructions |
| 42 | + |
| 43 | +RocksDB only needs to be built once. After that, you can install `seid` with RocksDB support directly. |
| 44 | + |
| 45 | +### Prerequisites |
| 46 | + |
| 47 | +Ensure your system includes the following packages: |
| 48 | + |
| 49 | +```bash |
| 50 | +sudo apt-get update |
| 51 | +sudo apt-get install -y build-essential pkg-config cmake git zlib1g-dev \ |
| 52 | + libbz2-dev libsnappy-dev liblz4-dev libzstd-dev libjemalloc-dev \ |
| 53 | + libgflags-dev liburing-dev |
| 54 | +``` |
| 55 | + |
| 56 | +### Build & Install |
| 57 | + |
| 58 | +Refer to the Sei `Makefile` [here](https://github.com/sei-protocol/sei-chain/blob/main/Makefile#L116) for the official targets. |
| 59 | + |
| 60 | +```bash |
| 61 | +# Step 1: Build RocksDB (one-time setup) |
| 62 | +make build-rocksdb |
| 63 | + |
| 64 | +# Step 2: Install seid with RocksDB backend |
| 65 | +make install-rocksdb |
| 66 | +``` |
| 67 | + |
| 68 | +Once installed, your `seid` binary will be built with RocksDB backend support: |
| 69 | + |
| 70 | +```bash |
| 71 | +seid version |
| 72 | +# should include "rocksdbBackend" build tag |
| 73 | +``` |
| 74 | + |
| 75 | +### Configuration |
| 76 | + |
| 77 | +After installation, update your configuration file to enable the RocksDB backend: |
| 78 | + |
| 79 | +```bash |
| 80 | +~/.sei/config/app.toml |
| 81 | +``` |
| 82 | + |
| 83 | +Set |
| 84 | + |
| 85 | +```toml |
| 86 | +ss-backend = "rocksdb" |
| 87 | +``` |
| 88 | + |
| 89 | +### Node Setup Notes |
| 90 | + |
| 91 | +- RPC Nodes — must perform a state sync when spinning up a new node configured with RocksDB. |
| 92 | +- Archive Nodes — currently, RocksDB is not supported for existing data unless syncing from genesis. A migration route from PebbleDB to RocksDB is being developed and will be shared soon. |
| 93 | + |
| 94 | +## Summary |
| 95 | + |
| 96 | +| Feature | PebbleDB | RocksDB | |
| 97 | +| ----------------------------- | ------------------ | ------------------------------------- | |
| 98 | +| MVCC Support | No | ✅ Native via user-defined timestamps | |
| 99 | +| Column Families | No | ✅ Yes | |
| 100 | +| Iteration Speed (Large State) | Slows with history | ✅ Up to 30× faster | |
| 101 | +| Installation | Default | One-time build (`make build-rocksdb`) | |
| 102 | + |
| 103 | +## TL;DR |
| 104 | + |
| 105 | +- RocksDB backend drastically improves trace iteration and historical query performance. |
| 106 | +- Install once, then simply run: |
| 107 | + |
| 108 | +```bash |
| 109 | +make install-rocksdb |
| 110 | +``` |
| 111 | + |
| 112 | +- Update ~/.sei/config/app.toml to use RocksDB: |
| 113 | + |
| 114 | +```toml |
| 115 | +ss-backend = "rocksdb" |
| 116 | +``` |
| 117 | + |
| 118 | +- RPC nodes require state sync; archive nodes must currently sync from genesis |
| 119 | +- Expect **10–30× faster** trace latencies, especially on archive nodes or long-history setups. |
0 commit comments