How Trubase works.

For the technical audience. The Tokio runtime, the timeline storage engine, quorum durability, and the backend lifecycle — explained in depth.

01 — THE RUNTIME

Tokio green-thread multiplexing

Every incoming TCP connection is accepted by tokio::net::TcpListener. Each connection spawns a tokio::spawn async task that runs the full backend lifecycle: handshake → authentication → query loop → response. Each task weighs a few KB of state machine memory.

Tokio's multi-threaded work-stealing scheduler distributes these tasks across all CPU cores automatically. When one core finishes its work, it steals tasks from another core's queue — perfect load distribution. No OS processes. No shared memory segments. No fork().

This is not a proxy sitting in front of Postgres. The Tokio task IS the backend. It runs the wire protocol parser, the SQL lexer, the query executor, the buffer pool lookups, the WAL writes — everything.

02 — STORAGE

The WAL is the database

Trubase DB has no data directory. Committed write-ahead log is the single source of truth; pages are derived from it, materialized on demand at any position in history. State lives as immutable image and delta layers on object storage.

Every read names the point in history it wants to see. That one read path serves live queries, time-travel queries, restores, replicas, and branches — they differ only in which timeline and which moment.

10,000 branches of a backend holding 1TB = 1TB plus only the divergent writes. Storage scales with actual divergence, never with the number of branches.

03 — BOTTOMLESS

Stateless compute, bottomless storage

Engine nodes hold no permanent state — only caches. The layers live on object storage; any node can materialize any backend. When a node dies, its backends re-wake on another node from shared storage.

Durability is layered correctly: a commit returns only after the WAL is acknowledged by a quorum of engine nodes. Layers then upload asynchronously to object storage, which provides eleven-nines durability and effectively infinite capacity.

04 — LIFECYCLE

Backend lifecycle

A backend is a value with a lifecycle: mint → wake → suspend → dispose. Minting allocates nothing — it's a metadata write. Traffic attracts resources automatically; silence releases them.

Suspension is a spectrum, not a switch. First a backend dozes: its tasks drop but its cache stays warm — wake is microseconds. Then it sleeps: cache demoted to local NVMe — wake is sub-millisecond. Finally it hibernates: everything on object storage — one batched storage round trip.

ARCHITECTURE

The full stack

L0
Tokio Runtime
Multi-threaded work-stealing async runtime — millions of backend tasks per engine node
L1
Wire Protocol
PostgreSQL wire protocol v3 — every existing client, ORM, and tool connects unchanged
L2
SQL Parser & Planner
Full SQL parsing and query planning — compiles to Rust async Futures
L3
Execution Engine
Query execution as zero-allocation state machines — no GC, no runtime overhead
L4
Backend Lifecycle
Backends as values: mint, branch, suspend, wake, dispose — metadata operations, milliseconds
L5
Timeline Storage
The WAL is the database — LSN-addressed copy-on-write layers, pages derived at any point in history
L6
Durability Quorum
Commits acknowledged by a quorum of engine nodes before returning — in-core, no external service
L7
Object Storage
Bottomless ground truth — engine nodes hold only caches; layers persist on any S3-class store