Building at scale · L2Monolith, modular monolith or microservices

Monolith, modular monolith or microservices

Microservices let teams ship on their own, but every network call has a cost. Learn what each style buys, what it costs, and why a modular monolith is often the best start.

L2 SeniorBuilding at scale18 min read
Fact-checked by AI against cited sources · Human review pendingLast reviewed 21 Oct 2026 · How we check content
Section 1 of 8

What broke

A made-up story to show a common failure. Not about a real company.

This story is made up, but the pattern is common.

A shop has one large app and 40 engineers. Deploys queue up, and one team's bug can block everyone's release. So the company decides to "move to microservices". In six months, the app becomes nine services.

But the services still read and write the same database tables. A new checkout feature needs changes in five services. The five teams must deploy them in the right order, on the same night.

Then a customer is charged, but gets no order. The request crossed four services. Each one has its own logs, and nothing ties them together. It takes two days to find a timeout between two of them.

The team kept the old pain, the shared release. They added new pain: network calls, partial failures and lost traces. They split the code, but not the ownership or the data.

Section 2 of 8

The idea in simple words

A monolith is one application that you build and deploy as one unit. Lewis and Fowler point to two limits. Change cycles are tied together, so a small change means you build and deploy the whole app. And you must scale the whole app, not just the part that needs more resources. 1

Microservices build one application as a set of small services. 1 Each service can be deployed and scaled on its own. 1

A modular monolith sits between them. Shopify describes it as one application in which "there are strictly enforced boundaries between different domains". 6 You get clear parts, but still one deploy.

The key idea. Microservices mostly buy independence for teams: each team deploys and scales its part on its own. You pay for it with network calls, data spread across databases and more to run. Pay only when the independence is worth more than the cost.

Section 3 of 8

How it works

What microservices cost

Step through one order request in both styles. Use Next and Back, or the ← and → keys.

One order request: inside a modular monolith, then across four servicesModular monolith: one process Orders Stock Payments Email 3 function calls · 1 database ✓ one transaction: all or nothing Microservices: four processes Orders Stock Payments Email reservechargenotify timeout: was the card charged? DBDBDBDB3 hops · 4 DBs · no shared transaction SeniorPath
  1. In a modular monolith, an order request reaches the Orders module. It calls Stock, Payments and Email as plain function calls, inside one process, with one database.
  2. All the writes go in one database transaction. If the payment fails, the stock change rolls back too. A stack trace shows the whole path.
  3. Now the same request with four services. Orders must call Stock, Payments and Email over the network. Each call adds a hop, and its own wait.
  4. Any hop can fail or time out. If the charge call times out, Orders does not know if the card was charged. It needs timeouts, retries and idempotency keys.
  5. Each service owns its database, so there is no single transaction. To undo the stock hold, you need a saga. To see the whole path, you need distributed tracing.
Step 1 of 5

Network calls. A function call in memory becomes a request over the network. Shopify lists this as one reason they did not pick microservices. Network calls add latency and reduce reliability. 6 Lewis and Fowler say services must be designed to cope when other services fail. 1 So every call needs a timeout, retries and idempotency.

Data and transactions. Each service usually owns its data. Lewis and Fowler write that distributed transactions "are notoriously difficult to implement". So microservice systems tend to accept eventual consistency and fix problems with compensating operations. 1 In practice, that means sagas, outbox and CDC.

Running it. Fowler calls this the "microservice premium". The style adds cost and risk that "often gets projects into serious trouble". You need deployment automation, monitoring, failure handling and a way to deal with eventual consistency. 3 Shopify also lists a test and deploy pipeline for each service, and infrastructure for each one. Large changes across services need coordinated deploys. 6

To follow one request across services, you also need good observability, with traces that cross every hop.

Conway's law

In 1968, Melvin Conway argued that organisations which design systems are "constrained to produce designs which are copies of the communication structures of these organizations". 5 This is Conway's law. Lewis and Fowler give an example. When teams are split by technical layer, such as UI, server and database, even simple changes become projects across teams. They call this "Conway's Law in action". Their answer is cross-functional teams and services organised around business capabilities. 1

