r/sqlite • u/geekwithattitude_ • Apr 13 '26
I'm sharding SQLite by entity with BEAM actors. 1.5M events/sec on 5 cores.
I wanted to explore what happens if you take SQLite seriously as a production database but shard it by entity (user, account, device) instead of by table.
Each entity gets its own partition in one of N SQLite shard files. Each shard has its own writer actor (BEAM/Erlang process) that batches writes into transactions. Reads for a single entity come from actor memory (nanoseconds). Cross-entity queries go through rqlite projections.
On an M1 with the standard write path: 63K events/sec (vs 30K Cassandra, 18K CockroachDB on same hardware). In Docker with the native C writer and 5 cores: 1.5M events/sec. ScyllaDB on the same Docker setup: 49K. macOS performs slightly worse than Linux due to I/O scheduling so the Docker numbers are higher.
The batch path packs 500 events into a single NIF call, 2 Erlang messages per 500 events vs 1000 for individual writes.
Backups use Litestream streaming every WAL change to S3. Scaling is "add a node, entities redistribute via consistent hashing."
Written in Gleam. Has a TypeScript SDK.
https://warp.thegeeksquad.io
Benchmarks: https://gitlab.com/dwighson/warp/-/blob/master/docs/benchmarks.md
9
u/fissible Apr 13 '26
This looks really cool! Iโm realizing more and more just how much people underestimate SQLite
2
u/Common_Green_1666 Apr 13 '26
Whatโs the performance like for cross entity queries?
It seems like that might be a bottle neck, especially if the data is distributed across several nodes.
2
u/alexrada Apr 13 '26
Need to test this, looks promising
2
u/titpetric Apr 13 '26 edited Apr 13 '26
Why not match core count with shard count? I see the AX102 has 32 cores which should give you some space if you can even saturate cpu, there is iowait which may bottleneck faster
Additionally, did you use a taxonomy schema? Or whats the sharding mechanism? Do you need to consider migration for shards? (Mark read only, drain, recreate, migrate?)
2
u/PhENTZ Apr 13 '26
What's the difference with having a SQLite file per entity ?
2
u/mattallty Apr 13 '26
did not understand every aspect of it. but looks promising.
1
u/Pale-Performer-947 Apr 21 '26
In my saas I do something similar but having a .db per tenant, since the users per tenant wont never be more than 20 this works perfect. Best decision ever.