Paul Bădărău

Rails 8.1 for production systems I actually operate

The Rails 8.1 stack I run for serious operational software: PostgreSQL, Phlex, Hotwire, Solid Queue, and Active Storage, tested on live production data.

A Rails 8.1 application I operate holds nearly 7 million observation records, more than 17 million attachments, and over 4 TB of media inside a 100 GB database. It runs a property inventory agency's operations workspace and client portal across more than 25,000 properties and 60,000 inspections, some of them dating back to 2011; importing third-party history, serving private PDFs, and stopping integrations from overwriting each other are daily work.

Those numbers set my baseline: Ruby 3.3, Rails 8.1, PostgreSQL, Hotwire, Phlex, and Tailwind for the application, paired with Solid Queue, Solid Cache, and Active Storage; in production I add AppSignal, Sentry, and Rack::Attack. I only swap a piece of that list when the product gives me a measured reason.

I start with the database that carries the awkward data

PostgreSQL is my default for shared operational software; SQLite only fits a small product with one writer and a narrow boundary. The property platform stores relational tables for clients, properties, inspections, reports, invoices, and payments alongside JSONB source snapshots, integration events, reconciliation records, audit logs, and Solid Queue metadata.

An inspection import fetches a paginated list, then pulls property details, contacts, report metadata, meters, and attachments, saving every raw response in JSONB before projecting canonical rows. Six months later I can still prove whether a provider sent a field or my code invented it; meanwhile, fields the product queries daily get projected into typed columns with constraints (if a dashboard query unpacks five layers of JSON, discovery dragged on too long).

I'd never put this workload on a document store because the access rules and relationships are strict. Reports belong to inspections, portal access scopes to a client, invoices have statuses, and a replayed webhook can't create a duplicate event. On an education platform I built, unique indexes on course deliveries, ordered steps, volunteer matches, and judging records stop two concurrent requests from creating double bookings or double ratings. At 100 GB, a missing index or a casual includes shows up straight away. Capacity planning is still my job.

One Rails monolith stays cheaper than early service boundaries

The property platform talks to an inventory provider, Airtable, and Xero; it sends one-time passcodes through Postmark, runs both admin and client workspaces, verifies signed webhooks, and gives operators a dead-letter and reconciliation console. Splitting that early into separate import, webhook, and portal services turns identifiers, permissions, and audit trails into distributed debugging. The legacy system it replaced ran a PHP webhook listener, a MySQL queue, cron jobs, and manual rerun screens; Rails consolidated that into signed endpoints, an integration ledger, and queue-backed replay so operators see the whole pipeline in one place.

Keeping one deploy doesn't mean one tangle of callbacks. Tested service objects for import selection, provider clients, canonical upserts, webhook verification, and media adoption sit right next to the transactions they control, so when a cursor stalls I can inspect the snapshot and projection without crossing a network. On a Phoenix judging app I maintain, OTP timers reset on restart and multi-instance deploys need coordination across supervision trees. Work that must survive a deploy has to be written down on purpose.

Phlex keeps complex views readable in plain Ruby

I default to Phlex over ERB because ERB templates rot once a page grows a filter form, status badges, empty states, modals, permission branches, and a compact Turbo Frame variant. Partial locals turn into an untyped API spread across templates, helpers, and CSS strings. Phlex turns each component into a Ruby object with an explicit initialiser, so a missing keyword fails at the call site and permission logic stays legible right beside the markup.

I don't wrap every paragraph or icon in a component, because that creates its own noise; I extract a component for a visual contract, a permission rule, or a domain concept like inspection state or portal document access. ViewComponent works well if an existing app already has partials everywhere, while Phlex keeps new builds simpler since everything is plain Ruby. I avoid React for the same reason: the property platform needs inspection preparation, field corrections, and private PDFs, and adding a JSON API plus a client cache would duplicate validation and permissions for no gain.

Hotwire handles interaction without a second runtime

Turbo leaves the server in charge of operational state while keeping the interface responsive. A portal user requests an asynchronous ZIP of reports, or an administrator works through reconciliation states inside a Turbo Frame without resetting the page; links and forms stay plain HTML, and Turbo Streams push status updates once background work finishes.

Stimulus covers browser-only behaviour like chosen-file labels, dialogs, and filter controls, avoiding a separate client store that can disagree with server permissions. I'd reach for React or Vue for a dense drag interface, offline field sync, a map with thousands of live points, or a collaborative editor, never for a dropdown that filters a table. Tailwind lets me iterate on server-rendered screens quickly, provided type, spacing, and colour live in shared tokens and Phlex components.

Solid Queue removes Redis until throughput demands it

Sidekiq is the wrong default for a new Rails 8.1 app when PostgreSQL already holds the durable state. An older public platform I run uses Sidekiq and Redis for CMS webhook cache invalidation, sitemap updates, and scheduled reminders, which hangs together fine since Redis also caches its page index; I wouldn't migrate it just to chase newer gems. For new builds, Solid Queue and Solid Cache remove an extra datastore, backup policy, and production service, keeping job tables and failure state inside the same database as the records they mutate.

Queueing in Postgres doesn't fix bad integration design. On the property platform, webhooks must be acknowledged fast and historical media downloads can't clog live integration queues, so we isolate heavy media work onto dedicated queues and persist every signed integration event before handing off jobs. Imports retry 429 and transient 5xx responses up to four times, honouring Retry-After or bounded exponential backoff; root cursors only advance on success, already synchronised roots are skipped, and webhooks never overwrite newer values with older ones. I'd only bring in Sidekiq when Redis is already justified or measured Postgres job throughput becomes the bottleneck.

Active Storage needs explicit migration controls

Active Storage gives me signed delivery, direct uploads, and variants, letting the portal serve private report PDFs and client documents through authenticated app endpoints instead of storage provider URLs. On a large migration, though, a cloud SDK or Active Storage alone won't prove the historic archive arrived intact.

The property platform writes current media to DigitalOcean Spaces while reading legacy storage on a read-only bucket, adopting images where safe and downloading others directly. Our verification pass caught an earlier download path that had silently skipped cover images and meter photos lacking a UUID; a subsequent manifest check confirmed all 17,595 distinct cover-image URLs and 42,494 distinct meter-photo URLs in the bounded migration set had landed, and we kept the source bucket alive until the remaining actions backfill finished. At 4 TB, egress, lifecycle rules, retries, and worker isolation are operational inputs, not a bucket you fill once.

Observability and rate limits belong in the first deploy

AppSignal tracks performance, Sentry catches exceptions, and Rack::Attack blocks bad traffic before it turns into support work. The public education platform pairs Rack::Attack with a honeypot and Cloudflare Turnstile on public forms, while the property platform locks down signed webhooks, one-time passcodes, and private document routes.

Integration failures rarely arrive cleanly; an incident might mix a 5xx spike, a rate limit, and a duplicate webhook, which is why we log retry audit events and reconciliation state. A job counter hitting zero doesn't finish a migration. Our per-property manifest proved the database had all the rows while the media archive was still incomplete. More on the deployment topology sits in hosting as a trust problem, and the verification rules live in tests as contracts.