Dev.to WebDev 🛠 Dev 👁 0 📖 18 min read

Modular Monolith vs Microservices for SaaS: When to Split

TL;DR: For a SaaS team of 2–15 engineers in 2027, the answer to modular monolith vs microservices is a modular monolith: one deployable whose modules own their data and talk only through public interfaces. Extract a modu

Modular Monolith vs Microservices for SaaS: When to Split

Modular Monolith vs Microservices for SaaS: When to Split

TL;DR: For a SaaS team of 2–15 engineers in 2027, the answer to modular monolith vs microservices is a modular monolith: one deployable whose modules own their data and talk only through public interfaces. Extract a module only when one of four measured signals outlasts its cheaper fix and six readiness checks pass. In my test on a throwaway two-module example, one dependency-cruiser rule failed on the one import that reached past a module's interface, so a CI step can catch such imports.

Before your SaaS app's first commit, you answer the microservices vs monolith question: one deployable or several. Split too early and a small team spends its weeks running a distributed system instead of building the product, but one tangled codebase turns any later split into a rewrite.

This is part one of The SaaS Architecture Playbook 2027, a series of decision articles for tech leads building or rebuilding a SaaS web app. Each part gives a dated recommendation and a checklist, and lists its sources at the end.

It assumes 2–15 engineers, no platform or SRE team, uncertain growth and no unusual regulation. If contracts demand isolation, signal 4 says what changes. If you have more engineers, the stage section explains why headcount alone shouldn't decide. You also get a boundary rule, tested on a small example, that fails the build when one module imports past another's interface, and four split signals, each with a starting threshold and a cheaper fix to try first.

What is a modular monolith, next to a monolith and microservices?

Monolith: one codebase, one deploy

A monolith is one codebase built, tested and deployed as a single unit, in the simplest case with one database. There is one thing to run and debug, but nothing stops any part calling or querying any other. Martin Fowler observed in 2015 that "Almost all the successful microservice stories have started with a monolith that got too big and was broken up".

Modular monolith: one deploy, boundaries a build can check

A modular monolith is still one application deployed as one unit. Its modules each own their tables and expose a small public interface. A check in CI fails the build when one module reaches past another's interface. Modules follow bounded contexts: domain-driven design "divides up a large system into Bounded Contexts, each of which can have a unified model".

Shopify's core app is a documented case, with "strictly enforced boundaries between different domains" in 2019. In 2020 it had "over 2.8 million lines of Ruby code" and "hundreds of developers currently adding features". That shows the pattern holds as a codebase grows, not that it suits a team of six.

A module that needs another's data calls its query interface, or reads a separate read model built for reports (CQRS). Once modules become services, Microsoft warns, a change across two of them is unlikely to be one ACID transaction. One answer is a saga of local transactions, where "a series of compensating transactions undoes the changes" if a step fails. Those compensations are code you write, not a database rollback.

Microservices: many deploys, a network between them

Microservices are services deployed separately, each owning its data and calling the others over the network. Each can be released and scaled on its own, and can fail without taking the rest down if its callers handle the fault. Microsoft's architecture guide names the cost: "Each service is simpler, but the entire system as a whole is more complex."

Microservices vs monolith vs modular monolith on six criteria

Matrix rating a monolith, a modular monolith and microservices on delivery speed, cost, complexity, security, maintainability and reversibility; the modular monolith matches the monolith on speed (fast) and cost (low) and rates highest on reversibility

Every part of this series scores its options on the same six criteria.

  • Delivery speed (idea to production) favours one deployable. A change that spans two modules ships in one pull request and one deploy, with no service contract to version first. Fowler goes further: "don't even consider microservices unless you have a system that's too complex to manage as a monolith".
  • Cost (people and operations, not only the cloud bill) rises with each service a small team runs, as the count below shows.
  • Complexity (what one engineer must hold in mind to change a feature) is lowest in one process. Shopify's engineers note that crossing the network "adds latency and decreases reliability with every call".
  • Security (blast radius and what you must defend) is a trade-off: services can contain a failure, but only if you run extra defences. In a monolith, components are "executing in-process", as Lewis and Fowler put it, so a module boundary is a code rule, not runtime isolation. Services contain a failure only "as long as any upstream microservices are designed to handle faults correctly" (Microsoft). Each must also "authenticate the calling service separately" (OWASP).
  • Maintainability (how safely code changes as it grows) favours in-process modules. Across services, "refactoring is much harder than with in-process libraries", Lewis and Fowler write.
  • Reversibility (what changing your mind costs) favours the modular monolith. Its module lines are the "clear demarcations" Microsoft says let you "migrate each part individually".

