When to split your monolith: metrics and thresholds

Track deploy frequency, change failure rate and module coupling — and know the exact numbers that justify splitting your monolith.

Maysan Engineering Team · · 4 min read

Xin

The monolith is rarely the problem. The problem is the Tuesday afternoon when a one-line rounding fix in pricing needs three senior engineers, a migration window, and a rollback plan nobody has tested since March. Founders and CTOs usually start asking about microservices at that point — years after the first warning sign, and with no numbers on the table to make the call.

Start with deploy frequency and lead time

Deploy frequency and lead time are the earliest honest signals that a monolith has stopped paying for itself; if a small change takes more than ten working days to reach production, the architecture has become a delivery tax. Both numbers are free — your CI logs and issue tracker already hold them. Count production deploys per week over the last two quarters, and measure the median time from "in progress" to "live". A team shipping twice a week with a one-day lead time does not have a monolith problem, whatever the code looks like. A team shipping once a month against a release calendar usually does.

Watch change failure rate, not code size

A change failure rate above roughly 15% means the module boundaries inside the monolith are already broken, whether or not you split it. Change failure rate is the share of production deploys that need a hotfix, rollback, or incident review within 24 hours. Track it per module if you can; most teams find it clusters in two or three areas — checkout, billing, permissions — where every change ripples. Pair it with blast radius: how many people get paged for a change they did not make. If a pricing tweak reliably wakes the payments on-call, those are one module, and a service boundary drawn between them just moves the paging into a network call.

Use coupling data to find the real seams

Split along the seams where changes rarely cross, and use version-control history rather than the architecture diagram to find them. Generate a coupling matrix from git log --name-only, or a tool like code-maat, and count how often files in module A change in the same commit as files in module B. Co-change above roughly 25-30% means one unit, not two. Do the same with runtime data: OpenTelemetry traces or APM call graphs show which modules are actually invoked inside a single request. What you are looking for is a module with high internal churn and low external coupling — that one extracts cleanly. Our architecture work usually starts with this measurement pass, because two weeks of counting beats a six-month migration in the wrong direction.

Check the database before the code

The database decides whether a split is real or cosmetic, so read the query logs before you read the code. If three modules write to the same orders table, extracting one of them into a service gives you a distributed monolith: same coupling, plus network latency and partial failure. Use pg_stat_statements on Postgres or the slow query log on MySQL to find joins and writes that cross module-owned tables. If the reporting module fires 40 joins against billing tables, reporting is not a service candidate until it has its own read model. Shared schema means shared fate, whatever the repository layout says.

Set the thresholds before you need them

Write the thresholds down in advance, because once the argument starts everyone has an opinion and nobody has a number. The triggers that hold up in practice:

  • Fewer than two production deploys per week, with a median lead time above 10 working days.
  • Change failure rate above 15% for two consecutive quarters.
  • More than 30% co-change between two modules, measured across six months of commits.
  • One workload — PDF generation, report exports, webhook fanout — eating 40%+ of CPU or sitting in the request path. That is a scaling problem first, and a queue plus caching often fixes it before infrastructure changes become architecture changes.
  • Two or more teams of four-plus engineers routinely blocked on the same release.

Take a typical case: a 180,000-line Django app deploying every 11 days, with a 22% change failure rate and 61% co-change between checkout and pricing. Only the last number justified extracting a service first. The other two were fixed by smaller release batches and a working CI pipeline.

Where to start

Start with two weeks of measurement, not a service map. Pull deploy frequency, lead time, change failure rate and a co-change matrix — four artefacts, all from data you already have — then pick one high-churn, low-coupling module, extract it behind a stable interface, and watch whether the numbers actually move. If you would rather someone ran that first pass with you, Maysan Labs does this kind of review for Indian SaaS and B2B teams, usually before anyone writes a Dockerfile.

Buying software or a website?

Twelve questions to ask any vendor before you sign: price, your data, fit for an Indian business and support.

Get the free checklist

Written by Maysan Engineering Team at Maysan Labs, a software studio in Gurgaon, India. Follow us on LinkedIn