A Complete System Design Guide. Understand the trade-offs, architecture complexities, and when to use which pattern.
It is NOT necessarily one machine! You can horizontally scale a monolith (e.g., multiple instances behind a load balancer).
| Factor | Monolith | Microservices |
|---|---|---|
| Setup | Simple | Complex |
| Deployment | Single Unit | Distributed |
| Debugging | Easier | Hard (network involved) |
| Observability | Basic | Needs tracing/logging infra |
Scale the entire system.
Inefficient if only one part is heavyScale specific services independently.
Much more efficientThis is where microservices truly shine in the real world.
"System design mirrors team structure."
Breaks a long-lived transaction into a sequence of smaller, local transactions to avoid locking bottlenecks (unlike traditional 2PC).
Coordination: Orchestration (central controller) or Choreography (event-driven).
Failure Handling: If a step fails, it executes compensating transactions to semantically reverse completed actions, ensuring eventual consistency.
Monolith: One failure = entire system crash.
Microservices: Partial failure possible. Requires Circuit Breakers, Retries, Timeouts.
Logs are in one place. Easy to track a request.
You desperately need:
Modern systems evolve. You don't jump straight to microservices.
This gradual extraction is called the Strangler Fig Pattern.
"Should we use Monolith or Microservices?"
Always start with Monolith. Tell the interviewer:
"I would start with a monolith. As the system scales and team size grows, I will gradually extract services based on scalability and independent deployment needs."
Microservices are not about scaling systems.
They are fundamentally about scaling teams and development speed.