Introduction

What Raft DB is, and what it is not

A short, honest description of Raft DB: the idea, the design goals, who it is for and what it does not try to be.

Raft DB (short name Raft DB) is a database written in Rust. It stores documents (JSON-like values) in tables, keeps them in memory or on disk with a write-ahead log, and answers questions about them with one query plan that serves both JSON filters and SQL. In front of that engine sit front-ends that speak the wire protocols of MySQL, MariaDB, SQL Server and PostgreSQL, so that the stock mysql, mariadb, sqlcmd and psql command-line clients, JDBC and ODBC drivers, PHP, Python, Node, .NET and other drivers of those databases can talk to Raft DB without change.

The project's stated aim is: in-memory concurrency, RDBMS durability and integrity, the write speed of NoSQL systems, one plan for JSON filters and SQL, and master-master and read-only nodes.

The idea in one paragraph#

A row of a table is stored as a binary document. A document keeps its own field names through a shared dictionary and is about 0.44 of the size of the same JSON text. A filter written as JSON and a WHERE clause written in SQL both compile to the same plan, and that plan runs in batches over the documents with the same index choices. Every acknowledged write is on disk: writes are appended to a write-ahead log (WAL), and many writers share one fsync (group commit). A table lives in several shards, each owned by one thread, so that writers of different keys do not wait for each other.

What you get#

  • A server (raftdb-server) with its own binary protocol and an HTTP/JSON API on one port, and the Studio, a web tool served by the same port.
  • SQL front-ends that run on the same engine: raftdb-mysql (answers as MySQL 8 or as MariaDB 11), raftdb-mssql (SQL Server, T-SQL over TDS) and raftdb-pg (PostgreSQL).
  • Replication: read-only replicas by log shipping, synchronous confirmation by a chosen number of replicas, automatic failover decided by a quorum of watchers, and table groups with one primary per group spread over the nodes. See the replication chapter.
  • A watcher (raftdb-watch) that checks the server, restarts it, tells people what it sees, and runs the control plane of a cluster.
  • Client libraries for many languages (see the connectors chapter).

The complete list is on Features.

What it is not#

Read this list before you decide to use it. Each item is explained, with its source, in the page named at its end.

  • It is not a drop-in replacement for MySQL, MariaDB, SQL Server or PostgreSQL in every respect. Compatibility is measured, not claimed: each SQL feature is checked by running the same statements on MySQL and on Raft DB, and the outputs are compared. What is not supported answers MySQL error 1235 ("doesn't yet support ...") instead of being ignored. See What is not there yet.
  • Transactions in the SQL front-end are isolated one table at a time. ROLLBACK works, savepoints work, and a session that writes a table inside a transaction holds it until the end, so other sessions wait instead of seeing uncommitted rows or overwriting them (@@transaction_isolation is READ-COMMITTED; no repeatable reads; a long transaction holds up others). SELECT ... FOR UPDATE and LOCK TABLES are accepted and lock nothing of their own. See Consistency guarantees.
  • TLS only on the SQL front-ends. The MySQL, MariaDB, SQL Server and PostgreSQL client connections can be encrypted (configure a certificate); the binary protocol, HTTP, the replication stream and the watcher's messages travel in clear text. Use a tunnel (SSH, WireGuard) on any network you do not control. See the security chapter.
  • It is not a distributed database that spreads one table over many nodes. Every node of a cluster holds a whole copy of the tables it replicates. Partitioned tables exist (a logical table made of several physical tables spread over groups), but "true partitioning" with a replication factor below the node count is a design, not a feature.
  • It has no backup or point-in-time recovery tool. The data is files in a directory; see Backup and recovery for what you can do and what you cannot.
  • It is not at version 1.0. The workspace version is 0.0.5. The project's README still calls the status "Stage 0" while the code is far past it; see Project status and stages.
  • Performance numbers are relative. They come from one Windows laptop, one Linux server and short runs; see How it compares.

Who it is for#

People who want one database that stores JSON documents and also answers SQL, that is durable by default, and that can sit behind an application written for MySQL, MariaDB, SQL Server or PostgreSQL. Today it suits evaluation, development and test environments, and users who read the status pages and accept their limits.

See also#