A transactional database whose only state is a bucket.
One static Rust binary serving strictly serializable transactions and ordered JSON scans over HTTP. Give every user, tenant, or agent its own database—an idle one is a 146-byte object in Backblaze B2 or S3. Servers hold no durable state: add them, remove them, or kill every one, and nothing is lost.
- ~8 MB static binary
- B2, S3-compatible, or local directory
- No locks, leases, or conditional writes
- Modelled in TLA+
TypeScript SDK
import { Database } from '@durable-db/client';
const db = new Database({ url, database: 'demo', token });
await db.set('users/ada', { name: 'Ada', logins: 1 });
const ada = await db.get<{ name: string }>('users/ada');
// Atomic. If anything read changes first, nothing is
// written and the callback runs again.
await db.transaction(async (tx) => {
const from = (await tx.get<number>('accounts/a')) ?? 0;
const to = (await tx.get<number>('accounts/b')) ?? 0;
if (from < 30) throw new Error('insufficient funds');
tx.set('accounts/a', from - 30);
tx.set('accounts/b', to + 30);
});
// Ordered prefix scan, paginated at one revision.
const page = await db.list({ prefix: 'accounts/', limit: 20 });HTTP / curl
export URL=http://127.0.0.1:7654/v1/databases/demo
export AUTH="Authorization: Bearer $(durable-db create demo)"
# Two keys written in one atomic transaction.
curl $URL/commit -H "$AUTH" -d '{"writes": [
{"key": "accounts/a", "value": {"balance": 100}},
{"key": "accounts/b", "value": {"balance": 100}}]}'
# {"revision":1}
# Transfer 30 only if accounts/a is still at version 1.
# Retried with the same key, it applies once.
curl $URL/commit -H "$AUTH" -d '{
"checks": [{"key": "accounts/a", "version": 1}],
"writes": [
{"key": "accounts/a", "value": {"balance": 70}},
{"key": "accounts/b", "value": {"balance": 130}}],
"idempotency_key": "transfer-7f3a"}'
# {"revision":2}
# Ordered prefix scan read at one revision.
curl $URL/read -H "$AUTH" \
-d '{"scans": [{"prefix": "accounts/"}]}'Explainer film · 14 min
Watch how a bucket with no locks gives you transactions
Why running a database server per agent or tenant is a chore, how the write-then-check protocol works, what happens when every server is killed mid-transaction, and how group commit keeps it fast.
Architecture
One writer per database, fenced by a claim object
Storage needs only PUT, GET, HEAD, LIST, and DELETE with read-after-write consistency. No conditional writes, no leases, no synchronized clocks, and no consensus cluster. Backblaze B2 and S3 run the exact same algorithm.
Objects of one database (app). Every key is written by one epoch and never overwritten.
- db/app/c/<epoch>
- Claim. The active writer's permit; deleted to revoke it.
- db/app/l/<epoch>/<n>
- Frame. One group of committed transactions.
- db/app/t/<epoch>/<id>
- Table. Sorted, LZ4-compressed, CRC-checked blocks + index.
- db/app/m/<epoch>/<gen>
- Manifest. The tables and revision making up current state.
- db/app/m/~
- Tombstone. Written once after deletion is final.
Every object is immutable
Frames, tables, manifests, and claims live under an epoch combining a monotonic number with fresh random hex digits. Two servers never write the same key, so no write ever needs to be conditional.
One server holds the claim
To open a database, a server lists claims and manifests, chooses a higher epoch number, and PUTs its own claim once. If a listing then reveals a higher claim, it deletes its own and steps aside.
A successor revokes before it reads
Before reading any manifest or frame, the new owner deletes every lower claim. Nothing the previous owner acknowledges afterwards can slip past the recovery listing.
Every commit waits for a HEAD on the claim
A commit is one frame upload followed by one HEAD. If the claim still stands, the frame was stored before any successor began reading. If it is gone, nothing is acknowledged and the client retries safely with its idempotency key.
Strong reads, cleanup, and deletion obey the same rule
Linearizable reads, garbage collection, and final database deletion each wait for a claim check that started after the state they depend on was stored. A replaced server fails the check—acknowledging nothing and deleting nothing.
On a laptop or single host, the same binary runs the same protocol over a local directory. See the architecture page for every edge case and the table of what happens when things fail.
Performance
Measured on Backblaze B2 and a local NVMe disk
Every commit waits for one upload and one HEAD, so storage latency is the floor. One database has one writer; throughput comes from group commit—every transaction arriving while an upload is in flight joins the next frame.
256 clients on one database (128 ms median). On local NVMe with fsync: 16,541 /s.
0.10 ms median on a B2-backed server. Linearizable reads: 6,480 /s on B2 (37 ms median).
Peak server memory under a 1 GiB limit at 1–16 GiB. Reopened a 16 GiB DB after a kill in 50 ms (local).
| Workload (256-byte JSON values, 1 server) | Local NVMe · fsync on | Backblaze B2 · 22 ms Wi-Fi |
|---|---|---|
| One commit, 1 client | 6.0 ms 161 /s | 77 ms 12 /s |
| Commits, 32 clients on one database | 2,105 /s 15.0 ms p50 | 183 /s 128 ms p50 |
| Commits, 256 clients on one database | 16,541 /s 15.3 ms p50 | 1,881 /s 128 ms p50 |
| Commits, 64 clients across 64 databases | 4,936 /s 12.0 ms p50 | 534 /s 88 ms p50 |
| Linearizable reads, 256 clients | 378,213 /s 0.64 ms p50 | 6,480 /s 37 ms p50 |
| Linearizable scans of 20 keys, 32 clients | 246,678 /s 0.11 ms p50 | 845 /s 37 ms p50 |
| Session reads, 32 clients | 297,289 /s 0.09 ms p50 | 276,223 /s 0.10 ms p50 |
Measured 2026-11-14 with durable-db bench (release 2.1.1 static binary) on one 32-core desktop with a consumer NVMe drive and a Backblaze B2 bucket in us-west-002 reached over residential Wi-Fi, 22 ms away; large-database figures measured with release 2.1.8. B2 upload latency moves roughly 2× between hours (the same single-client commit took 118 ms earlier that day), and brief Wi-Fi stalls drove the highest tail latencies. A server in a data centre on a wired link has not been measured.
Capabilities
Transactions, scans, and tenant isolation over plain HTTP
One stateless deployment serves thousands of independent databases. Give each user, project, or agent its own database, token, and budget.
-
Atomic transactions
All writes apply together or not at all, guarded by key-version and range checks. Strictly serializable within each database.
-
Ordered scans
UTF-8 byte-ordered keys scanned by prefix or start/end, forward or reverse, cursor-paginated. Every key and scan in one request reads at one revision.
-
Strong or session reads
strong(default) is linearizable at one shared HEAD.sessionanswers from memory while guaranteeing read-your-writes and monotonic revisions. -
Idempotent retries
Repeat a commit with the same
idempotency_keyand it returns the original result for 100,000 revisions. A503unknown outcome is always safe to retry. -
Cheap per-tenant isolation
An idle database is one 146-byte object. Each database gets its own signed token (checked before reading the body), byte quota, rate limit, and one-call revocation.
-
No persistent volumes
Runs as an ordinary Kubernetes Deployment with a HorizontalPodAutoscaler. Stopping pods hand databases over gracefully; killed pods lose nothing.
-
Automatic versioned cleanup
The owner removes superseded frames, tables, and old object versions in batches of up to 1,000. No bucket lifecycle rules needed.
-
SDK & agent storage ready
Zero-dependency TypeScript client, Prometheus metrics, readiness probe, and a built-in storage adapter passing
pi-durable's full conformance suite.
Read the details in HTTP API, TypeScript SDK, tokens and tenants, and Kubernetes.
Verification
Modelled in TLA+, tested with chaos and real kills
One TLA+ specification models ownership, commits, linearizable reads, retries, checkpoints, collection, late deletes, and database deletion. The Rust engine mirrors it step for step and is tested under fault injection, container S3 stores, and Kubernetes failover.
DeepDeletion (2 writers, 2 epochs, 2 txns + deletion), plus 3.59M core, 4.11M deletion, 659k retry, and 967k late-delete states. Zero invariant violations.
Negative controls
13 of 13
protocol rules individually switched off in TLC and refuted with counterexamples—confirming every rule in the spec is exercised and necessary.
Chaos & kills
200 seeds
of randomized fault injection (dropped, half-applied, and late storage requests, crashes, stale owners), 74 interleaving tests, and 1.94M ledger transfers balanced across 157 stops in 30 min.
Kubernetes + B2
18 cluster runs
on a three-node kind cluster backed by B2 scaling 2 → 5 → 2 with a pod force-deleted. 12,026 to 25,965 transfers balanced in every run; of 9–13M unretried reads alongside, 0–110 failed.
Bounded model checking is evidence about a model—not a proof of the Rust implementation or of every deployment. The verification page records every assumption, what the model leaves out, all 47 defects these tests and reviews found, and the obligations that remain.
Trade-offs & status
Limits, stated plainly
Read these before you choose durable-db.
By design
- One writer per database at a time. Scale throughput by spreading work across more databases, not more servers on one database.
- Storage latency is the floor. A commit costs one upload and one HEAD; a strong read shares one HEAD; session reads hit memory only.
- Single-database transactions, current state only. Transactions do not span databases, and there are no historical reads or point-in-time restore.
- Deleted database names cannot be reused. A permanent tombstone ensures a late upload from a prior owner can never revive deleted data.
- Full rewrites on growth and quota pressure. Merging the oldest table rewrites the database each time it grows by half, and once more when it reaches quota holding overwritten data. Default quota is 1 GiB; databases up to 16 GiB have been measured locally, 4 GiB on MinIO, and 1 GiB on B2.
- Reads beyond both caches hit the bucket per run. Size
--cache-dir-bytesto the working set for reads (2× for zero-download merges). Writes wait with503while a merge would leave more than 24 runs. - Servers trust each other. Cluster peers relay over plain HTTP on a private network and share bucket credentials. Per-tenant CPU accounting and billing are not provided.
Not done yet
- Only Backblaze B2 has been exercised among cloud stores. Amazon S3, Google Cloud Storage, and Cloudflare R2 share the S3 code path (except B2's native upload) but have not been run live. MinIO, RustFS, and Garage pass in single-machine containers.
- No soak of many hours on a real multi-node cluster. Kubernetes failover ran on kind. Memory was level through 10-minute local loads and 20-minute and 1-hour MinIO runs of 256 databases, and still rising within flag budgets after 5–11 minutes on B2—not yet measured for many hours.
- B2 was measured from one desktop over Wi-Fi. That link stalled briefly about once a minute, driving the slowest commits in the tables. A server in a data centre on a wired link has not been measured.
- No self-imposed provider rate cap. Servers back off after eight consecutive refusals of a request kind (tested on stand-ins and a proxy, not yet observed live on B2), and collection falls behind if a store takes over two minutes to answer purges.
- Prebuilt binary is Linux x86_64 only. Other platforms build from source (requires a C compiler and
makefor jemalloc). - No independent external review yet. Reviews so far were automated and commissioned by the project. The TLA+ model checks safety at small bounds, not liveness, receipt-window expiry, or exact check predicates.
Quick start
Run it on one machine, then point it at a bucket
The first three steps need no bucket, container, or external service.
Install the binary
Downloads the Linux x86_64 release, verifies its SHA-256 checksum, and installs
durable-dbin~/.local/bin.curl -fsSL https://ericflo.github.io/durable-db-site/install.sh | shStart a local server
Listens on
127.0.0.1:7654and stores objects in./data. First start generates./data/admin.keyfor signing tokens.durable-db serve --data ./dataCreate a database, write, and read
From a second terminal in the same directory.
durable-db createcreates the database and prints its write token.export URL=http://127.0.0.1:7654/v1/databases/demo export AUTH="Authorization: Bearer $(durable-db create demo)" curl -X PUT $URL/keys/greeting -H "$AUTH" -d '"hello"' # {"revision":1} curl $URL/keys/greeting -H "$AUTH" # "hello"Serve from a bucket
On Backblaze B2, create a private bucket and a key scoped to it. Share one signing key across every server; at startup, each server probes storage and refuses to start if its contract is not met.
openssl rand -hex 32 > admin.key && chmod 600 admin.key export AWS_ACCESS_KEY_ID=<keyID> AWS_SECRET_ACCESS_KEY=<applicationKey> durable-db serve \ --bucket my-bucket \ --endpoint https://s3.us-west-002.backblazeb2.com \ --key-file admin.key
Next: deploy on Kubernetes, use the TypeScript SDK, explore the Hono task-board example, or read the HTTP API.
Documentation
Every page
Generated directly from the Markdown files in the repository.
- OperationsDeploymentInstall the static binary and run it on a laptop, a bucket, or Kubernetes. Configuration, tenant limits, and metrics.
- ReferenceHTTP APITransactions, checks, ordered scans, read consistency levels, idempotency keys, errors, and limits.
- ClientTypeScript SDKZero-dependency typed client with retries and revision tracking, plus the pi-durable agent storage adapter.
- ProtocolArchitectureBucket object layout, taking ownership, commits, reads, compaction, collection, and failure modes.
- BenchmarksPerformanceLocal NVMe, Backblaze B2, large-database, disk-cache, and Kubernetes measurements with commands to reproduce them.
- CorrectnessVerificationClaims, assumptions, the TLA+ model, 13 negative controls, chaos tests, all 47 findings, and remaining obligations.
- SourceDevelopmentBuild from source with kache, run every check and soak script, repository layout, releases, and CI.