Video in progress

In an organization with dozens of microservices, how do you choose between a monorepo and a separate repo per service (polyrepo), and what is the hidden cost of each?

A monorepo makes atomic changes, single versions and broad refactoring easier, but it requires investment in build tooling, CI time and ownership management. A polyrepo gives independence and simple CI, but shared changes and version sprawl become expensive. The choice is more organizational: how coupled the teams are and how much effort goes into the platform.

📖 Answer

Both work: Google lives in a monorepo, many companies live in polyrepos. The difference is which problems you accept.

What gets easier in a monorepo:

  • changing a library's API and fixing all its users in one PR; a contract and the matching changes in one commit;
  • a single version policy: Spring Boot is the same everywhere, and a security update is one PR;
  • finding code, reuse, shared CI rules.

The cost of a monorepo:

  • Build. In a Maven/Gradle project with 50 services, building everything on every PR takes 40 minutes. You need to build only the changed modules (the Gradle build cache, Bazel, or detecting affected modules in CI). That is permanent work for the platform team.
  • Ownership: CODEOWNERS gives every folder an owner, otherwise everyone changes everything.
  • Keeping deploys independent: one repo doesn't mean one release. If each service doesn't deploy with its own pipeline, a monorepo opens the road to a distributed monolith.
  • Repo size, and git and the IDE slowing down (you'll need tools like sparse checkout).

The cost of a polyrepo:

  • A shared library update is 50 PRs and 50 reviews, and it isn't done even in 3 months. Renovate or Dependabot help, but not fully.
  • Version sprawl: one service is on Boot 3.5, another is stuck on the unsupported 2.7.
  • A change spanning several services needs coordination, but that is really the natural price of independent deploys.

How I decide:

  • if there are few teams (2–5), the services are around one domain and 1–2 people can be assigned to the platform, a monorepo, with good build tools;
  • with many independent teams, different technologies and strong ownership boundaries, a polyrepo, but with a versioned BOM, a template and automatic dependency updates for the shared parts;
  • a mixed option is common too: one repo per domain (team), with several services inside.

The main question: which changes happen often? If shared code and contracts often change together, a monorepo reduces that pain. If services rarely change together, a polyrepo's independence is cheaper.