Microservices and APIs · senior
Monolith or microservices, and how to split
Start with a modular monolith. Split into services only when teams or scaling need it, along business capabilities, with each service owning its data, using the strangler fig approach.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Start with a modular monolith: one deployable, clear module boundaries (packages, owned tables, internal interfaces), one database with a schema per module.
- Costs of microservices: network failures, sagas for distributed transactions, tracing and monitoring, a pipeline and on-call per service, data consistency and heavier local setup. They pay off with more teams and real need for independent scaling or deploys.
- Split when a module needs different scaling or runtime, teams block each other releases, a bounded context with its own data is clear, or compliance needs isolation. Often moving the hot part to async workers off a queue is enough first.
- Draw boundaries from business capabilities (bounded contexts): customer, restaurant and menu, order, payment, delivery, offers, notifications, ratings.
- Each service owns its data. Others subscribe to its events and keep read copies. An order keeps a snapshot of items and prices at the time of ordering.
- Strangler fig: route a slice of traffic to the new service, move its data, retire the old path. Use routing at the gateway, CDC from the monolith database, and the outbox or CDC, not dual writes.
- Extract first something with clear edges and frequent change (notifications, delivery tracking), not payments.
- Write a short decision record with options, costs and criteria for splitting later. Measure error rates, latency, deploys per team and incidents.
The red pen
Common traps: mistake → fix
Mistake: Microservices are best practice
Fix: they are a trade-off with real costs.
Mistake: One service per table
Fix: split by capability, not by table.
Mistake: Several services sharing one database for now
Fix: it rarely goes away and couples them.
Mistake: Split by technical layer, such as a database service
Fix: that creates long call chains.
Easy to hard
Questions interviewers ask, easy to hard
- Monolith or microservices for a new product?
- How do you split a food-delivery monolith?
- Which service do you extract first and why?
- How do you migrate without a big rewrite?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.