How do microservices differ from a monolith?
A monolith is an application where all the code (logic, interface, database) is combined into one common block. Microservices are a set of separate modules, each of which is a self-contained service with its own logic and database.
The main difference
| Characteristic | Monolith | Microservices |
|---|---|---|
| Structure | Everything in one application | Split into independent services |
| Development | One codebase, one team | Many teams, each responsible for its own service |
| Deployment | Everything is updated at once | A single service is updated |
| Scaling | Only the whole application | Selective - only the needed services |
| Dependencies | Strong coupling | Loose, through APIs |
| Data storage | Shared database | A separate database for each service |
Example
Monolith: an online store where one server handles orders, payments, and delivery. Microservices: orders, payments, and delivery are three separate services that communicate through APIs.
Summary: A monolith is simpler at the start but harder to scale. Microservices are more complex in infrastructure but provide flexibility, independence, and resilience to failures.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.