← Back to blog

October 15, 2026 · 16 min read

Microservices vs. Monolith: Making the Right Call, Not the Trendy One

From Mid-Level to Senior · Part 14 of 18

  • #Architecture
  • #microservices
  • #system-design
  • #senior-engineer

Few architecture discussions get as heated as this one, and few are argued with less evidence. One side has a slide showing how a famous streaming company runs hundreds of services. The other has a blog post about a company that merged all its services back into one and got faster. Both are real, and neither one is about your system.

I've been on both sides of this. Earlier in my career I worked on a large monolith running on WebLogic, where a production deploy took around five hours. Splitting it into services brought that under one hour. Later, as CTO and then engineering manager, I was responsible for an estate of 45 microservices, including a modernization that took all of them from Java 11 to 25 and Spring Boot 2.7 to 3.5. That was 45 upgrades, 45 pipelines and 45 sets of dashboards, with a team that grew from six to twelve people. Both experiences taught me the same thing from opposite directions: the number of deployable units is a cost you pay every week, and you should only pay it for something you actually need.

Part 13 ended with a design that kept everything inside one service, on purpose. This part is about when that's the right call and when it isn't.

Three shapes, not two

The debate is usually framed as two options. There are at least three, and the middle one is the one people skip.

A horizontal spectrum with three shapes. On the left, a classic monolith: one deployable box with code tangled inside it and one database, labelled one deploy, one database, no enforced boundaries. In the middle, a modular monolith: one deployable box divided into clearly separated modules (orders, payments, catalog, shipping) that talk through narrow public interfaces, with one database split into a schema per module, labelled one deploy, boundaries enforced in code. On the right, microservices: four separate boxes, each with its own database, connected by network arrows, labelled many deploys, boundaries enforced by the network. An arrow under the spectrum reads: more independence to the right, more operational cost to the right. A note says most teams should start in the middle.

A monolith is one deployable unit. One build, one artifact, one process type (maybe running as several instances), usually one database. Nothing about that is bad. What goes wrong with monoliths is not that they're one unit. It's that, over the years, every part starts reaching into every other part, and you end up with what people call a big ball of mud.

A modular monolith is still one deployable unit, but inside it the code is split into modules with real boundaries. Each module owns its data and exposes a small public interface. Other modules can't reach into its internals or its tables, and a test or a build rule fails if they try. You get most of the design benefits people want from microservices, without the network in the middle.

Microservices are separately deployable services, each owning its own data, talking over the network. The boundary is enforced by the fact that you physically can't call a private method in another process.

The important thing to notice is that the move from the left to the middle is about code design, and the move from the middle to the right is about deployment and organization. Many teams that say they need microservices actually need the first move. Their problem is tangled code, and putting a network between tangled pieces gives you tangled pieces that also fail over HTTP.

What microservices actually buy you

Let's be fair to them first. There are real benefits, and a few of them are hard to get any other way.

  • Independent deployment. A team can ship its service without coordinating a release with everyone else. With many teams, this is the big one. It's what took that WebLogic deploy from five hours to under one.
  • Team autonomy. A team can own a service end to end, from the code to the on-call rotation, and make its own decisions inside it.
  • Independent scaling. If one part of the system needs twenty instances and the rest needs two, you can scale just that part.
  • Fault isolation. A memory leak in the reporting service doesn't take checkout down with it, as long as the services are designed so they don't fail together.
  • Different technology where it truly fits. Occasionally a piece of the system needs a different runtime or a different database. This is real but rarer than people think, and it's a weak reason on its own.

Look at the list again and notice that most of the benefits are about people and change, not about the code. Microservices are mainly a way to let many teams work in parallel without stepping on each other. If you have one team, most of the list doesn't apply to you yet.

What they cost

The costs are less visible on a whiteboard, so they tend to get underestimated. They fall into four groups.

A two-column comparison titled what one call costs inside a process versus across the network. Left column, in-process call between modules: well under a microsecond, can't partially fail, shares one database transaction, one stack trace, refactored by the IDE in seconds. Right column, call between services: milliseconds plus serialization, can time out, fail or succeed without you knowing, no shared transaction so you need outboxes, sagas or compensation, needs distributed tracing to debug, and changing the contract means versioning and coordinating with other teams. Below, a row of per-service costs that multiply with the number of services: a pipeline, dashboards and alerts, dependency upgrades, security patches, on-call knowledge. A note says: multiply the bottom row by the number of services.

Operations. Every service needs a pipeline, a deployment, health checks, dashboards, alerts, log routing, secrets and someone who knows what it does at 3 a.m. Every library upgrade and every security patch happens once per service. The Java 11 to 25 modernization made this very concrete. In a monolith, that's one large upgrade. Across 45 services, it was 45 smaller upgrades, each with its own chance for something different to break. Without the platform work covered in Part 8, Part 9 and Part 12, an upgrade like that turns into months of manual work.

