Part 2 of 7 · 2 min read
Monolith or distributed
The first split between styles is how many things are deployed.
Think of a food truck and a chain of restaurants. The truck is one unit: cook, till and stock in one vehicle. The chain has separate kitchens, warehouses and delivery vans that depend on phone calls between them. The truck is simple but cannot serve ten thousand people. The chain can, but its parts must talk.
FSA sorts architecture styles into two groups. A monolithic style has a single deployment unit holding all the code. A distributed style has several deployment units connected by remote access protocols. The book lists layered, pipeline and microkernel as monolithic, and service-based, event-driven, space-based, service-oriented and microservices as distributed.
Monolith
A monolith is an application whose code is built and deployed as one unit, usually with one database.
Example: a web shop where product pages, the cart, checkout and admin all run in one program that is released as a whole.
Distributed architecture
A distributed architecture splits the system into several separately deployed parts that communicate over a network.
Example: a web shop where checkout, stock and email are three programs on different machines.
FSA says distributed styles are far stronger in performance, scalability and availability, but all share a set of problems that monoliths do not have. These are the fallacies of distributed computing, a list from 1994. The book names eight, and these are the first three:
| Fallacy (false belief) | Truth |
|---|---|
| The network is reliable | Calls can fail or time out, even when both services are healthy. Hence timeouts and circuit breakers |
| Latency is zero | A local call takes nanoseconds or microseconds. A remote call takes milliseconds |
| Bandwidth is infinite | Between services, big messages use real bandwidth. The book's example: a 500 KB reply fetched 2,000 times a second is about 1 Gb per second, while sending only the 200 bytes needed is far smaller |
A worked example (made up). A page needs data from 5 components. In a monolith each is a function call at 0.002 ms, so 0.01 ms in total. In a distributed system, each is a remote call of 3 ms, so 15 ms in total, and each can fail on its own. The same feature is 1,500 times slower in call time and has five more ways to fail.
Common mistake
Assuming a remote call behaves like a local one. It can be slow, fail halfway, or arrive twice (Level 6, page 2).
Check yourself:
- How does FSA tell a monolithic style from a distributed one?
- Why does a feature get more ways to fail when its parts are on different machines?