How do you decide the right size/boundaries for a microservice?
Topic: microservices, Design. Level: Hard.
Answer
Size by **business capability / bounded context** (DDD), not by lines of code. A good service owns one cohesive capability and its data, changes for one reason (high cohesion), and can be developed/deployed by one team independently (loose coupling). Signs a boundary is wrong: two services always change together (merge them), or one service does unrelated things (split it), or they need chatty sync calls / shared tables (boundary cuts through a transaction). Start coarser and split when real pain (scaling, team friction, deploy coupling) appears — premature decomposition is costly.
```text
Good boundary checklist:
[ ] owns one business capability + its own data
[ ] one team can build & deploy it independently
[ ] changes for a single reason (high cohesion)
[ ] no shared tables / no chatty cross-service transactions
Heuristic: if two services must deploy together, they're really one service.
```