Live data from Hacker News

How (and why) to run SQLite in production

fractaledmind.github.io

81–85 of 85 posts

Re: How (and why) to run SQLite in production

#81

I'm creating a flutter app, I need a database but don't need online storage, local only. SQLite really is the only option for this.

Firebird is sometimes an option.

At first I misread this as firebase but searched for Firebird. I want a local to the device database.

Re: How (and why) to run SQLite in production

#83
post #36

Earlier quoted context omitted.

How it that simplicity? To batch updates makes the code far more complex. To install any full strength DB is trivial. I don't get the 'simplicity'?

That depends entirely on what you're doing. If your workload is heavily transactional, then sure, that might add complexity. The simplicity is not having a separate process that can fail, and that requires fail over, and monitoring.

You're misunderstanding. No-one mentioned transactions, that's not what we're talking about.

We're talking about concurrent writes. We're talking about batching inserts. Because SQLite can't handle a high throughput, so you batch a bunch of inserts together.

If the only way to get performance is to batch inserts, then you've got to write a whole load of manual queue code to queue up X number of inserts to insert them all at once.

Worse still, if your server crashes, bug, etc. you've just lost all those inserts. But you've already responded with 201s! So if you want any sort of guarantee, you've got to write even more code to cache them on disk or redis or something.

You're basically re-implementing features of postgre, badly, to make up for SQLite's deficiencies,

It really doesn't matter HOW you do it, it's the fact you have to do it at all. It's not simpler, it's more complicated. Installing/using a fully fledged DB is trivial these days.

Re: How (and why) to run SQLite in production

#84
post #80
post #68

Earlier quoted context omitted.

But n can be so big that it you never run into it. My company has a read-heavy SQLite-backed service that serves roughly 150,000 daily users with p99.9 at about 5 milliseconds. We did some rough projection and determined we could reach the total addressable market of our product in the US without even approaching having a problem.

How can your company guarantee p99.9 if there is only one instance? Is there any log shipping/duplication etc? Is consistency maintained on one server fault?

p99.9 referring to latency. However, we also do a weekly test of how quickly we recover from a catastrophic crash, which is roughly about 6 minutes (which is the amount of time it takes for the autoscaling group to spin up a new host, Litestream to restore the database from s3, and the server to start up again).

Honestly, 99.9% uptime is pretty generous - we can fit in quite a few catastrophes per year and still have 99.9% uptime. In the 2 years this service has been running, we've had 100% uptime via zero-downtime deployments, anyway.

In terms of monitoring, traces and error logs are shipped to our observability solution, yes.

Re: How (and why) to run SQLite in production

#85

Is there a similar effort for Django? Django Sqlite driver is slow and not tested for production.

It also seems to have the same concurrency issues as described in the article. At least from my experience the "database is locked" error appears quite often.

A rather late reply, but in case anyone is reading this.... Django is basically designed to have sqlite deadlocks, and there's a trivial fix (that the dev team refused to include) that allows fixes the problem and allows you to run up to moderate loads.

https://centraltrunks.blogspot.com/2022/07/django-sqlite-dat...

https://code.djangoproject.com/ticket/29280

(I authored the rant in the first link)

Post reply on HN