What each extra service adds for a six-engineer team

Take an illustrative team of six engineers and 1, 3 or 6 deployables, where 1 is the modular monolith. Assume a pipeline per deployable. Locally you start each deployable, one database server holding a database per service, and a message broker once there are two or more. Possible service-to-service pairs are N(N−1)/2.

That gives 1, 3 and 6 pipelines, 2, 5 and 8 local processes, and 0, 3 and 15 possible pairs. From 3 to 6 services, pipelines double and pairs grow fivefold. At 6 services, readiness check 6 (a named owner and a second person for each service) means 12 owner or backup roles to fill, two for each of the six engineers. That counts roles, not on-call shifts: one rotation can cover several services.

Grouped bar chart for an illustrative six-engineer team at 1, 3 and 6 deployables: pipelines 1, 3 and 6, local processes 2, 5 and 8, possible service pairs 0, 3 and 15; from 3 to 6 services, pairs grow fivefold

Each pair is an interface whose changes, Lewis and Fowler write, "need to be coordinated between participants". Milan Jovanović also advises retries, a circuit breaker and timeouts on each real call. The pairs are a ceiling: a design has only the ones its calls need.

A modular monolith costs a boundary rule in CI and an in-process way for modules to react to each other's events. It also ships on one release train, so every module ships when any does, which signal 2 measures. Cloud prices are left out; build cost is in our breakdown of custom web application cost.

The 2027 answer to modular monolith vs microservices, by stage

Start with a modular monolith. Extract a module into a service only when one of the four signals below stays above its threshold after you've tried its cheaper fix, and all six readiness checks pass.

A modular monolith can also be where you stay: nothing below is a schedule for leaving it.

The three teams below are hypothetical, made up to show the rule rather than taken from client work.

Early stage: three engineers before product-market fit

Use one PostgreSQL database with a schema per module, one pipeline and the boundary rule in CI from week one. Signals 1 and 2 can't fire without production load and more than one team to measure. Signals 3 and 4 (a different runtime, required isolation) can apply from day one. If version one isn't settled, start with our guide to building an MVP.

If an outside team builds it, ask for the module map and the boundary check as handover deliverables.

Growing: ten engineers, and reports spike at month end

Reporting takes over half the CPU at each month-end on under a tenth of requests, three month-ends running, which crosses the threshold for signal 1 in the checklist below. Before splitting anything, run report generation from the same build behind a queue (the Web-Queue-Worker style) and scale that worker process alone. Extract reporting, and only reporting, if its jobs still miss the morning-of-the-1st deadline at the next three month-ends and profiling shows the limit is one the shared deployable imposes, such as load on the shared database. Slow queries would move into the new service with the module.

Several teams: fifteen engineers in three teams whose releases wait on each other

A release-ready change waited on another team in 4 of the last 6 sprints, over the threshold for signal 2 in the checklist below. Try its cheaper fixes first, starting with release toggles, which keep "incomplete and un-tested codepaths" switched off. Split along team lines, one service at a time, only if releases still wait in over half the next quarter's sprints. Team lines are the first candidate for the cut, since by Conway's Law a design copies "the organization's communication structure". Check that each line also follows a module boundary, so one business transaction doesn't end up spanning two services.

Team size alone doesn't decide it. DX's guide gives three cut-offs on one page (8–10, 10–15 and 15–20+ developers), Milan Jovanović suits a modular monolith to roughly 2–15, and neither cites a study. This post uses 2–15 as its scope, not as the point where you split.

Radar for new SaaS work, as of November 2026

  • Modular monolith: ADOPT (use now) for early-stage and growing SaaS teams.
  • Monolith without enforced boundaries: TRIAL (use where its condition holds) for a throwaway prototype. HOLD (start no new work on it) for a product you plan to grow.
  • Microservices from day one: HOLD for early-stage teams.
  • Extracting one service from a modular monolith: TRIAL under the rule above.

