10 ms·
Distributed SQLite: Paradigm shift or hype?
- west0n 3y agoSee some development frameworks for local-first apps support both SQLite and PostgreSQL. The advantage of using PostgreSQL is that when you add a cloud option to your local-first app, the migration becomes much easier.
- tptacek 3y agoThis is kind of missing the point. I can only speak for the company that sponsors LiteFS (I don't think any edge computing companies put 'otoolep up to doing rqlite, for instance). We love Postgres. Most of our users use Postgres. And Postgres works fine in edge/backhaul configurations; companies were doing geographically distributed Postgres read replicas long, long before we came around. That's where we got the idea. The idea of LiteFS is: * Most apps are read-heavy, and some of them are overwhelmingly read-heavy. * If you're read-heavy and can thus get away with it, there's a pretty significant performance win in replacing the networked n-tier architecture with SQLite, because Postgres round trips add up over the lifecycle of any given request. * In fact, that's so much the case that --- as Richard Hipp has been pointing out for over a decade --- you can blow off the N+1 problem and just write natural queries. I think Ben Johnson would be the first to tell you that LiteFS isn't a perfect fit for every application. We have systems that use both Postgres and LiteFS. Meanwhile, you have to dig to find it on our web page! It's an open source project that works everywhere Linux does. Dial back the cynicism a bit! :) A plug here for: https://kerkour.com/sqlite-for-servers https://kerkour.com/sqlite-for-servers Same author, and one of the best SQLite articles ever.
- codegangsta 3y agoMan! I can’t agree more. It does seem foreign right now, but I truly do believe edge computing will become another “CDN” type abstraction, but it will take time for folks to catch up. Can’t wait for the day that projects like litefs are just a default that nobody knows about, lol. Go from “technology nobody knows about” to “technology nobody knows about, but runs the world.”
- kragen 3y agothis page just says 'Forbidden'
- tptacek 3y agoI updated Chrome and reloaded.
- evgpbfhnr 3y agoYeah, says Forbidden in firefox or curl but loads in chromium - welcome to the open web of browser interoperability etc etc where servers now just decide your user agent or tls handshake or whatever is fishy.
- kragen 3y agothank you!
- 3y ago
- geenat 3y ago"Something went wrong! Try reloading the page. If the problem persists, please update your web browser to the latest version." RIP website. edit: it's back
- deleted 3y ago[deleted]
- ec109685 3y agoShould have used SQLite.
- zackify 3y agoI think this skips one mega benefit for apps. I’ve been using liteFS in production for a couple months. Your web app is able to resolve db queries instantly. You don’t need loading states if you’re using complex charts and other frontend JS that waits for data. All the data is resolved so fast and you can just return all your data like more traditional apps, and the load times are insane. If you’re multi region you can deploy one app instance there. Instead of 2-3. Postgres read replica, maybe something like redis. It really replaces both of those, assuming you have a read heavy app it works great.
- bgdkbtv 3y agoHow is it for writes? Would a CRM type system benefit from liteFS setup?
- thomasfromcdnjs 3y agoIn Fly's implementation; > LiteFS’ use of FUSE limits the write throughput to about 100 transactions per second so write-heavy applications may not be a good fit. https://fly.io/docs/litefs/faq/#what-are-the-tradeoffs-of-using-litefs https://fly.io/docs/litefs/faq/#what-are-the-tradeoffs-of-us...
- bgdkbtv 3y agoSeems that 100 writes per second is more than enough for a typical CRM (for a local business).
- linsomniac 3y agoThe article says "LiteFS supports roughly 100 writes per second".
- danappelxx 3y agoI think you always need loading states to account for slow network, or am I missing something?
- 3y ago
- icpmacdo 3y agoAmong the various free backend hosting options currently available, does Cloudflare stand out as the best choice with its offerings such as Workers and D1? I would love to hear users experiences with these services or if there any informative resources that discuss the costs associated with scaling applications on the infra?
- galaxyLogic 3y agoWhat portion of writes typically have to go to the primary server? If users are local then their data maybe is often local as well. In other words not all writes need to first go the central server from where they are distributed back to all edge-databases. I can see that the organization running the application needs a global view of all data. But regional users perhaps don't. Often they just need to know their own data. Write first to edge then copy to central database rather than write first to central database then trickle down to the site from where the write originated in. Just wondering what portion of applications could use this alternative design.
- rmbyrro 3y agoThis could work in very small projects. Still very risky. Say you flag a write as "local". Later, some other place in your app starts relying on this write in another locality. If you don't update your write spec from "local" to "primary", you don't have a consistent database anymore, but you will make decisions thinking that you do. Now consider a team of 10. Or 20... Mayhem can spiral very quickly from there.
- znkr 3y agoIt’s been done and it becomes quite complicated very quickly. Then it becomes necessary to manage that complexity and you end up with something like Spanner.
- geenat 3y agoWAL2 + BEGIN CONCURRENT ...to pretty much eliminate write contention. I know, it sucks these aren't built in yet. Also if we got some sort of router + map reduce helper (Vitess, Citus -like) it'd make massively distributed SQLite a lot more viable. Setups that don't hammer a single master would make all the difference. Postgres' main disadvantage at scale is all the additional machinery required (backups, failover, proxy, no DDL replication with built-in logical replication .... UGH!!), even when you're using Citus. Feels like it forces you into k8s with the amount of orchestration you need to run.
- raggi 3y agothis does not eliminate write contention, it just moves a bunch of the problem into the application as now you have to resolve conflicts yourself
- xray2 3y agoMost apps never need to scale. Also, worried about scaling? Just use an ORM that allows you to switch from SQLite to Postgres. It’s as simple as that.
- mind-blight 3y agoUnless your using database specific features. One of the biggest advantages for Postgres is how incredible the ecosystem is. It doesn't work for everything, but I have an OEM, multiple kinds of text search (vector, inverted indexes, trigrams), recursive and graph-like queries (though that's admittedly less of an issue if n+1 isn't a problem), row-level acls, locks, etc. It's really nice to have all of that power available in one piece of infrastructure.
- victorbjorklund 3y agoNot really a problem if you go from sqlite to postgres. Which sqlite feature is missing from Postgres?
- cnity 3y agoThis is saying: "just don't try to solve hard data storage problems". Not all applications are CRUD.
- dns_snek 3y agoYou're missing the point. Most software doesn't need to scale or solve hard data storage problems, and if it ends up having to, you can always upgrade to Postgres with minimal effort. That makes SQLite an attractive option if you won't immediately benefit from Postgres' rich features.
- cnity 3y agoWe're just going to be speaking past each other, I think. GP clearly stated they lean heavily on Postgres technologies (by calling out specifics like pgvector). Stating that the applications that don't need those technologies, indeed don't need them, is tautological!
- russellbeattie 3y agoI wonder if SQLite will ever be modified to allow concurrent writes. Right now it locks the whole DB on write [1]. But since SQLite usage is rapidly expanding from its embedded db roots, one has to wonder if the devs have considered creating some sort of SQLite daemon, or if the underlying architecture would have to be changed so drastically it wouldn't be worth it. 1. https://www.sqlite.org/faq.html#q5 https://www.sqlite.org/faq.html#q5
- deleted 3y ago[deleted]
- feverzsj 3y agoIn most SQL implementation, modification of row is table level locking anyway, so you can put tables in different sqlite db files and achieve same "concurrent" writes.
- simonw 3y agoThere's an official branch that implements BEGIN CONCURRENT: https://www.sqlite.org/cgi/src/doc/begin-concurrent/doc/begin_concurrent.md https://www.sqlite.org/cgi/src/doc/begin-concurrent/doc/begi...
- throwaway458864 3y agoSomething can be both hype and useful. Paradigm shift, no, because there's no fundamental architectural difference from any other replicated sql database. Sqlite only really works as a throwaway database. For that it's pretty great. Although a lot of the current use cases for sqlite could have just been a .ini file.
- deleted 3y ago[deleted]
- emmanueloga_ 3y agoAlso I think sqlite would not be a good fit if any sort of slow workers / background jobs are required.
- simonw 3y agoWhy not? (I'm planning a background job system based around SQLite at the moment)
- emmanueloga_ 3y agoBecause typically all writes need to happen from a single process, so if you want to run multiple processes writing to the same DB, you need to synchronize them somehow. If you are running a workers loop together with your http serving loop, running on the same process is awkward: you would need to stop serving your webapp each time you want to deploy new workers. Also you would need to wait until all workers are done before you could redeploy the app. If one of the workers does something unexpected, it could take down your webapp together with any other workers running, etc. If you used multiple processes you would need to perform sync through some IPC or something like redis to perform writes sequentially, but using a DB that already ships as a daemon would fit the problem better.
- simonw 3y agoThanks, that's useful. My design should be OK - I'm planning on having the workers retrieve jobs and send back their results via an HTTP API to a single process that wraps the SQLite database (Datasette with a custom plugin).
- emmanueloga_ 3y agoI'm not super familiar with Datasette but to a certain extent it does seem like you already implemented some sort of sqlite daemon over http? Is it fair to say Datasette is "like postgrest but for sqlite"? When I was thinking of using sqlite for bg jobs that's the kind of thing I wanted to avoid, but maybe you are already there :-) In case it helps, I've been investigating bg jobs too and saw a bunch of resources that can be helpful. One is a hn post about a job queue on top of pg [0] that has some cool pointers. Someone mentioned the "transactional outbox" pattern [1]. Separately, I found this video about implementing a work queue with Nats JS [2]. I suspect you could implement the outbox pattern in Datasette and provide a way to offload the jobs to any external queue, but Nats/JS seems nice since it provides all the building blocks to implement "exactly once" delivery, dead letter queue, hearbeats to ensure the workers completes the work, etc, and it is very easy to run. I think it could save you a lot of the tricky work of implementing all these features with SQL(ite). The overall design would be something like: def trigger(): """Enqueue a job transactionally: either fully succeeds or fully fails. job_id = transaction { job_data = ... enque job_data into outbox } # This can fail but no biggie, you will still need to poll in case of failure, # so no jobs will be created without their backing data, and no jobs will be dropped. transaction { remove job_id and send to nats } def background_poll(): """Poll the outbox in case we succeeded in inserting into the outbox but somehow failed to deliver to the queue.""" try periodically { transaction { remove from outbox and send to nats } } ... then in another process or processes, the workers would talk to nats/js to perform the work. Elsewhere someone described a job system that only relied on a database without support of events (that is, not pg), and required creating a sessions table to ensure workers complete the jobs, etc [3]. This is the kind of thing that I think could be simplified by using nats/js or another external job queue. -- 0: https://news.ycombinator.com/item?id=38349716 https://news.ycombinator.com/item?id=38349716 1: https://microservices.io/patterns/data/transactional-outbox.html https://microservices.io/patterns/data/transactional-outbox.... 2: https://www.youtube.com/watch?v=7Jp3tyCGMZs https://www.youtube.com/watch?v=7Jp3tyCGMZs 3: https://forum.cockroachlabs.com/t/how-to-implement-a-work-queue-without-skip-locked/3109/9 https://forum.cockroachlabs.com/t/how-to-implement-a-work-qu...
- skybrian 3y agoI don't believe Cloudflare D1 has read replicas yet? They describe how it will work in detail in a blog post [1], but in the future tense. > We’re actively working on global read replication and realizing the above proposal (share feedback In the #d1 channel on our Developer Discord). Perhaps it will be out by the time the book is finished. [1] https://blog.cloudflare.com/building-d1-a-global-database https://blog.cloudflare.com/building-d1-a-global-database
- _heimdall 3y agoD1 is still pretty limited in my experience. No read replicas really kills any of the meaningful benefit of the architecture, and being built off of a (mostly) SQLite-compliant API makes me nervous as it isn't really SQLite at all. Last year's major Cloudflare outage really was the final straw for me with regards to D1. I don't mean that as a knock at Cloudflare at all, the situation sounded horrible and I appreciate how the entire team responded to it. I just worry that internal responses to fundamental infrastructure issues will leave newer projects like D1 on ice for a year or two.
- rozenmd 3y agoD1 (the ability to query your database at the edge) didn't get knocked offline during that outage though?
- _heimdall 3y agoWe did actually run into D1 issues during the outage, though I don't remember exact details on what was down. Our issues may have been API related with reads still functional. My concerns, and this is very much my own concerns with no context of what has or is happening internally st Cloudflare, is that the outage exposed some serious issues that will take time to fix safely. The fact that D1 still doesn't support replication is an indication to me that it has been deprioritized, likely with other newer and less used products, while the infrastructure updates are dealt with.
- 3y ago
- benbjohnson 3y agoLiteFS author here. I don't disagree with any points in the article but perhaps a reframing could help. I previously wrote a tool called Litestream that would do disaster recovery for a single-node SQLite server and I still think it's a great default option for people starting new projects. Unless you're doing very database-specific things, most SQL will carry over between SQLite and Postgres and MySQL, especially if you add ORMs in the mix. Pick the one that gets you writing code the fastest and you can switch down the road if you need it. Rather than a paradigm shift or hype, I see distributed SQLite as an extension of a path that devs can go down. With Litestream, the most common complaint I got was that devs were worried that they couldn't horizontally scale with SQLite and they'd be stuck. While you probably won't hit vertical scaling limits of SQLite on most projects, it still caused concern. So LiteFS became a "next step" that a dev could take if they ever got to that point. It doesn't need to be your starting point. As for the "hacky" solution of txid, I'm not sure why that's hacky. Your application isn't required to use it or the optional built-in proxy but it's available if it fits your application's needs. It also works for plugging legacy applications into distributed SQLite without retrofitting the code. The proposed solution of caching seems orthogonal to the discussion of distributed application data. I don't think any database provider would suggest to avoid caching when it's appropriate but there's plenty of downsides of caching. Hell, it's one of the two hardest problems in computer science.
- TheCapeGreek 3y ago>most SQL will carry over between SQLite and Postgres and MySQL, especially if you add ORMs in the mix I think this goes underappreciated, or rather the opposite is overstated. Sure there are some edge cases that don't work the same, but most apps won't hit those. My _biggest_ gripe with SQLite so far is the lack of column reordering like other DBs. And my simplistic understanding is that the others do it exactly the same way as you'd do it manually with SQLite - table gets _replaced_ with an identical table with the data correctly ordered and the data is shoved into the new table.
- dkjaudyeqooe 3y agoWhy would you want to recorder columns? SQLite reads in a whole record at a time to access any column.
- _heimdall 3y agoSQLite is neither shift nor hype, its a misunderstanding of underlying architecture challenges. SQLite has pros and cons, like anything else. When it comes to web frameworks and app platforms, to fundamental problem is that many committed fully to server less/edge and ignored the los of persistent storage. You just can't use a local database when using serverless, or any type of distributed compute/rendering for that matter. Databases are centralized by design, you can dodge some of that complexity with clever synchronization protocols but you are still limited to having a single primary DB at the end of the day. For read-heavy use cases, tools like Turso can be invaluable. If database writes are more common, you'll always be limited by network latency. More importantly for most modern web apps, whether you render HTML in the browser or a server you can't avoid loading states. IMO you might as well lean on the platform and use server rendering whenever persistent state is involved.
- deleted 3y ago[deleted]
- Animats 3y agoSQLite is getting a lot heavier. This is becoming more like MySQL or Postgres.
- voidfunc 3y agoThe fate of all projects if they continue on long enough.
- internetter 3y agoNo it's not. SQLite is still the only "serverless" database of those three. Nothing has changed, aside from the companies selling variants of it, but that's not SQLite's fault
- simonw 3y agoThe most recent SQLite amalgamation zip file is 2732008 bytes. Version 3.26.0 from 2018 is 2286469 bytes. That's a 20% increase in 6 years, but it's still just 2.6MB of compressed C.
- internetter 3y agoSomething I've been thinking about is partitioning my SQLite. Instead of storing all user's data in one mega table, what if I made a SQLite database for each user? Provided users never talk to each other, I think this might work?
- tptacek 3y agoYou can attach to databases dynamically in queries and join across them. I probably wouldn't (in an ordinary data model) do per-user, but I would consider it for different functional areas.
- simonw 3y agoThere's a limit on how many databases you can attach to the same connection (SQLITE_LIMIT_ATTACHED), it defaults to 10.
- samatman 3y agoWorth noting that this limit can be raised up to 125 (as I'm sure Simon is aware). I would say that if one needs to query across more SQLite files than that, it's definitely time for a different data policy.
- danr4 3y agoI believe this is what one of the companies mentioned in the article, Turso, can help you do. a per-tenant database.
- sorenbs 3y agoThis setup can work great and even support elements that are shared between users, if you also give those elements their own DB. I’m working on a prototype to support this natively in Prisma.
- config_yml 3y agoYou can slice it and dice it any way you want, really. The constraint is often what data needs to be written within a transaction. You'll have to figure our a way to reliably apply a consistent schema to all these database files somehow and keep track of them.
- nurettin 3y agoThe only way I know for doing concurrent writes in sqlite is to open a transaction, accumulate a bunch of writes and then commit them. Otherwise it is dog slow. And it has to be a single process, or you get data corruption. Has this changed somehow?
- lxpz 3y agoThis is due to SQLite calling fsync a lot by default, to be on the safe side. You can use pragma journal_mode = "wal" and pragma synchronous = "off" and it should be much faster, without risking corruption if your server powers down unexpectedly (at least in theory, you should still make regular backups, which can be done from within a running sqlite instance using the backup command)
- Sytten 3y agoYes it has been years since the WAL mode fixed this. And WAL2 is even better now.
- infogulch 3y agoIf you're willing to accept eventual consistency (a big ask, but acceptable in some scenarios) then there are options like marmot [1] that replicate cdc over nats. [1]: https://github.com/maxpert/marmot https://github.com/maxpert/marmot
- geenat 3y agoThe major downside to marmot right now is schema changes don't propagate. Otherwise, keeping a very close eye on it.
- emseetech 3y agoIt is a pain, but if your use case allows for scheduled downtime, it's not terrible. I'm looking at Marmot for high availability. Not necessarily horizontal scaling, but instead having a backup server or two that have a constant up-to-date copy of the live db but also can take over if the main server dies, and the main server can then sync the data back when it comes online.
- throwaway2037 3y ago> While SQLite is a really amazing database, most teams will benefit from avoiding it and going the PostgreSQL way instead. > Bazillions of engineering hours have been spent to make Postgres the best backend database and choosing SQLite will inevitably force you to reinvent what Postgres already had for many years, in a fragile and buggy way. Could the same not also be said for MS SQL Server, Oracle, Sybase, MySQL, or MariaDB? The author offers no supporting evidence for this statement. Rewrite that: "Bazillions of engineering hours have been spent to make XYZ the best backend database..."
- klysm 3y agoWithout giving evidence, I do agree that Postgres is a better database that serves the general case better. I use both in production for different purposes, but postgresql makes a lot more sense then SQLite as our primary database
- throwaway2037 3y agoFair comment. First hand experience is important. HN is great for people sharing their technical experiences. I would not say that is "without giving evidence"!
- znpy 3y ago> Rewrite that: "Bazillions of engineering hours have been spent to make XYZ the best backend database..." What you're saying (and what the author is saying) however is clashing with the reality of so many developers using sqlite and being happy with it. I'd suggest to rewrite it another way: > Bazillion of developers think they'll need a full-fledged database for their new project while sqlite will cover most of their needs.
- throwaway2037 3y agoThis is a good reply. I want to clarify why I excluded SQLite in that list: It is not a database server (all of the others are); it is an embedded database. I say that with zero disrespect. I am 110% a SQLite fanboi. Honestly, I have no experience with PosgreSQL, but I have heard a lot of good things about it. The community looks amazing.
- superhx 3y agoIs there a distributed version of SQLite that keeps its embedded library feature? For example, it could use EBS and S3 for shared storage, allowing for distributed read and write access, and possibly even multiple concurrent reads and writes. Should this be available, numerous lightweight web applications could operate without having to set up a separate PostgreSQL or MySQL database.
- tptacek 3y agoYes, that's (for instance) what Litefs does.
- tutfbhuf 3y agoWe have so many distributed X applications nowadays that all try to solve the same problem, either in the same or different ways. I think we first have to come up with a simple, distributed, open-source storage solution. In the cloud, we have things like AWS S3, which is a very reliable distributed storage, but for self-hosting, we have: Ceph, with which I have much experience, is a very solid and quite bulletproof storage solution that offers S3 protocol and FS. However, maintaining it in the long run is really challenging. You better become a Ceph expert. SeaweedFS struggles with managing large data groups. It's inspired by an outdated Facebook study (Haystack) and is intended for storing and sharing large images. However, I think it's only average—it has poor documentation, underwhelming performance, and a confusing set of components to install. Its design allows each server process to use one big file for storage, bypassing slow file metadata operations. It offers various access points through gateways. MinIO has evolved a lot recently, making it hard to evaluate. MinIO relies on many small databases. Currently, it's phasing out some features, like the gateway, and mainly consists of two parts: a command line interface (CLI) and a server. While MinIO's setup is complex, SeaweedFS's setup is much simpler. MinIO also seems to be moving from an open-source model towards a more commercial one, but I have not closely followed this transition. All of these solutions are not simple enough to be the base for a distributed database application. What we really need would be something like an Ext4 successor, let's call it Ext5, with native distributed storage capabilities in the most dead-simple way. ZFS is another good candidate. ZFS has already solved the problem of how to distribute storage across multiple hard drives within one server very well, but it still lacks a good solution on how to distribute storage across different hard drives on different servers connected via a network. Yes, I know there is the CAP theorem, so it is really a hard challenge to solve, but I think we can do better in terms of self-hosted solutions.
- dikei 3y ago> While MinIO's setup is complex, SeaweedFS's setup is much simpler. Are you sure you are not talking in reverse? I find Minio single binary deployment very easy, and you also complained about SeaweedFS's complexity in the previous paragraph.
- moritzruth 3y agoThere is also Garage: https://garagehq.deuxfleurs.fr/ https://garagehq.deuxfleurs.fr/
- samwillis 3y agoThe paradigm shift that's going to come with distributed SQLite isn't to the edge, it's going to be to users devices. I believe the DX of building Local-first apps is going to hit the criticality point in the next year or so and its popularity is going to explode. With dynamic partial replication you can synchronise a subset of your database to a SQLite db on your users device, eliminating the network from the ui interaction loop. Then with the emerging eventually constant syncing systems, many using CRDTs, it's possible to have conflict free eventual consistency. Just read and write to a local database and it will sync with your central server or other clients in the background, both in realtime or after working offline. I work on one such system at ElectricSQL, but there are many people building variants of this such as Evolu, SQLsync, CR-SQLite, and PowerSync. That's all not to say SQLite on the edge isn't really damn cool!
- azeirah 3y agoAll of this makes me think we'll just be building meteor apps but with sqlite instead of mongo and minimongo whaha
- candiddevmike 3y agoYou've been able to build these apps for years now, hell PouchDB was released in 2012. I don't think anything significant is going to push for more of these apps--the DX isn't really that great compared to remote write--there are more abstractions, less caching, way more corner cases, and I call BS on your conflict free utopia.
- jkestner 3y agoI'm using Pouch/Couch on a web app, and the sync is really good DX - I got all the functionality I wanted, including easy undo, in a day or so. So yeah, what more DX would actually make people adopt local-first? I don't think it's a dev problem, but a business one. No consumer is demanding local-first, and no company wants to give up that profitable data. We're doing it because we're purposely not interested in users' data and resiliency is part of our value—but we're still holding some of it for consumer convenience.
- banish-m4 3y agoDon't get caught up in marriage to a particular tech flavor. Instead, architect and use a generic db adapter pattern that translates a more generic SQL/GraphQL flavor into whatever is necessary and efficient underneath for that particular DBMS or store. Meta does this for many warm storage services. It makes changing underlying DBMSes and scalability architectures much easier to develop and reason about than if every app has to know everything about its backend(s).
- datadeft 3y agoI think this is a false dichotomy to try to frame there is a Sqlite vs Postgres situation going on. Sqlite is amazing super fast single writer database without network service so it can be used locally as a library mostly while Postgres is a full fledged RDBMS. Both have use-cases that the given service is a better option and there are many other software products out there to be used for similar purposes. Notable SQLite use cases: https://www.sqlite.org/famous.html https://www.sqlite.org/famous.html Postgres does not have a similar page: https://www.postgresql.org/about/press/faq/ https://www.postgresql.org/about/press/faq/
- elithrar 3y ago> What a nightmare! Now your application code spills into your database and our initial goal of simplifying application development is nothing but a long-forgotten dream. All of that for what? To save a few milliseconds to display a web page. I think "a few milliseconds" vastly understates this: if you want to run your application closer to users, even just across the US, each query is (at least) 70ms just to get over the network and back again. "Application code spills into your database" was a bad thing when you wrote one language (say, Java, or PHP) and another language (PSQL/TSQL/etc) for your "stored procedures", but that's not what most modern databases are advocating for. Instead, and not unlike something like React Server Components (RSC), you can choose whether to run code close to the user or closer to the DB (for transactions) in the same language as your application, because it's still part of your application code. This is the model that Durable Objects[1], our coordinated storage service, uses. Disclaimer: I work on D1 & Durable Objects at Cloudflare, so I'm likely to be called biased here, but it's not like we haven't a) thought about this deeply and b) actually use D1 and Durable Objects to build distributed systems at Cloudflare. [1]: https://blog.cloudflare.com/durable-objects-easy-fast-correct-choose-three https://blog.cloudflare.com/durable-objects-easy-fast-correc...
- cryptonector 3y ago> What if there was a simpler solution? Then TFA mentions caching without talking at all about how that is a solution, let alone a simpler solution.
- williamstein 3y agoAnother relevant example is how MicroK8s uses distributed sqlite (dqlite) under the hood to make their Kubernetes distribution highly available, instead of using etcd. https://www.cncf.io/wp-content/uploads/2020/11/MicroK8s-High-Availability-Alex-Chalkias.pdf https://www.cncf.io/wp-content/uploads/2020/11/MicroK8s-High...
- SergeAx 3y agoThe problem with Postgres is that out of the box, it is not much different from SQLite in terms of availability and scaling. You need to add a Pgbouncer before it can handle multiple connections, and you need a really complicated dance to make it highly available, with read replicas and hot standbys. This is why I prefer MongoDB for that matter.