Our advice: draw the team chart next to the service map. If one team owns six services, it gets all the costs and little of the independence. If one service needs three teams to change it, its boundary is wrong. The lesson on team topologies and Conway's law goes deeper.

The modular monolith: a common middle path

Shopify runs "one of the largest Ruby on Rails codebases in existence". More than a thousand developers have worked on it for over a decade. 6 They judged that microservices "would bring their own set of challenges". 6

So they kept one app and changed how the code was organised. They moved from folders by software type (models, views, controllers) to components by business area, such as orders, shipping, inventory and billing. 6 A tool records the calls made while tests run in CI. An internal tool called Wedge uses this data to flag calls that cross component boundaries. Calls are allowed only to things a component makes public. 6

Fowler gives the same default. Do not even consider microservices unless the system is too complex to manage as a monolith. Build most systems as one application with good internal modularity. 3

Monolith first, then the strangler fig

Fowler noticed that "almost all the successful microservice stories have started with a monolith that got too big and was broken up". Systems built as microservices from scratch often "ended up in serious trouble". 2 One reason: even experienced architects find it hard to get boundaries right at the start. 2 He also notes that this view is not shared by everyone. 2

When it is time to split, do not rewrite everything at once. Fowler's strangler fig approach grows the new system around the old one. You add new parts next to the old code, then move behaviour across one piece at a time. 4 Each step is small, so the risk is lower and value arrives sooner. 4 Sam Newman's book covers this pattern, and how to split the database when you break up a monolith. It also asks a harder question: should you migrate at all? 9

Going back is allowed

In 2023, a Prime Video team wrote about a monitoring service built from distributed serverless parts. The way the team used some components hit a hard scaling limit at about 5% of the expected load. Its orchestration and the data passed between parts cost the most. 7 The team moved all the parts into one process, so data moved in memory. The infrastructure cost of this one service fell by over 90%. 7 The post adds that the choice between microservices and a monolith "has to be made on a case-by-case basis". 7

Segment had over 140 small services. Three full-time engineers spent most of their time keeping the system running. 8 They merged the services into one. Deploys and tests became much faster. 8 The post is honest about the cost: one bad part can now crash the whole service. 8

When to split, and signs you split too early

Our rules for when one part should become its own service:

  • A separate team owns it, and the shared release truly blocks that team.
  • It needs very different scaling, hardware or reliability from the rest.
  • Its boundary is already clean inside the modular monolith, with few calls across it.

Signs you split too early:

  • Most features change several services, which must deploy together.
  • Services share database tables.
  • You have more services than teams.
  • Nobody can follow one request from end to end.
Section 4 of 8

Trade-offs

OptionIndependent deploys?Main costUse it when
MonolithNo Change cycles are tied together. 1Shared release. You scale all of it. 1A small team, a new product, a domain still being learned.
Modular monolithNo , but teams work in clear parts. 6You must check the boundaries, for example with a CI tool. 6The default for most growing teams.
MicroservicesYes Each can deploy and scale on its own. 1Network calls, no shared transactions, more to run. 3 6Many teams that block each other, or parts with very different needs.
Services with shared tables and lockstep deploysNo All the costs of microservices, with few of the gains.Never on purpose. Merge back or fix the boundary.
Section 5 of 8

At work: how a senior uses this

  • When someone says "let's use microservices", ask: "Which team will deploy on its own because of this, and what does it stop waiting for?"
  • Start with a modular monolith. Make each module own its tables, and check the boundaries in CI.
  • Before you extract a service, count the calls across that boundary. If it is chatty, it is not ready.
  • Split one service at a time, with the strangler fig approach. Keep a way to send traffic back.
  • Give each service one owning team. More services than teams is a warning.
  • Budget the premium: tracing, dashboards, on-call, a pipeline for each service, and a plan for data that crosses services.
Section 6 of 8

With AI

What to ask the agent

"Here is our module list and the calls between modules from the last month. Group modules that call each other a lot. Suggest boundaries where cross-module calls are rare."

"We want to extract the Payments module into a service. List every database table it reads or writes that other modules also use, and every call into it. What must change first?"

"Act as a skeptical staff engineer. Argue against splitting this app into services. What new failures and costs would we take on?"

