What does splitting a monolith actually mean?

Splitting a monolith means turning one deployable artifact into several units that can be built, tested, released and rolled back independently. Each unit has a team that owns it, and ideally each owns its own data, so no other service reads or writes its tables directly. Those three properties together (independent deployment, separate ownership, separate data) are what make it a split. If services still share a database schema or must be released in lockstep, you have a distributed monolith. It carries the operational cost of a network boundary but does not remove the deployment coupling.

Extracting a library or adding a module boundary is a different move. Both keep a single process and a single deployment. A module boundary limits which code can call which, and a library packages shared logic behind an interface. Neither adds network calls, partial failure modes or cross-service data consistency problems. Both are cheap to reverse, because a bad boundary inside one codebase can be moved in a refactor rather than a migration.

This checklist rests on that distinction: modularize first, distribute only when needed. A split is a response to specific, observable pain, such as teams blocking each other on a shared release, components with conflicting scaling needs, or parts of the system that must ship on incompatible cadences. So the first question is not whether microservices are better. It is which of those signals are absent. This is not an argument against ever splitting. It is a way to make sure that when you do, it removes a real constraint.

MODULARIZE (cheap, reversible): one process, one deploy, one DB
+--------------------------------------------------+   +--------+
| +----------+     +----------+     +----------+   |   |        |
| | module A |---->| module B |---->| lib C    |   |-->| one DB |
| +----------+     +----------+     +----------+   |   |        |
+--------------------------------------------------+   +--------+

DISTRIBUTED MONOLITH (avoid)            SPLIT (distribute on real pain)
+----------+  net  +----------+         +----------+  API  +----------+
| svc A    |------>| svc B    |         | svc A    |------>| svc B    |
| deploy 1 |       | deploy 2 |         | deploy 1 |       | deploy 2 |
+----+-----+       +-----+----+         | team 1   |       | team 2   |
     |  lockstep release |              +----+-----+       +-----+----+
     +---------+---------+                   |                   |
               v                             v                   v
        +-------------+                 +----------+       +----------+
        |  shared DB  |                 | DB A     |       | DB B     |
        +-------------+                 +----------+       +----------+

A module boundary keeps one deployment and one database, a distributed monolith adds network calls but keeps lockstep releases and shared tables, and a real split gives each service its own deployment, owning team and data.

Which signals show it is too early to split services?

Each signal below is something you can observe from your repository, issue tracker, or database, not a matter of opinion.

Domain boundaries are still moving. If core concepts get renamed and logic keeps migrating between modules, any service boundary you draw now will be wrong soon. Moving code inside a monolith is a refactor. Moving it across services means changing APIs and migrating data.

Team topology does not call for a split. Conway's law cuts both ways. One or two teams that rarely block each other gain no autonomy from separate services. If team boundaries do not match the proposed service boundaries, every feature becomes a cross-service, cross-team change.

There is no need for differential scaling or isolation. When load is similar across the app, scaling the whole monolith is simpler than scaling its parts separately.

Shared database usage is heavy. Cross-module joins, tables written by several areas, and transactions that span modules all become network calls and consistency problems once you split.

Signal How to measure What "absent" looks like
Stable domain boundaries Renames and cross-module file moves in recent history Core terms and module ownership still changing
Team topology Teams per codebase; cross-team review waits One or two teams, little blocking
Differential scaling Per-endpoint CPU, memory, traffic Similar load profiles everywhere
Data independence Cross-module joins, multi-writer tables, spanning transactions Many of each

Read each row as a question: is the readiness condition present? Every "absent" answer is a constraint that splitting would make harder to remove, not easier.

Why does splitting early add cost without removing a constraint?

Inside a monolith, moving a function between modules is a refactor. The compiler or test suite finds every caller, and one commit changes both sides. Across a service boundary, the same move becomes a migration. The interface turns into a published contract, so you version it, keep old and new shapes alive until every caller upgrades, and coordinate releases.

