Service Decomposition Strategies

Introduction

One of the hardest decisions in microservices is determining where to draw service boundaries. Through decomposing several monoliths and designing greenfield microservice systems, I've learned that poor decomposition leads to distributed monolithsβ€”systems with all the complexity of microservices but none of the benefits.

This article covers practical strategies for identifying and defining service boundaries that align with your business and team structure.

The Decomposition Challenge

spinner

Poor decomposition results in:

  • Distributed Monolith: Services that must be deployed together

  • Chatty Communication: Excessive inter-service calls

  • Shared Databases: Services coupled through data

  • Circular Dependencies: Services that depend on each other

Bounded Contexts from Domain-Driven Design

The most reliable decomposition strategy comes from Domain-Driven Design (DDD). A bounded context is a boundary within which a particular domain model is defined and applicable.

spinner

Identifying Bounded Contexts

Context Mapping

When services need to interact, define explicit mappings:

Decomposition by Business Capability

Business capabilities represent what the business does, not how it does it.

spinner

Mapping Capabilities to Services

The Strangler Fig Pattern

For existing monoliths, the Strangler Fig pattern allows incremental migration.

spinner

Implementing Strangler Fig

Migration Strategy

Decomposition Heuristics

By Volatility

Separate components that change frequently from stable ones:

By Scalability Requirements

By Team Structure (Conway's Law)

spinner

Common Decomposition Mistakes

1. Too Fine-Grained

2. Shared Database

3. Circular Dependencies

spinner

Practical Exercise

Exercise: Decompose an E-commerce Monolith

Given this monolith structure, identify service boundaries:

Key Takeaways

  1. Use Bounded Contexts - DDD provides the most reliable decomposition strategy

  2. Start with capabilities - Decompose by what the business does, not technical layers

  3. Apply Strangler Fig - Migrate incrementally, not with big rewrites

  4. Respect Conway's Law - Align services with team structure

  5. Avoid common mistakes - No shared databases, no circular dependencies

What's Next?

With services identified, we need well-designed APIs for communication. In Article 3: API Design for Microservices, we'll cover REST principles, versioning strategies, and contract-first design with OpenAPI.


This article is part of the Microservice Architecture 101 series.

Last updated