Paul Bădărău

Rails SQLite deployment: single server or Postgres?

A practical Rails SQLite deployment decision guide: when one server, Solid Queue, and Solid Cache fit, and when managed PostgreSQL is safer in production.

A Rails system I run in production has a 100 GB PostgreSQL database, more than 4 TB of media, nearly 7 million observations, and over 17 million attachments. I wouldn't put that workload on SQLite on a single server.

I haven't deployed a production Rails app on SQLite, Hetzner, and Kamal; the live platform I operate runs on PostgreSQL, Hatchbox, DigitalOcean, DigitalOcean Spaces, Solid Queue, and Solid Cache for a property inventory agency's operations, client portal, and imports alongside webhooks, a report archive, and invoices. My single-server recommendation below is engineering judgement, not a report from that deploy.

One server puts recovery in one place

Putting the web app, database, queue workers, cache, and scheduled jobs on one machine removes network hops to Redis and cuts down on half-configured services. Solid Queue and Solid Cache store jobs and cache entries inside the application database, so a small product runs on one database file and durable disk without separate database credentials, bills, or backup policies. Kamal adds repeatable container deploys over SSH and health checks, and a host like Hetzner fits that shape well when the business has one clear failure domain and can accept a brief maintenance window.

SQLite works when writes are calm and data is replaceable

SQLite is fast and mature when five conditions hold:

  1. One writer at a time is acceptable, because users mostly read and occasionally edit their own records.
  2. Any data lost since the last backup is bounded and replayable from a payment provider, upstream API, or support log.
  3. Web traffic and background jobs can share one machine without needing separate CPU scaling.
  4. Both the database file and local Active Storage uploads sit on durable mounted storage, never on an ephemeral container filesystem.
  5. You can pause writes briefly for schema migrations that lock the single writer.

If any of those five fail, a small screen count won't save you from busy imports or webhook bursts.

Solid Queue removes Redis without removing contention

Keeping job state next to application data lets you enqueue a job inside the same database transaction as the record change, which is a clean trade for an app taking orders, emailing receipts, generating PDFs, and running nightly reports with one or two workers. An integration service behaves differently: when vendor webhooks, paginated imports, source snapshots, canonical projections, and retries run constantly, every background job competes with users to write.

On the property platform, a paginated importer saves each raw response before projecting rows, resumes from a saved cursor, and never lets an older import overwrite a newer webhook. Heavy media downloads stay off the queues that webhooks depend on, and Solid Cache writes still count as database activity; on a single SQLite file, an expensive cache write or a 4 TB media backfill shouldn't block a payment or an access-control update.

Concurrent work forces the switch to Postgres

Row counts alone don't draw the line, since ten thousand rows updated by a concurrent import hurt more than ten million append-only history rows. I decide with four questions: can important writes collide (user saves vs webhooks), does the queue have a tight recovery objective, can one copy restore both the database and linked object storage consistently, and does adding a second web server break the model?

The property platform crosses all four lines across more than 25,000 properties and 60,000 inspections going back to 2011. Losing a report or linking a photo to the wrong property could sit unnoticed for years; during our migration, a verification pass caught an earlier download path that had skipped cover images and meter photos without a UUID, and a follow-up check confirmed all 17,595 distinct cover-image URLs and 42,494 distinct meter-photo URLs were preserved while source deletion waited on an incomplete actions backfill.

Managed PostgreSQL earns its cost before you need a cluster

Moving to PostgreSQL doesn't force a complex architecture; one Rails monolith, an app server, a worker, managed PostgreSQL, and object storage is still straightforward to operate. The live property platform pairs PostgreSQL (with JSONB for integration snapshots) with DigitalOcean Spaces for active media and a read-only legacy Spaces bucket for historic archives. It retries 429 and transient 5xx responses with a bounded policy and exposes dead-letter replay, which are application responsibilities Postgres merely supports by handling concurrent writers and independent backups cleanly.

Choose managed PostgreSQL early if you expect steady inbound webhooks, restartable imports, an audit trail that matters, or more than one app server. You still keep Solid Queue, Solid Cache, and one monolith.

A small deployment still needs a tested restore

A fast deploy command without a recovery plan leaves you exposed when a disk fills or a migration breaks. Volume snapshots can preserve a bad migration or a compromised host, so keep encrypted backups off the machine and test restores on a schedule. If Active Storage sits on local disk, copying the database at 01:00 and uploads at 01:30 leaves orphan rows unless you pause writes, snapshot atomically, or move media to object storage.

Put real checks into your release pipeline too: confirm the worker can query the database, migrations finished, uploads are mounted, and schema changes are reversible before they run. I'd always pick a single server someone has actually restored over five managed services nobody has tested, and managed Postgres with tested backups over single-server optimism; hosting is a trust problem covers the operational side in more detail.