Ask HN: Have you used SQLite as a primary database?
518 pointsI periodically hear about projects that use/have used sqlite as their sole datastore. The theory seems to be is that you can test out an idea with fewer dependencies (and cost) and that it scales surprisingly far.
There are even distributed versions being built for reliability in the cloud: dqlite by canonical (of Ubuntu fame) and rqlite
Given the complexity it seems like there are use cases or needs here that I'm not seeing and I'd be very interested to know more from those who've tried.
Have you tried this?
Did it go well? Or blow up?
Were there big surprises along the way?
- https://sqlite.org
- https://dqlite.io
- https://github.com/rqlite/rqlite
Comments (325) 124 threads
Earlier commentsThis means it won't cost any money if it's not receiving any traffic, and it can scale easily by launching additional instances.
I wrote about my patter for doing this, which I call Baked Data, here: https://simonwillison.net/2021/Jul/28/baked-data/
A few examples are listed here: https://datasette.io/examples
How do you handle this? Do you store the SQLite file somewhere like s3 or just in memory?
How does this work for such high traffic sites?
Then I thought this is great and makes it easier to move the db file if it just has 1 table. So I can download it easily for local dev for ex.
And yes in case there's corruption which never rly happens, only one file thus table would be affected.
PS: one thing that really helped reduce issues was setting PRAGMA MODE to WAL
For example, Linux limits the number of file descriptors to 1024 per process to each process can open up to 1024 files at any point in time.
I ran into this problem in the past in another project (the system ran out of file descriptors for another reason).
SQLite may shine in edge cases where you know you can outperform a regular database server and you know why, and you could build everything either way. SQLite could be a way to e.g. decentralize state, using local instances to do local storage and compute before shipping off or coordinating elsewhere.
Otherwise, SQLite can simply be a recipe for lots of lock errors on concurrent operations. I've also never been very impressed with its performance as a general purpose replacement for postgres or MySQL.
Yes, I learned this the hard way. I understood that simplicity meant limitations, but I did not understand that simplicity meant danger until SQLite burned me.
If your perf tanks, you don't want to have to spend days putting timers all around someone else's codebase. Caveat: SQLite may be better these days -- my incident happened in 2013 -- but I spent more time tracking that one SQLite issue than I have spent spinning up postgres instances since then.
All comments shown.
Couldn't load more comments. Check your connection and try again.