Data. This is the one that hurts most and shows up latest. Once each service owns its data, you lose joins across that data and you lose transactions that span it. A report that used to be one SQL query becomes an API call, a cache, or a copy of the data kept in sync with events. Every "save this and tell the other service" becomes the dual write problem from Part 13, and the outbox pattern stops being a special case and becomes something you need everywhere. Business processes that cross services need sagas or compensating actions instead of a rollback.

Latency and failure. A method call between modules takes well under a microsecond and either works or throws. A call between services takes milliseconds, and it can also be slow, time out, or succeed on the other side while you see a failure. So now you need timeouts, retries, idempotency keys and circuit breakers, and you need to think about what happens when the five services a request touches are all having a slightly bad day at once.

Coordination. A change that crosses two modules in a monolith is one pull request. A change that crosses two services is two pull requests, an API version, a deploy order, and sometimes a meeting with another team. If your services keep needing to change together, you've paid for independence you aren't getting.

None of these costs are a reason to never use microservices. They're the price. The question is whether what you get is worth more than what you pay, for your team, this year.

The case for the modular monolith

For most teams, especially anything under three or four teams, a well-structured modular monolith is the better default. You get clear boundaries, one deploy, one database with real transactions, in-process calls that can't partially fail, and refactoring that your IDE can do for you. And if you ever do need to extract a service, the module boundaries are already the seams you'd cut along.

The catch is that the boundaries have to be enforced, or they decay. Conventions in a wiki don't survive a deadline. A test that fails the build does. In the Spring world, Spring Modulith treats each top-level package under your application as a module and can verify that nobody reaches into another module's internals:

com.example.shop
├── orders
│   ├── OrderService.java          ← public API of the module
│   └── internal
│       ├── OrderRepository.java   ← only orders may use this
│       └── OrderEntity.java
├── payments
│   ├── PaymentService.java
│   └── internal/...
└── shipping
    ├── ShippingService.java
    └── internal/...
class ModularityTests {

    @Test
    void modulesRespectTheirBoundaries() {
        ApplicationModules.of(ShopApplication.class).verify();
    }
}

If shipping imports something from orders.internal, that test fails, and the boundary violation shows up in code review instead of two years later. ArchUnit does the same job if you'd rather write the rules yourself.

Two more habits keep a modular monolith honest:

  • Each module owns its tables. One database is fine. One schema per module, with no module querying another's tables directly, is what keeps the data split possible later. A shared table that four modules write to is the thing that makes extraction a six-month project instead of a two-week one.
  • Modules talk through their public API or through events. Spring Modulith also supports publishing application events between modules, with an event publication log that works a lot like the outbox from Part 13. That gets you loose coupling inside one process, and it turns into a real message queue fairly easily if a module ever moves out.

How to decide

Here's the set of questions I'd go through, roughly in this order. They're the routine from Part 13 applied to this one decision.

A decision flowchart. It starts at: are your problems really about deployment and team coordination, or about tangled code? If tangled code, go to: build a modular monolith and enforce boundaries. Otherwise, the next question: do you have more than two or three teams that keep blocking each other's releases? If no, modular monolith. If yes: are the boundaries between those areas well understood and stable? If no, modular monolith first and let the boundaries settle. If yes: can you run many services well today, meaning automated pipelines, observability, on-call, and someone owning the platform? If no, invest in the platform first, then extract. If yes: extract services along the module boundaries, one at a time, starting with the one that has the strongest reason. A side note says: a single part with very different scaling, security or availability needs can justify extracting just that one part, even with one team.

What problem are you actually trying to solve? Write it down in one sentence. "Deploys take five hours and every team waits on every other team" is a problem microservices can help with. "The code is hard to change" usually isn't, because the code will still be hard to change after you split it, and now it's also distributed.

How many teams, and are they blocking each other? One team with a monolith has nobody to coordinate with. The coordination cost that microservices remove doesn't exist yet. Once you have several teams waiting on each other's releases, with merge conflicts in shared code and a release train nobody can get on, independent deployment starts to be worth its price.

Do you know where the boundaries are? Getting a module boundary wrong in a monolith costs a refactoring. Getting a service boundary wrong costs a distributed refactoring: moving data between databases, changing APIs that other teams use, and running both versions while you migrate. If the domain is still changing fast, as it usually is in a young product, keep the boundaries cheap to move.

Can you run many services well? Be honest here. If deploying one service today needs manual steps, if you can't follow a request across two services in your tracing, if nobody owns the shared platform, then more services means more of everything that already hurts. Fix the platform first. That work pays off either way.

Is there one part with very different needs? Sometimes the answer is "one service, not twenty". A PDF rendering job that needs a lot of memory, a public endpoint that takes ten times the traffic of everything else, or a payment component with stricter security and compliance rules can each justify being separate on their own. Extract that one part and leave the rest alone. That's a perfectly good architecture and much easier to run than splitting everything.

