From Monolith to Microservices: A Migration Playbook
The monolith-to-microservices journey is one of the most common architectural transitions, and one of the most frequently botched. Having led several of these migrations, here's the playbook I follow.
First: should you migrate at all?
The uncomfortable truth: most applications should stay as monoliths. Microservices solve organizational scaling problems, not technical ones.
If your team is under 20 people and your monolith deploys reliably, you probably don't need microservices. The operational complexity of distributed systems is enormous:
- Network failures
- Data consistency
- Deployment coordination
- Distributed tracing
The honest signal that it's time is organizational. Teams are blocked waiting on each other's releases, or one part of the system needs to scale or deploy on a very different schedule from the rest. "The codebase is messy" is not a reason. A messy monolith split into services becomes a messy distributed system, which is strictly worse.
Step 1: Identify service boundaries
When it does make sense, start by identifying service boundaries. Domain-Driven Design provides the best framework.
Look for bounded contexts: areas of your application that have their own language, their own data, and minimal interaction with other areas. These are often natural boundaries:
- User management
- Billing
- Notifications
- Content management
A useful test is to look at how often two areas change together. If nearly every billing change also needs a change in orders, they are one service, whatever the diagram says.
Step 2: Use the strangler fig pattern
The strangler fig pattern is the safest migration strategy. Don't rewrite.
- Put an API gateway in front of both the monolith and the new services.
- Build new features as services.
- Gradually move existing functionality out of the monolith.
- Route traffic based on the endpoint.
The monolith shrinks over time as services take over its responsibilities. At every point you have a working system, and any step can be reversed by changing a route. A full rewrite offers neither of those things.
Step 3: Deal with the data
Data is the hardest part.
In a monolith, a single database JOIN connects users to orders to products. In microservices, each service owns its data. The user service has a user database. The order service has an order database.
Cross-service queries require API calls or event-driven synchronization. This is genuinely harder and slower. Accept the trade-off or keep those domains together.
The trap to avoid is splitting the code while leaving every service pointed at the same database. That gives you all the costs of a distributed system and none of the independence, because any schema change still requires coordinating every team.
Step 4: Connect services with events
Events are the nervous system of microservices. When a user updates their profile, the user service publishes a ProfileUpdated event.
{
"type": "ProfileUpdated",
"userId": "u_1842",
"occurredAt": "2026-03-14T09:21:07Z",
"changes": ["displayName", "avatarUrl"]
}
Services that care subscribe to this event and update their own state:
- The notification service
- The search indexer
- The analytics pipeline
Google Pub/Sub or Apache Kafka provide the event backbone. The user service doesn't know who is listening, so adding a new consumer requires no change to it.
Step 5: Be careful with shared libraries
Shared libraries are necessary but dangerous.
A common models library creates tight coupling between services. Changing a model requires updating and deploying every consumer, which recreates the coupling you were trying to escape.
Instead, each service defines its own models and uses API contracts, such as OpenAPI specs or protobuf definitions, to communicate. Shared utility code for logging, tracing and auth middleware is fine.
Step 6: Invest in observability
Observability becomes non-negotiable. In a monolith, a stack trace tells you everything. In microservices, a single user request might traverse five services.
These are requirements, not nice-to-haves:
- Distributed tracing with OpenTelemetry.
- Centralized logging with Cloud Logging.
- Service-level metrics with Prometheus.
Set these up before the first service goes live. Debugging a distributed system without tracing means guessing.
Extract the easiest service first
My biggest lesson: extract the easiest service first. Don't start with the core business logic. Start with a peripheral service:
- Email notifications
- File processing
- Reporting
Build confidence in the patterns and tooling before tackling the complex stuff. Early wins build momentum and reveal problems at low stakes. If your deployment pipeline or tracing setup has gaps, you want to find them while moving a notification sender, not the checkout.
The playbook in brief
- Confirm the problem is organizational, not just untidy code.
- Find bounded contexts with Domain-Driven Design.
- Put a gateway in front and strangle the monolith gradually.
- Give each service its own data, and accept the cost.
- Connect services with events.
- Share contracts and utilities, never models.
- Have tracing, logging and metrics in place first.
- Start with the easiest service.
For where those services should run, see Kubernetes on GKE: When to Use It and When Cloud Run Is Enough. For how they should talk to their clients, see GraphQL vs REST: When Each Makes Sense.