Top
Best
New

Posted by upmostly 4 days ago

Do you even need a database?(www.dbpro.app)
305 points | 297 commentspage 6
Waterluvian 3 days ago|
My personal toolbox’s section for databases has three items: files (usually JSON), SQLite, Postgres. I haven’t and I doubt I will ever run into a situation where none of those fit. They exist, I’m sure, but I’m too general purpose to ever need anything else.
cold_tom 3 days ago||
you can get surprisingly far with files, but the moment you care about things like concurrent writes or not losing data on crash, the whole thing changes at that point you're not choosing speed vs simplicity anymore -you're choosing how much risk you're willing to carry
winrid 4 days ago||
My recent project - a replacement for CodeMaster's RaceNet, runs on flat files! https://dirtforever.net/

Just have to use locks to be careful with writes.

I figured I'd migrate it to a database after maybe 10k users or so.

mfro 4 days ago||
Neat, what happened to the original system? Last I checked multiplayer was working in DR2.
winrid 4 days ago||
EA is shutting down Clubs. That is the primary motivation here.

Sadly no solution for non-rooted consoles.

goerch 4 days ago||
And crashes you can exclude? Good luck!
winrid 4 days ago||
The security level is the same actually as the codemasters servers.
charcircuit 4 days ago||
>So the question is not whether to use files. You're always using files. The question is whether to use a database's files or your own.

It's the opposite. A file system is a database. And databases can recursively store their data within another database.

dxxvi 3 days ago||
Before reading that post, I would use sqlite/duckdb for everything related to data. After reading that post, I will use sqlite/duckdb + Rust for everything related to data :-)
stackskipton 4 days ago||
SRE here. My "Huh, neat" side of my brain is very interested. The SRE side of my brain is screaming "GOD NO, PLEASE NO"

Overhead in any project is understanding it and onboarding new people to it. Keeping on "mainline" path is key to lower friction here. All 3 languages have well supported ORM that supports SQLite.

tracker1 4 days ago||
I'm mostly with you here... it's amazing how many devs don't have a certain amount of baseline knowledge to understand file-io, let alone thin abstractions for custom data and indexing like tfa. Then again, most devs also don't understand the impacts of database normalization under load either.
goerch 4 days ago||
Sorry, this I think is a dangerous attitude: for me it is not about onboarding. Every newcomer reading `Huh, neat` is poised to repeat the mistakes of us and our ancestors.
tonymet 4 days ago||
If the cloud is just someone else’s hard disks (etc) then RDBMS is just someone else’s btree
theshrike79 3 days ago||
I have a vague recollection that 4chan (At least at one point) didn't use any kind of backend database, they just rewrote the static pages with new content and that was it.

That's why it could handle massive traffic with very little issues.

flomo 3 days ago||
I have a vague recollection that HN also doesn't use a database, it serializes the data structures or something.
ogurechny 3 days ago||
It is a typical solution from the 90s, first steps of interactivity after hand-written HTML pages served by Apache. POST request is handled by some Perl script that rewrites the HTML page, then redirects to it or directly sends it as a reply. See the most basic frame-based chats (no Javascript, no nothing).

It only handles massive traffic if reads of those static pages are frequent, and updates are rare. When thousands of users are posting, you have to either block everyone on each write, or subdivide the required synchronisation between boards. Also, the regenerated pages might be used just a couple of times before the next rewrite happens (or not viewed at all, like far away board pages, but you still have rewrite all involved pages as a batch), and not much caching happens. In addition to that, each short comment causes multiple full long pages to be regenerated, and stored on disk. You basically get a very ineffective database with very ineffective primitives.

So usually every image board owner starts with decoupling of message posting and page updates to only regenerate pages once in a while, and process multiple edits at once, then some things stop working, as they assume each state change happens in full in multiple places, then they try to rewrite everything or switch to a real database engine.

thegdsks 3 days ago|
For anything that starts as a side project, SQLite covers it. The moment you need to ask this question the answer is usually "not yet." Ship first, migrate when it actually hurts
kantselovich 3 days ago|
If there is no database, where one should persist state?

Most software is stateful and needs to persist state across restarts, so I would argue that one needs at least SQLite.

On SQLite being safe default: in practice it means supporting multiple databases, say SQLite and Postgres, this is more complicated that supporting just Postgres. As soon as a project leaves localhost and enters cloud development you need talk to a database over network, which warrants MySQL or Postgres.

Which is more complicated: supporting a docker container with mysql or Postgres for local development OR supporting multiple databases in the project?

Of course, the answer could be “it depends”, I but I would not call SQLite a default choice. It would be if you are writing desktop or mobile app, but for anything like a web app it’s a questionable choice.

More comments...