aja/workspace/engineering notes

IST --:--:--
engineering-notes

Scaling Rails Applications

15 Sept 2025·
RailsScalingArchitecture

01Problem

A Rails monolith serving enterprise traffic began missing its latency SLOs as tenants and data grew. The instinctive proposal was 'rewrite as microservices'; the budget said otherwise.

02Context

Most latency lived in a handful of endpoints; most of those in the database; the rest in synchronous work that had no business being synchronous.

03Solution

In order: instrument everything (per-endpoint, per-query); fix the query layer (indexes, N+1s, pagination); cache what's read-heavy and tolerant of staleness; push slow work to queues with idempotent jobs; only then extract the one boundary — document processing — that genuinely needed independent scaling.

04Tradeoffs

Extraction adds operational surface: deployment, monitoring, versioned contracts. That cost was worth paying exactly once, for the boundary that spiked independently — not for the whole app.

05Outcome

SLOs restored with a single extracted service instead of a rewrite. The monolith remains happily boring for everything else.

06Lessons Learned

Scaling problems are usually one hot path wearing a whole-app costume.

Extract services around load profiles and team boundaries, not around nouns.