---
title: Distributed SQLite with Litestream and LiteFS
url: "https://aaronfrancis.com/videos/distributed-sqlite-with-litestream-and-litefs"
path: "/videos/distributed-sqlite-with-litestream-and-litefs"
type: video
author: Aaron Francis
published: 2024-05-30
topic: Databases
keywords: [litestream, litefs, sqlite, sqlite replication, sqlite backup, ben johnson, fly.io, boltdb, sqlite wal mode, shadow wal, sqlite checkpointing, continuous backup]
youtube_url: "https://www.youtube.com/watch?v=TmZrZFIumhM"
chunked: true
full_bytes: 80129
section_count: 26
full_url: "/videos/distributed-sqlite-with-litestream-and-litefs/full.md"
site_index: "/llms.txt"
keyword_index: "/llms/keywords.txt"
---

# Distributed SQLite with Litestream and LiteFS

## Sections (78.3 KB full document — follow any link to read verbatim)

This page is long enough to hit agent truncation cliffs if fetched all at once. Pick the section matching your question below to read it 100% verbatim (< 35 KB each), or open the [full unsplit document (78.3 KB)](/videos/distributed-sqlite-with-litestream-and-litefs/full.md).

### 1. Introduction (00:00–01:05 · 1.4 KB)
Aaron introduces Ben Johnson and thanks him for his detailed Fly blog articles on distributed SQLite.
Keywords: `introduction`, `johnson`, `sqlite`, `ben`, `recognize`, `color`, `fly`, `working`
[Read section 1 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/1-introduction.md)

### 2. Ben Johnson's Role at Fly.io (01:06–02:29 · 1.9 KB)
Ben works at Fly.io on application hosting and created Litestream to enable SQLite backups on single nodes; previously created BoltDB at Shopify and worked on analytics databases.
Keywords: `johnson`, `ben johnson`, `johnson role`, `fly`, `sqlite`, `ben`, `role`, `fly.io`
[Read section 2 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/2-ben-johnsons-role-at-flyio.md)

### 3. Creating BoltDB for Shopify (02:29–04:45 · 3.5 KB)
Ben wrote BoltDB as a Go port of LMDB after Shopify's analytics database experienced mysterious disk-filling bugs; he eventually wrote his own database after scratching an itch in data visualization and behavioral analytics.
Keywords: `boltdb`, `creating boltdb`, `shopify`, `johnson`, `mm-hmm`, `data visualization`, `actionscript`, `flex`
[Read section 3 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/3-creating-boltdb-for-shopify.md)

### 4. Litestream Overview and Technical Details (04:45–05:56 · 1.7 KB)
Litestream was inspired by BoltDB's speed as an embedded database; Ben wanted to combine SQLite's SQL features with simple application development while solving disaster recovery through continuous incremental backups.
Keywords: `technical details`, `litestream overview`, `technical`, `litestream`, `overview`, `details`, `johnson`, `mm-hmm`
[Read section 4 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/4-litestream-overview-and-technical-details.md)

### 5. Running Databases Next to Applications (05:56–06:58 · 1.5 KB)
Ben recognized that most applications need three-nines uptime, not five-nines, and don't require complex deployments; he created Litestream to minimize data loss through continuous backups without touching SQLite internals.
Keywords: `running databases`, `databases next`, `databases`, `applications`, `sqlite`, `johnson`, `mm-hmm`, `works`
[Read section 5 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/5-running-databases-next-to-applications.md)

### 6. Backing Up SQL Databases with Litestream (06:58–08:10 · 1.5 KB)
Litestream continuously backs up SQLite transactions incrementally every few seconds as a separate process, minimizing catastrophic data loss windows without requiring application-level awareness.
Keywords: `sql databases`, `sqlite`, `backing`, `sql`, `databases`, `litestream`, `johnson`, `data loss`
[Read section 6 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/6-backing-up-sql-databases-with-litestream.md)

### 7. Preventing Data Loss with Continuous Backup (08:10–09:04 · 1.1 KB)
Ben designed Litestream to work outside SQLite without touching its closed-source codebase, using a clever approach to intercept and stream incremental backups.
Keywords: `continuous backup`, `preventing data`, `data loss`, `sqlite`, `preventing`, `data`, `loss`, `continuous`
[Read section 7 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/7-preventing-data-loss-with-continuous-backup.md)

