“No database required” sounds simpler—but when is a JSON file actually the better choice?
retained text
I’ve been thinking about the phrase “no database required” in small self-hosted applications. It’s an appealing selling point: fewer services to deploy, fewer credentials to configure, and a data file you can inspect without special tooling. For a small household application, those are real advantages. But I think two different decisions sometimes get bundled together: avoiding a separate database server, and avoiding a database altogether. SQLite makes that distinction interesting. You can use a database without deploying another container or maintaining a separate network service. So the practical comparison isn’t always “one JSON file versus an entire PostgreSQL installation.” Sometimes it’s a JSON file versus an embedded database inside the same application. My tentative view is that JSON is often a good choice for configuration and simple, infrequently changed data. Once an application starts maintaining shared mutable state, I’d want to understand its write and recovery behavior before treating the absence of a database as an advantage. Consider a small renewal tracker. One person edits an expiry date while a scheduled task records that a reminder was sent. The dataset could be tiny, yet the application still has two operations updating it. Depending on the implementation, both operations might read the same old state and then save different versions. The second save could overwrite the first change. That isn’t an inevitable problem with JSON, but preventing it requires coordination somewhere. A single application process doesn’t automatically settle the question either. Asynchronous operations can overlap. The application might serialize changes through a queue, use locking, or keep one authoritative in-memory state. Each approach has assumptions worth documenting, especially if someone later adds a worker or starts another instance. There’s also the difference between keeping a file readable and preserving every acknowledged update. Writing a replacement file and renaming it can be part of a safer design, but it doesn’t by itself explain concurrent updates or what survives an interruption. The relevant filesystem behavior and persistence requirements still matter. I’d rather see a clear description of those guarantees than assume that a human-readable format provides them. This isn’t an argument that every application needs SQL. A well-designed file-based store can be entirely appropriate. For a personal tool with one controlled writer and easily reconstructed data, the simplicity may outweigh everything else. I also wouldn’t claim that choosing SQLite solves all application-level consistency problems. Transactions only protect the operations that are actually included and used correctly. An old browser form can still overwrite newer information if the application doesn’t handle stale edits. The distinction I care about is where the complexity ends up. If an application avoids a database but then implements write serialization, recovery files, validation, migration handling, and increasingly complicated queries, has it really become simpler? Or has some of the storage engine moved into application code? SQLite has its own boundaries. It permits only one writer at a time per database file, so workload and transaction duration matter. Deployment assumptions matter too: WAL mode isn’t a solution for sharing a database file between machines over a network filesystem. “It’s a file” shouldn’t become “put it on any shared storage and expect the same behavior.” For evaluating a small application, I’d find a few concrete tests more useful than comparing container counts. In a disposable test instance, make two overlapping changes and check that both survive. Restart the application during repeated updates and inspect what it recovers. Restore its documented backup into a fresh instance. Try an older saved form after another client has changed the same record. Record which acknowledged changes remain and whether failures are reported clearly. Those tests need explicit expectations. A disposable cache losing recent entries may be acceptable. Losing a renewal date or silently reverting an inventory change may not be. An abrupt process termination also doesn’t reproduce every power-loss scenario, so passing one test shouldn’t be presented as proof against all interruptions. I haven’t run a comparative benchmark here, and I’m not suggesting that a particular project has these problems. I’m interested in what people consider a reasonable storage design for small self-hosted tools. For me, the appealing goal is one straightforward deployment with understandable persistence and recovery. JSON, SQLite, and a separate database service can each achieve that under different conditions. The absence of a database is useful when it reduces the total work, rather than just moving that work somewhere less visible. \- When has a JSON file been the right long-term choice for your application? \- What eventually made you move from files to SQLite or a database server? \- How does your application coordinate browser edits and background jobs? \- What failure test taught you something unexpected about its storage? \- As a user, which persistence guarantees would you want documented before trusting an app with important data?
document fetched 2026-10-15 00:32 · canonical https://reddit.com/r/selfhosted/comments/1x5klb4/no_database_required_sounds_simplerbut_when_is_a