Architectural Styles Deep Dive · 1 of 8

Monolith — One App, One Deploy

A monolith is a single codebase compiled into a single deployable unit. The whole product starts up together, runs in one process, and shares one database. It's the most boring, fastest, and — for most products on most days — the right architecture.

Single ProcessShared DBOne DeploySimple
← Back to Architecture
Quick Facts

What a Monolith Is

Basic Concepts

  • One codebase: all features live together in a single repository.
  • One process: at runtime, it's one binary, one JVM, one Python process — all calls are in-memory function calls.
  • One database: usually a single relational DB. ACID transactions span the whole feature set.
  • One deploy: ship the whole thing at once. Roll back the whole thing at once.
  • Not "legacy": Shopify, GitHub, Stack Overflow, Basecamp run massive monoliths on purpose.
Why It Wins

The Boring Advantages

Operational Simplicity

One thing to build, one to deploy, one to monitor, one to alert on. No service mesh, no distributed tracing required to debug a request, no schema registry. A junior engineer can run the whole stack on their laptop in five minutes.

Refactoring Is Cheap

Rename a function, the IDE updates every caller. Move a column, write a single migration. Try the same across a dozen microservices and you'll discover what "distributed coordination" really costs.

ACID Transactions Just Work

"Save the order, save the customer, save the invoice — atomically" is one DB transaction. No sagas, no compensating actions, no eventual consistency to explain to the business.

Performance — Yes, Really

An in-memory function call is ~1 nanosecond. A network hop, even on a fast LAN, is ~500,000 nanoseconds. Monoliths skip the network entirely for every internal call. They're often faster than the equivalent microservices system at small to medium scale.

Where It Hurts

When the Monolith Strains

Deploy Coordination

Every team's PRs land in the same artifact. One bad change blocks all releases until it's reverted or fixed. With 5 engineers this is fine; with 200, it's a daily fire.

Scaling the Wrong Things Together

The reporting endpoint is slow and CPU-heavy. The login endpoint is fast and frequent. In a monolith, you scale them by adding instances of the whole app — wasting memory replicating login code to handle reporting load.

One Process, One Blast Radius

A memory leak in the analytics module crashes the checkout. A long-running report drains the connection pool away from real users. Without internal isolation, one weak feature can take down the whole product.

Module Boundaries Erode

Without enforcement, internal modules import each other freely. After a few years you have a "big ball of mud" — every change touches half the codebase. This is what gives monoliths their bad name; it's a discipline failure, not an architectural inevitability.

Patterns

How to Keep a Monolith Healthy

  • Internal modules with enforced boundaries. Use ArchUnit (Java), dependency-cruiser (JS), or Go's internal/ packages to fail CI when modules cross-import improperly. This is the "modular monolith" approach.
  • Feature flags. Decouple deploy from release. Ship code dark; flip on for a percentage of users.
  • Background workers. Move slow or async work to a worker process reading the same DB. Same codebase, different runtime profile.
  • Read replicas. Direct heavy reads at a follower DB. The simplest scaling lever before you split anything.
  • Vertical scaling first. A 64-core server running a monolith handles a remarkable amount of traffic. Cheaper than the ops cost of going distributed.
Decision

When to Pick a Monolith

SignalMonolith?
Team size < 30 engineersYes.
Domain still being figured outYes — boundaries change weekly.
Tight transactional consistency requiredYes.
Need rich cross-feature queriesYes — joins are free.
20+ teams blocked by shared releasesTime to extract.
One feature has a wildly different scaling profileExtract that one.
Compliance demands hard isolation (PCI scope)Extract.

"If you can't build a well-structured monolith, you can't build well-structured microservices." — Simon Brown.

Continue

Other Architectural Styles