News for hackers. Stuff that matters.
Re:Hctree is an experimental high-concurrency database back ... by zie on Wednesday January 18, 2023 @07:02PM (#34434920)
May I introduce you to https://litestream.io
Re:Hctree is an experimental high-concurrency database back ... by bsaul on Wednesday January 18, 2023 @07:14PM (#34435028)
I don’t see how sqlite replicated to other servers can be faster than any other relational dbs replicated on those same servers, at least without taking more chances to loose data. The limit is most likely network latency anyway, isn’t it ?
Re:Hctree is an experimental high-concurrency database back ... by tptacek on Wednesday January 18, 2023 @07:49PM (#34435315)
Other relational databases require network roundtrips to fetch information from the database once it's replicated. SQLite doesn't. It's a huge performance difference, to the point where it changes how you access your database; for instance, there's not much point in hunting down N+1 query patterns anymore.
Re:Hctree is an experimental high-concurrency database back ... by bsaul on Thursday January 19, 2023 @03:17AM (#34437933)
hm i see.

so the cost is in the initial setup of the client instance, which needs to download the whole database to its local sqlite ?

Re:Hctree is an experimental high-concurrency database back ... by luckylion on Wednesday January 18, 2023 @07:15PM (#34435030)
From what I understand, that streams the file to a separate location, but it doesn't change the file-locking, does it?
Re:Hctree is an experimental high-concurrency database back ... by zie on Thursday January 19, 2023 @10:31AM (#34441345)
Right, for a SQLite based app, you are mostly limited to 1 instance running at any given time(there are multi-node stuff shoved behind SQLite done by 3rd parties, but that's a whole diff. can of worms).

The point being, you run 1 instance and you have litestream replicate to your backup node for HA purposes.

Now you are going to think, what about scaling?!!? How many apps actually need to scale beyond 1 node? Very few. If you run into scaling problems, that is when you deal with solving your scaling problem. Because scaling is unique to each application. But before you remotely think about scaling past one node, you just build the node bigger. Nodes can get pretty massive these days.

Re:Hctree is an experimental high-concurrency database back ... by hamandcheese on Wednesday January 18, 2023 @08:47PM (#34435742)
Litestream didn’t exist until late 2020, meanwhile postgres has existed for decades.

Moreover, SQLite requires the place you run your application to have durable storage, which is a huge departure from the status quo.

It’s definitely neat, but the stack as a whole doesn’t strike me as mature enough to replace Postgres just yet.

Re:Hctree is an experimental high-concurrency database back ... by tptacek on Wednesday January 18, 2023 @09:38PM (#34436102)
You're writing this as if LiteFS and Postgres were basically the same thing, and the selection criteria just boils down to the Postgres pedigree and maybe all the Postgres-specific SQL features. But that's not the case at all. The difference between replicated SQLite and Postgres is that SQLite is in-core: it doesn't have to round-trip on the network to fetch data; it can burn through a large set of N+1 queries faster than Postgres can handle a single select. The difference is that SQLite is much faster.

You sacrifice things to get that speed (Postgres features, set-and-forget write concurrency). Nobody is saying there's no reason to use Postgres, or maybe even that Postgres is the right call most of the time. But the idea that SQLite is rarely appropriate for concurrent serverside applications? It's received wisdom and it's wrong.

Somebody across the thread actually suggested that WordPress was an example of the kind of application that SQLite wouldn't work for, that needed an n-tier database. (Leave aside the fact that WordPress doesn't support SQLite, has instead a longstanding MySQL dependency). WordPress! WordPress is a perfect example of a concurrent serverside application that probably should almost exclusively use SQLite. As I said in a different comment: the whole movement towards static site generators is, in large part, a reaction to how bad n-tier databases are for a very large, popular class of concurrent serverside applications.

Re:Hctree is an experimental high-concurrency database back ... by hamandcheese on Wednesday January 18, 2023 @10:12PM (#34436278)
My second paragraph was specifically talking about the gigantic difference between operating a stateful application vs. a more typical stateless app + stateful DB. Most people aren’t deploying to Fly.io (yet!), so making Litestream work sounds pretty high risk to me :) combined with the lack of pedigree I led with, I just don’t see litestream as a good answer to “I need a HA database solution” for most people.
Re:Hctree is an experimental high-concurrency database back ... by tptacek on Wednesday January 18, 2023 @10:19PM (#34436318)
Litestream isn't a Fly.io feature.
Re:Hctree is an experimental high-concurrency database back ... by hamandcheese on Wednesday January 18, 2023 @10:43PM (#34436460)
No, but the ability to deploy it on stateful containers is.
Re:Hctree is an experimental high-concurrency database back ... by tptacek on Wednesday January 18, 2023 @10:46PM (#34436475)
I'm sorry, I don't understand any word of that sentence (for instance: we don't run containers?). We sponsor Litestream and LiteFS (in the sense that we pay Ben to work on it full time), but no part of Litestream is baked into or in any way coupled with our platform. If you can run Litestream on Fly.io, you can run it anywhere else.
Re:Hctree is an experimental high-concurrency database back ... by hamandcheese on Wednesday January 18, 2023 @11:05PM (#34436582)
> for instance: we don't run containers?

You "transmogrify container images into Firecracker micro-VMs" - surely you knew what I meant?

And there is no denying that fly.io is a _particularly_ well suited platform to run stateful SQLite apps (with or without Litestream), since fly makes running stateful applications easy. I think thats awesome.

I'm really confused why you seem to be trying to distance yourself from that, and why you are latching on so hard to my passing mention of fly. I wasn't making a dig, just pointing out that most people are stuck with (arguably worse) platforms that don't lend themself to stateful, "in-core" databases.

Re:Hctree is an experimental high-concurrency database back ... by tptacek on Wednesday January 18, 2023 @11:45PM (#34436789)
My confusion is that there's nothing container-y about Litestream. It works anywhere SQLite does. I like our platform a lot, but I mean, Litestream works just as well on AWS.

I'm just confused, is all. :)

Re:Hctree is an experimental high-concurrency database back ... by chillfox on Thursday January 19, 2023 @12:25AM (#34437002)
For most of the world (outside silicon valley) stateless is not the typical. The typical is stateful app + stateful DB run on stateful VMs.

For most enterprises, running a stateful app with SQLite is not only possible, it's easier than running stateless apps as their entire IT infrastructure is setup to support stateful apps and it's what their sysadmins know how to do.

I have tried to deploy stateless docker container apps into a typical enterprise network and it's a nightmare. The people done understand it, are not interested in understanding it, none of the infrastructure supports it and if you want to setup something like Kubernetes then you end up in configuration hell as none of the easy to deploy standard setups actually work out of the box in an enterprise network, everything ends up needing highly customized configuration to work.

Re:Hctree is an experimental high-concurrency database back ... by ec109685 on Thursday January 19, 2023 @03:12AM (#34437906)
If your application exceeds the capacity of a single server (e.g. a Java Web Service that is backed by a database), do you see SQLite as a useful solution for that case?

That seems like when you'd need a standalone database, no?

Re:Hctree is an experimental high-concurrency database back ... by vidarh on Thursday January 19, 2023 @06:40AM (#34439258)
If you think the capacity will never exceed that one standalone database. If not, you'll need to plan for sharding anyway, in which case sqlite can work just fine.
Re:Hctree is an experimental high-concurrency database back ... by ngrilly on Thursday January 19, 2023 @05:18AM (#34438709)
> SQLite requires the place you run your application to have durable storage, which is a huge departure from the status quo.

Having durable storage used to be the status quo for decades. It changed only recently with cloud providers (or their customers) pushing for stateless workloads because they are much easier to manage in a distributed system than stateful workloads.

Re:Hctree is an experimental high-concurrency database back ... by zie on Thursday January 19, 2023 @10:38AM (#34441441)
SQLite has been around for a very long time, it is easily the worlds most deployed SQL database. Litestream is just a way to do live sync/replication to make HA easier.

There are certainly use cases where SQLite is not a good fit. There are likewise use-cases where PostgreSQL is not a good fit either.

One is not better than the other, it just depends on your particular needs for that particular project.

My point is, SQLite is a totally sane and reasonable storage/DB solution for many server side applications as well.