Fly.ioProblem & solution
Litestream Writable VFS
Summary
Litestream’s VFS is being extended to support Sprites, whose storage stack needs SQLite-backed block maps to serve writes immediately during cold starts, before a full database or block map is available. The VFS indexes each database page by file, offset, and size in LTX files, serves reads from object storage, and now optionally buffers writes locally before syncing them roughly every second or on clean shutdown. Write mode assumes a single writer, disables polling, and offers only the same eventual durability already provided by Sprite storage. A separate hydration mode serves remote reads while reconstructing a complete database file in the background, then switches reads to that file; the temporary file is discarded on exit. These features target Sprite-like workloads, while ordinary Litestream sidecar deployments do not require them.
Context
Sprites need their SQLite-backed storage stack to serve writes milliseconds after a cold start, even when the full database or its block map has not been downloaded. Object-storage reads help with cold starts but are too slow for steady-state operation, and the original VFS could not write.
Approach / What changed
The VFS adds optional single-writer read-write mode with a local write buffer synchronized to object storage periodically or during clean shutdown. It also adds background hydration, which serves reads from object storage while creating a temporary full database copy and switches to that file when hydration completes.
Takeaways
Writable VFS mode assumes a single writer, disables polling for remote LTX changes, and does not treat writes as durable until the write buffer syncs.
The VFS stores page locations as file, offset, and size entries in LTX files, allowing requested pages to be fetched from object storage and cached without downloading the whole database.
Hydration uses LTX compaction to write only the latest page versions into a temporary full database file; reads continue during hydration, and the file is discarded when the VFS exits.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.