If you get to the end of the list and most answers point toward staying together, stay together, and put the effort into module boundaries instead. If they point the other way, the next section is about doing the split without stopping the world.

If you need to split, split gradually

The worst way to move to microservices is a big rewrite: freeze the monolith, build the new system on the side, switch over in one go. It takes much longer than planned, the old system keeps changing while you build the new one, and the switch is a single high-risk event.

What works much better is the strangler fig approach. You extract one piece at a time while the monolith keeps running, and route traffic for that piece to the new service. Over time the monolith gets smaller until there's nothing worth keeping. In practice:

  1. Get the module boundaries right inside the monolith first. If you can't separate a module cleanly in one process, you won't do it better across a network. This step alone often removes the need for the rest.
  2. Pick the first candidate on purpose. Choose the module with the strongest reason to leave (different scaling, a separate team, a different release rhythm) and the fewest dependencies into the rest. Not the most important one. Learn the process on something that isn't checkout.
  3. Split the data before or with the code. The module should already own its tables. Move them to their own database, and replace any remaining cross-module queries with API calls or events. This is usually the hardest step and the one that decides whether the extraction works.
  4. Put a routing layer in front. An API gateway or a simple proxy rule sends that module's traffic to the new service. If something goes wrong, you route it back. The deployment strategies from Part 12 apply here: send a small percentage first and watch the metrics.
  5. Delete the old code. Leaving the old module in place "just in case" means two implementations to keep in sync. Once the new service has handled real traffic for a while, remove it.
  6. Stop when the reason runs out. You don't have to extract everything. Ending up with a smaller core monolith plus a few services is a normal and healthy place to stay.

In the WebLogic case, the five-hour deploy came from shipping everything as one unit, and the gain came from being able to deploy pieces on their own. In most splits like that, writing the new services is the easy part. Finding where the old code and data are coupled, and pulling them apart, is where the time goes. That's why step 1 matters so much.

Traps to watch for

  • The distributed monolith. Services that have to be deployed together, or that can't start unless five others are up. You pay every microservice cost and get none of the independence. The test is simple: can you deploy one service on a Tuesday afternoon without telling anyone? If not, you have a distributed monolith.
  • A shared database across services. It looks like a shortcut and it brings back all the coupling you split to escape, now with no compiler to tell you about it. A schema change in one service breaks another one in production.
  • Splitting by technical layer. A "database service", a "validation service" and a "business logic service" means every feature crosses all of them. Split by business capability (orders, payments, shipping) so most changes stay inside one service.
  • Nano-services. One service per entity or per endpoint. The number of services grows faster than the number of people who understand them, and every request becomes a chain of network calls.
  • Splitting before you understand the domain. Early in a product, the boundaries move every few months. Moving them in one codebase is a refactoring. Moving them across services is a project.
  • Choosing an architecture for your résumé. If you can't explain the choice in terms of a problem your team has today, it's not the real reason, and it's worth being honest with yourself about that.

What to try this week

  • Write the one-sentence problem. If your team is talking about microservices, or about merging services back, write down the actual problem it would solve. If nobody can agree on the sentence, the architecture discussion is premature.
  • Map your current boundaries. For a monolith, list the modules and check which ones reach into each other's tables or internals. For services, check which ones always deploy together. Both are signs the boundary is in the wrong place.
  • Add one boundary test. Spring Modulith's verify() or a single ArchUnit rule between two packages. Start with a boundary that's already clean and keep it that way.
  • Count the per-service costs. For each service, does it have a pipeline, a dashboard, an alert and an owner? The gaps tell you whether your platform can take more services.
  • Find one place where you use a call when you could use an event. Or the other way around. Either way, think about what happens when the other side is down.

The short version

  • There are three shapes, not two: monolith, modular monolith and microservices. Most teams should start in the middle.
  • Microservices mostly buy independence for people: separate deploys, team ownership, separate scaling. With one team, most of that doesn't apply yet.
  • They cost you in operations, data, latency and coordination, and those costs multiply with every service you add.
  • Tangled code is a design problem. Putting a network in the middle doesn't fix it.
  • A modular monolith with enforced boundaries gives you most of the design benefits and keeps the option to split later.
  • Split when several teams are blocking each other, the boundaries are stable, and your platform can run many services well. Or extract just the one part that has very different needs.
  • If you split, do it one piece at a time, data included, behind a routing layer you can roll back.
  • Watch out for the distributed monolith. It has the costs of both options and the benefits of neither.

This is the last part of Module B. The next module moves from systems to people. Part 15 starts it with what changes when you become a tech lead, and how to set technical direction and run a project without a management title.

This is Part 14 of 18 in the series. The Senior Engineer Roadmap maps the whole series, with a short self-assessment and four reading orders.