Migration to Microservices

Basic System Design
≈ 2 min read

You Do Not Have to Rewrite Everything at Once

Moving from a monolith to microservices is safer when done gradually. First choose a part of the system with a clear boundary and a real reason for independent evolution, then separate its contract and move responsibility step by step.

Step 1: Client -> Monolith
Step 2: Client -> Router -> Monolith
                         \-> New Service
Step 3: more traffic/features move out

This allows the old and new solutions to run side by side for some time. The boundary can be validated under real load and individual changes can be rolled back without tying the project’s success to one large cutover.

Extract a Problematic or Valuable Area

A good first candidate may be a part that scales differently, changes frequently, blocks several teams, or already has a sufficiently independent model. Extracting a random module just to begin the migration does not create useful value.

Separate Dependencies First

Before moving code into a separate process, it is useful to remove direct access to the future service’s internal classes and data. The monolith should interact with that area through an explicit interface. After that, replacing the local implementation with a network call is easier because consumers no longer depend on its internals.

At every step, the data should have a clear source of truth, and a long period where both the monolith and the new service independently modify the same entity should be avoided.

Migration should deliver value incrementally. If the benefits appear only after a multi-year complete rewrite, the risk of such a project is usually too high.