Video in progress

Microservices have driven up infrastructure cost and team load. How do you determine whether services should be merged?

Each service's cost (compute, on-call, pipeline, library upgrades) is compared with the benefit it provides (independent deploy, separate scaling, isolation). Services that always change together, belong to one team and don't scale separately are candidates for merging.

📖 Answer

Every service has a "minimum cost", even if it does nothing: at least 2 replicas (each with a JVM, 300–500 MB), a DB instance or schema, a CI pipeline, dashboards, alerts, security updates, bumping the Spring Boot version. With 80 services, just upgrading the Spring Boot major version turns into a project of several months.

I gather this data:

  • Changing together: from git history, which services change together in one ticket.
  • Deploying together: which ones always ship together in releases.
  • Ownership: the number of services belonging to one team. If a team of 4 holds 12 services, that's a signal.
  • Load profile: do they scale separately? If both are 5 RPS a day, separate scaling brings no benefit.
  • Cost: each service's CPU/RAM requests and actual use. Often the requests are 5–10 times larger than the usage.
  • Chatty communication: dozens of calls between two services on every business operation.

A merge candidate is a pair where several of these signs hold at once.

The merge itself is gradual too: first as two modules inside one deployment unit (the package boundary stays), with the DBs on one instance but in separate schemas. Internal HTTP calls become method calls, so latency and error types go down.

There are other ways to cut cost too, and they are checked before merging: fitting requests/limits to real usage, 1 replica + a PodDisruptionBudget for low-traffic services, shutting down dev/staging environments at night, JVM tuning (CDS, a smaller heap), a GraalVM native image for some services.

This decision is made with numbers, not ideology. Both the conclusion "microservices were a mistake" and the claim "everything should be separate" are usually wrong.