Course contentsShow
← Software Engineering
Lesson 1311 of 1,93339. Microservices ArchitectureFree lesson

Service Decomposition Patterns

Practical patterns for splitting monoliths: strangler fig, branch by abstraction, and identifying seams in existing systems.

Service Decomposition Patterns

You'll learn: Practical patterns for systematically breaking apart a monolithic codebase into independent services without causing downtime or chaos.

The Challenge of Breaking Apart a Monolith

When you decide to decompose a monolith into microservices, you can't just shut everything down and rewrite it. Your business depends on that system running continuously. You need safe, incremental patterns that let you extract services while keeping the lights on.

The Strangler Fig Pattern

Named after a plant that gradually envelops and replaces its host tree, this pattern involves:

  1. Routing new requests to a new service implementation
  2. Leaving old functionality running alongside it
  3. Gradually migrating functionality piece by piece
  4. Eventually "strangling" the old system when it's no longer needed

Think of it like replacing planks on a ship while it's sailing—one board at a time, not all at once.

Branch by Abstraction

This pattern creates an abstraction layer that sits between your application and the functionality you want to extract:

  1. Introduce an interface that hides the implementation
  2. Route calls through this abstraction
  3. Create a new implementation (your future service)
  4. Gradually switch traffic from old to new behind the abstraction
  5. Remove the old implementation and abstraction when complete

The abstraction acts as a "seam" where you can cleanly separate concerns.

Identifying Seams in Existing Systems

A seam is a place where you can alter behavior without editing code in that location. Look for:

  • Module boundaries with clear interfaces
  • Areas with low coupling to other parts of the system
  • Database tables used by only one part of the application
  • Business capabilities that align with bounded contexts

These seams are your natural extraction points—where you can pull out a service with minimal disruption.

Key Takeaway: Service decomposition requires incremental patterns like Strangler Fig and Branch by Abstraction that allow safe, live migration by identifying and exploiting natural seams in your monolithic system.