Splitting data costs more. A transaction that commits atomically today becomes a sequence of local commits held together by a saga, an outbox pattern, or an explicit decision to accept inconsistency. Each option brings failure modes the monolith never had: partial completion, duplicate messages that require idempotent handlers, and reconciliation jobs that repair drift.

Illustrative estimate (assumed numbers, not a benchmark)

Assume a request makes 3 sequential calls that run in-process today at negligible cost. After the split, each call is a network hop at an assumed 3 ms.

Added happy-path latency ≈ hops × per-hop latency = 3 × 3 ms = 9 ms.

The failure budget is the bigger cost. With an assumed 100 ms timeout and 1 retry per hop:

Worst case ≈ hops × (retries + 1) × timeout = 3 × 2 × 100 ms = 600 ms.

Each hop also needs its own timeout value, retry policy, and idempotency decision. Plug in your own hop count and numbers.

If the boundaries are wrong, you get a distributed monolith: services that deploy together, share a database, or call each other in long synchronous chains. You pay the network costs and keep the coupling.

Operational overhead grows with the number of services, not with traffic. Every service adds a pipeline, dashboards, alerts, dependency upgrades, and on-call surface. None of this removes a constraint you already have.

Is your deployment pain an architecture problem or a pipeline problem?

When releases are slow or risky, the shape of the codebase is the easy thing to blame. First check where the time actually goes. Common causes include a forty-minute test suite, flaky CI jobs that get re-run until they pass, manual deploy steps kept in a runbook, no feature flags for shipping code dark, and no fast rollback path. None of these exist because you have one deployable. If you split the system, each problem gets copied into every new pipeline, and you add version skew between services on top.

Measure before you decide. Track lead time for changes (from commit to running in production) and deploy frequency for the monolith over a few weeks. If most of the lead time is spent waiting on CI, retries or manual approvals, the constraint is the pipeline, and fixing it helps every future service as well. These numbers can be gamed or misread. For example, splitting work into trivial deploys inflates frequency without improving anything. Pair the metrics with what the teams say actually slows them down.

Platform prerequisites

If these do not exist for the monolith, they will not exist for ten services:

  • Automated environment provisioning
  • CI/CD that builds, tests and deploys one unit independently
  • Centralized logging
  • Metrics and alerting
  • Distributed tracing
  • Service discovery or request routing
  • Secrets management
  • An on-call model with clear ownership

How can you enforce module boundaries inside the monolith today?

Every item on that list is a cost you pay before a split delivers anything. A cheaper test comes first: can the modules you plan to extract stay separate while they still share a process? If they can't, a network call won't separate them. It will only make each violation slower and harder to see.

Make boundaries fail the build

Give each module one public surface, such as an api package or an exported interface, and treat everything else as internal. Use the language's own visibility rules where you can: package-private classes, unexported identifiers, or internal directories. Where the language can't express the boundary, add a check to CI. That can be an architecture test or a short script that scans imports and fails when module A references anything under B/internal. The rule only works if it blocks merges. A warning that people can ignore gets ignored.

Count violations over time

Code imports are half the coupling. The other half lives in the database. Tag each table with its owning module. Then compare query logs or data-access code against that map and count the queries where one module reads or writes another module's tables. Track this count and the import-violation count as two numbers per release. If both stay near zero for several months while features keep shipping, the boundary is real. If they keep creeping up, the domain lines are wrong, and moving them is still cheap.

A monolith that holds its boundaries is the strongest evidence that a split would hold. Many teams find they never need to take that next step.

#!/usr/bin/env python3
"""Fail CI when one module imports another module's internals.

Assumed layout: src/<module>/api/ is the public surface,
src/<module>/internal/ is private to that module.
"""
import re
import sys
from pathlib import Path

SRC = Path("src")
# Matches "import billing.internal..." and "from billing.internal... import ..."
IMPORT_RE = re.compile(r"^[ \t]*(?:from|import)[ \t]+(\w+)\.internal\b", re.MULTILINE)

