Show HN: SQLite for Rivet Actors – one database per agent, tenant, or document
42 points| NathanFlurry | 1 day ago |github.com
Today we've released SQLite storage for actors (Apache 2.0).
Every actor gets its own SQLite database. This means you can have millions of independent databases: one for each agent, tenant, user, or document.
Useful for:
- AI agents: per-agent DB for message history, state, embeddings
- Multi-tenant SaaS: real per-tenant isolation, no RLS hacks
- Collaborative documents: each document gets its own database with built-in multiplayer
- Per-user databases: isolated, scales horizontally, runs at the edge
The idea of splitting data per entity isn't new: Cassandra and DynamoDB use partition keys to scale horizontally, but you're stuck with rigid schemas ("single-table design" [3]), limited queries, and painful migrations. SQLite per entity gives you the same scalability without those tradeoffs [2].
How this compares:
- Cloudflare Durable Objects & Agents: most similar to Rivet Actors with colocated SQLite and compute, but closed-source and vendor-locked
- Turso Cloud: Great platform, but closed-source + diff use case. Clients query over the network, so reads are slow or stale. Rivet's single-writer actor model keeps reads local and fresh.
- D1, Turso (the DB), Litestream, rqlite, LiteFS: great tools for running a single SQLite database with replication. Rivet is for running lots of isolated databases.
Under the hood, SQLite runs in-process with each actor. A custom VFS persists writes to HA storage (FoundationDB or Postgres).
Rivet Actors also provide realtime (WebSockets), React integration (useActor), horizontal scalability, and actors that sleep when idle.
GitHub: https://github.com/rivet-dev/rivet
Docs: https://www.rivet.dev/docs/actors/sqlite/
[1] https://news.ycombinator.com/item?id=42472519
[2] https://rivet.dev/blog/2025-02-16-sqlite-on-the-server-is-mi...
fastball|1 day ago
There have been some small issues but nothing show-stopping, and the Rivet team has been very responsive to help get things sorted (or help us understand when it was us doing something wrong).
Not using the SQLite datastore yet, but I am excited about the possibilities!
NathanFlurry|1 day ago
o175|10 hours ago
fastball|2 hours ago
Personally I think the benefits of lazy outweigh the downside of that single 30s request, but to each their own.
siliconc0w|1 day ago
SqliteDB per tenant may make sense, not sure about per actor. You really don't want to re-implement database transactions.
NathanFlurry|1 day ago
swaminarayan|1 day ago
NathanFlurry|1 day ago
However, we are planning on building a query engine that can operate over multiple databases. One option we're considering is exposing Rivet SQLite as a DuckDB datasource: https://duckdb.org/docs/stable/data/data_sources
ZeroAurora|1 day ago
Would it be interesting to write about comparisons against Cloudflare Durable Object to the project README? Both for clarity and marketing reasons.
NathanFlurry|1 day ago
malkosta|1 day ago
NathanFlurry|1 day ago
We're taking a different approach of building the best actor primitive for mainstream languages and letting people build a thin AI layer on top. We did not set out out build for AI when we started it, it was a happy accident.
nudpiedo|1 day ago
Better usage of resources and it always allows a parent style agent do complex queries (e.g: intersection of two different actors data doesn’t need to fetch all, copy and do it in buggy non sql code)
NathanFlurry|1 day ago
In our experience, most apps don't need cross-tenant queries outside of BI. For example, think about the apps you use on a daily basis: Linear, Slack, ChatGPT all fit well with an actor-per-workspace or actor-per-thread model.
To be clear, we're not trying to replace Postgres. We're focused on modern workloads like AI, realtime, and SaaS apps where per-tenant & per-agent databases are a natural fit.
Using SQLite for your per-tenant or per-agent databases has a lot of benefits:
- Compute + state: running the SQLite database embedded in the actor has performance benefits
- Security: solutions like RLS are a security nightmare, much easier to have peace of mind with full DB isolation per tenant
- Per-tenant isolation: important for SaaS platforms, better for security & performance
- Noisy neighbors: limits the blast radius of a noisy neighbor or bad query to a single tenant's database
- Enables different schemas for every tenant
- AI-generated backends: modern use cases often require AI-generated apps to have their own custom databases; this model makes that easy
A few other points of reference in the space:
- Cloudflare Durable Objects & Agents are built on this model, and much of Cloudflare's internal architecture is built on DO
- https://neon.com/use-cases/database-per-tenant
- https://turso.tech/multi-tenancy
- https://www.thenile.dev/
- Val.town & Replit
> Better usage of resources
I'd be curious to hear more about what you mean by this.
> always allows a parent style agent do complex queries
Do you have a specific use case in mind where agents need to query other agents' data?
nimbus-hn-test|1 day ago
[deleted]
OussamaAfnakkar|12 hours ago
[deleted]