Topic 144 / Core
Microservices decomposition
Chapter 9.2 · Decomposition and Boundaries
What and why
Having decided to split (→ 143), the next failure mode is splitting along the wrong seams — by technical layer (all controllers in one service, all database access in another) or by noun (a generic "User service" everyone calls for everything). Decomposition is the practice of drawing service boundaries along bounded contexts (→ 56): each service owns one cohesive piece of business capability, and the data it needs to do it alone. Builds on: → 56 (bounded contexts and domain boundaries).
Diagram
Wrong seam (technical layers) Right seam (bounded contexts)
────────────────────────── ──────────────────────────
[UI layer service] [Order Service] — owns orders,
[Business-logic service] every order lines, order state
[Data-access service] request
crosses [Catalog Service] — owns products,
all 3 pricing, availability
[Shipping Service] — owns
fulfillment, tracking
How it works
- Identify the business capabilities (what the business does), not the database tables.
- Group by bounded context (→ 56): data and behavior that change together, for the same reason, stay together.
- Check cohesion: a well-formed service answers most of its own requests without calling several other services first — a chatty call chain is a decomposition smell.
- Check ownership: one team can name the boundary and defend it without needing another team's sign-off for routine changes.
- Draw the seam where the domain model (→ 54) already has a natural discontinuity — a different vocabulary, a different rate of change, or a different consistency requirement.
- Expect to get it wrong the first time; a boundary that turns out too fine-grained (two services that always deploy together) should be merged back, not patched with more calls.
Practical example
(illustrative). Decomposing an e-commerce system by noun gives "User service," "Product service," "Order service" — but checkout now needs synchronous calls to all three for every request, and a change to how orders affect loyalty points touches two services owned by two teams. Decomposing by capability instead gives "Catalog" (browse, price), "Ordering" (cart, checkout, payment coordination), "Fulfillment" (pick, pack, ship) — each call chain is now mostly internal to one service, and loyalty points live wherever that business behavior actually lives.
When to use it
- Use when: the system has already outgrown the modular monolith (→ 143) and bounded contexts are stable enough to draw a boundary around.
- Avoid when: the domain model is still being discovered — decomposing early locks in a boundary before anyone knows if it's the right one; keep it in one module until the shape repeats.
- Failure scenarios: entity services (a "Customer service" everyone calls for every customer field, regardless of which business capability needs it) become a bottleneck and a shared-everything dependency; decomposition by database table just moves JOINs onto the network.
- Simpler alternative: inside the modular monolith (→ 53), enforce the same bounded-context module boundaries first — if that already relieves the pressure, there may be nothing left to gain from a network split.
Practice
(Process kind — fill the template on a small real system; 25 min). Take a small system you know (or: a blog platform with posts, comments, users, notifications). List its business capabilities, not its tables. Group them into 3–5 candidate services by bounded context, then for each pair of services count how many requests would need to cross the boundary for the system's three most common use cases. Redraw the boundary once to reduce the worst cross-boundary count.
Done when you can name, for your final boundary, the one business reason each service exists and the one team that would own it.
Key takeaway
Decompose by business capability and bounded context, never by technical layer or database table — a boundary that doesn't match where change actually happens produces chatty calls and shared ownership. Done when you can: draw service boundaries for a small system and defend each one by the business reason it exists. Used next in → 145 (ownership and Conway's law), → 146 (database per service).
References
A pattern language for microservices — see references.md.
Source directory