Microservices vs Monolith

Two ways to structure and deploy an app: as one unit, or as many independent pieces.

What is it?

Early on, it's simplest to build everything (users, payments, notifications) as one application, deployed and scaled as one unit. This is a monolith.

As the system and team grow, some organizations split it into many smaller services that are deployed independently, each owning one part of the system and talking over the network. This is microservices.

Neither is always right. A monolith is simpler to build, test and deploy. Microservices allow independent scaling and deployment, at the cost of real operational complexity.

Explain like I'm 10

A monolith is like one big kitchen where the same staff make every dish in the same space. Microservices are like a food court where each stall specializes and runs on its own. You can scale one popular stall without touching the others, but now you have to coordinate many separate operations instead of one.

Examples

The same feature, two different structures

// Monolith: one codebase, one deployment
function handleOrder(order) {
  chargePayment(order);   // same process
  updateInventory(order); // same process
  sendConfirmationEmail(order); // same process
}

// Microservices: separate services, communicating over the network
async function handleOrderMicroservices(order) {
  await paymentService.charge(order);       // a network call
  await inventoryService.update(order);     // another service
  await notificationService.notify(order);  // yet another
}

How it works

In a monolith, the whole app runs as one process, sharing memory and usually one database, so calling another part is just a function call.

In microservices, each service is its own process (often with its own database) and talks to others over the network, usually via HTTP APIs or message queues. That brings network latency, partial failure (one service down while others work) and the need for careful API contracts.

Why does it exist?

As a codebase and team grow, a monolith gets hard to work on: every change risks breaking unrelated parts, and everything must be deployed together. Microservices let teams own, deploy and scale their own piece independently, at the cost of much more operational complexity.

When to use it

Start most new projects as a monolith. It's simpler, easier to reason about and faster to change early on.

Consider microservices once the team is big enough that separate teams need to deploy independently, or parts of the system have very different scaling needs.

When not to use it

Don't choose microservices just because big companies use them. For a small team or early product, the overhead (network calls, service discovery, distributed debugging) usually costs far more than it's worth. Many successful products run as a monolith for years.

Common mistakes

  • Adopting microservices too early, taking on distributed-systems complexity before the team or product needs it.

  • Splitting services along lines that don't match how teams are organized, so every feature still needs changes across many services.

  • Forgetting that a network call between services can fail in ways a function call never could, and not handling those failures.

Practice exercises

  1. Easy:

    Explain the main tradeoff between a monolith and microservices.

  2. Medium:

    Describe a warning sign that a monolith is becoming hard for a growing team to work in.

  3. Hard:

    Explain why one feature (like placing an order) is harder to reason about when split across three microservices instead of one monolith.

Interview questions

What is the main difference between a monolith and microservices?

A monolith is one deployable app containing everything. Microservices split it into many independently deployable services that talk over the network.

What's a real cost of microservices that a monolith doesn't have?

Network calls between services can fail independently, add latency, and need careful handling of partial failures. A single in-process monolith never faces these.

Why might a company choose microservices despite the added complexity?

So independent teams can deploy and scale their own services without coordinating with every other team, and so only the parts that need it get scaled.

What is a "distributed monolith," and how does a team end up with one despite having "microservices"?

Separate deployable services that still can't be deployed or changed independently, because they share a database, call each other in tightly coupled synchronous chains, or share versioned libraries that force lockstep updates. It happens when a team splits the code without splitting the coupling: all of microservices' cost, none of the independence.

What are some warning signs that you actually have a distributed monolith rather than true microservices?

You can't deploy one service without deploying others. Features routinely need coordinated changes across many services. Services share a database or mutable state. A failure or slowdown in one service reliably cascades into others instead of degrading gracefully.

What does "each microservice owns its own data" mean, and why is a shared database across microservices considered an anti-pattern?

Only the owning service reads or writes its storage directly; others go through its API, never its database. A shared database re-couples services at the data layer: one service's schema change can silently break another, and nobody can tell which service is responsible for the data's integrity.

Scenario: an orders service and an inventory service share the same underlying database. What problems does this cause?

Either can change the shared schema and break the other without anyone noticing. Neither can be deployed or scaled independently, since both depend on one database's availability and schema version. And it's unclear who maintains data integrity, which defeats a core reason for splitting them.

