Rails Monolith vs Microservices: When to Split and When to Hold
Rails monolith vs microservices: a fractional CTO's decision framework for when splitting your Rails app creates value—and when it just creates pain.
Three years ago I joined a Series A startup as fractional CTO. They had forty engineers, a Rails monolith that had been running in production for six years, and a Jira epic titled “Microservices Migration” with 847 open tickets. The founding engineer—smart, earnest, had read all the right blog posts—had convinced the board that microservices were the only path to scale. Eighteen months earlier they had extracted their first three services: payments, notifications, and “user management” (a name that tells you nothing about what it actually does). Each service had its own Postgres, its own deploy pipeline, its own on-call rotation.
In those eighteen months, mean time to deploy had gone from forty minutes to four hours. Incidents had tripled. Two engineers had quit citing “deployment complexity.” The CTO who started the migration had also left.
The irony: their actual traffic problem was a single slow Postgres query on the orders table that an index would have fixed in an afternoon.
This is not a rare story. I have seen it play out in some variation on a dozen Rails codebases over nineteen years. The rails monolith vs microservices question is one of the most expensive architectural decisions a startup can get wrong, and it gets wrong in the same direction almost every time: splitting too early, for the wrong reasons, without understanding what the monolith was giving you for free.
Why the Rails Monolith Has a Bad Reputation It Does Not Deserve
The case against the monolith is usually stated in terms of scale and team size: once you have many engineers, they step on each other; once you have high traffic, one slow component degrades everything; once you have complex domains, one team’s deploy breaks another team’s feature. These are real problems. They are also problems that microservices solve at the cost of introducing different, often worse, problems.
What the monolith gives you—and what you give up the moment you extract a service—is transactional consistency, shared schema, easy cross-domain querying, and a single deployment unit. These are not small things. The ability to run Order.includes(:user, :line_items, :payments).find(id) and get everything you need in one round trip is enormously valuable. The ability to wrap a business operation that touches three models in a single database transaction and have ACID guarantees for free is something that distributed systems engineers spend years trying to replicate badly.
DHH called it the “majestic monolith,” and the phrase stuck because it captures something true: a well-structured Rails monolith is a genuinely elegant thing. Single codebase, single deploy, referential integrity enforced by Postgres, a full object model available everywhere, and ActiveRecord relationships that join across any boundary without a network hop. The Rails stack was designed to make this easy, and it does.
The startup in my opening story was handling roughly 50,000 orders per day when they started the microservices migration. Shopify handled millions of orders per day on a monolith for years. GitHub ran on a Rails monolith for most of its first decade. Basecamp still does. The monolith does not fail at scale—undisciplined code fails at scale, and distributing undisciplined code makes it both slower and undisciplined.
The Real Signals That a Monolith Is Genuinely Hurting You
There are real reasons to split a monolith, and they are not about theoretical scale. They are about concrete, measurable pain you are experiencing today.
Teams cannot deploy independently. If two teams need to coordinate deploys because their code lives in the same repo and their changes interact, that is a genuine bottleneck. But the solution is not always a service boundary — it might be a better review process, feature flags, or a module structure that reduces coupling. The service boundary only helps if the teams genuinely have independent release cycles. If they will still coordinate to keep API contracts aligned, you have traded one kind of coordination for a harder one.
A single component has wildly different scaling requirements. The classic example: your image processing pipeline consumes forty-five CPU cores at peak while your web tier sits idle. Colocating them means you provision for the peak of both, which wastes money. When one subsystem genuinely needs different hardware—GPU instances, memory-optimized instances, a completely different runtime—extraction makes economic sense. This is different from “our web tier might someday need more instances than our API tier.” That is solved by horizontal scaling the whole app.
A domain is owned by a genuinely separate organization. Not a separate team inside the same company — a separate organization with separate business objectives, separate deployment cadence, and potentially a separate contract. If you are acquiring a company, integrating a third-party payments vendor, or partnering with a team that runs a different stack, a service boundary is natural. If it is two squads on the same floor reporting to the same VP, a service boundary is bureaucracy pretending to be architecture.
Compliance requires data isolation. GDPR, SOC 2, PCI-DSS, HIPAA — some regulatory regimes require that certain data not coexist in the same store as other data. This is a real constraint that forces service boundaries even when you would rather not have them. Build the boundary because the regulator requires it, not because an architecture diagram looks cleaner.
If you cannot point to one of these four conditions and show it is causing measurable pain today, you should not be extracting a service. You should be making your monolith better.
The Modular Monolith: The Answer Most Teams Skip Over
Between “one big ball of mud” and “forty microservices,” there is a third path that the Rails ecosystem supports extremely well: the modular monolith.
The idea is simple. You keep one codebase, one deploy, one database, and all the operational simplicity that entails. But you structure the code with explicit module boundaries that enforce domain separation and limit coupling between contexts. You get most of the team-autonomy benefits of services without the distributed systems overhead.
Rails Engines are the original tool for this. Each domain becomes an engine with its own models, controllers, migrations, and routes, namespaced so there is no accidental coupling through class name collisions:
# engines/billing/app/models/billing/subscription.rb
module Billing
class Subscription < ApplicationRecord
self.table_name = "billing_subscriptions"
belongs_to :account, class_name: "Accounts::Account"
has_many :invoices, class_name: "Billing::Invoice"
end
end
# engines/billing/app/services/billing/subscription_provisioner.rb
module Billing
class SubscriptionProvisioner
def call(account:, plan:)
ActiveRecord::Base.transaction do
subscription = Subscription.create!(account: account, plan: plan)
Billing::Invoice.generate_for(subscription)
Accounts::Account.find(account.id).touch(:billing_updated_at)
end
end
end
end
The engines can share the same database—cross-domain joins still work, transactions are still ACID—but the namespace boundary makes it clear when you are crossing a domain. Cross-module references become visible and auditable.
For even stricter boundary enforcement, Packwerk adds a linting layer that fails CI when code violates declared package boundaries. Shopify built it to manage their famously large Rails codebase, and it works. A package.yml declares what each module exports and what it is allowed to depend on:
# components/billing/package.yml
enforce_dependencies: true
enforce_privacy: true
dependencies:
- components/accounts
This fails a build the moment a developer in the notifications module tries to reach into billing’s internals. The discipline is enforced automatically, without anyone needing to review for it.
A modular monolith with Packwerk gives you:
- Independent, reviewable domain boundaries
- CI-enforced dependency rules
- A single deploy unit with zero distributed systems overhead
- The ability to eventually extract a module to a service with confidence (you already know the API)
For most teams under three hundred engineers, this is the right answer. It is the architecture I recommend first in every Fractional CTO engagement where the question of “should we do microservices?” comes up.
When Microservices Are Actually the Right Answer
They are the right answer, sometimes. The conditions are specific.
Truly independent scaling with different infrastructure requirements. Your ML inference service needs GPU instances and can tolerate eventual consistency. Your billing API needs to meet PCI compliance and strict data isolation. Your customer-facing web API needs to scale to ten thousand requests per second while your internal admin tool handles one hundred. These are not theoretical scale concerns—they are concrete infrastructure and compliance constraints that make co-location genuinely impractical.
Team autonomy at scale. When you have fifteen teams deploying to the same codebase, even with Packwerk, the friction of coordinating releases and managing CI queue times becomes real. At that scale—which typically means hundreds of engineers and multiple product lines with genuinely different release cadences—service boundaries start to pay off in team velocity. Below that scale, they almost never do.
Legacy system integration. When part of your system runs on a fifteen-year-old Java codebase that the remaining expert just retired from, wrapping it in a service boundary lets you expose a clean API and migrate incrementally without touching the internals. This is the strangler fig pattern and it is one of the most useful architectural moves in legacy modernization.
Technology isolation. You genuinely need Python for ML, Elixir for the real-time messaging component, Go for the high-throughput data ingestion pipeline. Polyglot architectures are a real use case. They are also rarer than the blog posts suggest.
The common thread: these conditions are observable now, not hypothetical. You are not splitting because you might need this someday—you are splitting because you have a concrete constraint today that the monolith cannot accommodate.
The Practical Cost of Microservices You Must Account For
Before you extract your first service, build a cost model that accounts for what you are taking on.
Distributed tracing becomes mandatory. You cannot debug a production incident without it. Plan for OpenTelemetry instrumentation across every service, a trace aggregation backend, and engineers who know how to read flame graphs and trace waterfalls. The OpenTelemetry Rails guide covers this, but multiply the work by the number of services you extract.
Each service boundary is an RPC call that can fail. Network partitions, slow services, cascading timeouts—all the failure modes of distributed systems now apply to what was previously a method call. Circuit breakers, bulkheads, timeout budgets, retry strategies with backoff: all of this needs to be implemented and tested. The Rails timeouts post covers some of this, but in a monolith your biggest timeout risk is a slow database query. In a microservices architecture, every inter-service call is a potential timeout cascade.
Data consistency across service boundaries requires explicit choreography. You can no longer wrap multi-service operations in a database transaction. If the billing service writes successfully but the notifications service fails, you have an inconsistency. The solutions—sagas, outbox patterns, eventual consistency with idempotent event handlers—all add significant complexity. The transactional outbox post covers the Rails implementation. This is non-trivial work that becomes invisible complexity that future engineers must understand to make any change.
Deployment complexity scales with service count. Each service needs its own CI/CD pipeline, its own container image, its own Kamal or Kubernetes deployment config, its own secrets management, its own health check, its own log aggregation. At three services, this is manageable. At twenty, it is a full-time job for a platform team you may not have.
The rough rule I use: extracting a service takes a team one to two months to do properly (service, CI pipeline, observability, contract testing), and adds two to four hours per week of ongoing operational overhead per service, indefinitely. Run that number against the team you have.
A Decision Framework You Can Actually Use
When a team asks me whether to extract a service, I ask these questions in order:
-
What specific, measurable pain are you trying to solve? “It will be cleaner” and “we might need to scale differently someday” are not acceptable answers. Acceptable answers: “deployment coordination between Team A and Team B is delaying releases twice a week” with data, “our image processing blew our AWS bill by 40% last quarter and needs GPU instances,” “PCI says this data cannot coexist with that data.”
-
Have you tried solving it inside the monolith first? A slow query is not a reason to extract a service. A missing Packwerk boundary is not a reason to extract a service. A big classes that is too long is not a reason to extract a service. Try the monolith-native solution first.
-
Do you have a modular monolith with explicit boundaries? If not, build that first. It is faster, cheaper, and reversible. Extracting a service from an already-modular codebase takes a week. Extracting a service from a tangled monolith takes three months and usually makes the monolith more tangled in the process.
-
Can you afford the operational overhead? This requires honesty about team size and engineering bandwidth. A four-person team cannot operate six microservices without it consuming all their time. A twelve-person team can probably operate two or three.
-
What is the rollback plan? If the service extraction does not achieve what you expected, can you merge it back? If the answer is “no, it’s too entangled once it’s out,” that is a risk signal. The best extractions are reversible for at least the first six months.
If you cannot answer questions one and four satisfactorily, the answer is: not yet, possibly not ever.
When You Must Extract: Doing It Right
If you have been through the framework and service extraction is genuinely warranted, do it incrementally.
Extract one bounded context at a time. Start with the least coupled domain — the one with the fewest foreign key relationships to the rest of the schema, the fewest places where the rest of the codebase calls into it. Payments and billing are often well-bounded. User authentication often looks well-bounded but is not (everyone touches the users table).
The strangler fig pattern: build the new service, then route traffic to it gradually with a proxy or feature flag layer, while keeping the monolith path working. Only decommission the monolith path after weeks of clean production data from the new service.
# Transitional routing in the monolith: flag controls which path handles the request
class PaymentsController < ApplicationController
def create
if FeatureFlags.payment_service_enabled?(current_user)
result = PaymentServiceClient.charge(params: payment_params, user_id: current_user.id)
handle_service_result(result)
else
PaymentProcessor.new(payment_params).process
end
end
end
Keep the API contract in a shared schema definition (OpenAPI, Protobuf, JSON Schema) that both sides validate against. This is the contract test layer. Without it, you will discover API mismatches in production.
For data: start by giving the new service read access to the shared Postgres, then migrate it to its own store once the service is stable and its data model is understood. Migrating the schema is the hardest part—do not try to do it on day one.
FAQ
Is a Rails monolith too slow for high traffic?
No. The bottleneck in almost every high-traffic Rails app is the database, not the application code. A properly tuned Rails monolith with connection pooling, caching, background jobs, and read replicas can handle hundreds of millions of requests per month. GitHub, Shopify, and Basecamp are not edge cases. What creates performance problems in monoliths is N+1 queries, missing indexes, synchronous operations that should be async, and over-loading web workers with CPU work. All of these are solvable inside the monolith.
When should a startup consider microservices for a Rails app?
The earliest realistic inflection point is around fifty to one hundred engineers with two or more product lines that have genuinely independent deployment cadences. Below that, the operational overhead of microservices exceeds their team-autonomy benefits. The exception is compliance-driven isolation (PCI, HIPAA) or infrastructure-driven separation (you need GPUs for one component). Those constraints appear at any company size and are legitimate extraction triggers regardless of team size.
What is the difference between a modular monolith and microservices for Rails?
A modular monolith has domain boundaries enforced in code (Rails Engines, Packwerk packages, namespacing) but deploys as a single unit to a single process with a shared database. Microservices deploy as separate processes with separate databases, communicating over the network. The modular monolith gives you ~80% of the team-autonomy benefit at ~10% of the operational cost. The service boundary adds network-call failure modes, distributed tracing requirements, data consistency challenges, and per-service deployment pipelines. Use the modular monolith until you hit a concrete constraint that it cannot solve.
How do I convince my team to not use microservices?
Share the production incident data. Teams that have lived through three-service distributed debugging sessions at two in the morning, chasing a stale cache in a service that should have been invalidated by an event that was silently dropped, do not need convincing. Teams that have read architecture blog posts from Netflix do. The question to put to the room: “What specific thing that is hurting us today would this solve, that we cannot solve with better code organization inside the monolith?” If the answer is fuzzy, that is your answer.
The wrong architecture decision costs eighteen months and multiple engineers. TTB Software has helped Rails teams navigate this exact decision—from modular monolith restructures to careful, incremental service extractions—for nineteen years. If your team is debating the monolith question, let’s talk before the Jira epic gets to 847 tickets.
Related Articles
DORA Metrics for Rails Teams: Tracking Deployment Frequency, Lead Time, and Change Failure Rate
DORA metrics for Rails teams: track deployment frequency, lead time, and change failure rate with GitHub Actions and ...
Rails Technical Due Diligence: A Fractional CTO Checklist for Acquirers and Investors
Rails technical due diligence checklist from a fractional CTO. What to audit before acquiring or investing in a Rails...
Build vs Buy Software: A Fractional CTO's Framework for Engineering Decisions
Build vs buy software decisions can sink a startup. A fractional CTO's framework for evaluating vendors, total cost, ...