Microservices vs Monolith
Microservices are an organisational technology with a technical implementation. They let many teams deploy independently. That is the benefit. Everything else — network calls, distributed transactions, duplicated data, versioned contracts, tracing — is the cost.
The question in an interview is not “microservices or monolith” but “what forces are pushing you apart, and is the split worth the bill?”.
The 60-second answer
Section titled “The 60-second answer”A monolith is one deployable with shared memory and one transaction; a microservice architecture is many deployables owning their data and communicating over the network. Split along business capabilities or bounded contexts, one team per service, each owning its own schema. Synchronous calls for queries, asynchronous events for state propagation, and sagas with compensating actions instead of distributed transactions. The costs are operational: latency, partial failure, eventual consistency, duplicated data, testing, and versioning. Start with a modular monolith and extract services when a boundary is proven.
What actually differs
Section titled “What actually differs”| Monolith | Microservices | |
|---|---|---|
| Calls | In-process function call | Network call with latency and failure |
| Transactions | One ACID transaction | Sagas, outbox, compensation |
| Data | Shared schema, joins | Per-service schema, no joins |
| Deploy | All or nothing | Independent |
| Failure | Process crash or nothing | Partial failure everywhere |
| Testing | In-process integration tests | Contract tests, environments, stubs |
| Team scaling | Coordination overhead | Autonomous teams |
| Debugging | Stack trace | Distributed trace across services |
The decisive column is the last two. If you have one team of six and a straightforward domain, microservices will slow you down. If you have 40 engineers on one deploy pipeline, the monolith is the problem.
Finding boundaries
Section titled “Finding boundaries”Good boundaries follow business capabilities and bounded contexts from domain-driven design: a region of the domain with its own ubiquitous language and its own model of the world. “Order” means something different to fulfilment than to billing, and that difference is a boundary.
Practical heuristics:
- Data ownership. A service owns its tables; no one else reads them directly. If two services must share a table, they are one service.
- Change cadence. Things that change together live together. A boundary that forces coordinated deploys is not a boundary.
- Team ownership. Conway’s law is descriptive, not prescriptive: your architecture will mirror your communication structure. Choose the structure deliberately.
- Transaction boundary. If an invariant must hold atomically across two entities, they belong together — or you pay for a saga.
- Chattiness. If every request needs five calls between two services, they are coupled and should merge.
Bad boundaries are worse than no boundaries: a distributed monolith has all the coupling of a monolith and all the operational cost of distribution.
Communication
Section titled “Communication”Synchronous (HTTP/gRPC) when the caller needs an answer to continue. Simple to reason about; creates a runtime dependency chain. If the callee is down, the caller fails unless it degrades.
Asynchronous (events/queues) when the caller does not need to wait. Decouples availability and absorbs load. Costs eventual consistency and requires idempotent consumers.
| Need | Choose |
|---|---|
| Read data to render a response | Synchronous query |
| “This happened, react to it” | Asynchronous event |
| Fire-and-forget side effect | Asynchronous command |
| Long-running workflow | Orchestrated saga |
A healthy system is mostly asynchronous between domains and synchronous within them. A chain of ten
synchronous calls is a latency amplifier and an availability cliff: 0.999^10 ≈ 99% availability
even if each service is three nines.
Distributed transactions
Section titled “Distributed transactions”Two-phase commit exists but blocks, needs coordinator support, and couples availability. Avoid it.
Saga: a sequence of local transactions, each publishing an event or invoking the next step, with compensating actions for rollback.
Order created → Reserve stock → Charge payment → Arrange shipping ↓ fail ↓ fail ↓ fail (nothing to undo) Refund payment Release stockTwo coordination styles:
- Choreography: each service listens for events and decides. No central point, but the flow is implicit and hard to see as it grows.
- Orchestration: a coordinator drives the steps and handles compensation. Explicit and debuggable; the orchestrator becomes a component to own and scale.
Compensations are not rollbacks. A refund is a new transaction, not the absence of a charge, and it can fail. Every saga step must therefore be idempotent and retryable, and the saga itself must be durable (a state machine in a database).
The transactional outbox is the building block that makes “commit locally, then publish” safe — see Message Queues.
Service discovery and routing
Section titled “Service discovery and routing”With dynamic instances, callers cannot hardcode hosts.
- Server-side discovery: the client calls a load balancer or DNS name; the platform routes. Simplest (Kubernetes Service, cloud LB).
- Client-side discovery: the client queries a registry (Consul, etcd) and picks an instance. One fewer hop, more logic in the client.
- Service mesh: a sidecar proxy per pod handles discovery, retries, mTLS and telemetry, so the application code does not. Powerful and expensive in latency, memory and cognitive load.
Also needed at the edge: an API gateway for authentication, rate limiting, routing and response aggregation. It is not a service mesh; it is the front door.
The operational bill
Section titled “The operational bill”Be explicit about what you are signing up for:
- Deployment: N pipelines, N version matrices, backward-compatible contracts. A breaking change now requires a rollout order.
- Observability: distributed tracing is mandatory, not optional. Without it, every incident is a hunt across five teams.
- Testing: unit and contract tests replace the integration test you used to get for free. Consumer-driven contracts (Pact) catch schema drift.
- Data: no joins across services. You duplicate data, or you build an aggregation service, or you accept N calls.
- Consistency: read models lag. UIs must tolerate it.
- Cost: more instances, more network egress, more idle capacity per service.
- Local development: running 12 services on a laptop is a project of its own.
When not to split
Section titled “When not to split”- The domain is not understood yet. Boundaries drawn too early are guesses and expensive to move.
- One team owns everything.
- You need strong consistency across the whole flow.
- The “services” would all deploy together anyway.
- The motivation is résumé-driven rather than a deployment or scaling constraint.
Modular monolith is the honest default: one deployable, strict internal module boundaries, no cross-module database access, and events between modules where you would later use a queue. If a module needs to become a service later, the boundary already exists and the extraction is mechanical. Strangler fig is how you get there: route traffic to the new service incrementally, keep the old path alive until the new one is proven, then delete.
Follow-up questions
Section titled “Follow-up questions”- How would you split an e-commerce monolith, and what goes first?
- Where does a transaction span two services, and what replaces it?
- What happens when one service in a synchronous chain is slow?
- How do two services share reference data without a shared database?
- Why is a distributed monolith worse than a monolith?
- What does a contract test catch that an integration test does not?
Common traps
Section titled “Common traps”- “Microservices scale better.” They scale organisationally. A monolith scales horizontally fine until the database is the bottleneck, and that bottleneck moves with you.
- “One service per entity.” That produces a CRUD service per table and a network call per join.
- “We will use 2PC for consistency.” It blocks and couples availability; sagas with compensation are the standard answer.
- “Events are fire-and-forget, so no error handling needed.” Events are at-least-once and can fail; consumers need idempotency and dead-letter handling.
- “We do not need tracing, we have logs.” Logs from five services without a trace id will not reconstruct a request.