27. Monolith vs Microservices
1
The picture to keep in your head2
27.1 What is a monolith?3
27.2 What are a monolith's strengths?4
27.3 What is a modular monolith?5
27.4 What are microservices?6
27.5 What is the real cost of microservices?7
27.6 How do you draw service boundaries?8
27.7 How does service discovery work?9
27.8 Sync vs async calls between services: when to use which?10
27.9 What does "database per service" mean?11
27.10 When should you split?12
Memory card and where the analogy breaks13
Practice: five levels14
Interview questions15
Solutions16
Sources17
Code lab27. Monolith vs Microservices
27.4 What are microservices?
3 min read+10 XP
In the restaurant: A food court. Each stall is its own business: own staff, own pantry, own hours, own menu changes. The dosa stall can add a new dosa today without telling anyone.
In the system: In a microservices architecture, the application is split into small services, each:
- Owning one business capability (orders, payments, catalogue).
- Deployed independently, on its own schedule.
- Owning its own data (27.9).
- Talking to others over the network: HTTP/gRPC APIs (Chapter 24) or events (Chapters 22 and 23).
- Owned by one team that builds and runs it.
What you gain:
- Independent deploys: the payments team ships five times a day without waiting for search.
- Independent scaling: run 50 copies of search and 3 of payments.
- Fault isolation, if designed well: recommendations being down shouldn't stop checkout.
- Technology choice per service: search in one language with Elasticsearch, payments in another with PostgreSQL.
- Team autonomy: teams own outcomes end to end. (Conway's law: systems end up mirroring the communication structure of the organisation that builds them.)
Memory code: "Each stall runs itself, from pantry to counter."