Distributed Patterns
Once a system is split into services that each own their data, three things that a single database gave for free have to be built again: changing several things together, announcing a change without losing it, and handling a message that arrives twice. A fourth problem comes from the other end: how to get from the old, single system to the split one without stopping. This module teaches one pattern for each. Each one exists because of a specific failure, and you will watch that failure happen.
You will step through an order saga that fails at its last step and see the compensations, a retried refund and an orchestrator that crashes; compare orchestration and choreography on the same failure; crash the relay of an outbox before and after it publishes; redeliver a message to a consumer with and without an inbox; and move paths from a legacy system to a new service behind a facade. You will also read three C# examples, sort twelve problems under the pattern that fixes them, answer a quiz, and practise two interview questions.
The lessons
Section titled “The lessons”- Sagas: a business transaction across services (24 min). Why no transaction spans services that own their databases, local transactions with compensations, orchestration against choreography, and what a saga does not isolate.
- The transactional outbox: a write and a message as one step (22 min). The dual-write problem, the outbox table and its relay, and what a crash between publishing and marking does.
- The inbox: idempotent consumers and exactly-once effects (22 min). What exactly-once can and cannot mean, a message id stored in the same transaction as its effect, how long to keep ids, and ordering.
- The strangler fig: replacing a system one path at a time (20 min). A routing facade, moving one path at a time, branch by abstraction, the data both systems share, and when not to.
- Recap and quiz (14 min). The module in one page, how the patterns fit together in a checkout, a checklist, a sorting exercise, a quiz and two interview questions.
What you will be able to do
Section titled “What you will be able to do”- Explain why a transaction cannot span services, and design a saga with a compensation for each step, idempotent and retried.
- Choose between orchestration and choreography for a flow, and say what each costs.
- Write an event and its data in one transaction with an outbox, and explain why it still delivers at least once.
- Make a consumer safe against repeats with an inbox, and state accurately what exactly-once means.
- Plan a migration behind a routing facade, with a way back for each step.
The circuit breaker and the bulkhead are in the reliability module, and CQRS and event sourcing in the architecture patterns module; neither is taught again here. All the numbers in the flows are model output, for comparing choices, not for forecasting any real system.
Built by GhaziAlibi.
© ShardCraft. All rights reserved.