Skip to main content
Home › Categories › Software Engineering, Cloud & Cybersecurity › Modular Monolith vs Microservices Architecture: Distributed Complexity, Team Topologies, and Migration Patterns

Modular Monolith vs Microservices Architecture: Distributed Complexity, Team Topologies, and Migration Patterns

Author: ZUVDEX Team 4 min read
modular monolith vs microservices distributed monolith anti pattern domain driven design bounded contexts transactional outbox saga pattern conways law team topologies strangler fig microservice extraction

A Modular Monolith organizes an application into strongly encapsulated domain modules—each owning private internal logic and isolated database tables—compiled and deployed together as a single stateless artifact, whereas Microservices split domains into independently deployed network services with separate datastores. Because microservices solve organizational scaling bottlenecks for 100+ engineer orgs at the cost of distributed network latency and eventual consistency, starting with a strict Modular Monolith is almost always the highest-velocity engineering choice.

Key Highlights

  • Microservices are primarily an organizational scaling tool (Conway’s Law) allowing dozens of independent squads to deploy without release-train bottlenecks—not a shortcut to cleaner code.
  • If you cannot enforce clean module boundaries inside one repository with compiler linter rules, splitting that tangled code across 15 network repos simply creates a 'Distributed Monolith' that must still deploy in lockstep.
  • In-process function calls take ~1 nanosecond and never drop packets; cross-service HTTP/gRPC calls take 1–5 milliseconds (1,000,000× slower) and require timeouts, retries, circuit breakers, and idempotency.
  • When extracting a true bottleneck (like video transcoding or GPU inference), carve it out cleanly along an existing module seam using the Strangler Fig and Transactional Outbox patterns.

1. Three Architectures Compared: Big Ball of Mud vs Modular Monolith vs Microservices

Microservices gained fame because engineers compared them against ‘Big Ball of Mud’ legacy monoliths where any controller randomly joined any table across 400 files. A disciplined Modular Monolith keeps single-artifact deployment simplicity while enforcing microservice-grade encapsulation:

Big Ball of Mud vs Modular Monolith vs Microservices
Dimension Tangled Legacy Monolith Modular Monolith Microservices Architecture
Deployment Unit Single artifact Single stateless horizontally scaled artifact Dozens of independent containers & CI pipelines
Code Boundaries None (cross-imports everywhere) Compiler/linter enforced public module APIs only Network API boundaries (gRPC / REST / Events)
Database Ownership Global cross-table joins everywhere Logical schema isolation per module (no cross-module SQL joins) Separate database / schema per service
Transaction Model Simple ACID `BEGIN…COMMIT` ACID within module + domain events across modules Eventual consistency via Sagas & Outbox
Refactoring Boundaries Painful due to global coupling Easy (IDE rename & typechecker catch everything) Very expensive (multi-repo versioned API migrations)
Local Dev Setup 1 command (`docker compose up`) 1 command (`docker compose up`) Heavy (mocking or cloud dev namespaces)

2. Four Concrete Rules That Keep a Modular Monolith Clean

Good intentions rot under deadline pressure unless enforced automatically in CI/CD:

  • Rule 1 — Public Facade Imports Only: Module `billing` may call `identity/public_api`, never `identity/internal/models`. Enforce this with architectural linters (`eslint-plugin-boundaries`, Rust crates, Go `internal/` packages, or ArchUnit).
  • Rule 2 — Zero Cross-Module SQL Joins: Give each module its own Postgres schema (`billing.*`, `catalog.*`, `auth.*`). Modules read neighbor data via explicit in-process service interfaces, making future database extraction trivial.
  • Rule 3 — Stateless Horizontal Scaling: Store zero sticky session state on local disk so running 20 replicas of your monolith behind a load balancer handles tens of thousands of requests per second.
  • Rule 4 — Transactional Outbox for Side Effects: Write outbound events into an `outbox_events` table inside the same SQL transaction as business state changes so background workers never miss or duplicate events.

3. Genuine Triggers to Extract a Standalone Service

Extract a module out of your Modular Monolith into a separate service only when a concrete engineering force justifies network serialization: asymmetric hardware requirements (e.g., Python/CUDA GPU workers alongside a Go/TypeScript web core), radically different scaling/fault profiles (bursty untrusted webhook ingestion), or strict regulatory isolation (PCI-DSS cardholder vaulting).

FAQs

How do you recognize if you accidentally built a Distributed Monolith?

Ask two diagnostic questions: (1) Do multiple microservices read and write the exact same shared SQL tables directly? (2) Does shipping one product feature require coordinating simultaneous deployments across four services in a specific order? If yes to either, you have all the pain of distributed systems with none of the autonomy.

Can a Modular Monolith scale to millions of users?

Absolutely—Shopify, GitHub, and Stack Overflow famously scaled modular monolith cores to massive global traffic by horizontally scaling stateless web tiers, partitioning databases, and offloading heavy async jobs to queues.

What is the Strangler Fig migration pattern?

Named by Martin Fowler, Strangler Fig places an HTTP/API router in front of an existing system and migrates one bounded domain slice at a time to a new module or service behind feature flags—avoiding risky multi-year 'big bang' rewrites.

References & Sources

  • Evans, E. — Domain-Driven Design: Tackling Complexity in the Heart of Software, Addison-Wesley.
  • Skelton, M.; Pais, M. — Team Topologies: Organizing Business and Technology Teams for Fast Flow, IT Revolution.
  • Newman, S. — Monolith to Microservices: Evolutionary Patterns to Transform Your Monolith, O’Reilly Media.
  • Richardson, C. — Microservices Patterns (Transactional Outbox & Saga Coordination), Manning.