Book Deep Read · Fundamentals of Software Architecture · Chapter 9

Foundations of Architecture Styles: The Network Decides Monolith vs Distributed

Fundamentals of Software Architecture · Ch 9 · Mark Richards & Neal Ford · 2020

中文 →

What is this chapter about?

Every app you use has an overall "shape" behind it: are all the features crammed into one program, or split into dozens of small programs that shout to each other across a network? This chapter doesn't teach one particular shape. It covers the ground all shapes stand on: what the worst shape looks like, and the most basic dividing line between "one program" and "many programs."

An analogy: one kitchen, or a street of takeout shops

In one big kitchen, the person chopping vegetables turns around and hands them to the cook. Fast, nothing gets lost, no charge. Now split the work across ten shops on a street: chopping happens in shop A, cooking in shop B, and couriers carry things in between. Couriers get stuck in traffic, deliver to the wrong door, get robbed; every trip costs money; and the street can be dug up and rerouted without warning. Separate shops can each grow on their own, but "handing something over" has turned from free into a business.

Why the old world was hard

The most common software shape is actually no shape at all: features get piled on one by one, anything grabs whatever it needs directly, and eventually everything is tangled together like a spilled bowl of noodles. Pull one strand and the whole bowl moves. So people want to split things up. But many make one mistake when they do: they assume shouting across a network is as dependable as handing something across a room. At small scale the illusion holds; at large scale it fails all at once.

The core idea: the network's eight lies

The book lists this illusion as eight beliefs that earlier engineers already paid for: that the network never drops anything, that a message takes no time, that the pipe is infinitely wide, that nobody is listening in, that the roads never change, that one person is in charge, that delivery is free, and that every road is the same. Each one is a real trap. Say you assume the next shop answers instantly; if one order passes through ten shops in a row and each adds a little delay, the customer waits forever. Another is easy to miss: with one program, when something breaks you read one notebook; with ten programs, you piece the truth together from ten notebooks, and the promise "either everything happens or nothing does" becomes very hard to keep.

What it gives you / how to choose

Every architecture shape in the following chapters is first sorted into one of two buckets: the "one program" bucket and the "many programs" bucket. The first is simple, cheap, and easy to debug. The second lets parts grow independently, ship independently, and fail without taking everything down. The choice depends on whether you truly need parts to grow on their own; if you don't, don't pay the street's tolls for nothing. The honest cost: once you pick "one program," scaling up a single feature means scaling up the whole thing.

One line to remember

Before splitting, ask one question: how much am I willing to pay to hand things over a network? The network is unreliable, slow, and costs money; the benefits of splitting must outweigh that.

Want the Big Ball of Mud and client/server evolution, the eight fallacies of distributed computing one by one, the bandwidth math, and the monolith-vs-distributed comparison? → Switch to Deep