Before the first commit: a module map and a boundary rule that fails the build

I tested the rules below on 25 November 2026, on a throwaway two-module example (billing and reporting) made for this post, not on client code.

Three checks before the first commit

  1. Write the module map: one module per bounded context, each with a named owner. It comes out of scoping a SaaS project.
  2. Add a boundary rule to CI that fails the build on an import past another module's public interface, and give each module its own schema.
  3. Record the rules in an architecture decision record for new hires, contractors and AI assistants. With spec-driven development, put them in the spec too.

A tested boundary rule for TypeScript

dependency-cruiser 18.9.0 checks a JavaScript or TypeScript project's imports against your rules. This one lets a module import another only through its index.ts, and the $1 keeps a module's own imports allowed:

/** A module may use another module only through that module's index.ts */
module.exports = {
  forbidden: [
    {
      name: 'only-through-public-interface',
      severity: 'error',
      from: { path: '^src/modules/([^/]+)/' },
      to: {
        path: '^src/modules/[^/]+/',
        pathNot: ['^src/modules/$1/', '^src/modules/[^/]+/index\\.ts$'],
      },
    },
  ],
  options: { tsPreCompilationDeps: true, tsConfig: { fileName: 'tsconfig.json' } },
};

I ran npx depcruise src --config .dependency-cruiser.cjs. With one import from reporting into billing/internal/, it exited with code 1, which fails a CI step:

error only-through-public-interface: src/modules/reporting/month-end-report.ts → src/modules/billing/internal/invoice-repository.ts

x 1 dependency violations (1 errors, 0 warnings). 4 modules, 4 dependencies cruised.

Through billing/index.ts, it gave 0 violations and exit code 0. The reverse direction failed the same way.

In PHP I ran vendor/bin/deptrac analyse --no-progress with Deptrac 4.7.2. It reported App\Modules\Reporting\MonthEndReport must not depend on App\Modules\Billing\Internal\InvoiceRepository, with the file and line, and exited with code 1. Through BillingApi it gave 0 violations and exit code 0. Its layers are hand-written, a pair per module:

deptrac:
  paths: [./src]
  layers:
    - name: BillingApi
      collectors: [{ type: classLike, value: '^App\\Modules\\Billing\\[^\\]+$' }]
    - name: BillingInternal
      collectors: [{ type: classLike, value: '^App\\Modules\\Billing\\Internal\\.*' }]
    - name: Reporting
      collectors: [{ type: classLike, value: '^App\\Modules\\Reporting\\.*' }]
  ruleset:
    BillingApi: [BillingInternal]
    BillingInternal: ~
    Reporting: [BillingApi]

What the rule doesn't catch, and checkers for other stacks

The test covered static imports between two modules, run locally; a CI step that fails on a non-zero exit code behaves the same. It misses imports built at runtime, service-container lookups and queries into another module's tables.

I then ran three cases the rule should worry about, and it passed all three with exit code 0:

  • A cycle between the two modules through their public interfaces. Adding dependency-cruiser's circular check, { name: 'no-circular', severity: 'error', from: {}, to: { circular: true } }, failed it with exit code 1.
  • An internal function re-exported from index.ts. The rule checks which file is imported, not what that file exposes, so the public interface still needs review.
  • A shared helper outside src/modules/ importing a module's internals. The rule's from path covers only modules. Widen it if you keep shared code.

The Deptrac test covered only the one disallowed class reference. Its BillingApi layer matches every class directly under the namespace, whether you meant it to be public or not. Its summary also counts "Uncovered" dependencies, 0 in my run. Watch that number as you add modules: a rise can mean a class sits in no layer.

A schema per module (check 2) makes cross-module queries easy to spot in review. PostgreSQL can make them fail: by default, "users cannot access any objects in schemas they do not own" unless the owner grants access. That excludes the public schema, where every role has access by default, so keep module tables in their own schemas.

