Monolithic Architecture
A single deployable unit containing all functionality. When it is the right answer, how monoliths degrade, and how to keep one healthy.
Intent
Build and deploy the whole application as one unit: one codebase, one build artifact, usually one database. All modules call each other in-process.
flowchart LR
U[Users] --> LB[Load balancer]
LB --> M1[Monolith instance]
LB --> M2[Monolith instance]
M1 & M2 --> DB[(Single database)]
subgraph M1
UI[Web/UI] --> SVC[Business logic:<br/>orders, catalog, users, payments]
SVC --> DAL[Data access]
endWhen it fits
- New products where the domain is still being discovered.
- Small teams (one or two) that need speed.
- Strongly transactional domains where most operations touch many entities.
- Applications with modest scale needs (vertical scaling + replicas is enough).
Real-world example
Many successful companies (Shopify, Basecamp, Stack Overflow historically) have run very large majestic monoliths with high scale by investing in modularity, caching and database tuning. Shopify publicly describes a "modular monolith" approach for its core Rails application.
Pros and cons
| Pros | Cons |
|---|---|
| Simple development, testing and debugging | Codebase can become a "big ball of mud" without boundaries |
| In-process calls: fast, transactional | Whole app redeployed for any change |
| One deployment pipeline and runtime | Scaling is all-or-nothing |
| Easy refactoring across modules | Technology stack is shared by everything |
| Lowest operational cost | Many teams in one codebase cause merge and release contention |
Java example: layered structure
// Package by feature, not by layer, to keep future extraction possible.
com.shop.orders.OrderController
com.shop.orders.OrderService
com.shop.orders.OrderRepository
com.shop.catalog.ProductService
com.shop.payments.PaymentServiceWhen not to use
When many independent teams must release independently, when parts have radically different scaling or availability needs, or when regulatory isolation requires separate deployment units.
Interview questions
Is a monolith an anti-pattern?
No. A badly structured monolith is a problem; a well-modularized monolith is often the best starting architecture. The anti-pattern is the distributed monolith: services that must be deployed together and share a database.
How do you know it is time to split a monolith?
Release contention between teams, deployment risk slowing delivery, a component with very different scaling or reliability needs, or a technology need that cannot coexist. Measure lead time and change failure rate before deciding.