Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 37 ยท Getting Started

When (and When Not) to Use Microservices

Decide whether microservices fit your team: team size, scaling needs, the modular monolith, the distributed monolith smell, costs, and a scoring checklist.

Microservices solve real problems, but the problems are mostly about people and scale, not about code. A team of five building a new product rarely has them. Choosing microservices too early is one of the most expensive mistakes in modern software, because the costs arrive immediately while the benefits arrive only after you grow.

This lesson gives you honest criteria. You will see what you pay for distribution, learn the smell of a "distributed monolith", and run a small scoring tool that turns a checklist into a recommendation. It builds on the definitions in What Are Microservices?.

Good reasons to split

Many teams Teams block each other in one codebase.
Uneven load One part needs 50 times the capacity.
Release speed Parts must ship daily, others rarely.
Isolation A failure or breach must stay contained.
1 / 2

The real cost of distribution

Every call that used to be a function call is now a network request. That brings costs you pay forever.

  • Latency and failure. A local call takes nanoseconds and cannot be "lost". A network call takes milliseconds and can time out, fail halfway or arrive twice. See The Fallacies of Distributed Computing.
  • Data consistency. One transaction across orders, stock and payments is gone. You replace it with sagas and eventual consistency (Sagas).
  • Operational load. Each service needs a pipeline, monitoring, alerts, logging, secrets and an on-call story. Ten services means ten of everything.
  • Debugging and testing. A single user action spans many processes, so you need tracing and contract tests (Distributed Tracing, Testing Microservices).
  • Organizational overhead. APIs between teams need versioning, documentation and negotiation.

A useful rule of thumb: you should be able to name the specific pain that microservices remove before you adopt them. If you cannot, wait.

Team size and structure

Microservices mirror your organization (this is often called Conway's law: a system's design copies the communication structure of the people who build it). If one team of eight works on one product, one deployable matches that structure perfectly. If forty developers in six teams keep colliding on the same release train and the same database migrations, separate services let each team move at its own pace.

A common guideline is that a team should own a small number of services it can fully understand and operate. Having more services than teams is a warning sign; the services will be neglected, or one team will become the bottleneck for everything.

Scaling needs

Scaling one busy component in isolation is a genuine advantage. Suppose image resizing needs forty servers on sale days while the account pages need two. In a monolith you must replicate the whole application forty times. As a separate service, only the resizer scales.

But check that you really need it. A well-built monolith, replicated behind a load balancer with a properly indexed database, handles surprisingly large traffic. Measure first. Often the bottleneck is one slow query, not the architecture.

Start with a modular monolith

For most new products the best path is:

  1. Build a modular monolith: separate modules with explicit public interfaces, no reaching into each other's tables, and dependencies that point one way.
  2. Watch where the pain appears: slow releases, scaling hot spots, team collisions.
  3. Extract a module into a service only when a concrete pain justifies it. Because the boundary already exists in code, the extraction is mostly mechanical. Decomposition Strategies shows how.

This route lets you learn your domain boundaries cheaply. Getting a boundary wrong in a monolith means moving a class. Getting it wrong across services means rewriting APIs and migrating data.

The distributed monolith smell

A distributed monolith has the network boundaries of microservices but the coupling of a monolith. You pay for both and gain neither. Warning signs:

  • Services must be deployed in a fixed order, or together.
  • One user request touches six services synchronously, so one slow service slows everyone.
  • Several services read and write the same database tables.
  • A change to one service's data format breaks others.
  • A shared library holds business logic and every service must upgrade it at once.
  • Nobody can run or test a service without starting all the others.

If several of these are true, merging services back together is often the right fix. Common Microservices Mistakes and Anti-Patterns goes deeper.

Merging services is not failure. Teams that notice a distributed monolith and consolidate it often become faster, cheaper to run and happier. The architecture serves the business, not the other way around.

A decision scoring tool

A checklist cannot make the decision for you, but it can make the discussion concrete. The stand-in below scores a project on eight yes/no questions. Positive answers (pressures that favor splitting) add points; negative ones (the readiness you would need) subtract points when missing. The weights are illustrative, not scientific: change them and see what happens.

JS Should we split? A scoring tool

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The "eager" team has genuine pain but no deployment automation and no clear boundaries. The tool tells it to build that foundation first, which matches real experience: teams that adopt microservices without CI/CD usually end up with slower, riskier releases than before.

A checklist you can use in a meeting

Before agreeing to split a service out, ask whether you can answer yes to each of these.

  • What measurable problem does it fix (release time, cost, outages)?
  • Does one team clearly own it end to end?
  • Can it keep its own data without joining other services' tables?
  • Can it be deployed, rolled back and monitored independently?
  • Do you know how callers behave when it is down?
  • Is the benefit larger than the added operational cost?

Counting the cost of the last question is not optional. Cloud bills, tooling licenses and engineer time spent on plumbing are real and recurring.

A second look at the numbers

The scoring tool encodes a principle: pressure alone is not enough. Read the same data a different way by checking which condition blocks a decision.

JS What blocks the decision?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which is the strongest reason to move to microservices?

    Independent deployment and ownership help most when many teams collide. Fashion, messy code and a brand-new product are weak reasons.
  2. 2. What is a distributed monolith?

    It combines the network costs of microservices with the coupling of a monolith. Replicating a monolith behind a load balancer is perfectly normal.
  3. 3. Why is starting with a modular monolith often wise?

    Wrong boundaries cost little to fix inside a monolith, but are expensive across services. A modular design also makes later extraction easier.
  4. 4. A team has severe release pain but no CI/CD and unclear boundaries. What is the best next step?

    Without pipelines, monitoring and stable boundaries, services multiply the pain. Build the foundation first.

Summary

  • Microservices mainly solve people-and-scale problems: many teams, uneven load, release speed and isolation.
  • Distribution costs latency, consistency, operations, debugging and coordination, so name the pain before paying.
  • A modular monolith is the best default starting point; extract services when a concrete pain justifies it.
  • A distributed monolith (fixed deploy order, shared tables, synchronous chains, shared business libraries) is a sign to consolidate.
  • CI/CD, observability, stable boundaries and on-call ability are prerequisites, not extras.

Next: The Fallacies of Distributed Computing.