Lesson 2 of 17
27. Monolith vs Microservices

27.1 What is a monolith?

3 min read+10 XP

The two shapes

In the restaurant: One kitchen does everything. One team, one menu, one set of opening hours. If the kitchen closes, the whole restaurant closes.

In the system: A monolith is an application built and deployed as one unit: one codebase, one build, one process (usually run as many identical copies behind a load balancer, Chapter 6), usually one database. For the bookstore, catalogue, cart, orders, payments, search and recommendations are all modules inside the same application.

monolith, modular monolith and microservices for the same bookstore.

Figure: same features, three ways of packaging them.

Two things "monolith" does not mean:

  • Not one server. A monolith scales horizontally: 20 identical copies behind a load balancer.
  • Not bad code. "Monolith" describes how it's deployed, not how well it's organised. A messy monolith is a big ball of mud; a well-organised one is a modular monolith (27.3).

Memory code: "One kitchen, one menu, one door."