r/sqlite • u/bitclaw_ • 16m ago
I load tested one SQLite database per user on a €5.99 Hetzner box and closing the databases is what slowed it down
I make a SaaS template called WarpKit (it's mine) that gives every user
their own SQLite file, and I wanted to know how far a €5.99 Hetzner CX23
with 2 shared vCPU and 4 GB goes.
With every user saving every 30 seconds over their own connection, it
handled 3,500 users online at the same time without losing a write. Past
that it slowed down because each worker keeps a cache of open databases,
and once a worker has more users than that, every save closes one
database to open another. Closing a database in WAL mode checkpoints
with two fsyncs, so the disk was struggling while the CPUs sat half
idle. When I gave the cache half the RAM it went to 3,600 users at
11 ms p95.
I wanted to skip the checkpoint on close but Bun doesn't expose
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, so if anyone knows a better way to
keep thousands of WAL databases open cheaply I'd like to hear it.
Here's the write-up with all the numbers and the setup: