Thursday, January 26, 2023

Litestream + LiteFS: Distributed SQLite by Fly.io

I Migrated from a Postgres Cluster to Distributed SQLite with LiteFS

by Kent C. Dodds

Litestream was originally created to improve reliability of SQLite in edge cases (specifically, disaster recovery), but the way this was done also lends itself well to the idea of distributed SQLite deployments.

LiteFS

Litestream has had "read-replicas" as a desired future feature for over a year. LiteFS...  works similarly to Postgres clusters. One LiteFS node is the "primary" and other nodes automatically replicate data writes. LiteFS acts as a proxy to your SQLite database (you connect to LiteFS instead of the underlying database) and then LiteFS effectively replays data updates to all read replicas. And this reply happens behind the scenes normally within 200ms (on par with distributed Postgres clusters).

LiteFS allows us to get distributed SQLite...

Additionally, SQLite data access is much faster than Postgres...


Litestream.io - Streaming SQLite Replication

Continuously stream SQLite changes to AWS S3, Azure Blob Storage, Google Cloud Storage, SFTP, or NFS. Quickly recover to the point of failure if your server goes down.

Runs as a separate process so you can integrate into existing applications with no code changes.

Only costs pennies per day. Object storage is cheap so there's no need to waste money on additional servers.


benbjohnson/litestream: Streaming replication for SQLite. @GitHub


I'm All-In on Server-Side SQLite · Fly




No comments: