FullStack AI Hub
Studio
System Design · 06. Architecture
10 min
10 steps
Beginner

Monoliths vs Microservices

Know when modular monoliths beat network hops, how team contention forces splits, and how to extract services safely via Strangler Fig.

System Design06. ArchitectureLesson 1 of 4
10 minBeginner10 steps

Monoliths vs Microservices

Know when modular monoliths beat network hops, how team contention forces splits, and how to extract services safely via Strangler Fig.

CHECKOUT P95
28 ms
NETWORK HOPS
1 Hop
DEPLOY UNITS
1 Binary
RPC ERRORS
0.0%
MODULAR MONOLITH FLEET · Users · Catalog · Orders20K usersLoadBalancer28%Monolith A32%In-proc callsMonolith B32%In-proc callsPrimary SQL34%
in-process / API call
database write
fast reply
cross-service RPC / traffic
cascade / deploy freeze
In This LessonStep 1 of 10
What You Will Master
  • ✓Recognize why a well-structured modular monolith beats premature microservices on latency and simplicity
  • ✓Identify true microservice triggers: independent scaling profiles, blast-radius isolation, and org-wide deploy contention
  • ✓Extract services incrementally with the Strangler Fig pattern instead of risky big-bang rewrites
  • ✓Budget for the hidden microservice tax: network serialization, tail latency amplification, and distributed tracing

Architectural Trade-Off Comparison Matrix

PatternBest ForKey Trade-Off
Modular MonolithEarly-to-mid stage teams (1–40 devs) needing sub-ms in-process calls, ACID joins, and fast refactorsAll modules share one deploy pipeline, runtime memory, and scaling unit
MicroservicesLarge orgs (50+ devs) with independent scaling needs (e.g., GPU ML vs CRUD) and strict team autonomyIntroduces network latency, partial failures, distributed transactions, and DevOps overhead
Strangler Fig PatternSafely migrating legacy monolith routes one domain at a time behind an edge routing proxyTemporarily operates dual systems and data sync bridges during transition
Distributed Monolith (Anti-Pattern)Avoid! Happens when microservices share one database or require lockstep deploymentsWorst of both worlds: microservice network latency with monolith coupling

Step-by-Step Architectural Breakdown (10 Steps)

Full architectural walkthrough transcript and state transitions for Monoliths vs Microservices.

STEP 01 · SETUPJump to step →

Start simple: the fast, clean Modular Monolith

A **Modular Monolith** keeps `Users`, `Catalog`, and `Orders` inside one deployable binary—separated by clean internal module interfaces instead of HTTP network calls.

Function calls take **nanoseconds**, multi-table SQL joins remain strictly **ACID**, and one engineer can trace a checkout bug locally in seconds.

good:Most successful tech companies—Shopify, Stack Overflow, Stripe—scaled massively on modular monoliths long before splitting hot domains.

Modular MonolithIn-Process CallsLocal ACID Joins
STEP 02 · PROBLEMJump to step →

Pain #1: shared blast radius & asymmetric scaling

Two years later, your app adds a heavy **Video Transcoder / PDF Export** module inside the same monolith process. One memory leak in PDF generation OOM-kills the JVM/Node process—**taking down Checkout with it**!

Worse, scaling CPU-hungry video jobs forces you to over-provision 20× expensive monolith replicas just to handle one heavy endpoint.

watch:Shared runtime means shared fate: an OOM crash or CPU spike in a low-priority analytics module takes down revenue-critical checkout.

Shared Blast RadiusAsymmetric ScalingNoisy Neighbor
STEP 03 · PROBLEMJump to step →

Pain #2: 120 engineers fighting over one deploy train

Microservices are often an **organizational scaling** pattern as much as a technical one. When 12 teams merge into one giant repo, CI builds take 50 minutes and one broken Billing test blocks Search from shipping for hours.

Conway’s Law kicks in: independent squads need independent release cadences and clear runtime ownership.

idea:Rule of thumb: split a service when team deploy contention, independent scaling needs, or blast-radius isolation hurt more than network complexity.

Conway’s LawDeployment ContentionTeam Autonomy
STEP 04 · SOLUTIONJump to step →

Extract safely with the Strangler Fig pattern

Never freeze product work for a 12-month "big-bang microservices rewrite"—those almost always stall or launch with regressions.

Instead, place an **Edge Routing Proxy** in front of the legacy monolith and peel off one domain at a time (starting with heavy `Media/Export` or `Search`), shifting traffic `5% → 50% → 100%` while the rest of the monolith stays untouched.

good:Named after strangler fig vines: new services grow around the legacy monolith route-by-route until the old code can be retired peacefully.

Strangler Fig PatternIncremental ExtractionZero-Rewrite Migration
STEP 05 · SOLUTIONJump to step →

Break the shared DB: private data ownership per service

Splitting code into 3 aligned services while leaving all 3 pointed at the same `Shared SQL` creates a **Distributed Monolith**—a single table lock or column rename still crashes all three teams.

True microservices enforce **Database-per-Service**: `Catalog`, `Orders`, and `Billing` each own private storage and exchange facts via APIs or CDC events.

watch:If two services read and write the same SQL tables, they are NOT decoupled microservices—they are tightly coupled with extra network latency.

Database per ServiceDistributed Monolith TrapIndependent Schemas
STEP 06 · TRADE-OFFJump to step →

The hidden tax: RPC chains & tail-latency amplification

Every time you replace a `50 ns` function call with a network RPC, you pay TLS, JSON/Protobuf serialization, and queueing jitter. Worse, **tail latency compounds** across fan-outs!

If 1 checkout request calls 5 downstream services in sequence—each with `99%` uptime and `40 ms` P99—overall availability drops to `0.99^5 = 95.1%` and P99 spikes past `200 ms`.

watch:Avoid "nano-services"! Deep 6-hop synchronous call chains multiply latency and failure probability geometrically.

Tail Latency AmplificationRPC Serialization TaxAvailability Math (0.99^N)
STEP 07 · TECHNIQUEJump to step →

Flatten call chains: parallelize reads & go async for writes

Tame microservice latency with two rules: **fan out independent reads in parallel** (`Pricing` + `Inventory` concurrently, taking `max()` instead of `sum()`), and move non-blocking steps (`Fraud Audit`, `Receipts`) onto an **async Event Bus**.

Now checkout waits only on the slowest parallel call (`~42 ms`) instead of summing 5 serial hops (`268 ms`).

good:Serial latency = A + B + C. Parallel latency = max(A, B) while C runs asynchronously off the critical path.

Parallel Fan-OutAsync Critical-Path TrimShallow Service Graphs
STEP 08 · TECHNIQUEJump to step →

Debugging across machines: distributed tracing & correlation IDs

In a monolith, one stack trace shows the exact failing line. Across 12 microservices, a failed checkout leaves scattered logs on 6 hosts.

Every edge request must stamp an OpenTelemetry `traceparent` (`trace_id`) header propagated across every RPC and Kafka header into a central **Tracing Collector**.

idea:Never split your first microservice until centralized logs, metrics, and distributed tracing (`trace_id`) are already running in production.

Distributed TracingOpenTelemetry trace_idMicroservice Prerequisites
STEP 09 · TRADE-OFFJump to step →

Right-sizing: coarse "macroservices" beat tiny nano-services

Splitting into 150 tiny one-endpoint "nano-services" maximizes ops pain without helping teams move faster. Industry leaders (Amazon Prime Video, Segment, Shopify) deliberately re-consolidated overly fragmented services into **coarse domain services**.

Aim for **one cohesive domain per squad** (`Commerce Core`, `Media Pipeline`, `Search`)—keeping tightly related entities together and crossing network wires only at true scaling or ownership seams.

good:A healthy architecture is rarely "100% monolith" or "200 microservices"—it is a modular core plus selectively extracted services where scale or autonomy demands it.

Coarse-Grained DomainsAvoid Nano-ServicesHybrid Architecture
STEP 10 · RECAPJump to step →

Evolution roadmap: Modular Monolith → Strangler → Cohesive Domains

Start every greenfield product as a **Modular Monolith** with clean internal seams. Only extract a service when you hit real pain: asymmetric resource scaling, blast-radius isolation, or multi-squad deploy contention.

When you do split, migrate incrementally with **Strangler Fig**, enforce **Database-per-Service**, parallelize reads, decouple side effects onto an Event Bus, and trace every hop.

good:Decision Rule: earn your microservices. Modular Monolith first → Strangler Fig extraction → Private DBs → Parallel/Async hops + OTel Tracing.

Evolutionary ArchitectureStrangler FigEarned Microservices

Related Production Deep-Dives & Simulators

Included In Free Course
Free · Verifiable Credential

FS-102LLM Systems Foundations

Build a connected mental model from tokens through retrieval evaluation security and operations.

24 concepts~18h self-paced
Start Free Course
Weekly Engineering Dispatch

Get the weekly systems teardown

One technical note per week covering inference bottlenecks, retrieval harnesses, and commit-pinned teardowns.