Lesson 06 · Architecture

Monolith vs Microservices: The Art of Splitting

It's the most heated debate of the decade. Should you build a single giant application or an army of small autonomous services? The answer is not technical, it is organizational.

1

The Three Musketeers

The Monolith

The Swiss Army Knife. Everything is in one block of code (Auth, Payment, Products). A single database.

  • Simple to deploy.
  • Hard to maintain when it grows.
Microservices

The Toolbox. Dozens of small independent programs talking via network (HTTP/gRPC).

  • Precise scalability.
  • Operational hell (DevOps).
Modular Monolith

The Middle Ground. Single deployable unit, but with strictly separated folders inside.

  • Best of both worlds to start.
2

Visualization

Architecture Diagram: Monolith vs Microservices
🧊 vs 🎲Architecture Diagram
Left: Single Shared DB (Tight Coupling). Right: Each service has its own DB (Independence).
3

Truth Table

CriteriaMonolithMicroservices
DeploymentSimple (1 binary)Complex (Orchestration needed)
DevelopmentFast at start, slow at scaleSlow at start, fast at scale
DatabaseShared (Easy Joins)Separate (No Joins possible)
FailureEverything crashes (SPOF)Isolated (Rest survives)
TeamsEveryone touches everythingAutonomous Squads
4

When to choose what? (The Survival Guide)

Choose Monolith if...

  • You are a Startup or in MVP phase.
  • Your team is small (< 10 developers).
  • The business domain is fuzzy and changes often.
  • You don't have a dedicated DevOps expert.

Switch to Microservices if...

  • You need to scale specific parts (e.g., Video Encoding) independently.
  • You have multiple teams (> 30 developers).
  • You need different technologies (Python for AI, Node for API).
5

In Interviews (System Design)

The Perfect Answer

"Never propose Microservices on Day 1, unless you are explicitly asked to design Uber or Netflix."

The Approach:"To start, I would choose a **Monolithic** architecture for deployment simplicity and data consistency. However, I will structure the code in a modular way (Modular Monolith) to facilitate future extraction of services (e.g., Payment Service) if the load increases."
6

Flash Quiz

Self-Evaluation
7

Your Turn: The Surgeon

Mission: Extract a Service

You have a monolithic E-commerce site.
The "PDF Invoice Generation" module consumes 80% of the CPU and slows down the whole site.

Your mission: Draw the architecture after extracting this module into its own Microservice. Don't forget communication (Queue or HTTP?) and storage.

8

For the Curious (Bonus)

The Strangler Fig Pattern
How to migrate an old monolith to microservices? We don't rewrite everything!
Like a Strangler Fig (tropical plant), we build new services around the old system, intercepting requests little by little, until the monolith is no longer needed and can be turned off.
Service-Oriented Architecture (SOA)
The ancestor of Microservices (2000s). The difference? SOA aimed at reusing enterprise services via a central bus (ESB), often heavy and complex. Microservices aim for decoupling and speed ("Smart endpoints and dumb pipes").