TopGit
GitHub Repo Review

SurrealKV embedded key-value database

surrealdb/surrealkv
STopGit review image for surrealdb/surrealkv
Review by Topgit.dev for surrealdb/surrealkv, with GitHub repository stats and README context.
Quick verdict

SurrealKV is a suitable embedded key-value database for Rust applications that need transactional writes without running a separate database service. Its asynchronous commit pipeline, snapshot isolation, and optional encryption make it unusually complete for an embedded LSM tree. I would choose it for server-side or native Rust workloads, but the mixed async/synchronous API and limited browser coverage narrow the audience.

Stars
★ 657
Forks
⑂ 55
Contributors
👥 18
Language
Rust
License
Apache-2.0
Topic
—
Updated
Nov 2026
Homepage
GitHub

An Embedded LSM Storage Engine

SurrealKV is an embedded key-value database and versioned storage engine written in Rust, built around an LSM tree with WAL, SSTables, and compaction. It provides ACID transactions, asynchronous commits, synchronous point reads and iteration, optional point-read asynchrony, and browser persistence through OPFS.

Why This Storage Engine Exists

Embedded Rust applications often have to choose between a simple key-value crate and a full database server when they need transactional writes, concurrent reads, crash recovery, and historical queries. SurrealKV addresses that gap with a standalone storage engine that runs inside the application, keeps writes on an asynchronous commit path, and exposes snapshot-isolated transactions over an LSM tree and WAL.

Core Features and Architecture

  • ✓An asynchronous commit pipeline uses lock-free ring buffers and optimistic concurrency control, while ordinary point reads and iteration remain synchronous.
  • ✓Snapshot isolation combines multi-version concurrency control with non-blocking reads, and read transactions can observe isolated database states.
  • ✓Versioned queries retain write timestamps, expose `get_at` and `history`, and use a configurable retention period without requiring a separate value log or index.
  • ✓WiscKey-style value-log separation is optional, moving values above a configurable threshold outside the LSM tree to reduce write amplification during compaction.
  • ✓Transparent encryption covers the manifest, SSTables, value log, and WAL with AES-256-GCM or XChaCha20-Poly1305, using per-file keys derived from an application-provided root key.
  • ✓CRC32 checksums protect SSTable blocks and WAL records, while the `skv scrub` command performs an offline integrity sweep over SSTable data blocks.
  • ✓Automated migrations can convert SurrealKV v0.20 and v0.21 databases, compatible SurrealDB RocksDB data, and legacy browser IndexedDB data without exposing the old storage implementation to callers.
How this repository's GitHub stars have grown over time. Source: star-history.com.View the star history ↗

Adding SurrealKV to Rust

Add the library and Tokio to a Cargo project with `cargo add surrealkv tokio`. Enable Tokio’s `full` feature set in `Cargo.toml`, matching the dependency configuration shown in the README, then import `surrealkv::TreeBuilder` in your application.

Opening and Using a Tree

rust use surrealkv::TreeBuilder; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let tree = TreeBuilder::new() .with_path("data/mydb".into()) .build()?; let mut tx = tree.begin()?; tx.set(b"user:001", b"Alice")?; tx.commit().await?; let tx = tree.begin()?; if let Some(value) = tx.get(b"user:001")? { println!("{}", String::from_utf8_lossy(&value)); } tree.close().await?; Ok(()) } The public shape is straightforward: `TreeBuilder` opens the database, `Tree::begin` creates a transaction, writes are applied through the transaction, and `commit` is awaited. Reads are synchronous. Range iteration uses `LSMIterator` and supports forward or backward traversal over a key interval.

Strengths

  • ✓The transactional API covers more than raw key-value access: commits, snapshot isolation, version history, and encryption all live in the same package.
  • ✓Point reads are synchronous by default, which avoids forcing every lookup through an async runtime; `get_async` remains available when concurrent point reads matter.
  • ✓Durability is explicit enough for different workloads: commits are eventually durable by default, while `Durability::Immediate` waits for the WAL sync before returning.
  • ✓Data protection is unusually thorough for an embedded store, with authenticated encryption across the main on-disk files and checksums on blocks and WAL records.
  • ✓Deterministic simulation testing compares the engine against an in-memory reference model, making concurrency and recovery bugs harder to miss.

