Video in progress
How do you plan splitting services out of a monolith, and which part do you start with?
With the strangler fig approach: I put a routing layer in front of the monolith and move functions one by one into a new service, gradually deleting the old code. I take first the part with a clear boundary that changes independently and exchanges little data with the rest. But before that there has to be an answer to "why are we splitting?".
📖 Answer
Start with the reason. Good reasons: teams block each other on deploys; one part needs to scale differently (search, say); a security or compliance requirement (payments). A bad reason: "microservices are modern".
When picking a candidate I look at: is the boundary clear (a bounded context), do other modules not JOIN its tables, does it change often or belong to a separate team. For a first attempt, pick something low-risk that still gives real value, such as notifications or reports.
The next steps:
- First separate it inside the monolith: the module gets its own tables, and it's accessed only through its API. If you split it out without this step, you end up with a distributed monolith.
- Separate the data, which is the hardest part. The new service gets its own database; during the transition you use CDC or two-way sync, and the old JOINs are replaced by an API call or a local copy updated through events.
- Move traffic over at the gateway: routing, a feature flag, or by percentage, and compare the results (shadow traffic).
- Delete the old code. If you forget this, you carry two systems forever.
Every new service is a new operational cost: deploy, monitoring, on-call, version compatibility. If the platform (a CI/CD template, observability) isn't ready, spend time on that first.
Sign up to mark studied questions and save your progress.