News for hackers. Stuff that matters.
Re:SQLite the only database you will ever need in most cases by danielmarkbruce on Wednesday February 15, 2023 @07:32PM (#34813207)
It's a c library. Other languages will have a library/package/whatever to use it. You point it at a file.
Re:SQLite the only database you will ever need in most cases by irskep on Wednesday February 15, 2023 @07:42PM (#34813300)
The sarcasm and intentionally-missing-the-point here is not really in the spirit of HN, but I'll try to address what you seem to be trying to say, which is that "it's obvious and I'm an idiot for not seeing that it's obvious":

- Will multithreading make it break? (Not with WAL mode, but you have to set it manually, as this article suggests.)

- When using a PaaS, you need to explicitly add a volume and mount it on your server machine, which you might not think to do if you're a brand new bootcamp grad

- You can't(?) run migrations from another process (or at least, people don't seem to talk about doing this), so you need to prevent your server from writing while you run the migration. Even if I'm wrong, and I would love to be, it's frustrating that people don't talk about the completely ordinary need to run migrations on a database.

- Backups just mean copying the file somewhere, which is nice, but you might need to configure that yourself instead of just using somebody's managed Postgres backup feature

So, there is at least some complexity that comes with managing a "real" SQLite web server.

(I'm probably at least 25% wrong on some details above, but that's kind of the point, it's not always easy to figure this stuff out.)

Re:SQLite the only database you will ever need in most cases by danielmarkbruce on Wednesday February 15, 2023 @07:51PM (#34813375)
It's not sarcasm. The fact that it's a library and you point it at a file matters, and should be thought about. It implies that it's not built for distributed systems. It's not supposed to be a managed service. It's not a good option for what you appear to want. You deploy it as part of your application.. it's a library.
Re:SQLite the only database you will ever need in most cases by sanderjd on Wednesday February 15, 2023 @08:15PM (#34813600)
> It's not a good option for what you appear to want.

Ok but the article you're replying in the comments to says "SQLite is all you need for nearly everything", and what the comment you're replying to is describing is, to use their very apt word choice, entirely ordinary.

So how do we square this circle of somebody being told both "SQLite is all you need for everything" and "it is not a good option for your totally ordinary use case"?

I think the answer is that you are a different person than the author of the article and you don't agree with the article's claim. Which, great, that was irskep's entire point!

I tend to agree with irskep that this SQLite architecture is really interesting, but I also don't quite get it. There seem to be a lot of missing details for totally bog standard applications, that people frustratingly seem to just not even mention - like the migrations thing, or how to do zero downtime deploys in general, or a few other things - as if those concepts are irrelevant or uncommon. But they aren't, they're important and typical things to think about.

Re:SQLite the only database you will ever need in most cases by danielmarkbruce on Wednesday February 15, 2023 @08:30PM (#34813746)
Third paragraph of the article says:

"In contrast to many other database management systems, SQLite is not a client-server database engine, but you actually very rarely need that. If your application software runs on the same physical machine as the database, which is what most small to medium sized web applications does, then you probably only need SQLite."

That's how we square it. It's right there in the article.

Re:SQLite the only database you will ever need in most cases by butlerm on Wednesday February 15, 2023 @08:59PM (#34813968)
That is a claim, not an explanation. Satisfactory answers need to be provided for the typical requirements that a small to medium web app might have, or the claim is unjustified.

(Nearly) zero down time is a common requirement. Can a live backup be made while transactions are in progress? That appears to be the case. What about schema changes? Can columns or indexes be added without interfering with access to the tables in question? And so on.

Re:SQLite the only database you will ever need in most cases by rakoo on Thursday February 16, 2023 @01:20PM (#34823028)
> (Nearly) zero down time is a common requirement.

Are we still talking about small to medium web apps ? I'm sorry but if HN goes down things will be OK. In fact, there is a very large majority of services that can go down go down and things will still be OK.

Re:SQLite the only database you will ever need in most cases by sanderjd on Wednesday February 15, 2023 @09:16PM (#34814096)
I've realized that this whole thing comes down to the word "most" doing too much duty here. I don't think it's true that most applications just run a single db-and-application node. I've never worked on such an application. You and the author do seem to think this is true. It would be difficult for either of us to support our intuition empirically, so this is where the divide comes from.
Re:SQLite the only database you will ever need in most cases by naniwaduni on Wednesday February 15, 2023 @09:35PM (#34814245)
> I don't think it's true that most applications just run a single db-and-application node. I've never worked on such an application.

Rather than applications you've worked on (many of us spend years on end working on a narrow range of applications), consider software you use (most of us flip between multiple applications every day spanning the gamut of uses). Ignore, for a moment, whatever you know about their implementation, and focus on the user-facing functionality.

Do even half of them logically communication between application nodes?

(Consider that there is still a rich class of software that is fully capable of running locally on the "client"'s computer!)

Re:SQLite the only database you will ever need in most cases by sanderjd on Wednesday February 15, 2023 @11:16PM (#34814944)
Yes I think pretty much all the applications I interact with require fault tolerance and uptime that (to me) seems simpler to implement with separation between application and database nodes.
Re:SQLite the only database you will ever need in most cases by mharig on Thursday February 16, 2023 @08:54AM (#34818582)
So you do not interact with

- Browsers

- Messengers

- The telephone directory of your cellphone

- SMS apps

- The sqlite.org Website

- ...

?

Re:SQLite the only database you will ever need in most cases by danielmarkbruce on Wednesday February 15, 2023 @09:31PM (#34814222)
Yep, that's probably true.
Re:SQLite the only database you will ever need in most cases by pastor_bob on Wednesday February 15, 2023 @08:36PM (#34813801)
Distributed databases are rarely needed. I wouldn't call it an ordinary use case. The article isn't claiming Elon Musk can run Twitter off SQlite
Re:SQLite the only database you will ever need in most cases by sanderjd on Wednesday February 15, 2023 @09:20PM (#34814146)
It is honestly difficult for me to imagine what kind of applications people are working on that have these - to me - very lax reliability constraints. But we're just disagreeing over what "most" applications are like, based on our experiences, without any empirical data to say either way, so :shrug:.
Re:SQLite the only database you will ever need in most cases by yawaramin on Wednesday February 15, 2023 @10:16PM (#34814540)
WordPress is the obvious example of an application that can run like 99% of instances just fine with SQLite.
Re:SQLite the only database you will ever need in most cases by sanderjd on Wednesday February 15, 2023 @11:20PM (#34814972)
Interesting!
Re:SQLite the only database you will ever need in most cases by bravura on Thursday February 16, 2023 @07:55AM (#34818050)
Off-the-top of my head.

* Hobby apps designed for yourself and your friends.

* Hobby apps that you hope will become products but probably won't achieve traction.

* Apps where you're trying a new stack or framework.

* Annotation apps for academia.

Basically, every single app written by people who aren't doing internet facing web dev as their core engineering function.

Also intranet apps as other commenter mentioned.

Re:SQLite the only database you will ever need in most cases by sanderjd on Thursday February 16, 2023 @08:45AM (#34818475)
When I read an article like this that claims some architectural technique is broadly applicable, I don't think it is talking about hobby or just-for-learning applications. Certainly you can do whatever you want with those, but that's not very illuminating.

I'm not sure exactly what you have in mind for annotation apps for academia - things like zotero that run client side? If so, sure, there is a big world of client side software where a database is useful, and I think SQLite (or DuckDB) seems like a no brainer there.

I don't really agree about intranet apps, which are often even more critical to the people using them than an arbitrary consumer app. But I'll grant that for a company that spans a small number of time zones, you can at least have downtime windows outside work hours.

In any case, as I've said all over this thread, the only disagreement here is over what kinds of software is "most". And my intuition for "most" is based on my experience working on and using applications where a lot of effort is made to keep the thing running all the time while still evolving it. Maybe you're all right that "most" software isn't like that.

Re:SQLite the only database you will ever need in most cases by riku_iki on Wednesday February 15, 2023 @10:17PM (#34814549)
you almost always need it if you don't want service interruption because server died.
Re:SQLite the only database you will ever need in most cases by chillfox on Wednesday February 15, 2023 @09:01PM (#34813984)
Most things don't need zero downtime deployment. Now it's nice to have and might be an interesting technical challenge to solve, but it's usually not strictly needed.

edit: when I worked as a sysadmin we would have to schedule outages for updating apps that were designed for zero downtime anyways because those were the processes of the organisation.

Re:SQLite the only database you will ever need in most cases by sanderjd on Wednesday February 15, 2023 @09:18PM (#34814123)
Yeah I've realized this is just a disagreement over the word "most" which won't really be resolvable empirically. It doesn't fit my experience that most applications are single node with lax uptime and failover requirements.
Re:SQLite the only database you will ever need in most cases by chillfox on Wednesday February 15, 2023 @11:50PM (#34815175)
That's fair.
Re:SQLite the only database you will ever need in most cases by mixmastamyk on Thursday February 16, 2023 @01:48AM (#34815815)
There’s likely to be many more intranet apps than customer-facing ones.
Re:SQLite the only database you will ever need in most cases by maxthegeek1 on Wednesday February 15, 2023 @10:54PM (#34814782)
What? I've never worked for a company that would tolerate downtime during deployments. Downtime is ok for personal projects, but not for most business applications.
Re:SQLite the only database you will ever need in most cases by chillfox on Wednesday February 15, 2023 @11:48PM (#34815161)
Most business have daily downtime where the entire business is closed as in not business hours. Being sensitive to downtime is more common for companies that has some kind of online service as their primary product, but most companies are not online companies, or even global companies with offices across all the time zones.

Even for online business some downtime might be acceptable or even preferred. I used to work for a company that made most of it's money through a website and it would take the site offline for 8 hours a few weeks before important events to run a full scale load test on the production infrastructure.

Another place I worked we had to schedule downtime even when updating applications that were designed for zero downtime.

I have never worked a place that didn't allow for downtime or even heard of such a place other than the big tech companies.

Re:SQLite the only database you will ever need in most cases by fomine3 on Thursday February 16, 2023 @12:07AM (#34815287)
scheduled maintenance downtime at night != unplanned failure downtime at random time
Re:SQLite the only database you will ever need in most cases by chillfox on Thursday February 16, 2023 @02:03AM (#34815888)
Correct, but in the context of deploys I would hope they are not random failures, but rather planned events that you do when you have updates to... deploy.
Re:SQLite the only database you will ever need in most cases by maxthegeek1 on Thursday February 16, 2023 @04:32PM (#34826631)
Yes, but you also don't want to have to deploy in the middle of the night in order to avoid downtime during peak hours.

Not only is that a pain for whoever is monitoring the deployment, but now if the deployment breaks something you're going to have to go wake up all of the relevant stakeholders, if you even know who they are.

Not to say late night deployments are never justified, but definitely not something devs want to be doing regularly.

Re:SQLite the only database you will ever need in most cases by chillfox on Friday February 17, 2023 @10:24PM (#34843559)
There’s alternatives like making rollbacks really easy, and then automating it.
Re:SQLite the only database you will ever need in most cases by chillfox on Wednesday February 15, 2023 @08:56PM (#34813947)
I haven't looked into how everyone else does migrations in SQLite.

The way I do it is to check the DB version `PRAGMA user_version;` on application start and run migrations if required, before the app starts taking connections. Yes, this means my app will be unavailable for a few seconds when upgrading. If you want a zero downtime solution then you will have to do it in a different way.

Re:SQLite the only database you will ever need in most cases by paranoidrobot on Wednesday February 15, 2023 @07:38PM (#34813267)
"Just point it a file" skips all the bits you need for a production system.

How do you back it up, replicate it, handle two different processes/containers/servers wanting to access the same data.

Using a PAAS solution for a database, you get all that functionality.

Re:SQLite the only database you will ever need in most cases by samtho on Wednesday February 15, 2023 @07:46PM (#34813331)
I think the point to be learned here is that SQLite fundamentally does not fit in a PaaS model. They are even transparent with this limited use case[0]. I work with embedded systems so I use it a lot, and all the web work I do nowadays is one-off project site and small utilities that are usually a single process so I end up use SQLite 90% of the time I’m reaching for a solution.

0: https://www.sqlite.org/whentouse.html

Re:SQLite the only database you will ever need in most cases by irskep on Wednesday February 15, 2023 @07:51PM (#34813380)
I think it's more that PaaS vendors aren't interested in first-class SQLite support when they can sell overpriced managed Postgres instead. Sure, it doesn't scale the same way, so it's hard to move upmarket and sell to Enterprise, but it's a shame that there's no one-click solution like there is for a managed database.
Re:SQLite the only database you will ever need in most cases by azurelake on Thursday February 16, 2023 @12:51AM (#34815552)
Let's say the following product existed:

1. You can only run one instance of your app.

2. There is a small window of downtime each deploy.

3. Your app has access to 10 GB of storage. The storage is persisted across deploys and can be used for sqlite.

4. Your sqlite data is automatically backed up and can be restored / downloaded as needed.

How much per month would you pay for that product?

Re:SQLite the only database you will ever need in most cases by irskep on Thursday February 16, 2023 @01:08AM (#34815646)
Interesting question. I think you could probably get those features by deploying Piku or Dokku for like $4/mo on a VPS, and the equivalent managed Postgres on Render would be like $20/mo (16GB SSD), so something like $6-10 seems like the right range to me. Maybe not a booming business, but a nice margin percentage and worth paying for good UX. And the cheap version doesn't need to be the only version if people want more RAM, etc.

I'd find such a product really appealing, especially with a dedicated backup strategy that uses the SQLite backup API to do hourly snapshots or uses Litestream to S3 by default.

Re:SQLite the only database you will ever need in most cases by azurelake on Thursday February 16, 2023 @02:25AM (#34816008)
Let's say the price was 12. If this idea is compelling enough for you at that price point to venmo me an advance for your first month, I have some ideas to explore that could actually make this viable. FWIW, I've worked professionally on a PaaS and a managed database offering.
Re:SQLite the only database you will ever need in most cases by canadiantim on Thursday February 16, 2023 @09:38AM (#34819188)
If you make it so I can have one SQLite database per user, I’d be a customer too
Re:SQLite the only database you will ever need in most cases by azurelake on Thursday February 16, 2023 @10:08AM (#34819640)
When you say per user, you mean per user of your app?
Re:SQLite the only database you will ever need in most cases by canadiantim on Thursday February 16, 2023 @12:20PM (#34821761)
yeah exactly. I want each user's data to be silo'd in their own sqlite database each. It's basically just a multi-tenant setup using sqlite.
Re:SQLite the only database you will ever need in most cases by azurelake on Thursday February 16, 2023 @01:51PM (#34823727)
Cool, thanks for the clarification!
Re:SQLite the only database you will ever need in most cases by bravura on Thursday February 16, 2023 @07:59AM (#34818087)
$20 per month assuming:

* Someone who knows Django but has zero devops skills can deploy my app with a few simple commands, add a fix, and demo it to me. Crucial: They must ask me zero questions.

* The backups happen to a non-you service, I one-click auth my google drive and/or dropbox.

* There are instructions on how to stand-up the web app on another service if you shut down. Those instructions might require two hours of my time, but should be complete.

Re:SQLite the only database you will ever need in most cases by cldellow on Thursday February 16, 2023 @11:04AM (#34820438)
I'd probably be willing to pay ~$10/mo. i.e. a 100% markup on a low-end $5 VPS box.

...but in addition to bravura's requirements, I'd add: I'd want SSL termination, ideally with the option of me bringing a custom domain.

Re:SQLite the only database you will ever need in most cases by danielmarkbruce on Wednesday February 15, 2023 @07:46PM (#34813334)
That's why "most cases".

If you are trying to replicate or make available to a bunch of machines or similar - it's likely the wrong thing (although there are tools to do this, I've never used them). If you are just trying to back it up there is a pretty simple back up command.

Re:SQLite the only database you will ever need in most cases by paranoidrobot on Wednesday February 15, 2023 @11:04PM (#34814853)
I think we disagree on the "most cases" aspect that

For most of the things I touch, having a single-point-of-failure data store is typically not acceptable for production environments, except perhaps caching.

Re:SQLite the only database you will ever need in most cases by danielmarkbruce on Wednesday February 15, 2023 @11:34PM (#34815065)
If you are a good software engineer, you probably work at a place that needs good software engineers, which by definition tends to be a place with a system that needs high availability or low latency or both or something else all of which basically results in a pretty complicated distributed system...

So in your day to day job as a good software engineer, yeah sqlite isn't going to be a good choice. It doesn't work well for the sorts of systems you work on. But if you were going to build a new social network for your college or something trivial like that, and you just want to move fast and have a crazy simple deployment setup, you might well use sqlite.

Re:SQLite the only database you will ever need in most cases by lelandbatey on Wednesday February 15, 2023 @08:09PM (#34813556)
It's a file is relevant. It allows you to think of it like other files:

- how do you back up a JPG? You copy it, cause it's a file

- how do you replicate it? You copy it, cause it's a file. Unless you're talking about fancy DB replication, in which case well, that's not really a thing we do with files much. You'll have to do more research. but that's cause you're trying to do non-file things to a file.

- how do you handle two different processes accessing a JPG? They both open and read the JPG. Same for SQLite. For other concerns, you're trying to do things that don't map well to files, so once again more research needed.

Re:SQLite the only database you will ever need in most cases by billyhoffman on Wednesday February 15, 2023 @08:28PM (#34813724)
Only you can’t copy it if it’s in the middle of a transaction or you corrupt it and have to roll back the Journal. And coping the journal, WAL, and DB itself directly and trying to backup from that isn’t recommended. In fact SQLite itself has a purpose built backup API.

https://www.unixsheikh.com/articles/sqlite-the-only-database...

Yes, technically a SQLite database is just a file on disk. And for the most part, you can treat it like other files on disk. Except for when you can’t. The GP’s questions are valid

Re:SQLite the only database you will ever need in most cases by sanderjd on Wednesday February 15, 2023 @08:22PM (#34813665)
I don't update and append to jpgs though...
Re:SQLite the only database you will ever need in most cases by aembleton on Thursday February 16, 2023 @04:37AM (#34816752)
how do you handle two different processes writing to a JPG?