Limits and Compatibility Constraints

  • △The application must handle a mixed async and synchronous API: commits return futures that are awaited, but reads and iteration are synchronous. That split is not free when designing call paths around a runtime.
  • △Commits use eventual durability by default, so code that requires each acknowledged write to reach the disk must opt into `Durability::Immediate`. Browser durability is also weaker than native WAL durability.
  • △Encryption cannot be added to an existing database, and the selected cipher is fixed when the database is created. The on-disk formats are not frozen yet, so important data still needs backups.
  • △Only Chrome is supported for browser testing; its implementation excludes encryption and checkpoints, along with the RocksDB and SurrealKV v0.x migrators.
  • △Migrations are one-way. Original files are moved into backup directories, but those backups are not rollback points, and a database opened by this version cannot be reopened by an earlier release.
  • △Integrity checking is available through CRC32 verification and the offline `skv scrub` command, but continuous background scrubbing is not implemented.

Comparison With Other KV Stores

RocksDB is the closest conventional alternative: the README benchmark reports SurrealKV ahead on its tested point reads, writes, updates, deletes, and range scans with synchronous durability enabled.SlateDB appears substantially slower in the README benchmark for the tested operations, while sharing the broader category of embedded LSM-oriented storage.Fjall and ReDB are alternatives for embedded key-value workloads; SurrealKV leads the reported point-read figures, although benchmark results depend on the durability mode and operation.LMDB is particularly competitive for scans and full counts in the README results, so scan-heavy workloads deserve direct measurement rather than assuming SurrealKV wins.Libmdbx is another compact embedded option, but the README reports a much larger memory footprint for it under the tested workload.The comparison is workload-specific: the README uses its own benchmark setup, and the strongest result for SurrealKV is its point-read throughput, not every possible scan pattern or memory configuration.

Who Should Use SurrealKV

Rust developers embedding transactional storage should look at SurrealKV when they want an in-process database with an LSM tree, asynchronous commits, snapshot isolation, and version queries. It is also a sensible migration target for compatible SurrealDB RocksDB or legacy IndexedDB data. Teams that require broad browser testing, mature backward compatibility, a frozen file format, or a uniformly asynchronous API should evaluate another store before committing.

Frequently Asked Questions

What license does SurrealKV use and can it be used commercially?

SurrealKV uses the Apache-2.0 license. That permissive license allows commercial use, modification, distribution, and private use, subject to its notice and license conditions.

What language is SurrealKV written in and how is it used?

SurrealKV is written in Rust and is used as a library inside an application. Developers add it through Cargo, open a `Tree` with `TreeBuilder`, and access transactional reads, writes, and range iteration through the Rust API.

Does SurrealKV support ACID transactions and asynchronous commits?

SurrealKV provides ACID-compliant transactions and an asynchronous commit pipeline. A transaction is begun synchronously, then its commit is awaited; point reads and iteration are synchronous by default, with `get_async` as an opt-in.

How does SurrealKV handle durability and encryption at rest?

SurrealKV uses eventual durability by default, while `Durability::Immediate` waits for the WAL sync before a commit returns. With encryption enabled, it protects the manifest, SSTables, value log, and WAL using AES-256-GCM or XChaCha20-Poly1305.

Does SurrealKV work in browsers and which browsers are tested?

SurrealKV can run a `Tree` in a browser Web Worker with files stored in OPFS. Chrome is the only browser tested by the project, and browser encryption, checkpoints, and some migration tools are not yet available there.

Can SurrealKV migrate existing RocksDB or IndexedDB databases?

SurrealKV can migrate compatible databases written by SurrealDB’s RocksDB backend and legacy browser IndexedDB stores. The conversion happens when the database is opened, but it is one-way and does not create a rollback-capable backup.

Best use cases

  • •Embed a transactional key-value store directly in a Rust server or desktop application without deploying a separate database service.
  • •Preserve key history for audit-oriented workflows by enabling versioning and querying a value as it existed at a particular timestamp.
  • •Support a browser application that stores a `Tree` in OPFS from a dedicated Web Worker, accepting Chrome-only testing and reduced browser functionality.
  • •Migrate an existing SurrealDB RocksDB database or legacy IndexedDB store into the newer storage format while keeping the transition largely automatic.
  • •Serve high-concurrency workloads that value synchronous point reads and asynchronous batch commits, provided the application can accommodate the split API.

Related repositories

Source & attribution

Source: GitHub repository surrealdb/surrealkv, including its README and repository metadata.

GitHub data · last synced Oct 28, 2026Reviewed by Henry
← Back to TopGit

Want a second opinion on surrealkv?

Ask an AI that can read this page — one click and you get its take on surrealkv.

GitHub