Live data from Hacker News

Learning a few things about running SQLite

jvns.ca

51–60 of 101 posts

Re: Learning a few things about running SQLite

#51
post #37

Earlier quoted context omitted.

To be fair they also say > Generally speaking, any site that gets fewer than 100K hits/day should work fine with SQLite.

So about one per second (up to ten, less conservatively). I concur. But if you think your site might ever scale beyond that, do yourself a favor and use Postgres from the get-go.

SQLite can happily handle thousands of reads and writes per second even on modest hardware.

Re: Learning a few things about running SQLite

#52
post #2

> I’ve been backing up to AWS, which is always a pain because it’s annoying to navigate the AWS console to generate credentials. I got so annoyed with that a few years ago that I ended up building a whole tool just to solve that one problem: uvx s3-credentials create my-existing-s3-bucket This spits out read-write credentials that are scoped JUST for that bucket. You can add --read-only or --write-only to have creden…

Prior art also has https://litestream.io/

Re: Learning a few things about running SQLite

#53
Litestream is super interesting, I managed to get it to run with S3 as a backend. Making apps with sqlite backends (there are a _lot_ lf them) almost stateless, at least no filesystem stare. I feel like s3 state is much more manageable, backups and syncing is done by the provider.

Re: Learning a few things about running SQLite

#55
post #16

It's great! However, it's only meant for local systems. Once you need to connect over a network or robustly handle simultaneous requests, you need something like postgres.

Use WAL (yes this should be the default, or at least explained much better) and you can have one writer, many readers.

Don't move to the network unless you have to - every single request gets massively slowed down because it has replaced local reads with network connections.

Of course if you are building a startup you must consider scaling.

Re: Learning a few things about running SQLite

#56
IMHO for a small DB I’d encourage sending out an email on each successful backup to ensure it’s completed successfully as a safety check, and zipping it up and emailing it to a known account even. With inboxes being able to take gigabytes, it’s a no brainer. This can be done daily or weekly.

And yes, never allow the files to be deleted from outside. The transfer is a one way valve. If uploading, it’s a write-only operation, no delete unless the file has meta data for expiry.

Re: Learning a few things about running SQLite

#57

I run my backups like this: OUT="${i}.sql.zst" PART="${OUT}.part" sqlite3 -readonly "${i}" .dump | zstd --fast --rsyncable -v -o "${PART}" - mv "${PART}" "${OUT}" That doesn't block writers (when the writer uses WAL), and gives me a dump that's compressed well while also being easy to sync. My Home Assistant DB is 1.8GB, my dump is 286MB compressed, and I'd guess 90% of that is consistent from one day to the next.

Nice. I switched to .backup for live DBs because .dump locked me out once. The .part + mv trick is clean though.

Re: Learning a few things about running SQLite

#59
post #50
post #48

Earlier quoted context omitted.

this is pretty brilliant, aws cli should sherlock this. when would you want write only?

For logging, in particular for an environment where you don't want a leaked credential to allow the deletion of any previously recorded files.

does write only prevent overwrites?

Re: Learning a few things about running SQLite

#60
post #59
post #50

Earlier quoted context omitted.

For logging, in particular for an environment where you don't want a leaked credential to allow the deletion of any previously recorded files.

does write only prevent overwrites?

Good point, no it doesn't.
Post reply on HN