Monolith First: Why Microservices Shouldn't Be Your Starting Point
Microservices trade simplicity for firm boundaries and independent deployment, at a real premium. Start with a well-modularized monolith and split only when complexity demands it.
A team of four starts a new booking product. Before the first customer signs up, the diagram already has eight services, a message broker, an API gateway and a Kubernetes cluster. Three months later, most features touch three repositories, and the most common production bug is one service shipping a contract change before the service that calls it. None of these pieces is wrong on its own. The team simply paid, on day one, for problems it didn't have yet.
The common misconception
The belief: microservices are how modern systems are built, and a monolith is legacy you'll eventually throw away because it can't scale. Starting with services, the thinking goes, saves a painful rewrite later.
It's easy to see why smart people believe it. The famous success stories are microservice stories. Microsoft's Azure guide lists real benefits: independent deployment, small focused teams, fault isolation and scaling each service on its own. And many developers have suffered a tangled monolith. Fowler observes that the Big Ball of Mud is the most common architectural pattern, and that frustration with what usually happens to monoliths is what drove several teams to microservices.
The half-truth: those benefits are real. But they come at a price, and two of the biggest reasons people give, scaling and modularity, don't actually require services.
What actually happens
Services come with a premium
Fowler's 2015 post puts it bluntly: microservices "introduce complexity on their own account. This adds a premium to a project's cost and risk - one that often gets projects into serious trouble." He lists what you take on: "automated deployment, monitoring, dealing with failure, eventual consistency, and other factors that a distributed system introduces." His guideline follows: "don't even consider microservices unless you have a system that's too complex to manage as a monolith."
His trade-offs article spells out the costs. Distribution: "Distributed systems are harder to program, since remote calls are slow and are always at risk of failure." Operations: "You need a mature operations team to manage lots of services, which are being redeployed regularly." Microsoft's guide agrees: "Each service is simpler, but the entire system as a whole is more complex."
A monolith can scale
Lewis and Fowler's original microservices article states it plainly: "You can horizontally scale the monolith by running many instances behind a load-balancer." The real limitation is narrower: scaling a monolith means scaling the whole application, not only the part that needs more resources. That matters for some systems, but it's a specific problem, not a reason to start distributed. Continuous delivery doesn't require services either: Fowler cites Facebook and Etsy.
Boundaries are hardest to get right at the start
Services "only work well if you come up with good, stable boundaries between the services," Fowler writes in MonolithFirst, which is the job of finding the right . "Any refactoring of functionality between services is much harder than it is in a monolith. But even experienced architects working in familiar domains have great difficulty getting boundaries right at the beginning." In a monolith, a wrong boundary costs a refactoring. Between services, it costs a contract change, a data migration and a coordinated release.
That's why he reports a pattern: "Almost all the successful microservice stories have started with a monolith that got too big and was broken up", while almost every system he'd heard of that was built as microservices from scratch "has ended up in serious trouble."
What you need first is modularity
The benefit people actually want is strong module boundaries, and a monolith can have them. Fowler: "It's perfectly possible to have firm module boundaries with a monolith, but it requires discipline." That discipline is what makes a later split possible. A is one deployable unit whose modules own their data and talk only through small public contracts.
The fix: modules with real boundaries
C# · Ordering/Checkout.cs
public sealed class Checkout(ShopDb db){ public async Task<string> PlaceAsync(Order order, CancellationToken ct) { db.Orders.Add(order); // Ordering writes Billing's table and copies Billing's tax rule var invoice = new Invoice(order.Id, order.Net * 1.14m); db.Invoices.Add(invoice); await db.SaveChangesAsync(ct); return invoice.Number; }}// Every module reaches into every table: Billing can't change alone,// and splitting it out later means untangling all of this first
C# · Billing/BillingModule.cs
// The module's public contract: one coarse call, no tables exposedpublic interface IBilling{ Task<string> InvoiceAsync(Guid orderId, decimal net, CancellationToken ct);}// Tax rules and Billing's tables stay internal to this projectinternal sealed class BillingModule(BillingDb db) : IBilling{ public async Task<string> InvoiceAsync( Guid orderId, decimal net, CancellationToken ct) { var invoice = Invoice.For(orderId, net); // the VAT rule lives here db.Invoices.Add(invoice); await db.SaveChangesAsync(ct); return invoice.Number; }}public static class BillingSetup{ public static IServiceCollection AddBilling(this IServiceCollection s) => s.AddScoped<IBilling, BillingModule>();}
Ordering now calls billing.InvoiceAsync(order.Id, order.Net, ct) and can't see Invoice or Billing's tables, because the compiler stops it. Billing can change its tax rule or schema without touching Ordering. Both modules still share one process and one database, so a single transaction across them stays possible; with a monolith, Fowler notes, "you can update a bunch of things together in a single transaction". If Billing ever becomes a service, the seam already exists. Keep the contract coarse, though: Lewis and Fowler warn that "a good in-process interface is usually not a good service interface."
Myth
Reality
Microservices are the modern default
Fowler: "The majority of software systems should be built as a single monolithic application."
A monolith can't scale
It scales out with many instances behind a load balancer; it just can't scale one part alone
Starting with services avoids a rewrite
Early boundaries are often wrong, and moving them between services is much harder
Services give you modularity for free
They make boundaries firmer, but wrong boundaries become a handicap
Continuous delivery needs services
Facebook and Etsy deliver large monoliths continuously
How to apply it in your project
Write down why you want servicesList the concrete pain each split would solve. If the answer is "it's modern" or "it scales", a monolith behind a load balancer already covers it.
Draw modules around bounded contextsOne project per module, internal by default, and each module owns its own tables. No module reads another module's tables.
Keep module contracts coarseDesign each public interface as if it might become remote one day: few calls, whole requests and results, no entities leaking out.
Split when a specific pain appearsWhen one module needs its own release cadence, team or scaling, peel it off at the edge, the gradual route Fowler describes, and keep the rest together.
Key takeaways
Microservices are a trade-off with a real premium in distribution, consistency and operations, not a modern default.
A monolith scales out behind a load balancer; what it can't do is scale one part on its own.
Service boundaries are hardest to get right early, and much harder to move once they're remote.
Firm module boundaries are possible inside a monolith with discipline, and they're what makes a later split possible.
Split when a specific complexity demands it, starting from a modular monolith, not from a diagram.
التعليقات (0)