Skip to content

Lesson 9 of 9 · 22m

When SQLite Beats a Server — and When It Doesn't

Evaluate workload shape, write concurrency, operational ownership, latency, and failure domains to choose SQLite or a server database on evidence.

Choosing SQLite is not a ideological stand. It is an architectural trade. You give up a shared, network-accessible writer and gain simplicity, locality, and brutal latency advantages. The correct decision comes from workload shape, not fashion.

SQLite often wins on latency

For a single-node application, SQLite removes network and process boundaries. Reads can be shockingly fast:

PostgreSQL local network path:
parse request -> IPC/socket -> server execution -> response copy -> client parse

SQLite path:
execute SQL in-process -> return rows

A content site, internal tool, admin panel, or edge application with modest write volume can be simpler and faster with SQLite. Fewer moving parts also means fewer failure modes. There is no database server outage independent of the application because there is no database server.

SQLite often wins operationally

Small teams underestimate the cost of operating a database service: patching, credentials, network policy, backups, failover, storage tuning, monitoring, version upgrades, and access control. Sometimes that cost is justified. Sometimes the service has twelve users and a write every few minutes.

With SQLite, deployment can be one binary and one database file. Migration, backup, encryption key management, and lifecycle still need discipline, but the infrastructure surface shrinks.

Server databases win on shared write concurrency

The bright line is concurrent write ownership. If multiple application instances or independent services must write frequently to the same logical data, a server database is usually the correct default. PostgreSQL gives you concurrent writers, network access, roles, constraints enforced centrally, replication options, connection management tooling, and decades of operational practice.

SQLite can coordinate multiple writers through file locks, but that is not the same as designing for many hot writers across machines. On network filesystems it can become actively dangerous depending on locking behavior.

Evaluate the shape with real questions

How many application instances write?
What is peak writes per second?
How large is the working set?
Can data be partitioned per tenant/device/site?
Must services query each other's data directly?
What failure isolation is required?
Who restores at 03:00, and from what?

If tenancy or device boundaries naturally partition data, SQLite can scale horizontally as many independent databases. If all data is one shared mutable graph, a server database starts pulling ahead.

Replication changes the calculus, carefully

Tools such as Litestream can stream SQLite WAL changes to object storage for disaster recovery. LiteFS and other distributed SQLite systems explore replication and failover. These are real options, but they do not make SQLite identical to PostgreSQL. Understand write failover, split-brain prevention, restore semantics, and operational maturity before betting a business on them.

Hybrid designs are normal

The best systems often mix shapes. A server database may hold shared identity and billing truth while edge nodes use SQLite for local cache, queues, or tenant-local state. Embedded SQLite is also excellent for immutable snapshots, exports, local development fixtures, and test parallelism.

The decision table

ConditionSQLite leaningServer leaning
one application instancestrongoptional
many concurrent writersweakstrong
local-first or offlinestrongweak alone
multi-service shared writesweakstrong
minimal operations budgetstrongcostly
complex access control in DBweakstrong
partitionable datastrongoptional

Field notes

  • Choose based on write topology first; read throughput is rarely the decisive constraint.
  • "SQLite handles terabytes" and "SQLite is only for toys" are both useless slogans without workload shape.
  • Replication tooling adds operational sophistication; do not treat it as magic multi-writer support.
  • A server database can be overkill for one small service and essential for a shared platform.
  • Hybrid architectures are a sign of maturity, not indecision.
  • Revisit the decision when write concurrency or service ownership materially changes, not when a blog post does.

Was this lesson helpful?

Sign in to rate