That only holds if each module's queries run under its own database role. An app that connects as one role for everything gets no protection from this unless it switches role per module, and with a separate connection for each module, one transaction can't span two of them. I'd start with schemas and review, and add roles where a boundary must hold. I didn't test the database part. These are starting rules from a small test, so run them on your own code before you rely on them.

For other stacks I read the docs but didn't test the tools. Teams on ESLint can use eslint-plugin-boundaries. Rails has Packwerk, which Shopify runs to "reject changes that break the dependency graph or component encapsulation" before they merge. Java has ArchUnit or Spring Modulith's ApplicationModules.verify().

When microservices, or a modular monolith, is the wrong choice

Splitting by default can leave a small team running the system rather than building on it. In Segment's 2018 account, "operational overhead increased linearly with each added destination". It ended up with over 140 services and "3 full-time engineers spending most of their time just keeping the system alive": over 46 services per engineer on that count. Once it merged them into one, "One engineer can deploy the service in a matter of minutes." That is one company's per-destination design.

A distributed monolith carries the costs of both styles. Milan Jovanović defines it as services "that share data, deploy together, and fail together". At Segment, shared-library changes hit every destination, and in the end they were all "using different versions of these shared libraries".

Services cut too fine for the workload can multiply the bill. In 2023 a Prime Video team moved one monitoring service from serverless microservices to a single process. InfoQ reported a 90% cut in operational costs: a tenth of the old bill. It was a data-heavy video-analysis service, not a typical SaaS app, and its first design supported "around 5% of the expected load".

A modular monolith is the wrong choice in four cases:

  • Nobody enforces the boundaries, so it decays into a plain monolith.
  • Teams still block each other's releases after the cheaper fixes (signal 2 persists).
  • A component needs its own runtime or strict isolation from day one (signals 3 and 4).
  • It's a throwaway prototype, where boundaries are overhead.

If you already run a tangled monolith or services that deploy together, treat it as modernising an existing system, one module at a time.

Clay illustration: the young man untangles a knot of strings between many small boxes while the Netling robot packs the boxes back into one large box with compartments

When to split a monolith into microservices: 4 signals, a cheaper fix first, 6 readiness checks

Flowchart: from a modular monolith with a boundary rule in CI, a signal above its threshold leads to the cheaper fix and a re-measure; extract one module by strangler fig only if it stays above and all 6 readiness checks pass

The four signals are the extraction triggers in Milan Jovanović's 2026 guide. Rahul Garg's 2023 Thoughtworks article lists four situations: three overlap with Jovanović's (different scaling needs, a growing team, different technologies), and the fourth is a firm grasp of the domain. Neither sets thresholds. The thresholds and "try first" steps are my suggested starting points, not research findings: replace them once you have your own data. Signals 1, 2 and 4 each need a repeat, so one bad month-end or one outage can't start a split on its own, though one severe outage is reason enough to review signal 4 early.

Treat each threshold as the point where you review the module, not as proof that a split will help. Before you extract, write down what the split fixes that the cheaper fix couldn't. Then weigh the migration work and one more service to run against what the signal costs you today.

Signal 1: one module's load is out of step with the rest

  • Measure: the module's share of peak CPU or memory against its share of requests or jobs, and whether its jobs meet the deadline you promise customers (say, month-end reports by the morning of the 1st).
  • Source: per-endpoint and per-job figures in your APM, or a load test (non-functional testing covers how).
  • Threshold: over half the peak CPU or memory on under a tenth of requests, three peaks running (three month-ends for a monthly report).
  • Try first: scale the whole app out, which Milan Jovanović says may be cheaper. Then a worker process from the same build behind a queue, then a read replica if the module can read data slightly behind the live database.
  • Extract if: with workers scaled out, its jobs still miss their deadline at the next three peaks, and profiling points to a limit the shared deployable imposes (the shared database, a memory or runtime limit), not to slow queries.

Signal 2: teams wait on each other's releases

  • Measure: sprints where a release-ready change waited on another team's change, and how many days it waited.
  • Source: your deploy log, merge queue or release notes.
  • Threshold: over half the sprints in a quarter, with two or more teams (say 4 of 6 two-week sprints).
  • Try first: release toggles, tests scoped to the touched modules, and an owner per module.
  • Extract if: holds continue in over half the next quarter's sprints.

Signal 3: a module needs a different runtime

