Bookmarks

Monolith

An application built as a single unit: one codebase, one build process and one deployment instead of a set of separate services.

Also: monolithic system, monolithic application, monolithic architecture

checked 8 Nov

All terms

In a monolith, all the logic — the web interface, the API, database access, background jobs — lives in a single codebase and is deployed as one process: any change means building and releasing a new version of the whole application. The Unix community has long used the word “monolith” in this sense, describing systems that had grown too large.

How it is structured

LayerWhat it does
Interface and APIaccepts user requests and returns responses
Business logicdomain modules: orders, invoices, users
Data accessworks with the database through a single layer or an ORM
Integrationscalls external services and sends messages

Inside, a monolith is usually split into modules or layers — a layered or a hexagonal architecture — but at runtime it is still a single process, and the modules call each other with ordinary function calls, without the network. Load is handled with copies: the built application is installed on several identical servers behind a load balancer and scaled as a whole, even when only one module needs the extra capacity.

When a monolith is the right choice

  • a small team and a new product: there is no data on how the system will change, and nothing to split it into in advance;
  • unclear load: a dedicated server or a few copies behind a load balancer are cheaper and simpler than a distributed system;
  • straightforward operations: a single deployment, one database, familiar debugging within one process — all within reach of a small team with no dedicated platform team;
  • strict data consistency: transactions in a single database work out of the box, with no need for distributed patterns such as saga and transactional outbox.

The limit comes when releasing one small change means rebuilding and redeploying the whole application, when different modules need different resources, or when the modules have grown together over time so much that a change no longer fits into a single module. Then the monolith is split into services — usually gradually, cutting them away at the edges — or order is restored inside it first: a modular monolith.

Monolith and microservices

Microservices break the system into independent services, each with its own database and independent releases. The price is the network: every call across a service boundary can be delayed or fail, data consistency is maintained with patterns such as saga, and running it all takes mature DevOps. Martin Fowler calls this set of costs the microservice premium and advises starting with a monolith: in his observation, nearly all the successful microservice stories began with a monolith that had grown and was then split up, while systems designed as microservices from the start more often ran into trouble — at the outset almost nobody guesses the right boundaries between services.

Sources

the term is written from these pages

Verified 8 Nov

Not to be confused with

what it is mixed up with and how it differs

  • modular monolith

    A modular monolith is the same single deployable unit, but with clear module boundaries inside: each module has its own public interface and its own data.

  • microservices

    Microservices are many independently deployable services; a monolith is one process, one database, one release.

  • distributed monolith

    A distributed monolith — the services have been formally split up, but they are changed and released together: the costs of a distributed system without its benefits.

In depth in the references

where the topic is covered in detail