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
| Layer | What it does |
|---|---|
| Interface and API | accepts user requests and returns responses |
| Business logic | domain modules: orders, invoices, users |
| Data access | works with the database through a single layer or an ORM |
| Integrations | calls 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 pagesVerified 8 Nov