This is the one yes-or-no signal.

  • Measure: whether a library, language or hardware (such as a GPU) fits the main build without changing every instance.
  • Source: a spike branch that adds it.
  • Threshold: it doesn't fit, or every instance would need the hardware.
  • Try first: a library or managed API the main runtime can call.
  • Extract if: no such option exists.

Signal 4: a failure or a trust boundary must not cross

  • Measure: incidents where a fault in this module degraded unrelated features; for trust, whether it runs customer code or holds data a contract says must be isolated.
  • Source: your incident log, post-incident reviews and contracts.
  • Threshold: two such incidents in a quarter; for trust, yes.
  • Try first: timeouts, circuit breakers, and a separate worker pool and queue: the bulkhead pattern, so "if one element fails, the others continue to function".
  • Extract if: another such incident in the next quarter after those fixes; for trust, as soon as it's true.

6 readiness checks before you extract

Checks 1–3 are Milan Jovanović's, 4 and 5 come from Martin Fowler's microservice prerequisites, and 6 is my own suggestion.

  1. The module has a public interface, and no other module reads its tables.
  2. It owns its data in its own schema, with no foreign keys or joins across modules.
  3. Other modules already reach it through events or a versioned contract, in-process today.
  4. You can provision an environment and deploy it automatically, with a rollback.
  5. It has monitoring and alerts, plus tracing across the calls it will make over the network.
  6. A named owner and a second person who knows it will carry its on-call.

Three cautions on these checks:

  • Check 2 has a price today. Without foreign keys across modules, the database no longer guarantees those references. Apply it to modules you may really extract.
  • Check 3 changes meaning after the split. An in-process event is a function call. Across a network the same event can be lost or arrive twice, so plan durable delivery and handlers that are safe to run twice before the move.
  • Required isolation doesn't wait for the checks. If a contract demands it (signal 4), the checks are the work list for the extraction, not a reason to delay it.

Extract a module that passes with the strangler fig pattern: put a facade in front and move one capability at a time. I'd also keep the old path as the fallback until the new service has handled real traffic. Once the new service takes writes, falling back needs a plan for the data written since, so I'd move reads before writes.

Frequently asked questions

Is a modular monolith better than microservices?

For a team of 2–15 engineers starting out, yes: you run one deployable, and its boundaries let a module leave later. Microservices pay off when parts of the product must scale, release or fail separately.

What is the difference between a monolith and microservices?

A monolith ships as one unit and microservices as many, so the practical difference is where a call between parts goes. In a monolith it stays inside one process and one database, so a change across two parts ships in one deploy. With microservices it crosses the network to a separately deployed service with its own data. Each part can then be released and scaled alone, at the cost of versioned contracts and network failures to handle.

Should a startup start with microservices?

For the 2–15 engineer teams this guide covers, start with a modular monolith instead. Before product-market fit there is little load or team friction to measure, so services add pipelines, network calls and on-call work before they solve a measured problem. The risk is a distributed monolith: services that still share a database and ship together.

What is replacing microservices?

Nothing has replaced them across the board: Segment merging its services back into one in 2018 and a Prime Video team moving one monitoring service into a single process in 2023 were specific cases. For a new product, this guide recommends a modular monolith, the structure of Shopify's core app.

Which is faster, a monolith or microservices?

Per call between modules, a monolith: its modules call each other inside one process, and "Remote calls are more expensive than in-process calls", as Lewis and Fowler put it. Microservices can add capacity where one part must scale alone, but that doesn't make each request faster.

Before your next architecture review: three things to do

  1. Add the boundary rule to CI this sprint, with the module map beside it.
  2. Start recording the numbers behind signals 1, 2 and 4 now: per-module load at peak, held releases per sprint and cross-module incidents. Then the data exists when someone proposes a split.
  3. Copy the six readiness checks into your architecture decision record template.

If an outside team will build it, custom SaaS development at Netling starts with discovery, then a phase in which you sign off the architecture, schema and API contracts before any code is written. Or send us a brief.

Next in this series: single-tenant vs multi-tenant SaaS, and how to place tenants in your database.

Sources

Sources checked 25 November 2026.

Originally published at netling.digital.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.