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 commentsBut I've run into on prod that didn't exist in dev on my MacBook M1, and I'm curious if anyone has any suggestions:
My app is basically quiet and serves requests in the dozens (super easy to run on a tiny instance), but for a few hours a day it needs to run several million database transactions, N+1 queries, etc. Because of the high number of IOPS needed, a small instance falls down and runs suuuuuper sluggishly, so I've found myself needing to shut everything down, resize the instance to something with more CPUs, memory, and IOPS ($$$), doing the big batch, then scaling down again. That whole dance is a pain.
Were I using a more traditional postgres setup, I'd probably architect this differently -- the day-to-day stuff I'd run on Cloud Run and I'd spin up a separate beefy instance just for the daily batch job rather than resizing one instance up and down over and over again. The constraint here is that I have a 50GB+ sqlite db file that basically lives on local SSD.
Any thoughts?
Edit: a several hundred million txns over a few hours math. How many per second? ~500
According to here (question 19), for old HDDs you could expect 3 orders of magnitude improvement by using bigger txns. Not sure SSD wise but worth a shot.
https://www.sqlite.org/faq.html
[1] https://www.sqlite.org/cgi/src/doc/begin-concurrent/doc/begi...
Maybe for sqlite because it's stored in ssd, it's only 1-2 minutes to shutdown+change parameter+restart if it's scripted?
The problem is it's the exact kind of pain that I avoid, so many times I just keep the larger (8-core) instance up and just eat the cost. I should probably script this to solve this pain point, but I'd SO rather have a setup that doesn't require this sort of jiggering.
Never tried, but I believe that's how these GCP disk work: https://cloud.google.com/compute/docs/disks#pdspecs
HTTPS: https://vatcomply.com/ Github: https://github.com/madisvain/vatcomply
Client (incident response dept at megacorp) had a problem: their quarterly exercises of switching network storage devices from live servers to disaster recovery (DR) servers was a manual operation of reconciling about 8 Excel spreadsheets and setting up ACLs before (luckily) an automated process would switch the storage mounts from live to DR.
We modeled and matched up all the hosts, servers, and ACLs and did a daily write to a single SQLite database. (We redundantly sent all the data to Splunk.) Now the DR employees are automating a daily diff of servers, hosts, ACLs etc to further automate the switch.
To echo a bunch of comments here, we decided on SQLite for a few reasons:
- only one user would write to the DB - only a few users need to access the data - besides standard retention policies, the data could be considered ephemeral and easily recompiled - the script we wrote to compile the data runs in 5 minutes, so if we lose the db, we can easily recompile it.
SQLite (and SQLalchemy) is useful for inexpensive data.
All comments shown.
Couldn't load more comments. Check your connection and try again.