Tools & Infrastructure

Monolith vs Microservices

Learn the difference between two major ways to build software — and figure out which one is right for your project.

Scroll to start

What Does "Monolith" Even Mean?

Think of a monolith like a big box of LEGO where everything snaps together in one piece. A monolith is a software program where all the parts — the login system, the search bar, the shopping cart — are all built as one single block of code. They all live together, share the same resources, and get updated together.

A microservices approach is more like a team of specialists. Instead of one big system doing everything, you have lots of tiny programs that each do one job. One tiny program handles logins. Another handles search. Another handles payments. They talk to each other over the internet, but they're totally separate pieces of code.

Both ways work. It's a bit like the difference between owning one big house where the whole family lives, versus each family member living in their own small apartment and meeting up when they need to collaborate.

Why This Choice Changes Everything

The way you build your software affects how fast you can move, how easily you can fix problems, and how big your team needs to be. Choose wrong, and you can spend years buried in slow code and messy updates.

Big companies like Netflix and Amazon started with monoliths, then switched pieces to microservices as they grew. You might not need what they need — but understanding the trade-off helps you make smarter choices for your own project.

💡 Key Insight

Most startups and small projects should start as a monolith. Microservices sound cool, but they come with a ton of extra complexity that you only need once you're big enough to have separate teams managing separate pieces.

Two Ways to Build the Same App

Imagine you're building a food delivery app. Here's how the two approaches differ:

Monolith — One Block

  • 🏗️ One codebase contains everything
  • 🚀 Easy to get started and test
  • 🔄 All parts update together
  • 💸 Cheaper to host when starting out
  • ⚠️ One bug could affect the whole app
  • 📦 Harder to scale just one piece

Microservices — Many Pieces

  • 🧩 Each feature is a separate service
  • 🔧 Fix or update one without touching others
  • 📈 Scale just the busy parts
  • 👥 Different teams can work on different pieces
  • 🔀 More complex to set up and manage
  • 🌐 Needs tools to coordinate all the pieces

A Simple Monolith App

Here's what a tiny monolith app looks like in code. This is a simple web server that handles a homepage, a login, and a product list — all in one file:

server.py
# A simple monolith web server — one file, three features

from flask import Flask

app = Flask(__name__)

# Homepage
@app.route("/")
def home():
    return "Welcome to the Food Delivery App!"

# Login
@app.route("/login")
def login():
    return "Login page here"

# Product list
@app.route("/products")
def products():
    return "Here are the restaurants near you."

app.run()

All three routes live in the same file, share the same server, and update together. That's a monolith. If this app grew into a microservices setup, each of those routes might be its own tiny program running on its own server, talking to the others through API calls.

Knowledge Check

Test what you learned with this quick quiz.

Quick Quiz — 3 Questions

Question 1
What is the main characteristic of a monolith architecture?
Question 2
What is a key advantage of microservices over monoliths?
Question 3
When should a small project most likely start with a monolith approach?
🏆

You crushed it!

Perfect score on this module.