Video in progress

What signs tell you your system has turned into a "distributed monolith", and how do you get out of it?

The signs: one feature requires deploying several services together, services call each other in synchronous chains, one service going down stops everything, and there is a shared database or a shared model jar. The way out is redrawing the service boundaries, and sometimes merging services.

📖 Answer

What you expect from microservices is that teams change and deploy independently. In a distributed monolith you don't get that independence, but you do get the network, eventual consistency and operational complexity. In other words, the downsides of both worlds.

The signs I check, with measurable ones:

  • Deploying together. In the release history, how many times was it "we ship A and B together"? If the frequency is high, the boundary is wrong.
  • Depth of synchronous chains. In distributed tracing, one user request passes through 6-7 services in sequence. If each has 99.9% availability, the chain drops to 99.3%.
  • A shared database. Two services write to one table. A schema change needs coordination.
  • "Chatty" communication. Dozens of calls between services for one request: the data lives in the wrong place.
  • Cascading failures. One small service goes down and the whole site stops working.

How I get out: first I find the cause, because usually the services were split by technical layer (user-service, notification-service, validation-service), not by business capability.

  1. Remap the bounded contexts: which data and rules change together? An analysis of "files changed together" in the git history helps a lot.
  2. Merge the services that change together. This looks like a step backward, but it is often the biggest win: a modular monolith. The team at least gets a single deploy.
  3. Shorten the synchronous chains: store the data you need as a copy in your own database via events, and don't call out for it at request time.
  4. Split up the shared database: every table has one owner, and the others use an API or events.

This isn't a one-quarter job. You have to show the business the results in metrics like "deploy frequency", "number of teams needed for a change" and "number of incidents"; otherwise the refactoring gets stopped at the first deadline.