Book Deep Read · Fundamentals of Software Architecture · Chapter 13

Service-Based Architecture: A Few Coarse-Grained Services and a Shared Database, the Pragmatic Middle Ground

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

中文 →

What is this chapter about?

Picture a mid-sized company: orders, inventory, shipping and accounting all live in one piece of software. It keeps growing, and now changing one line of accounting code means stopping the whole system and releasing it again. Everyone has heard that "microservices" are the fashion: split it into hundreds of little programs. But the team is twenty or thirty people, and they could never keep hundreds of programs running. This chapter is about the road in between: split it into just a few big pieces. The book calls it service-based architecture.

An analogy: turning one big restaurant kitchen into a few stations

Before, one big kitchen cooked everything, and if one stove broke the whole restaurant stopped. Now there are four or five stations: cold dishes, hot dishes, noodles, desserts. Each has its own cooks and opens and closes on its own; if the noodle station is being renovated, hot dishes still go out. But they all still share one big walk-in fridge. The ingredients sit in one place, so no station needs its own fridge or someone running back and forth moving food around.

Why the old world was hard

With one big kitchen, every change touched everything. But go to the other extreme, one tiny kitchen and one fridge per dish, and just keeping track of "who has this piece of meat right now" wears everyone out. A customer orders a full table, a dozen kitchens have to check with each other, one of them slips, and the bill no longer adds up.

The core mechanism: big stations and a shared store room

It comes down to three things. A few big stations: split by line of business, usually four to a dozen, each able to open and be upgraded on its own. One front counter: customers only talk to the counter, which passes each order to the right station. One shared fridge: every station takes from the same place, so a single order can be handled start to finish inside one station. Either all of it happens or all of it is undone, never the half-done "money taken, food never served".

The fridge gets divided too: the shelves everyone uses are off-limits for casual changes, and each station looks after its own shelves.

What it buys you / how to choose

You get most of what microservices promise (change one piece, release one piece; one piece breaks, the rest carry on) while dodging the most expensive part. Plenty of companies stop here and are happy. The price: because each station is big, changing one thing means checking the whole station, and rearranging the shared fridge forces several stations to adjust.

One line to remember

Service-based architecture = a few big services cut by business area + one shared database: you get independent releases and failure isolation, and keep "one job, done in one go" simple.

Want the topology and its variants, how each service is layered inside, federated entity libraries for the shared database, the book's full electronics-recycling example, and the star ratings against microservices? → Switch to Deep