Book Deep Read · Fundamentals of Software Architecture · Chapter 17

Microservices Architecture: Prefer Duplication to Coupling

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

中文 →

What is this chapter about?

When you open a shopping app, place an order, pay, and track the parcel, there are probably dozens or hundreds of small, separate programs passing the job along behind the scenes. That approach is called "microservices." It has been the hottest architecture word of the past decade, and also the most misused. This chapter explains what it really is, how finely to cut it, and the few things that make it hard.

An analogy: a street of small shops, not one department store

An old-style system is like a department store: every counter shares one warehouse and one ledger, and rearranging one counter means closing the whole building for stocktaking. Microservices are like a street of independent shops: the bakery, the pharmacy and the bookshop each have their own storeroom and their own books, and when one renovates, the neighbors stay open.

Why the previous generation got stuck

The previous chapter showed an older approach that wanted "one set of parts for the whole company," and every part ended up tied to every department. Microservices flip the idea: rather than share, keep your own copy. Two shops both need customer addresses? Each keeps its own, even if that means repeating work.

How it pulls this off

Each shop handles exactly one line of business, from counter to storeroom, and nobody else is allowed into its storeroom to read its books; you ask at the door. Chores every shop needs, like security guards and bookkeepers, come from one shared property-management company that stations staff in each shop, so the house rules are the same everywhere while the business stays separate.

The hardest part is a job that needs several shops at once, like "place an order," which must take stock, collect money and arrange delivery. In the department store, one ledger entry does it. On the street, you visit shops one by one, and if one fails midway, you have to go back to each earlier shop and undo what it did.

What you get, and how to choose

The win is speed of change and resilience: one shop has trouble, the rest of the street stays open; whichever shop gets busy can hire on its own. The cost is just as real: running errands between shops is far slower than shouting across one building, and managing a whole street is much more work than managing one store.

One line to remember

Microservices = a street of independent shops: each does one thing, owns its storeroom, and never reads another's books; you trade duplication for independence, and pay in slower errands and harder management.

Want to see what a "bounded context" really is, the three tests for how fine to cut services, why the book says "don't do transactions in microservices," choreography versus orchestration, and the star ratings? → Switch to Deep