### 8. WAL Mode and Checkpointing in SQLite (09:04–12:13 · 4.1 KB)
SQLite's Write-Ahead Log (WAL) mode separates changes into a WAL file before merging back via checkpointing; Litestream intercepts this process by holding an open read transaction to prevent checkpoints until it captures all changes.
Keywords: `sqlite`, `wal mode`, `wal`, `checkpointing`, `johnson`, `file`, `actual database`, `database`
[Read section 8 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/8-wal-mode-and-checkpointing-in-sqlite.md)

### 9. How Litestream Works and Design Goals (12:13–14:06 · 2.7 KB)
Litestream maintains a long-running read transaction to block SQLite checkpoints, captures WAL data before releasing, then immediately reopens the read transaction to maintain continuous backup streaming.
Keywords: `design goals`, `litestream works`, `works`, `sqlite`, `litestream`, `design`, `goals`, `johnson`
[Read section 9 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/9-how-litestream-works-and-design-goals.md)

### 10. Shadow WAL and Network Latency Handling (14:06–18:02 · 4.7 KB)
Litestream maintains a shadow WAL file to handle S3 outages gracefully; when S3 is unreachable, writes are queued in the shadow WAL and replayed once connectivity returns, keeping the database unfrozen.
Keywords: `network latency`, `shadow wal`, `sqlite`, `wal`, `shadow`, `latency handling`, `network`, `latency`
[Read section 10 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/10-shadow-wal-and-network-latency-handling.md)

### 11. Data Compression and File Recovery (18:02–19:56 · 3.1 KB)
Litestream stores snapshots and incremental WAL files in S3 with LZ4 compression, achieving 16% of original database size; recovery combines a snapshot with replayed WAL files to restore any point-in-time state.
Keywords: `file recovery`, `data compression`, `data`, `recovery`, `compression`, `file`, `johnson`, `mm-hmm`
[Read section 11 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/11-data-compression-and-file-recovery.md)

### 12. Handling Transactions and Shadow WALs in Practice (19:56–22:05 · 2.9 KB)
Litestream's restore command pulls snapshots and WAL files from S3, then uses SQLite to replay transactions; shadow WAL contains checksums to verify consistency after Litestream restarts.
Keywords: `shadow wals`, `wals`, `sqlite`, `handling transactions`, `transactions`, `shadow`, `practice`, `johnson`
[Read section 12 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/12-handling-transactions-and-shadow-wals-in-practic.md)

### 13. Litestream Recovery Process and Best Practices (22:05–24:08 · 2.7 KB)
Litestream leverages 25 years of SQLite's durability handling rather than reimplementing WAL replay; Ben prefers avoiding ownership of that complexity.
Keywords: `best practices`, `sqlite`, `litefs`, `litestream recovery`, `recovery process`, `litestream`, `recovery`, `process`
[Read section 13 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/13-litestream-recovery-process-and-best-practices.md)

### 14. Introducing LightFS for Distributed SQLite (24:09–28:43 · 7.3 KB)
LiteFS uses FUSE (user-level filesystem in Linux) to intercept SQLite operations at the filesystem layer, making it invisible to applications while enabling distributed replication without modifying SQLite.
Keywords: `litefs`, `sqlite`, `distributed sqlite`, `introducing lightfs`, `github`, `file system`, `distributed`, `johnson`
[Read section 14 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/14-introducing-lightfs-for-distributed-sqlite.md)

### 15. Using LightFS as a Custom Filesystem (28:43–31:29 · 3.3 KB)
LiteFS mounts as a custom filesystem between the OS and application; developers point SQLite at the LiteFS mount directory and writes are invisibly replicated to other nodes without application code changes.
Keywords: `litefs`, `custom filesystem`, `sqlite`, `filesystem`, `file system`, `johnson`, `mm-hmm`, `file`
[Read section 15 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/15-using-lightfs-as-a-custom-filesystem.md)

