CSE Roadmap

Core tier · about 3 hours · 7 parts

Part 6 of 7 · 3 min read

Big ball of mud, and when a monolith is right

A monolith without structure decays. A monolith with structure is often the best start.

Big ball of mud, and when a monolith is right

Think of a garden. With paths and beds it stays easy to walk. With no plan, weeds and ad hoc paths spread, and soon you cannot find anything.

FSA names the failure case big ball of mud, from a 1997 paper by Foote and Yoder: a haphazard, sprawling system where information is shared between distant parts and nothing has clear structure. It is the absence of an architecture. The book says few architects mean to create one, but many projects end in one through lack of governance on code quality and structure. In the book's example, a Java web application built quickly over several years had so many tangled links that any change made it hard to predict the effects elsewhere. The book describes a change in such a system as "a terrifying affair". Deployment, testing, scalability and performance all suffer.

Big ball of mud

A big ball of mud is a system with no discernible structure, where almost any part may depend on any other.

Example: a script-style web app where button handlers call the database directly, and over years every file imports every other.

How does a team avoid it? By the tools of the previous pages: decisions that are written down, modules with limited dependencies, and automatic checks. Without them, a layered or modular design decays.

When is a monolith the right answer? The books give these conditions:

Condition Why a monolith fits
Small team and small application The simplicity and low cost are the main strengths
Tight budget or short schedule No distributed machinery to build
Requirements still unclear Boundaries cannot be placed well yet. Getting service boundaries wrong is costly (Building Microservices)
One set of characteristics for the whole system A single deployment unit is enough

FSA's Silicon Sandwiches case concludes that a single quantum (one deployable unit with one set of characteristics) suffices for a simple application without a big budget, so the simplicity of a monolith appeals.

When does it stop fitting? When parts of the system need very different characteristics, for example one part must scale far beyond the others, or teams are blocked by each other's releases. The one-line change that forces a whole release, in the Building Microservices book, is its picture of the pain.

Interview angle

Answer in your head first, then open it.

What is a monolith, and is it bad?

One deployment unit. Not bad: simple, cheap, easy to test end to end. It becomes costly when it grows without structure.

Layered or modular monolith?

Layered groups by technical role and spreads each feature across layers. Modular groups by domain, which fits changes and later splitting.

What are open and closed layers?

Closed layers must be passed through, which gives isolation. Open layers may be skipped.

What is a big ball of mud?

A system with no structure, where changes have unpredictable effects.

Would you start a new product with microservices?

Usually start with a modular monolith, unless clear needs justify the extra cost.

Check yourself:

  • Name two situations in which a monolith is the better choice.
  • What stops a modular monolith from turning into a big ball of mud?

Words you will meet

Word Plain meaning
Monolith An application built and deployed as one unit
Distributed architecture Several separately deployed parts talking over a network
Deployment unit The piece that is released as one
Layered (n-tier) architecture Code grouped in layers by technical role
Presentation, business, persistence, database The four usual layers
Closed layer A layer that requests must pass through
Open layer A layer that requests may skip
Layers of isolation Changes in one layer do not harm others if contracts hold
Technical partitioning Grouping code by technical job
Domain partitioning Grouping code by business area
Modular monolith One deployment, with domain modules
Conway's law Systems copy the communication structure of the organisation
Inverse Conway Maneuver Shape the teams to get the architecture you want
Architecture sinkhole Requests that pass through layers with no processing
Big ball of mud A system with no clear structure
Fallacies of distributed computing False beliefs, such as "the network is reliable"