I've built and maintained both monoliths that hum along for years with minimal operational overhead and microservices estates that sprawl across dozens of repositories, pipelines, and dashboards. The decision between the two is rarely about technology fashion and almost always about team constraints, domain complexity, and how you need to ship software. In my experience, teams that choose well do so because they have a clear framework for weighing trade-offs, not because they followed a blog post that declared one approach dead. This article lays out the decision framework I actually use with teams when they are standing at that fork in the road.
Why Most Teams Should Start With a Well-Structured Monolith
A monolith gets a bad reputation because we conflate it with a big ball of mud. They are not the same. A well-structured monolith is a single deployable unit with clear internal module boundaries, enforced dependencies, and isolated data access. It gives you transactions, refactoring with IDE support, single-path debugging, and a deployment model that a team of three to eight can reason about. I've found that for most products before product-market fit, that simplicity is a competitive advantage.
The strongest argument for the monolith is the cost of the alternative. Microservices shift complexity from code to operations. You trade in-process method calls for network calls, compiler errors for eventual consistency bugs, and a single log stream for distributed tracing. If you do not yet have strong observability, mature CI/CD, and a platform team that can manage service discovery and secrets rotation, you will feel that cost immediately.
What a Modular Monolith Looks Like in Practice
Structure matters more than the deployment artifact. I organize monoliths around domain modules with explicit public APIs. Each module owns its own services, repositories, and domain models, and other modules cannot reach into its internals. This is where ideas from Clean Architecture in Practice: Beyond the Theory pay for themselves, even if you never split a service.
// Example: Enforced module boundaries in a Node.js / TypeScript monolith
// modules/orders/public-api.ts - the ONLY entry point other modules may import
export interface OrderService {
createOrder(cmd: CreateOrderCommand): Promise<Order>;
getOrder(id: string): Promise<Order | null>;
}
// modules/orders/internal/repository.ts - NOT exported from public-api
// Attempting to import this directly fails the dependency lint rule
import { db } from '../../shared/infrastructure/db';
export class OrderRepository {
async save(order: Order): Promise<void> {
// Transaction stays local, no distributed saga needed
await db.tx(async t => {
await t.insert(order).into('orders');
await t.insert(order.lines).into('order_lines');
});
}
}
// ESLint rule enforces: modules/[name]/internal/** cannot be imported cross-module
With this layout, you can keep ACID transactions, run a single test suite that covers cross-module workflows, and still extract a module into a separate service later with minimal rewriting. The boundary is logical first, physical later.
When the Monolith Scales Further Than You Expect
I have seen monoliths handle millions of daily active users on a single primary database with read replicas, a Redis cache layer, and background job workers. Vertical scaling and read scaling get you surprisingly far. The MDN Web Docs on HTTP is a useful reference when you are tuning caching and connection handling before you reach for service decomposition. Adding a CDN, optimizing N+1 queries, and moving async work to a queue often delays the need for distribution by 12 to 18 months.
That does not mean a monolith is forever. It means you should make the split when the pain of staying together outweighs the cost of distribution, not because a diagram looked cleaner.
Mapping Your Domain Boundaries Before Choosing Services
The most expensive microservices mistake I see is splitting by technical layer or by entity table. Teams create a UserService, an OrderService, and a ProductService because those tables exist. Those are not bounded contexts; they are data entities that are highly coupled. Every order needs a user and a product, so you end up with synchronous fan-out calls for every request.
Start with the business capabilities. Where does the ubiquitous language change? Where do invariants belong to a single aggregate? If you talk to the business, "Inventory," "Pricing," and "Fulfillment" often turn out to be separate contexts with different lifecycles, even though they all touch the concept of a product.
This mapping exercise is non-negotiable. I will not recommend microservices until a team can sketch their bounded contexts and explain the aggregates inside each. If that modeling is fuzzy, a modular monolith will force you to clarify it with less risk. The concepts are covered thoroughly in Domain-Driven Design: Bounded Contexts and Aggregate Roots Explained, and applying them inside a monolith first will save you from building the distributed version of a confused domain.
A Lightweight Workshop That Works
I run a half-day event storming session with product, engineering, and support. We put domain events on the wall in chronological order, then cluster them into aggregates and contexts. We look for three signals: 1) contexts that change for different reasons and at different rates, 2) invariants that must be consistent within a transaction, and 3) workflows that are naturally eventual. The first suggests a potential service boundary, the second argues for keeping things together, and the third hints at an async boundary where messaging fits.
# Python example: Keeping invariants inside a single aggregate
# This would be painful to split across services
class Order:
def __init__(self, order_id: str, lines: list[OrderLine]):
self.order_id = order_id
self.lines = lines
self.status = "DRAFT"
def confirm(self) -> None:
# Invariant: An order can only be confirmed if inventory was reserved
# and total matches pricing rules - needs immediate consistency
if not self.lines:
raise ValueError("Order must have at least one line")
if sum(l.quantity for l in self.lines) == 0:
raise ValueError("Quantity must be positive")
if self._total() <= 0:
raise ValueError("Total must be positive")
self.status = "CONFIRMED"
def _total(self) -> float:
return sum(l.unit_price * l.quantity for l in self.lines)
If your invariants span what you thought were two services, your boundary is wrong. Keep that aggregate in one process until you have a clear strategy for sagas and compensations. Reference the Python Documentation on dataclasses and domain modeling for practical patterns for keeping aggregates pure and testable without infrastructure noise.
When Deployment and Team Friction Signal a Need to Split
Architecture should reflect how teams need to work. I pay close attention to deployment and organizational signals because they predict microservices pain or payoff better than technical diagrams.
You have a real signal to split when: a single team's change routinely breaks another team's flow, your main branch is blocked for hours because ten teams merge to the same codebase, or a small change to the reporting module requires a full regression test and release of the checkout path. In my experience, the threshold is usually 2-3 independent product teams of 5-8 engineers each, all needing to ship at least weekly without coordination.
Conway's Law Is Not Just a Theory
If you have one team, giving them eight microservices means one team now operates eight deployment pipelines, eight health checks, and eight failure modes. Cognitive load goes up, throughput goes down. If you have four teams that own discrete business capabilities and you give them a single monolith with no module boundaries, every pull request becomes a cross-team negotiation. Match the architecture to the team topology you have, not the one you wish you had.
Ask these questions honestly: Do we need independent deployability for different business risks? Does checkout require higher availability and stricter change control than the internal admin portal? Can we afford to version and maintain public contracts between services? If the answers are no, the monolith with feature flags and well-isolated modules will let you move faster.
Data Ownership, Transactions, and the Consistency Trade-off
Data is where monolith vs. microservices stops being an application debate and becomes a distributed systems debate. In a monolith, a single relational database gives you ACID transactions. Creating an order, reserving inventory, and charging a payment can succeed or fail together. In microservices, each service is supposed to own its data. That is the whole point, otherwise you have a distributed monolith that shares a database and inherits the worst of both worlds.
Once data is owned separately, cross-service workflows become eventually consistent. You cannot wrap them in a single transaction. You need to design for sagas, idempotency, outbox patterns, and compensating actions. This is solvable, but it is a step change in complexity that needs to be justified.
Patterns That Capture the Cost
Consider an order workflow. In a monolith, it is a transaction. With services, it becomes a saga: Order Service creates a pending order, Inventory Service tries to reserve stock, Payment Service attempts to charge, and failures trigger compensations in reverse order. You need message durability, deduplication, and observability to reason about where a stuck order is. I often point teams to Event-Driven Architecture: Commands, Events and Sagas when they first confront this, because the messaging pattern choice determines whether you can debug the system at 2 a.m.
// Outbox pattern: ensures atomic commit of state + event in one service
// No distributed transaction needed, consumers read from outbox table
async function createOrderWithEvent(order: Order) {
await db.transaction(async (trx) => {
await trx('orders').insert(order);
await trx('outbox').insert({
aggregate_id: order.id,
type: 'OrderCreated',
payload: JSON.stringify(order),
created_at: new Date().toISOString()
});
});
// Separate relay publishes outbox rows to the message bus
// Consumer must handle duplicates - make handler idempotent
}
async function handleOrderCreated(event: OrderCreatedEvent) {
if (await processedEvents.exists(event.id)) return;
await inventory.reserve(event.payload.lines);
await processedEvents.mark(event.id);
}
If your business cannot tolerate eventual consistency for a particular workflow — for example, you cannot oversell limited inventory — you either keep that workflow inside one service boundary or you design a reservation model with explicit timeouts and compensations. Do not pretend a network call is as reliable as a function call. Plan for retries, timeouts, and duplicate delivery from day one.
My Decision Matrix for Choosing Between Monolith and Microservices
After several migrations in both directions, I now use a weighted checklist rather than a single rule. No single factor should drive the decision; the pattern across factors should. Score each row honestly for your current context, not your projected headcount in two years.
| Factor | Favors Monolith | Favors Microservices |
|---|---|---|
| Team Size & Structure | 1 team, < 10 engineers, shared ownership | 3+ autonomous teams, > 25 engineers, clear capability ownership |
| Deployment Frequency | Weekly or less, coordinated releases acceptable | Multiple teams need daily independent deploys |
| Domain Boundaries | Fuzzy contexts, shared invariants, frequent cross-entity transactions | Stable bounded contexts with isolated invariants |
| Consistency Requirements | Strong consistency required across workflows | Eventual consistency acceptable, saga/compensation understood |
| Operational Maturity | Limited observability, basic CI/CD, no platform support | Centralized logging, tracing, progressive delivery, on-call per service |
| Scaling Needs | Uniform load, scales with replicas and caching | Heterogeneous load, isolated scaling or tech stack per capability |
| Regulatory & Tenancy | Single compliance scope | Isolated data residency or per-tenant deployment required |
How I use it: If you lean microservices on four or more rows and you can articulate your bounded contexts, a split is worth piloting with one boundary, not five at once. If you lean monolith on most rows, invest in modularization, faster tests, and a better delivery pipeline. The return on that investment is almost always higher than a premature service extraction.
The Incremental Path That Rarely Fails
When a split is justified, I never recommend a big bang rewrite. I extract one capability that scores high on the matrix — often something like notifications, search indexing, or billing — and leave the core transaction path in the monolith. We put a strangler facade in front, migrate traffic gradually, and keep the database separate from day one. That first extraction teaches the organization how to handle contracts, versioning, and on-call before the architecture depends on it.
In my experience, the teams that succeed treat the monolith and microservices as points on a spectrum. A modular monolith with a single extracted service often remains the right answer for years, even at significant scale.
Frequently Asked Questions
Isn't a monolith harder to scale than microservices?
Not necessarily. A monolith can scale horizontally behind a load balancer just like any stateless service. You scale the whole unit. That is inefficient if only one capability is hot, but for many workloads the load is fairly uniform or can be handled with caching, read replicas, and async workers. I only split for scaling when I have data showing one bounded context has radically different resource or latency needs that would waste resources if scaled as part of the monolith.
How do I know if my bounded contexts are correct before splitting?
You never know with absolute certainty, which is why I suggest proving them inside the monolith first. If two modules constantly need synchronous calls between them to satisfy invariants, the boundary is probably wrong. A good test is whether a team can describe its context's business rules and data without referencing another context's internals. If you can build and test the module with a fake boundary, the boundary is likely stable enough to make physical.
What about microservices for technology diversity?
Polyglot persistence and language choice are valid but rarely decisive alone. I have seen teams adopt three languages for three services and then struggle to hire and rotate engineers. In practice, most microservices estates still converge on one or two stacks. Only choose a separate technology if the capability has a requirement that your primary stack handles poorly — for example, a real-time processing engine or ML inference service — and you have the operational capacity to support it.
We already built microservices and regret it. Can we go back?
Yes, and it is more common than people admit. I have helped teams consolidate services back into a modular monolith when the operational overhead exceeded the team benefits. The path is to identify services with high coupling and low independent deploy value, merge them into a single codebase with preserved module boundaries, and unify the data store where consistency is needed. It reduces latency, simplifies transactions, and often improves reliability without losing the domain modeling you did.