Hacker News Viewer

Litestream VFS

by emschwartz on 12/11/2025, 5:59:10 PM

https://fly.io/blog/litestream-vfs/

Comments

by: psanford

Oh hey this is using my go sqlite vfs module[0]. I love it when I find out some code I wrote is useful to others!<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;psanford&#x2F;sqlite3vfs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;psanford&#x2F;sqlite3vfs</a>

12/11/2025, 7:39:39 PM


by: bencornia

&gt; What we’re doing here is instantaneous point-in-time recovery (PITR), expressed simply in SQL and SQLite pragmas.<p>&gt; Ever wanted to do a quick query against a prod dataset, but didn’t want to shell into a prod server and fumble with the sqlite3 terminal command like a hacker in an 80s movie? Or needed to do a quick sanity check against yesterday’s data, but without doing a full database restore? Litestream VFS makes that easy. I’m so psyched about how it turned out.<p>Man this is cool. I love the unix ethos of Litestream&#x27;s design. SQLite works as normal and Litestream operates transparently on that process.

12/11/2025, 7:24:58 PM


by: zackify

This is great... just got it working using bun:sqlite! Just need to have &quot;LITESTREAM_REPLICA_URL&quot; and the key id and secret env vars set when running the script.<p><pre><code> import { Database } from &quot;bun:sqlite&quot;; Database.setCustomSQLite(&quot;&#x2F;opt&#x2F;homebrew&#x2F;opt&#x2F;sqlite&#x2F;lib&#x2F;libsqlite3.dylib&quot;); &#x2F;&#x2F; Load extension first with a temp db const temp = new Database(&quot;:memory:&quot;); temp.loadExtension(&quot;&#x2F;path&#x2F;to&#x2F;litestream.dylib&quot;, &quot;sqlite3_litestreamvfs_init&quot;); &#x2F;&#x2F; Now open with litestream VFS const db = new Database(&quot;file:my.db?vfs=litestream&quot;); const fruits = db.query(&quot;SELECT * FROM fruits;&quot;).all(); console.log(fruits);</code></pre>

12/11/2025, 9:33:10 PM


by: simonw

This is such a clean interface design:<p><pre><code> export LITESTREAM_REPLICA_URL=&quot;s3:&#x2F;&#x2F;my-bucket&#x2F;my.db&quot; export AWS_ACCESS_KEY_ID=&quot;your-access-key&quot; export AWS_SECRET_ACCESS_KEY=&quot;your-secret-key&quot; sqlite3 .load litestream.so .open file:&#x2F;&#x2F;&#x2F;my.db?vfs=litestream PRAGMA litestream_time = &#x27;5 minutes ago&#x27;; select * from sandwich_ratings limit 3;</code></pre>

12/11/2025, 8:05:21 PM


by: honktime

I dont fully understand this, would this be useful for scaling sqlite on systems that have really high read needs and a single writer? I thought that was what LiteFS was for, or am i off on that too?

12/11/2025, 10:29:46 PM


by: indigodaddy

This is awesome. Especially for sqlite db’s that are read only from a website user perspective. My use case would be an sqlite DB that would live on S3 and get updated by cron or some other task runner&#x2F;automation means (eg some other facility independent of the website that is using the db), and the website would use litestream vfs and just make use of that “read only” (the website will never change or modify the db) db straightup. Can it be used in this described fashion? Also&#x2F;if so, how will litestream vfs react to the remote db updating itself within this scenario? Will it be cool with that? Also I’m assuming there is or will be Python modules&#x2F;integration for doing the needful around Litestream VFS?<p>Currently on this app, I have the Python&#x2F;flask app just refreshing the sqlite db from a Google spreadsheet as the auth source (via dataframe then convert to sqlite) for the sqlite db on a daily scheduled basis done within the app.<p>For reference this is the current app: (yes the app is kinda shite but I’m just a sysadmin trying to learn Python!) <a href="https:&#x2F;&#x2F;github.com&#x2F;jgbrwn&#x2F;my-upc&#x2F;blob&#x2F;main&#x2F;app.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jgbrwn&#x2F;my-upc&#x2F;blob&#x2F;main&#x2F;app.py</a>

12/11/2025, 7:08:49 PM


by: ncruces

I also have this implemented and ready to go in my Go SQLite driver: <a href="https:&#x2F;&#x2F;github.com&#x2F;ncruces&#x2F;go-sqlite3&#x2F;blob&#x2F;main&#x2F;litestream&#x2F;example_test.go" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ncruces&#x2F;go-sqlite3&#x2F;blob&#x2F;main&#x2F;litestream&#x2F;e...</a><p>Slightly different API (programmatic, no env variables, works with as many databases as you may want), but otherwise, everything should work.<p>Note that PRAGMA litestream_time is per connection, so some care is necessary when using a connection pool.

12/11/2025, 9:52:08 PM


by: joshstrange

I work with many distributed, often offline, hosts with varied levels of internet speeds. Does this do any offline caching? Like if I load a vfs litestream database on one of my nodes and it goes offline can it still query or will it fall over unless the data was recently fetched?

12/11/2025, 10:04:00 PM


by: darintay

Does this work with sqlite extensions? If I were using e.g. sqlite-vec or -vss or some other vector search extension would I be able to use litestream to back it up to S3 live, and then litestream-vfs to query it remotely without downloading the whole thing?

12/11/2025, 8:21:38 PM


by: dangoodmanUT

I&#x27;m glad they did this! I&#x27;ve always thought VFS was a better fit for the objectives of Litestream than the original design.<p>SQLite VFS is really cool tech, and pretty easy to work with (IMO easier than FUSE).<p>I had made a _somewhat similar_ VFS [1] (with a totally different set of guarantees), and it felt pretty magical how it &quot;just worked&quot; with normal SQLite<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;danthegoodman1&#x2F;gRPSQLite" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;danthegoodman1&#x2F;gRPSQLite</a>

12/11/2025, 9:12:37 PM


by: chickensong

As a sandwich enthusiast, I would like to know more about these sandwich ratings.

12/11/2025, 8:11:26 PM


by: skybrian

This sounds pretty cool, but I’m confused about what software being announced. Is there a new release of Litestream?

12/11/2025, 6:44:29 PM


by: orliesaurus

Been tinkering with litestream... the read-only VFS is neat but I&#x27;m curious about eventual write capabilities... using VFS for distributed DBs could unlock some interesting patterns.<p>ALSO I&#x27;m thinking about mixing this with object store caching... maybe combining memfs with remote metadata; would love to see more details on performance.<p>BUT I might be overthinking it... just excited to see SQLite exploring beyond local files...

12/11/2025, 7:06:57 PM


by: dzonga

dumb question: can this be used for versioned tables then ? what to see the state of a table 1 hour ago ?

12/11/2025, 7:26:37 PM


by: hintoftime

Does this mean that I can run an application in K8s via one or many horizontally scaled pods all running off DB in s3? No StatefulSet required?

12/11/2025, 6:39:50 PM


by: born-jre

more goodies nice!<p>I am going to integrate Litestream into the thing I am going to building[1]. I experimented with a lot of ways, but it turns out there is WebDAV support recently merged, not in the docs.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;blue-monads&#x2F;potatoverse" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;blue-monads&#x2F;potatoverse</a>

12/11/2025, 6:38:41 PM


by: jauntywundrkind

So much fun streaming&#x2F;sync&#x2F;cdc stuff happening, all so cool. Having an underlying FUSE driver doing the Change Data Capture is really neat. This looks like such an incredibly lightweight way to remote-connect to sqlite. And to add a sort of exterior transaction management.<p>Different use case, but makes me think of sqlite Rewrite-it-it-Rust Turso announcing AgentFS. Here the roles are flipped, sqlite is acting as a file store to back FUSE, to allow watching&#x2F;transaction-managing the filesystem&#x2F;what agents are doing. Turso also has a sick CDC system built in, that just writes all changes to a cdc table. Which is related to this whole meta question, of what is happening to my sqlite DB. <a href="https:&#x2F;&#x2F;turso.tech&#x2F;blog&#x2F;agentfs" rel="nofollow">https:&#x2F;&#x2F;turso.tech&#x2F;blog&#x2F;agentfs</a>

12/11/2025, 6:42:31 PM


by: rekwah

Now do this with DuckDB.

12/11/2025, 7:18:33 PM


by: petcat

Are people still trying to shoehorn sqlite to run in a server-side context? I thought that was a fad that everyone gave up on.

12/11/2025, 6:20:24 PM


by: itissid

Really nice. We should have this as an add-on to <a href="https:&#x2F;&#x2F;app.codecrafters.io&#x2F;courses&#x2F;sqlite&#x2F;overview">https:&#x2F;&#x2F;app.codecrafters.io&#x2F;courses&#x2F;sqlite&#x2F;overview</a> It can probably teach one a lot about the value of good replication and data formats.<p>If you are not familiar with data systems, havea read DDIA(Designing Data Intensive Applications) Chapter 3. Especially the part on building a database from the ground up — It almost starts with sthing like &quot;Whats the simplest key value store?&quot;: `echo`(O(1) write to end of file, super fast) and `grep`(O(n) read, slow) — and then build up all the way to LSMTrees and BTrees. It will all make a lot more sense why this preserves so many of those ideas.

12/11/2025, 7:21:27 PM