ConfigsMay 21, 2026·3 min read

Sled — Modern Embedded Database for Rust

A lightweight, lock-free embedded key-value store written in Rust, inspired by modern B-tree research.

Agent ready

This asset can be read and installed directly by agents

TokRepo exposes a universal CLI command, install contract, metadata JSON, adapter-aware plan, and raw content links so agents can judge fit, risk, and next actions.

Native · 98/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
Sled Overview
Universal CLI install command
npx tokrepo install 6678c522-5551-11f1-9bc6-00163e2b0d79

Introduction

Sled is an embedded database written in Rust that provides a concurrent, ACID-compliant key-value store. It was designed from the ground up to leverage modern hardware with lock-free data structures, making it suitable for applications that need high-throughput embedded storage without an external database process.

What Sled Does

  • Provides a zero-config embedded key-value store with ACID transactions
  • Supports ordered iteration, range scans, and prefix scanning
  • Offers merge operators for conflict-free concurrent value updates
  • Delivers crash-safe storage through write-ahead logging
  • Enables structured data through typed trees and namespaced keyspaces

Architecture Overview

Sled uses a lock-free B+ tree variant called a Bw-tree for its core index structure. Writes go through a write-ahead log for durability, and background compaction reclaims space. The page cache uses epoch-based reclamation to avoid locks, and the storage engine is designed around flash-friendly I/O patterns to minimize write amplification.

Self-Hosting & Configuration

  • Add sled as a Cargo dependency; no external process or server needed
  • Configure cache size, flush interval, and compression via the sled::Config builder
  • Use temporary mode for testing to avoid writing to disk
  • Set segment size and snapshot thresholds for write-heavy workloads
  • Monitor database statistics through the built-in sled::Db::size_on_disk method

Key Features

  • Lock-free concurrent reads and writes using modern B-tree research
  • Built-in ACID transactions with serializable isolation
  • Zero external dependencies beyond the Rust standard library
  • Merge operators for conflict-free counters and append-only logs
  • Subscribes to key-change events for reactive application patterns

Comparison with Similar Tools

  • RocksDB — RocksDB is C++ with Rust bindings; sled is pure Rust with a simpler API
  • SQLite — SQLite provides relational SQL; sled is a key-value store for structured Rust data
  • LevelDB — LevelDB is read-optimized; sled targets balanced read/write workloads with concurrency
  • redb — redb is a newer Rust embedded DB focused on simplicity; sled offers more features like subscribers
  • LMDB — LMDB uses memory-mapped files; sled uses a log-structured approach with compaction

FAQ

Q: Is sled production-ready? A: Sled is widely used but still pre-1.0. The API is stable for the 0.34 line, and the author is working on a 1.0 rewrite with improved performance.

Q: Does sled support multi-process access? A: No. Sled is designed for single-process, multi-threaded use. Use a client-server database if you need multi-process access.

Q: How does sled handle crash recovery? A: Sled uses write-ahead logging and periodic snapshots to recover to a consistent state after unexpected shutdowns.

Q: Can sled be used in WebAssembly? A: Not directly, since sled depends on filesystem I/O. It is designed for native Rust applications.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets