Few architectural debates generate as much heat as monoliths versus microservices. For much of the last five years, microservices were presented as the modern way to build software, and monoliths as legacy. Conference talks from Netflix, Amazon and Uber showed hundreds or thousands of services, and many teams concluded that was what good architecture looked like.
The reality is more nuanced. Some high-profile teams have publicly moved back. Segment wrote in 2018 about collapsing more than 100 microservices into a single service. Shopify has described investing in a modular monolith instead of breaking up its large Rails application.
So what should you actually build?
What each approach really is
A monolith is a single deployable unit. All the code runs in one process (or several identical copies behind a load balancer), usually with one database. That does not have to mean a "big ball of mud". A monolith can be well structured internally.
Microservices split a system into independently deployable services, each owning its data and communicating over the network through APIs or messages. Each service can be written, deployed and scaled separately, ideally by a separate team.
What microservices actually solve
The strongest argument for microservices is organisational. When dozens of teams work on the same codebase, they get in each other's way: merge conflicts, coordinated releases, shared ownership of everything. Splitting the system along team boundaries lets each team deploy independently. This is Conway's law in action: systems mirror the communication structure of the organisations that build them.
Secondary benefits include:
- Independent scaling of hot components.
- Technology freedom per service.
- Fault isolation, if designed carefully.
What microservices cost
Every benefit comes from turning function calls into network calls, and network calls bring new problems:
- Latency and partial failure. A request that used to call three functions now makes three network hops, any of which can be slow or fail. You need timeouts, retries, circuit breakers and idempotency.
- Distributed data. Each service owns its data, so cross-service consistency needs sagas, outbox patterns and eventual consistency instead of database transactions.
- Operational overhead. Dozens of pipelines, deployments, dashboards and on-call rotations. You need container orchestration, service discovery, centralised logging and distributed tracing before the architecture is manageable.
- Harder debugging. A bug may span five services and three teams.
- Harder refactoring. Moving a boundary between services is far harder than moving code between modules.
flowchart LR
subgraph Monolith["Modular monolith (one deployable)"]
O[Orders module] -->|function call| P[Payments module]
O --> I[Inventory module]
P --> DB[(One database)]
I --> DB
O --> DB
end
subgraph Micro["Microservices"]
OS[Orders service] -->|HTTP / gRPC| PS[Payments service]
OS -->|events| IS[Inventory service]
OS --> ODB[(Orders DB)]
PS --> PDB[(Payments DB)]
IS --> IDB[(Inventory DB)]
endThe middle ground: the modular monolith
A modular monolith keeps a single deployable unit but enforces strong internal boundaries:
- The code is organised into modules by business capability (orders, payments, inventory), not by technical layer.
- Modules talk to each other through explicit interfaces, not by reaching into each other's tables or internal classes.
- Boundaries are enforced by tooling, for example package visibility rules, architecture tests or build-time dependency checks.
// ArchUnit test: the orders module may only use the payments module's public API
@ArchTest
static final ArchRule orders_uses_payments_api_only =
classes().that().resideInAPackage("..orders..")
.should().onlyAccessClassesThat()
.resideOutsideOfPackage("..payments.internal..");If a module later needs to become a service, because a team needs to deploy it independently or it has very different scaling needs, the boundary is already there. Extraction becomes a mechanical change rather than an archaeological dig.
A decision framework
Start with a modular monolith if:
- you have fewer than roughly four or five teams working on the system,
- the domain is still being discovered and boundaries are likely to move,
- you do not yet have mature CI/CD, observability and container operations, or
- the system is new and speed of iteration matters most.
Consider extracting services when:
- a boundary has been stable for a long time,
- a team is regularly blocked by others' release schedules,
- a component has clearly different scaling, availability or security needs (a payments service with PCI DSS scope is a common example), or
- you have the platform (orchestration, tracing, service discovery) to support it.
Avoid microservices when the main motivation is that they are "modern". The cost is paid every day in operations; the benefits arrive only if you have the organisational problem they solve.
Security considerations
Architecture choices change the attack surface:
- Microservices add service-to-service authentication and authorisation. Every internal API is an API, and internal traffic should be authenticated and encrypted rather than trusted because it is "inside".
- More services mean more dependencies, images and configurations to patch.
- Monoliths concentrate risk: one injection bug may expose everything. Strong internal module boundaries help here too.
The bottom line
Choose the simplest architecture that lets your teams move independently today, and design it so it can evolve. For most teams in 2020, that is a well-structured monolith with clear module boundaries, and a plan for extracting services when, not if, the organisation needs it.
Planning a new platform or modernising an old one? Our secure SDLC team designs architectures that fit your team as well as your technology.