What it is
Three common ways to structure a backend:
- Monolith: one deployable unit, usually one database; components call each other in-process.
- Modular monolith: still one deployable unit, but split into modules along business boundaries, each with its own data (schema) and a small public interface, enforced by the build.
- Microservices: each module runs as its own service with its own database, deployed independently and called over the network.
Choosing between them is a trade-off across latency, failure isolation, team autonomy and operational cost. No option wins on every axis.
Why it exists
Teams often pick an architecture by fashion: microservices because large companies use them, or a monolith because it is the default. Both choices have real costs that show up later: a tangled monolith slows every team, and a premature microservices split adds hops, outages and an operations bill for benefits the organisation does not need yet. Naming the forces explicitly lets you pick deliberately and revisit the decision when they change.
How it works
Latency. A function call costs nanoseconds to microseconds. A call between services costs a network round trip plus serialisation, TLS and often a sidecar proxy: typically somewhere between a fraction of a millisecond and several milliseconds inside one data centre, more across zones. On a synchronous path these add up, and each extra service adds its own queueing, so tail latency grows faster than the median. In the lesson's model a checkout goes from one internal hop to four and its P95 rises by more than half.
Blast radius. Components in one process share memory, threads and fate: a leak or crash in one module takes down everything, which is equally true of a modular monolith. Separate processes fail separately, but a request still fails if its path makes a synchronous call to the failed service. Isolation therefore follows the dependency graph: asynchronous messaging, timeouts, circuit breakers and fallbacks are what turn separate processes into contained failures.
Team autonomy. A modular monolith gives each team ownership of a module and its data, but everyone ships in the same release. Services let each team build, test, deploy and scale on its own schedule, and pick technology per service where that is justified. This is the main reason large organisations use them (Conway's law in reverse).
Operational cost. Each service brings a pipeline, a runtime, a database with backups and migrations, dashboards, alerts and on-call. Across services you need service discovery, an API gateway, versioned contracts, distributed tracing, and patterns for consistency without distributed transactions (sagas, outbox, idempotent consumers).
| Monolith | Modular monolith | Microservices | |
|---|---|---|---|
| Internal call latency | Lowest | Lowest | Network per hop |
| Failure blast radius | Whole app | Whole app | Per service, along sync dependencies |
| Boundaries enforced | By discipline | By the build | By the network |
| Deployment | One, together | One, together | Independent per service |
| Scaling | Whole app | Whole app | Per service |
| Data consistency | Local transactions | Local transactions (per module schema) | Eventual between services |
| Operational cost | Low | Low | High, grows with service count |
In .NET, a modular monolith is typically one ASP.NET Core host composed of module projects, each registering its own services and its own DbContext on a separate schema, communicating through public contracts or in-process messages; architecture tests (e.g. NetArchTest or ArchUnitNET) keep modules from referencing each other's internals. Extracting a module later means moving the project behind an HTTP/gRPC API or a message broker, with its data already separate.
When to use it
- Monolith: small teams, early products, simple domains, tight latency budgets.
- Modular monolith: most new systems with more than one team or a domain still being discovered; the default good starting point.
- Microservices: several teams blocked by shared releases, components with very different scaling or availability requirements, or organisations with the platform maturity (CI/CD, observability, on-call) to run many services.
When not to
- Microservices with one team, an unclear domain or no platform support: you pay the distribution tax without the autonomy benefit.
- A monolith without internal boundaries once several teams work in it: coupling makes every change slower.
- Splitting by technical layer (a "database service", a "validation service") instead of business capability: it maximises hops and coupling.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Modules instead of services | No hops, local transactions, cheap refactoring of boundaries | One deployment, shared blast radius |
| Services instead of modules | Independent deployment, scaling, fault isolation | Latency per hop, eventual consistency, operations |
| Synchronous calls between services | Simple request/response semantics | Availability and latency couple along the chain |
| Asynchronous messaging between services | Failure and time isolation | Eventual consistency, harder debugging |
| Fewer, larger services | Fewer hops and contracts | Less autonomy per team |
Alternatives
- Serverless functions: very fine-grained deployment units; same distribution costs, plus cold starts and platform limits.
- Macro-services / "right-sized services": a few services aligned with team boundaries rather than one per entity.
- Self-contained systems: vertical slices including UI, each owning its data, integrated mostly asynchronously.
- Strangler fig migration: incrementally route functionality from a legacy monolith to new services or modules.
Failure modes
- Distributed monolith. Services that must be deployed together and call each other synchronously everywhere: microservice costs with monolith coupling, and a larger blast radius than it looks.
- Big ball of mud. A monolith without enforced boundaries, where every change touches everything.
- Chatty services. Fine-grained APIs that need many calls per user request; latency and failure probability multiply.
- Shared database between services. Schema changes need every team again; isolation exists only on paper.
- Premature extraction. Boundaries drawn before the domain is understood are expensive to move once they are network calls.
In production
Write the decision down (an ADR) with the forces that drove it and the conditions that would change it. Enforce module boundaries in the build from day one. Before extracting a service, make sure the module already owns its data and talks to others only through its contract; then measure the new hop's latency and set timeouts, retries and circuit breakers on it. Track deployment frequency and lead time per team, P95 per call path and incident blast radius, so the architecture is judged by outcomes rather than diagrams.
Common misconceptions
- "Microservices are more scalable." Monoliths scale horizontally too; services let you scale parts independently, which matters only when the parts differ.
- "Microservices are more reliable." They fail more often in total (more parts), but can fail more narrowly if dependencies are designed for it.
- "A modular monolith is a stepping stone you must leave." Many systems stay modular monoliths for good.
- "The architecture is a one-time decision." Forces change with team size and load; plan for extraction and consolidation.
Interview angle
Start with a modular monolith unless the requirements name a force for services, and say which force would make you extract which component. Quantify the cost of a split (extra hops × latency, availability of a synchronous chain as the product of its parts), discuss blast radius in terms of the dependency graph, and mention the operational prerequisites: CI/CD per service, tracing, contract versioning, consistency patterns. Interviewers look for trade-offs stated in both directions.
Model assumptions
The simulation is a simplified model, not a benchmark. Requests arrive as a Poisson stream (80/s, 20% checkouts as writes, 80% browsing as reads). The monolith has 32 workers and 15 ms of work per request and a database 2 ms away (16 connections, reads 5 ms, writes 10 ms, lognormal cv 0.3). In the microservices version the gateway (2 ms) routes reads to Catalog (8 ms) and writes to Orders (8 ms), which writes its own database and then calls Payments (6 ms), which writes its own; every internal hop costs 5 ms one way, an illustrative stand-in for network, serialisation, TLS and sidecars. Crashes are modelled as the node refusing requests. The deployment and operational-cost step is a scripted illustration. Numbers show behaviour and orders of magnitude only.