From libSQL to Rust Rewrite: The Architectural Evolution of TursoDB
Why the Turso team moved from maintaining a C fork of SQLite (libSQL) to building an async, MVCC-capable SQLite engine from scratch in Rust.
For twenty-five years, SQLite has been the most widely deployed database engine on earth—embedded in phones, browsers, aircraft, and developer laptops. Yet when teams tried to bring SQLite into cloud-native, multi-tenant, and AI agent workloads, two architectural walls appeared: synchronous C I/O and single-writer locks.
Phase 1: libSQL — Opening SQLite to the Cloud
When Turso launched libSQL as an open-contribution fork of SQLite, the mission was practical and urgent:
- Add an official HTTP/WebSocket protocol (
Hrana) so serverless runtimes like Cloudflare Workers could talk to SQLite without persistent TCP pools. - Build
sqldin Rust to manage replication, WAL frame streaming, and Embedded Replicas. - Ship native vector types (
F32_BLOB) and randomized/custom extensions directly inside the database.
libSQL proved that SQLite could power millions of lightweight databases in production. However, patching a decades-old C codebase whenever you want fundamental storage changes—such as true async I/O or lock-free MVCC—becomes exponentially harder over time.
Phase 2: Rewriting SQLite in Rust (Limbo → TursoDB)
Rather than fighting C’s synchronous assumptions forever, the team began a clean-room rewrite in Rust—initially codenamed Limbo, and now the foundation of TursoDB.
What Changes Under the Hood?
- Step-Driven Virtual Machine: Instead of blocking an OS thread when a B-tree page is missing from cache, the bytecode VM yields an I/O request and resumes once
io_uringcompletes it. - MVCC Concurrent Writes:
BEGIN CONCURRENTremoves the classic “database is locked” error under concurrent multi-writer workloads. - Deterministic Simulation Testing: Every I/O syscall goes through a pluggable trait, making it possible to simulate disk corruption, out-of-order writes, and power failures reproducibly in CI.
- Native Local-First Sync: Turso Sync treats local writes as first-class operations rather than mere read-only caches.
Which One Should You Use Today?
- Production serverless apps needing battle-tested Drizzle/Prisma support today:
@libsql/client+ Turso Cloud or self-hostedsqldremains rock-solid. - Rust native apps, local-first desktop tools, and concurrent embedded workloads: Start experimenting with the native
tursoRust crate and track compatibility milestones as TursoDB reaches full parity.
Community Discussion
Have benchmarks, migration notes, or questions about this topic? Join the conversation with fellow TursoDB developers.