Fly.ioExplainer
Skip the API, Ship Your Database
Summary
The post describes an unexpected use for LiteFS, a distributed SQLite database: replacing service-to-service APIs with read-only database replicas. Typical APIs require anticipating access patterns; shipping the full database lets clients use SQL joins, aggregation, and windowing locally, while one-way LiteFS replication avoids chatty gossip and is simple to configure with an upstream primary hostname. Moving queries to client hardware removes shared service compute contention and the need for tenant rate limiting and timeouts, but replicas cannot handle mutations and raw schema changes create looser contracts, mitigated by backward-compatible changes and views. Data access is harder to restrict in multi-tenant databases, so per-tenant SQLite files are a suggested workaround. The approach is positioned for specific read-heavy use cases, potentially including local copies of Stripe or GitHub data, with event buses such as Kafka generating per-tenant databases.
Context
LiteFS was initially intended to distribute data geographically, and its Corrosion test deployment exposed a way to make server state available to internal services without designing an API.
Approach / What changed
Run read-only LiteFS instances downstream from an upstream primary node, streaming a full SQLite database to client services so they can query it locally with SQL. Per-tenant databases can limit data exposure in multi-tenant environments.
Takeaways
Clients can query and join a full local database with vanilla SQL, including aggregation and windowing that the post says GraphQL does not provide as built-in capabilities.
Read-only replicas move query computation onto each tenant’s hardware, reducing concerns about shared resource contention, rate limiting, and query timeouts.
Replicas do not support mutations, and shipping raw schemas makes contract changes harder; backward-compatible schema changes and database views can help preserve compatibility.
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.