### 16. Failover and Read Replicas with LightFS (31:29–34:34 · 4.3 KB)
LiteFS streams transactions from primary to replicas in under a millisecond plus physical latency; rolling XOR checksums on page changes detect corruption and enable efficient incremental syncing.
Keywords: `read replicas`, `litefs`, `failover`, `replicas`, `johnson`, `fly.io`, `mm-hmm`, `checksum`
[Read section 16 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/16-failover-and-read-replicas-with-lightfs.md)

### 17. Right Forwarding and Application Consistency (34:35–36:04 · 2.0 KB)
LiteFS includes an optional HTTP proxy that ensures application consistency by tracking write transaction IDs and preventing reads until replicas catch up, avoiding out-of-order application state.
Keywords: `application consistency`, `application`, `forwarding`, `consistency`, `johnson`, `mm-hmm`, `sqlite`, `litefs`
[Read section 17 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/17-right-forwarding-and-application-consistency.md)

### 18. Getting Started with LightFS on Fly.io (36:05–37:51 · 2.5 KB)
LiteFS is available on Fly.io as a Docker image; developers copy the binary and run it as a supervisor that proxies application requests, supporting systems like WordPress with minimal configuration.
Keywords: `litefs`, `fly`, `wordpress`, `sqlite`, `fly.io`, `johnson`, `docker image`, `docker`
[Read section 18 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/18-getting-started-with-lightfs-on-flyio.md)

### 19. Vision for Litestream and LightFS (37:52–39:02 · 2.1 KB)
Litestream is single-node disaster recovery only; LiteFS handles distributed replication and failover; LiteFS Cloud is a paid $5/month backup service with point-in-time recovery.
Keywords: `litefs`, `vision`, `litestream`, `johnson`, `lightstream`, `mm-hmm`, `recovery`, `stream`
[Read section 19 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/19-vision-for-litestream-and-lightfs.md)

### 20. LightFS Cloud: A Paid Backup Service (39:03–41:10 · 3.2 KB)
LiteFS Cloud is a paid backup service for LiteFS; Ben is exploring point-in-time recovery exports and keeping the project scope simple rather than adding features like Oracle's complexity.
Keywords: `litefs`, `paid backup`, `lightfs cloud`, `cloud`, `service`, `backup service`, `paid`, `backup`
[Read section 20 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/20-lightfs-cloud-a-paid-backup-service.md)

### 21. SQLite Performance and Simplicity (41:10–43:30 · 3.5 KB)
SQLite and LiteFS share SQLite's philosophy of doing one thing well; Go's standard library analogy shows most applications need far fewer dependencies than modern frameworks require.
Keywords: `sqlite`, `sqlite performance`, `litefs`, `performance`, `simplicity`, `johnson`, `mm-hmm`, `ascii art`
[Read section 21 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/21-sqlite-performance-and-simplicity.md)

### 22. The Growing Popularity of SQLite (43:30–45:29 · 3.1 KB)
SQLite's renaissance is driven by rejection of project complexity and unnecessary dependencies; modern hardware speeds enable SQLite to handle hundreds or thousands of requests per second reliably.
Keywords: `sqlite`, `growing popularity`, `popularity`, `johnson`, `mm-hmm`, `go`, `complexity`, `seems`
[Read section 22 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/22-the-growing-popularity-of-sqlite.md)

### 23. Use Cases for SQLite in Modern Applications (45:30–49:00 · 5.4 KB)
Most applications receive far fewer than one request per second, eliminating the need for complex deployments; SQLite handles hundreds of queries per page with zero network latency overhead.
Keywords: `sqlite`, `modern applications`, `applications`, `mysql`, `modern`, `johnson`, `mm-hmm`, `queries`
[Read section 23 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/23-use-cases-for-sqlite-in-modern-applications.md)

### 24. Future Possibilities: Remote SQLite over SSH (49:00–52:05 · 5.2 KB)
Ben built a proof-of-concept SQLite driver that runs queries over SSH connections, communicating through shell prompts; it works but needs a low-level language rewrite for production use.
Keywords: `sqlite`, `remote sqlite`, `remote`, `ssh`, `future possibilities`, `possibilities`, `johnson`, `mm-hmm`
[Read section 24 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/24-future-possibilities-remote-sqlite-over-ssh.md)

### 25. The SQLite Community and Innovation (52:05–54:09 · 3.6 KB)
The SQLite ecosystem includes Alex Garcia's vector database extensions, Philip O'Toole's RQLite (Raft consensus), Turso, and RedSQLite (Redis clone); projects demonstrate SQLite's flexibility as a foundation.
Keywords: `sqlite`, `sqlite community`, `community`, `innovation`, `johnson`, `mm-hmm`, `key value`, `rqlite`
[Read section 25 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/25-the-sqlite-community-and-innovation.md)

### 26. Where to Follow Ben Johnson (54:10–54:33 · 0.5 KB)
Ben Johnson is active on Twitter and the Fly blog; interested users can open GitHub issues or reach out directly with questions.
Keywords: `follow ben`, `johnson`, `ben johnson`, `ben`, `github`, `active`
[Read section 26 verbatim](/videos/distributed-sqlite-with-litestream-and-litefs/sections/26-where-to-follow-ben-johnson.md)

---

## Related on aaronfrancis.com

- [Migrating from Postgres to SQLite with Kent C. Dodds](/videos/migrating-from-postgres-to-sqlite-with-kent-c-dodds) *(Video · 2024-06-20 · shared: sqlite, litefs, fly.io)*
- [SQLite's WAL mode is fast fast](/videos/sqlites-wal-mode-is-fast-fast) *(Video · 2024-07-10 · shared: sqlite wal mode, sqlite, sqlite performance)*
- [Developer to Business Owner](/podcast/developer-to-business-owner-3adb2856) *(Podcast · 2024-08-06 · shared: sqlite, fly.io)*
- [High Performance SQLite](/courses) *(Course · 2024-07-01 · shared: sqlite, sqlite wal mode)*
- [Morning Person](/podcast/morning-person-ba1c0c8a) *(Podcast · 2024-06-11 · shared: sqlite, ben johnson)*

## Relevant Resources from Aaron Francis

- **[High Performance SQLite](https://databaseschool.com)** (overview on site: [/courses](/courses)): Comprehensive video course on running SQLite in production: WAL mode, concurrency, FTS5, strict tables, backups, and performance tuning.
- **[MySQL for Developers](https://databaseschool.com)** (overview on site: [/courses](/courses)): Full video course covering MySQL indexing, deferred joins, pagination, query plans, and schema design for application developers.

## Search aaronfrancis.com (2-Hop Static Keyword Index)

Pick the alphabetical shard matching any topic to find exact pages across all articles, newsletters, videos, talks, and podcast transcripts (every shard is < 40 KB):
[A-B](/llms/keywords/a-b.txt) · [C](/llms/keywords/c.txt) · [D-E](/llms/keywords/d-e.txt) · [F-G](/llms/keywords/f-g.txt) · [H-J](/llms/keywords/h-j.txt) · [K-L](/llms/keywords/k-l.txt) · [M-N](/llms/keywords/m-n.txt) · [O-P](/llms/keywords/o-p.txt) · [Q-R](/llms/keywords/q-r.txt) · [S](/llms/keywords/s.txt) · [T-Z](/llms/keywords/t-z.txt) · [Directory](/llms/keywords.txt) · [Site Map](/llms.txt)

Shards for this page's topics: `litestream` ([K-L](/llms/keywords/k-l.txt)), `sqlite` ([S](/llms/keywords/s.txt)), `ben johnson` ([A-B](/llms/keywords/a-b.txt)), `fly.io` ([F-G](/llms/keywords/f-g.txt)).

## About Aaron Francis (Current Context)

Aaron Francis is VP of Marketing and Community at [Laravel](https://laravel.com), founder of [Try Hard Studios](https://tryhardstudios.com), creator of [Solo](https://soloterm.com), co-host of [Mostly Technical](/podcast), and author of [Mastering Postgres](/courses), [High Performance SQLite](/courses), [MySQL for Developers](/courses), and [Screencasting.com](/courses). Full bio: [/about](/about) · Current focus: [/now](/now).
