0
0
Microservicessystem_design~7 mins

Service decomposition strategies in Microservices - System Design Guide

Choose your learning style9 modes available
Problem Statement
When a monolithic application grows, it becomes hard to maintain, slow to deploy, and difficult to scale. Teams face delays because changes in one part affect the whole system, causing frequent conflicts and outages.
Solution
Service decomposition breaks the monolith into smaller, independent services. Each service owns a specific business capability and can be developed, deployed, and scaled separately. This reduces dependencies and improves agility.
Architecture
User Client
API Gateway

This diagram shows a user client sending requests to an API Gateway, which routes them to multiple independent services (A, B, C), each handling a specific business function.

Trade-offs
✓ Pros
Improves scalability by allowing independent scaling of services based on demand.
Enables faster development cycles as teams can work on separate services without conflicts.
Increases fault isolation; failure in one service does not crash the entire system.
Supports technology diversity; different services can use different tech stacks.
✗ Cons
Introduces complexity in managing inter-service communication and data consistency.
Requires robust monitoring and logging to trace issues across services.
Deployment and testing become more complex due to distributed nature.
When the application has grown beyond a few thousand lines of code and multiple teams work on it. Also, when scaling parts of the system independently is needed, typically at 1000+ daily active users or complex business domains.
For small applications with simple logic and low traffic (under 1000 daily users), where the overhead of managing multiple services outweighs benefits.
Real World Examples
Netflix
Decomposed their monolith into microservices to independently scale streaming, recommendations, and user management, improving reliability and deployment speed.
Amazon
Split their e-commerce platform into services like catalog, orders, and payments to allow teams to innovate and deploy independently.
Uber
Used service decomposition to separate rider, driver, and trip management services, enabling rapid feature development and scaling.
Alternatives
Modular Monolith
Keeps the application as a single deployable unit but organizes code into modules with clear boundaries.
Use when: When you want better code organization without the operational complexity of microservices.
Shared Database Decomposition
Services share a common database schema but have separate codebases, reducing data duplication but increasing coupling.
Use when: When data consistency is critical and eventual consistency is not acceptable.
Event-Driven Decomposition
Services communicate asynchronously via events, decoupling them more than direct API calls.
Use when: When you need high scalability and loose coupling with eventual consistency.
Summary
Service decomposition breaks a large application into smaller, independent services based on business capabilities.
This approach improves scalability, fault isolation, and team autonomy but adds complexity in communication and operations.
Choosing the right decomposition strategy depends on application size, team structure, and business needs.