Skip to content
Ameen Abozaid
SRB-001

Distributed architecture patterns

  • 8 Lessons
  • 4.5 h practice (estimate)
On this page 9 topics

Overview

Topics

  • CQRS
  • event sourcing
  • sagas
  • orchestration
  • materialized views

Learn first

4.5 h of practice (estimate)

Learning outcomes

  1. Apply full CQRS with separate write and read models, and say when CQRS-lite is enough.
  2. Explain event sourcing (event store, projections, snapshots, upcasting) and its operational costs.
  3. Build materialized views across service boundaries and manage their staleness.
  4. Choose between orchestration engines (e.g., Temporal, Camunda) and hand-built sagas.

Lessons

  1. 01Patterns as trade-offs, not upgrades
  2. 02CQRS in full
  3. 03Event sourcing
  4. 04Projections, snapshots, and upcasting
  5. 05Materialized views across services
  6. 06Workflow engines vs hand-built sagas
  7. 07Demo: modeling shipment tracking with and without event sourcing
  8. 08Demo: rebuilding a broken projection from the event store

Lab and exercises

Lab

SRB-001-LAB1 · Shipment tracking design

Outcomes: 1, 2, 3, 4 · Time: ~4.5 h

  1. List FulfillCo's shipment tracking requirements (status, history, corrections, partner feed, audit).
  2. Design option A: event-sourced; option B: state plus outbox.
  3. Estimate replay time, schema evolution effort, and storage for each at expected volume.
  4. Write an ADR with the decision, rejected option, and revisit triggers.

Acceptance: operational costs (replay time, schema evolution, storage) estimated for both options; ADR records the decision.

Exercises

IDOutcomeTask
SRB-001-EX011Your read screens need a different shape but load is light. Choose CQRS-lite or full CQRS and justify.
SRB-001-EX022List three costs of event sourcing for shipment tracking that a state table would not have.
SRB-001-EX032A v1 event lacks a field the new projection needs. Describe the upcasting approach.
SRB-001-EX043Shop shows carrier status from FulfillCo. Define acceptable staleness and the reconciliation job.
SRB-001-EX054Three workflows exist, each two steps with no timers. Engine or hand-built saga? Argue.
SRB-001-EX061Review a proposal to event-source the product catalog. Write a five-line critique.
Show solutions
  • EX01 CQRS-lite: SQL views or separate read classes on the same database; full CQRS adds a second store and lag for no needed gain.
  • EX02 Replay time for rebuilds, permanent event schema and upcasting work, harder ad hoc queries and deletion of personal data.
  • EX03 Add an upcaster mapping v1 to v2 with a default or derived value on read; do not rewrite history unless unavoidable.
  • EX04 e.g. status within 30 s of the event, timestamp shown; a nightly job compares counts per status and repairs gaps by re-consuming.
  • EX05 Hand-built with an outbox and state table: small, short, no timers; revisit if workflows grow.
  • EX06 Catalog history is rarely business-critical, reads dominate, edits are simple; an audit history table suffices; propose a spike measuring need first.

Workplace evidence: a design where you chose a simpler pattern over a fashionable one and could show why.

Quiz

Outcomes: O1 CQRS · O2 event sourcing · O3 materialized views · O4 orchestration choice.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1What defines CQRS-lite?O1
  2. 2Which is the strongest reason for full CQRS?O1
  3. 3In event sourcing, current state is obtained by:O2
  4. 4A snapshot is used to:O2
  5. 5Upcasting means:O2
  6. 6A cross-service materialized view is best described as:O3
  7. 7Staleness of a view should be:O3
  8. 8A hand-built saga is usually enough when:O4
  9. 9A projection nobody can rebuild is a problem because:O2
  10. 10Adopting a workflow engine for a single saga is typically:O4

Practical part

Pattern-selection defense: present the ADR from SRB-001-LAB1 and defend it against challenges. Pass: 70% on the quiz and an ADR with costs estimated for both options.

Common mistakes

Event sourcing everything; projections nobody can rebuild; workflow engines adopted for one saga.

Assessment

Pattern-selection defense.

Workplace evidence

A design where you chose a simpler pattern over a fashionable one and could show why.

Career relevance

Architecture at scale (SRA-001).

Type to search levels, phases, modules and lessons.