Monolithic vs. Microservices Architecture
One codebase that does everything, or many small services that each do one thing — and what each choice actually costs.
Beginner
| Problem | Why it happens |
|---|---|
| Single technology stack | The whole app is one language/runtime. Adding a component that's a much better fit in a different language (e.g. a Python ML model for recommended restaurants) means bolting on a separate service anyway or awkwardly forcing it into the existing stack. |
| Shared blast radius | A memory leak in the driver-tracking module can take down the checkout flow, because they're the same process. |
| All-or-nothing deploys | Every deploy ships the entire codebase, even for a one-line change to the menu page — slower builds, slower rollbacks, more coordination between teams. |
| Can't scale parts independently | During a lunch rush, order volume spikes but account-settings traffic doesn't. A monolith scales as one unit, so idle code gets scaled along with the hot path. |
| Cost | What it looks like |
|---|---|
| Latency | A function call within a monolith is microseconds; a call to another service over the network is milliseconds, and can fail in ways a function call can't. |
| Distributed debugging | A single failed order now requires correlating logs across the Cart, Payment, and Dispatch services instead of reading one stack trace — this is why centralized logging becomes mandatory, not optional. |
| Service discovery & config | Every service needs to know where every other service currently lives, and that changes as instances scale up and down. |
| Operational overhead | Health checks, retries, access control, and inter-service authentication all need their own infrastructure once there are dozens of services instead of one. |