Service Size and Granularity
What You'll Learn
You'll learn how to right-size microservices by avoiding nano-services and keeping services cohesive and focused.
The Goldilocks Problem of Service Size
After decomposing domains into service boundaries, you face a critical question: how big should each service be? Too large and you lose microservices benefits; too small and you create operational chaos.
Nano-services (also called "micro-microservices") are excessively small services that do too little. Imagine a GetUserName service that only returns a user's name, or a ValidateEmail service that checks email format. These create massive overhead:
- Each requires its own deployment pipeline, monitoring, and infrastructure
- Network calls replace simple function calls
- Latency multiplies across dozens of tiny hops
- Debugging becomes a nightmare across fragmented logic
Cohesive services, by contrast, group related capabilities around a business domain. A UserProfile service might handle names, emails, preferences, and avatar management together because they change for related reasons and share data naturally.
The Right Balance
Think of services like kitchen appliances. A nano-service is like having separate tools for slicing, dicing, chopping, and mincing—technically possible but impractical. A cohesive service is your food processor that handles all related cutting tasks. You wouldn't put your blender inside the food processor (too big), but you also wouldn't have 20 single-purpose gadgets (too small).
Guidelines for right-sizing:
- Services should own complete business capabilities
- Changes should rarely require coordinating updates across services
- Teams should own 2-5 services comfortably, not dozens
- Services should justify their operational overhead
Key Takeaway: Right-sized microservices balance independence with practicality—cohesive enough to deliver business value independently, yet small enough to deploy and change autonomously without becoming an operational burden.