CSE Roadmap

Common tier · about 4 hours · 8 parts

Part 7 of 8 · 3 min read

Two warnings

Premature decomposition and the technical seam.

Two stories of going wrong

BM tells two stories from real projects.

Premature decomposition. BM's own company built SnapCI, a hosted tool for continuous integration and delivery (CI/CD, which builds and ships code automatically). The team had built a similar tool before. That experience made them confident, so they drew service boundaries early. After a few months it was clear that the new product's use cases differed in subtle ways, and the boundaries were wrong. Many changes had to be made across several services, and the cost of change was high. The team merged the services back into one monolith, gave themselves time to learn the domain, and a year later split it again. The second set of boundaries was much more stable. BM's remark is that splitting an existing codebase is easier than starting with microservices.

Premature decomposition

Premature decomposition means splitting a system into services before the boundaries are understood.

Example: a team picks ten services on week one, and by month three every feature needs changes in six of them.

The technical boundary. BM worked with a client whose public application had grown. A new group of developers in Brazil took on part of the work, and the system was split by team: a stateless front half for the website, and a back half that was little more than a remote procedure call (RPC) interface over a data store. In effect, the repository layer had become a separate service. Changes often needed both halves. The calls were low-level and fragile, and the interface was so chatty that the team built elaborate batching to fix the speed. BM called it an onion architecture: many layers, and it brought tears when the team had to cut through them.

The lesson is that a split along a technical layer is a horizontal slice, while a good split is a vertical slice, with a bit of everything for one business area. BM adds that a technical split is not always wrong, for instance when a performance goal needs it, but it should be a second reason and not the first.

Common mistake

Splitting by layer, such as a "data service" and a "web service". Almost every change then has to touch both, and the network sits in the middle of every request.

Interview angle

Answer in your head first, then open it.

How do you decide service boundaries?

Start with the business: find the bounded contexts, name services by capability, then check each against the architecture characteristics.

Why not one service per table?

It gives thin services that need many calls and transactions to do one thing.

When should a team avoid splitting?

When the domain is new to them. Start with modules in one codebase, learn where change actually happens, then split.

What is the sign of a wrong boundary?

One business change forces edits in many services, or two services talk on almost every request.

Check yourself: 1. What did the SnapCI team do after finding the boundaries were wrong? 2. Why is a layer split a horizontal slice? 3. Give one sign that a boundary is wrong.

Words you will meet

Word Meaning
Domain-driven design (DDD) A way to design software around the business domain
Bounded context A part of the business with one responsibility and an explicit interface
Shared model What a context publishes to others
Hidden model What a context keeps to itself
Business capability Something a part of the business does for the rest
Anemic service A service that only creates, reads, updates and deletes rows
Entity trap One component per database entity
Component A building block with a clear job inside a system
Event storming Finding components by listing the events in the system
Premature decomposition Splitting before the boundaries are understood
Onion architecture BM's name for many layers split across services