The number of SQLite hosting companies abounds, and I saw another added today, Bunny Database. While I admire these companies and think the work they do is cool, I do not find their work useful. The reason being, while I like SQLite, I think hosted SQLite is not needed. In this article I hope to make the case that these companies should work on something else, given that money and effort is finite.
Hosted SQLite destroys its strengths
Here is how I view SQLite’s strengths, and how a hosted version undermines them. Even SQLite documentation states that once there’s a network boundary, go elsewhere.
| Strength | When Hosted |
|---|---|
| No configuration | Add several drop downs and buttons seen in your providers web UI |
| No network boundary | Add at least 15-20 ms per trip, best case |
| Reliable | Not the hosted implementation, random timeouts and no transactions (D1) |
| Easily access data | No more sqlite3 example.db, now it’s a web UI or figuring out libsql:// |
| Free | An example.db costs $0, but now you’re billed by the row |
| Simple | Sidecars with Litestream, no transactions with D1, and libSQL with Turso |
Another route to go is what fly.io has promoted, where you keep the SQLite database coupled with your
application, but you do backups/replicas via Litestream/LiteFS.
To run and test Litestream locally, the documentation
recommends using Docker to install minio. You also have to run an additional process as a sidecar
with your application in production.
Overgeneralizing, why not use a PostgreSQL image for development and a managed database
in production and be done with it? Maybe this makes sense if you’re doing a bunch of N+1
queries, but collapsing those isn’t hard.
If you need SQLite replicas or more than the occasional sqlite3_rsync,
you’ll run into other SQLite limitations to the point where it’s worth using a full RDBMS.
You should never have to pay for, or have added complexity when using example.db.
Conclusion
SQLite is awesome when your schema changes little, the data model is simple and local, and you’re sticking to
the basics. It’s great for offline devices, $compute at the edge™, low resources, etc. However, if
you’re at the point where you need to pay for a database in the cloud, you’ll want
to consider if you’ll ever need better ALTER TABLE support, the niceties of having fully fleshed RETURNING /
CTE / EXPLAIN, concurrent writers, roles, monitoring, etc. If so, I’d consider something else.