Part 4 of 8 · 2 min read
Orchestration or choreography
Who runs a process that spans services.
Page 5 introduced these two words. BM's example is creating a customer at MusicCorp. Three things must happen: a record in the loyalty points bank, a welcome pack sent by post, and a welcome email.
Orchestration and choreography
Orchestration means one central service drives the process, like a conductor. Choreography means each service knows its own part and reacts to the others, like dancers.
Example: orchestration: the customer service calls loyalty, post and email in turn. Choreography: the customer service announces "customer created" and the three react.
Orchestration is easy to see. The flowchart on the whiteboard is almost the code. The customer service can track which step the customer has reached, and with request and response it knows at once whether each stage worked. BM names the cost: the central service can grow into a governing authority. He has seen a few smart "god" services telling thin create-read-update-delete services what to do.
Choreography is more decoupled. The customer service announces one event, and any new service just subscribes. The cost: the process is now only implied. Nobody can look at one place to see it. If the loyalty bank had a bug and made the wrong account, who would notice? BM's remedy is monitoring that has the flowchart as a lens: it tracks what each service does by itself and shows odd cases against the expected process.
BM's view is that more choreographed systems are more loosely coupled and easier to change, and he found heavily orchestrated ones brittle and costly to change. He prefers choreography, as long as the extra monitoring is done. FSA reaches a more balanced position: choreography preserves the style's decoupling, while orchestration is the better tool for a complex flow with error handling (page 5, section 4). These are not opposites; mixing is allowed.
A worked example (made up). A sign-up creates an account (needed at once), then sends a welcome email, adds loyalty points and notifies a sales tool (none needed at once). Create the account with a direct call. Announce "customer created" for the other three. The first part wants an answer, and the second part wants low coupling.
Read it as
Use a conductor when the steps depend on each other, need an answer, or need undo. Use dancers when the steps are independent reactions to one fact.
Check yourself: 1. What is the main danger of orchestration in BM's account? 2. What is the main danger of choreography, and what does BM suggest? 3. In the sign-up example, why is the account created by a direct call?