Video in progress

When you split up a large monolith with the strangler fig approach, what roles do a proxy and a facade play?

A routing proxy (gateway) goes in front of the monolith, and endpoints are redirected to the new service one by one. Inside the monolith, a facade is the single entry point to the part being extracted: the code is first gathered behind that facade, then moved out.

📖 Answer

A "big bang" rewrite almost always fails: the business won't wait a year, and the old system keeps changing in the meantime. Strangler fig means replacing parts of the old system gradually while it keeps running.

The outer layer is a proxy. An API gateway or plain Nginx/Envoy takes all the traffic:

routes:
  - path: /api/notifications/**
    target: http://notification-service
  - path: /**
    target: http://legacy-monolith

When the new service is ready, the route changes. If a problem appears, you roll back with a single configuration change. Percentage-based routing (canary) or a "dark launch" (the response comes from the old one, the new one is called in parallel and the results are compared) is done at this layer.

The inner layer is a facade. In a monolith, the "notification" logic is usually scattered across 30 places. The first step is to gather it behind a single NotificationFacade interface, inside the monolith. This stage doesn't move anything out yet, but it makes the boundary clear. Then the facade's implementation is swapped for an adapter that calls the new service over HTTP/Kafka, and the calling code doesn't change.

The hardest part isn't code but data. The new service needs its own database, but during the transition the monolith still reads the same tables. Options: one-way synchronization with CDC, a temporary dual write (carefully), or having the monolith read through the new service's API as well.

The risks I watch for:

  • the transition dragging on, with two systems living side by side for years: every stage needs a date for "deleting the old part";
  • the gateway itself becoming a place where business logic piles up;
  • picking the most tangled module as the first one to extract. To start, pick a module with a clear boundary and low risk, and let the team learn the process.