violations = []
for path in sorted(SRC.rglob("*.py")):
    owner = path.relative_to(SRC).parts[0]  # module that owns this file
    text = path.read_text(encoding="utf-8")
    for match in IMPORT_RE.finditer(text):
        target = match.group(1)
        if target == owner:
            continue  # a module may use its own internals
        line = text.count("\n", 0, match.start()) + 1
        violations.append(f"{path}:{line}: {owner} -> {target}.internal")

# Emit the count in a stable format so it can be recorded per release
# and tracked over time alongside the cross-module table access count.
print(f"boundary_violations={len(violations)}")
for v in violations:
    print(v)

# A non-zero exit blocks the merge; a warning alone gets ignored.
sys.exit(1 if violations else 0)

A dependency-free CI check that scans Python imports, fails the build when a module reaches into another module's internal package, and prints a violation count you can track release over release.

What are the alternatives to splitting into microservices?

Each option below targets a specific constraint. Pick the one that matches your actual bottleneck, not the most ambitious one.

Option What it solves Dev / ops cost Reversibility Leaves unsolved
Modular monolith Tangled code, unclear ownership Low / none High Shared failure domain, uniform runtime
Library extraction Reuse across codebases, versioned contracts Low / low High Runtime isolation, independent deploys
Horizontal scaling (replicas, read replicas, caching, background workers) Throughput, read load, slow requests Low / moderate High Hot paths with very different resource profiles
Pipeline fixes Slow builds, flaky tests, risky releases Moderate / low High Teams blocked on each other's release timing
Targeted extraction of one component Isolation for one hot or risky part Moderate / moderate Medium Everything still inside the monolith

The modular monolith has real limits. Every module shares one process and one deploy unit. A memory leak in reporting can exhaust the heap that checkout runs in, and a bad deploy of one module rolls back all of them. You also stay on one language and runtime. That is a problem only if a component needs something else, such as a different concurrency model or a library ecosystem your stack lacks.

Horizontal scaling works because most monoliths are stateless at the web tier. Adding replicas multiplies everything, though, including the parts that don't need it. When one component dominates memory or CPU, extracting only that component gives you isolation without paying the full distributed-systems cost everywhere.

How to score the checklist and decide who should split, and when

Go through each signal from the checklist and mark it present, absent or unknown. Treat "unknown" as a task, not a neutral answer. If nobody can say how often two teams edit the same module, measure it from version control before you decide.

Outcome Decision
No strong pain signal present Stay modular; keep enforcing boundaries
Strong pain present, platform prerequisites missing Fix CI/CD, observability and on-call first
Strong pain present, prerequisites in place Extract one pilot component
Compliance isolation, different runtime, or acquired system Targeted extraction, regardless of other signals

Require at least one strong pain signal, such as persistent merge contention or a release train that blocks independent teams. The platform prerequisites must also be in place. For the pilot, pick a component with a narrow interface and little shared data. A broad decomposition plan commits you to many boundaries at once, before you know whether any of them are right.

The exceptions are narrow on purpose. Each one sets a real constraint that the monolith cannot meet: a regulator requires isolation, a library exists only for another runtime, or an acquired system already runs on its own.

Waiting has a cost too. Coupling builds up with every release. As headcount grows, merge contention and coordinated release trains slow everyone, and a later extraction becomes harder.

Scoring honestly saves engineering time in two ways:

  • Fewer wrong boundaries. A badly drawn service boundary later needs coordinated API versioning and data migrations to undo.
  • Product focus for small teams. Teams that do not split early spend their time on product work instead of running a platform they do not yet need.

How OneEnv can help

Disclosure: OneEnv is the product behind this blog.

OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.

Applied to when to split a monolith, this is where it helps:

Saves time

  • Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
  • One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
  • Changing a shared variable is one edit and one review instead of editing every service's .env by hand.

Saves cost

  • Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
  • Less duplicated configuration to maintain: one shared definition inherited by many services.
  • A wrong or stale value is caught at review time by the services it affects, not by a failed deploy.
  • OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.

These are qualitative benefits, not measured results — how much you save depends on how many services share the value.

Want to try it? Start at oneenv.io.