What to check yourself

  • The call data is real, from traces or code analysis, not guessed by the agent.
  • Every table in the split plan has one owner. No two services write the same table.
  • Every new network call has a timeout, a retry rule and an idempotency key where it changes data.
  • The plan says which team owns each new service, and who is on call for it.
  • Claims about a tool's limits come from its official docs.
Section 7 of 8

Check yourself

1. According to Lewis and Fowler, what does a monolith force on you that microservices avoid?

Show answer

Change cycles are tied together, and you scale the whole app, not just the busy part. In a monolith, a small change means building and deploying the whole app. Scaling also means scaling all of it.

2. What is a modular monolith, in Shopify's words?

Show answer

One application with strictly enforced boundaries between domains. All the code powers one application, but the boundaries between domains are checked. Shopify wanted more modularity without more deployment units.

3. Your team of 6 engineers is starting a new product. The domain is still unclear. What does Fowler's MonolithFirst suggest?

Show answer

Start with a monolith, and split it once you understand the boundaries. Fowler notes that even experienced architects find it hard to get boundaries right at the start. Almost all successful microservice stories began with a monolith.

4. Four services must always be deployed together, and they read the same database tables. What is the best description?

Show answer

A system with the network costs of microservices but without the independent deploys. Services that must ship together and share tables cannot change on their own. You pay for network calls and get little back.

5. Why did Prime Video's monitoring team move to one process?

Show answer

Orchestration and passing data between parts were the biggest costs, and their design hit a scaling limit at about 5% of the expected load. Moving the parts into one process kept the data in memory and cut this service's infrastructure cost by over 90%. The post says the choice must be made case by case.

Your progress is saved only in this browser. Export it to keep it safe.

Was this clear?
Report a mistake (opens GitHub in a new tab)
Section 8 of 8

Go deeper

Show 9 sources and related lessons
  1. James Lewis and Martin Fowler, “Microservices” (martinfowler.com, March 2014) (opens in a new tab)
    The common definition of the style, the comparison with a monolith, Conway's law, decentralised data and design for failure.
  2. Martin Fowler, “MonolithFirst” (June 2015) (opens in a new tab)
    Why most successful microservice stories began as a monolith, and why boundaries are hard to get right early.
  3. Martin Fowler, “MicroservicePremium” (May 2015) (opens in a new tab)
    The extra cost and risk of microservices, and when not to consider them.
  4. Martin Fowler, “Strangler Fig” (August 2024 version) (opens in a new tab)
    How to replace an old system bit by bit instead of in one big rewrite.
  5. Melvin E. Conway, “How Do Committees Invent?”, Datamation, April 1968 (opens in a new tab)
    The original paper behind Conway's law. The main claim is in the conclusion.
  6. Kirsten Westeinde, “Deconstructing the Monolith: Designing Software that Maximizes Developer Productivity”, Shopify Engineering (February 2019) (opens in a new tab)
    Why Shopify chose a modular monolith over microservices, how they split the code, and the Wedge tool that checks boundaries.
  7. Marcin Kolny, “Scaling up the Prime Video audio/video monitoring service and reducing costs by 90%”, Prime Video Tech (March 2023, archived copy) (opens in a new tab)
    One team moved a service from distributed serverless parts into one process, and cut its infrastructure cost by over 90%.
  8. Alexandra Noonan, “Goodbye Microservices: From 100s of problem children to 1 superstar”, Segment (July 2018) (opens in a new tab)
    Segment merged over 140 small services back into one, and lists what got better and what got worse.
  9. Sam Newman, “Monolith to Microservices” (O'Reilly), book page (opens in a new tab)
    A book on whether to migrate at all, migration patterns such as the strangler fig, and splitting the database.

Case studies: Shopify: Choosing a modular monolith over microservices · Swiggy: Turning a delivery monolith into a logistics platform

Related: Domain-driven design · Team Topologies and Conway's law (coming soon) · Sagas, outbox and CDC · Evolutionary architecture and the strangler fig (coming soon) · Making architecture trade-offs · Observability, SLOs and error budgets

Term

See full entry

Jump to a section

  1. 1What broke
  2. 2The idea in simple words
  3. 3How it works
  4. 4Trade-offs
  5. 5At work
  6. 6With AI
  7. 7Check yourself
  8. 8Go deeper