Monolith vs microservices
Monolith or microservices: what are the trade-offs, and how do you decide?
TL;DR
A monolith is one deployable unit: simple to develop, test, deploy and debug, with in-process calls and single-database transactions. Microservices split the system into independently deployable services, each owning its data. They let many teams ship independently and scale parts separately, but you pay with network calls, distributed data consistency, observability and operational overhead. Most teams should start with a well-structured modular monolith and extract services only when team size, deploy contention or very different scaling needs justify it.
Key points
- Microservices solve an organizational problem first (Conway's law): teams blocked on each other's deploys.
- Costs: network latency and failures, no cross-service transactions (sagas, eventual consistency), distributed tracing, versioned contracts, and more infrastructure.
- Distributed monolith anti-pattern: services that must deploy together or share one database. You get all the costs and none of the benefits.
- Modular monolith: clear module boundaries and no reaching into another module's tables. That makes later extraction easy.
- Split along business capabilities (bounded contexts), not technical layers.
- Migrate with the strangler fig pattern: route one capability at a time to a new service.
Example
- Five-person startup: a modular monolith, one database, one deploy pipeline.
- 200 engineers across 20 teams, with the search team blocked by the checkout team's release cycle: extract search into its own service with its own data store and an API contract.
Common follow-ups
- How do services share data? They don't share databases. They use APIs for queries, and events for propagating changes, keeping local read copies where needed.
- How do you handle a transaction across services? A saga: a sequence of local transactions with compensating actions on failure, usually with an outbox for reliable events.
What interviewers look for
Tip
Balanced trade-offs, microservices as a team-scaling tool, and a migration path such as modular monolith → strangler fig.
- Red flag: "microservices are best practice", or services sharing one database.