GitHub - jgarzik/roodb: RooDB

GitHub

4 min read Original article ↗

The fastest SQL database on a single machine.

RooDB is built to extract every last drop of performance from modern multi-core CPUs and high-speed storage devices (NVMe SSDs, Optane). On single-node and leader-replica configurations, nothing should be faster.

Goals

  • Maximum single-node throughput — saturate all cores and I/O bandwidth with lock-free data structures, io_uring, and a unified memory budget that adapts to workload in real time
  • General purpose SQL — not a niche engine; a real database for real workloads, fast out-of-the-box without tuning
  • High availability — optional Raft replication across leader + replicas, with reads served locally
  • Near-zero config — self-tuning defaults that just work; no knob-turning required

Why RooDB?

Most SQL databases were designed in an era of slow disks and single-core CPUs. RooDB is designed from scratch for today's hardware: dozens of cores, millions of IOPS from NVMe, and batched direct I/O via io_uring. The result is a database that keeps the hardware busy instead of waiting on locks and syscalls.

Features

  • io_uring I/O — direct I/O (no page cache) submitted in batches by reactor threads on Linux; a POSIX worker-pool backend everywhere, chosen at startup
  • Lock-free memtable — concurrent skip list for zero-contention writes
  • Unified memory budget — block cache and memtables share a single adaptive pool
  • LSM storage engine — write-optimized with cascading compaction
  • Raft consensus — distributed replication via OpenRaft for high availability
  • Full SQL — parser, query planner with optimizer, Volcano-style executor
  • MySQL-compatible protocol — connect with mysql CLI or any MySQL client library (TLS required)
  • SQL Server protocol (TDS) — optional second port for TDS clients, over TDS 8.0 or TDS 7.x, always encrypted (see admin.md)

Quick Start

Build

Initialize and Run

# Initialize the database and generate TLS certificates in ./certs
# (first time only, idempotent)
ROODB_ROOT_PASSWORD=secret ./target/release/roodb_init --data-dir ./data --generate-tls

# Start server
./target/release/roodb --port 3307 --data-dir ./data

Windows

Install roodb-<version>-x64.msi (it registers a RooDB service, stopped and set to start manually, listening on this machine only), then from an elevated PowerShell:

$env:ROODB_ROOT_PASSWORD = 'secret'
roodb_init --config "$env:ProgramData\RooDB\roodb.toml" --generate-tls
Start-Service RooDB

Configuration, logs, remote access, upgrade and uninstall (which keeps your data): admin.md.

Connect with Client

# A new server has no databases but its own: create one to work in
mysql -h 127.0.0.1 -P 3307 -u root -p --ssl-mode=REQUIRED -e "CREATE DATABASE app"
mysql -h 127.0.0.1 -P 3307 -u root -p --ssl-mode=REQUIRED app

Run Tests

Documentation

File Contents
SQL.md Supported SQL
admin.md Configuration, deployment, users and privileges, backup, troubleshooting
CONTRIBUTING.md Building, testing, debugging, source layout, where to start reading
design.md Architecture and per-module reference
LOCKING.md Locks and lock ordering
mtesting.md MySQL test suite integration
doc/ROADMAP.md Work that remains, in order

Architecture

The source layout and the path of a statement through the code are in CONTRIBUTING.md; design.md describes each module.

Replication Model:

  • A server starts as a cluster of one; further nodes join it with --join and are sent the data
  • The leader is the primary and takes all writes, replicated via Raft; the other nodes are read-only secondaries that answer reads from their own state
  • When the primary fails, another node takes over; no acknowledged commit is lost
  • Schema stored in system tables, replicated like data
  • Raft log serves as the write-ahead log

See admin.md for running a cluster.

Test Suite

Integration tests start the real server binary and drive it through client libraries: mysql_async for the RooDB (MySQL-compatible) protocol and tiberius for TDS, plus hand-built packets for malformed and adversarial input. Other tests kill and restart the server to check durability, and run three-node Raft clusters inside the test process. CI runs the tests on Linux, macOS and Windows, and on Linux with both I/O backends (io_uring and posix). A Linux CI job also connects to the TDS port with sqlcmd over Microsoft ODBC Driver 18, and a Windows workflow builds the MSI installer and, on clean runners, proves the installed service: fresh install to uninstall and reinstall, upgrade, refused downgrade, failed starts and a squatted data folder. See CONTRIBUTING.md.

Dependencies

Key dependencies:

  • openraft - Raft consensus
  • sqlparser - SQL parsing
  • io-uring - Linux io_uring (Linux only)

License

MIT