SkillSprout
Chapter 9 · Lesson 1
Intermediate
4 min read

From Monolith to Microservices

Overview

Most products start as one application that does everything. As the product and the team grow, that single application becomes harder to change safely. Microservices are one way to break it into smaller pieces that can be built and deployed on their own.

Detailed Notes

What is a monolith, and what are microservices

A monolith is an application where all features live in one codebase and are deployed together as one unit. An online shop might have users, products, orders and payments all inside one program, talking to one database.

Microservices split that application into many small services. Each service:

  • does one business job (for example "orders" or "payments");
  • has its own codebase and is deployed on its own;
  • is owned by one small team;
  • is reached through a well-defined API (from the API Design chapter).

The problem it solves

A monolith is wonderfully simple at first. But as it grows:

  • Slow, risky releases: a tiny change to the payment code means redeploying and retesting the whole application.
  • One bug can take everything down: a memory leak in the search feature can crash the checkout too.
  • Team collisions: fifty engineers editing one codebase step on each other's work.
  • All-or-nothing scaling: if only the product-search feature is busy, you still have to copy the entire application onto more servers (horizontal scaling from the Scalability chapter), wasting resources.
  • Stuck technology: the whole app must use one language and framework.

Microservices attack exactly these pains: independent releases, isolated failures, separate scaling and clear team ownership.

How it works

  1. Find the natural boundaries in the business: users, catalog, orders, payments, shipping. Each boundary becomes a service (this is often called a bounded context).
  2. Each service runs as its own set of servers, often several copies behind a load balancer (from the Load Balancing chapter).
  3. Services expose an API and only talk to each other through it, never by reaching into each other's code.
  4. Each service can be deployed, scaled and even rewritten without touching the others.

A good boundary is one where a change usually stays inside a single service. If every feature needs edits in five services, the boundaries are wrong.

A simple example

Think of a food court versus one giant kitchen. In the giant kitchen, one cook handles every dish; if the grill breaks, no one eats. In the food court, each stall runs on its own: the pizza stall can hire more staff on a busy day, and a broken burger grill does not close the sushi counter. But now customers need to visit several stalls, and the stalls must agree on how to work together.

System design example

An online shop starts as a monolith. During sales, search and product browsing are slammed while payments are calm. The team splits out a catalog service and runs 20 copies of it, while the payment service keeps 3. A bug in the recommendations service now only hides the "you may also like" box instead of breaking checkout.

Most mature systems get there gradually: they keep the monolith and carve out one service at a time, starting with the part that changes most or needs to scale most.

Summary

  • A monolith is one deployable application; microservices are many small, independently deployable services.
  • Microservices help with release speed, failure isolation, targeted scaling and team ownership.
  • Split along business boundaries, not technical layers.
  • Each service exposes an API and is usually run as several copies behind a load balancer.

Architecture Diagram

One monolith split into services
Architecture

Monolith

Users + Catalog + Orders + Paymentsone deploy

Microservices

Catalog service20 copies
Orders service6 copies
Payment service3 copies

Each service owns one business job and can be scaled and deployed on its own.

  1. 1The monolith ships every feature as one unit.
  2. 2Business boundaries are identified.
  3. 3Each boundary becomes its own service.
  4. 4Services deploy and scale independently.

Common Interview Questions

Finished this lesson?

0 of 91 lessons done · 0% of the course