What is Conway's Law, and how does it argue for aligning service boundaries with team boundaries?

Conway's Law says a system's architecture tends to mirror the communication structure of the organization that built it. So draw service boundaries around how teams are actually organized, letting one team own and change a service without constant cross-team coordination, rather than drawing boundaries first and hoping teams reorganize around them.

What is a "bounded context" (from domain-driven design), and why is it a common way to decide where to draw a microservice boundary?

A boundary within which a business concept (like "order" or "inventory") has one consistent meaning and model; outside it, the same word may mean something slightly different. It fits service boundaries well because each bounded context tends to have its own data and rules and can be owned by one team.

What is the "monolith-first" approach, and why do many experienced teams recommend it even when they expect to eventually need microservices?

Start as a single, well-structured monolith and split out services only once real usage shows where the boundaries and scaling needs are. The right boundaries are hard to guess upfront, and restructuring a monolith internally is far cheaper than undoing badly drawn service boundaries.

What is the strangler fig pattern, and how does it let you migrate a monolith to microservices incrementally?

A new service gradually takes over one responsibility while the monolith keeps handling everything not yet moved. Piece by piece the monolith shrinks until it can be retired. It avoids a risky big-bang rewrite by migrating one bounded piece at a time, each verifiable on its own.

What is the saga pattern, and what problem does it solve for a "transaction" that spans multiple microservices?

A saga splits a multi-service business operation into a sequence of local transactions, each with a compensating action that undoes it if a later step fails. With no shared database to wrap everything in one ACID transaction, it gets an equivalent all-or-nothing result through explicit forward and backward steps.

Scenario: placing an order charges payment, reserves inventory, then schedules shipping, across three services with no shared database. Payment succeeds but inventory reservation fails — walk through how a saga handles this.

The saga sees the failure at the inventory step and runs the compensating action for every step that already succeeded: here, refunding the payment. The customer isn't left charged for an order that can't be fulfilled, and the shipping step is never reached.

What's the difference between choreography-based and orchestration-based sagas?

In choreography, each service reacts to the others' events and decides its next step itself, with no central coordinator: more decoupled, but the overall flow is hard to see in one place. In orchestration, a central coordinator tells each service what to do and in what order, and triggers compensations: easier to reason about and observe, but every service in the saga depends on that coordinator.

Why does distributed tracing become necessary in microservices in a way it isn't for a monolith?

In a monolith, one stack trace or profiler within one process can diagnose a slow request. In microservices, one request can fan out across many services, each with its own logs, and there's no single process to inspect. Distributed tracing stitches the request's full path (with per-hop timing) into one view instead of manually correlating scattered logs.

Scenario: a single user-facing request touches 6 services and is slow. Without distributed tracing, why is this hard to debug?

Each service only sees its own part; none knows how long the other 5 took or which was the bottleneck. Without a shared trace id linking all 6 services' logs for that request, engineers must cross-reference timestamps across six logging systems just to find where the time went.

What is a circuit breaker, and why does calling another microservice over the network need one when calling a function within a monolith doesn't?

A circuit breaker notices calls to a downstream service keep failing or timing out and fails fast (without trying the call) for a cooldown period, instead of letting callers keep waiting on a struggling service. In a monolith, a function call succeeds, throws, or the whole process crashes together. There's no "the other side is down but I'm up" state to protect against, because there's no network in between.

Why is versioning API contracts between microservices a much bigger deal than versioning function signatures within a monolith?

In a monolith, changing a function's signature and updating every caller happen in one deploy, checked by the same compiler or type system. Across services, caller and service deploy independently, so a breaking change can be live while callers still expect the old shape. Contracts need explicit versioning and backward compatibility, since callers won't all upgrade in lockstep.

What is contract testing, and what problem does it solve between independently-deployed services?

It checks that a service's actual API matches what its consumers expect, without running every real consumer and provider together. It catches a breaking contract change before deploy, without a slow, flaky end-to-end test across every dependent service.

Why is testing generally harder in a microservices architecture than in a monolith?

A monolith's tests can run a whole business flow in-process, fast and deterministically. In microservices the same flow crosses several services over the network, so a true end-to-end test needs several real (or realistic fake) services running together, and network flakiness and version-mismatch bugs become possible.

What does "independent deployability" actually buy a team, concretely — and what does it cost operationally?

One team can ship a change to its service without waiting for or coordinating a release with every other team: faster, lower-risk releases scoped to its own code. The cost: each service needs its own deployment pipeline, monitoring and on-call ownership, and every API change must stay compatible with whatever consumer versions are still running.

Scenario: the payments team wants to deploy a breaking API change. What does true independent deployability require of how they roll this out?

They can't just break the old contract. They must support both old and new API shapes for a transition period (versioning), or coordinate with every known consumer to migrate first, because other services may still use the old contract and deploy on their own schedules.

What is the "premature decomposition" trap, and why does it commonly happen to teams inspired by big tech blog posts?

Adopting microservices because a much larger company uses them well, without that company's scale, team size or bottlenecks that justified it. The blog post shows the payoff, not the years of pain or the organizational scale that made the tradeoff worth it for them.

What's a realistic signal that a monolith has actually grown to the point microservices would help, rather than just "it feels big"?

Independent teams are blocked from deploying without coordinating releases with unrelated teams, or parts of the system have such different scaling or reliability needs that scaling the whole monolith for one part wastes a lot on the rest. A feeling of size or code sprawl isn't the same signal, and better internal modularity often fixes it.

Why can splitting a monolith along the wrong boundaries make things worse rather than better?

If a boundary cuts through one cohesive piece of business logic, most features still need coordinated changes across the resulting services. You pay for network calls, versioning and distributed debugging without gaining independent deployment.

What operational capabilities does a team typically need in place before microservices become net-positive, that a monolith doesn't require?

Centralized logging and distributed tracing, service discovery, automated per-service deployment pipelines, per-service monitoring and alerting, and usually some container orchestration. Without them, teams end up rebuilding by hand what a monolith gets almost for free, one struggling service at a time.

Why does network partial failure require different error-handling thinking than a monolith's function calls?

A monolith's calls either complete or the whole process crashes together; part of your own process can't be unreachable while the rest runs. Over a network, one dependency can be slow, timing out or down while everything else is fine, so microservices code must treat timeouts, retries and partial degradation as normal conditions, not rare edge cases.

What is a service mesh, and what problems does it solve that would otherwise be re-implemented independently in every microservice?

An infrastructure layer (usually sidecar proxies next to each service) that handles cross-cutting network concerns centrally and consistently: retries, timeouts, circuit breaking, mutual TLS, load balancing and observability. Otherwise each service would reimplement this in its own language or framework.

Scenario: after splitting into microservices, feature development actually slowed down because most features still touch three or four services at once. What does this suggest about how the boundaries were drawn?

The split doesn't match how the business logic varies. The boundaries probably followed technical layers (e.g. one service per database table) instead of cohesive business capabilities, so each feature's logic is spread across services that must change together. You pay the coordination cost with none of the independence.

Why is "our team is small" often a stronger argument against microservices than any specific technical concern?

Microservices' main benefit is letting several independent teams work and deploy without stepping on each other. With one team, that benefit doesn't exist: the team still coordinates across every service it owns, while paying the full network, deployment and observability overhead.

What's the relationship between eventual consistency and microservices — why do cross-service reads often end up eventually consistent even if each service's own database is strongly consistent?

Each service can be strongly consistent in its own database, but keeping its copy of another service's data up to date (via events or async replication) happens over the network on its own schedule. So a consumer relying on another service's data always has a window where its copy may be behind, like database replication but between whole services.

Common misconception: "microservices make a system more reliable." Why is this not automatically true?

Splitting into many services multiplies what can fail (each service, each network hop). Without deliberate resilience patterns (circuit breakers, retries with backoff, graceful degradation), a microservices system can be less reliable than a monolith, since a failure in any one dependency can cascade. It's more reliable only when that added failure surface is actively engineered for.

What's a realistic warning sign in a monolith that one specific piece (not the whole system) is a good first candidate to extract into its own service?

A piece with very different scaling needs from the rest (e.g. heavy image processing dragging down an otherwise fast API), or one with a clear, stable API boundary and its own data that one team could own end to end. A good first candidate is narrow and well isolated, not "split everything at once".