Chapter 45 · Reading
Defend the complete design
Compose patterns, budgets and evidence into a production decision.
Prerequisites All pattern, time, recovery, performance and production chapters. Find chapters in the course contents.
Produce a reviewable streaming design with explicit pattern choices, correctness boundaries, resource budgets and a validation plan.
The situation
The shop now wants a live sales view, an audited history, corrected late orders and safe customer notifications. Each individual operator works on a fixture. The final task is to compose them without inventing a guarantee at the joins between systems.
Choose patterns from required answers
Start with observable business questions and their freshness/completeness needs. Select transformation, routing, expansion, aggregation, enrichment, join, projection and sequence patterns to answer them. Name each key, identity, timestamp and state-retention rule. Separate provisional results from corrected or audited ones so consumers know which contract they receive.
For the shop, an identified source event can feed validation/quarantine, a keyed/windowed sales projection and an independent audit reader. A late sale rejected from a finalized dashboard window still needs an audited correction/reconciliation path if finance requires it eventually. A policy-correct total of 15 does not mean every real sale was included.
Budget the composition rather than isolated operators
Record offered/admitted/completed/rejected work, bytes per event, fan-out, distinct keys, open windows, join multiplicity and retained history. Add retries and backfill traffic to the offered load. A compact aggregate can coexist with a huge quarantine or retained source; moving the backlog does not eliminate it.
Allocate recovery headroom and retention so an outage can actually be caught up. Name which budgets are measured natively, modeled arithmetically or still need deployment evidence. A local filter rate cannot justify a whole topology’s capacity, and a median latency among completed results can omit queued or dropped work.
Worked case
This worked case uses an example written for the course.
| Pattern choice | Use when | Ask before production |
|---|---|---|
| Map/filter/branch/flat-map | Independent transformation, routing, fan-out | Payload/output bounds and error accounting |
| Keyed state/window/sequence | History affects the answer | Key, clock, expiry, replay and match/reset rules |
| Join/materialized view | Related or changing facts must be combined | Multiplicity, version authority, deletes and history |
| Outbox/inbox/idempotent effect | Independent systems can fail between acknowledgements | Exact transaction/effect scope and unknown outcomes |
| Bounded backfill + versioned view | History must be rebuilt or reinterpreted | Source cut, retention, validation and fenced cutover |
Draw the consistency boundaries
Identify the source-transaction/publication boundary, processor source/state checkpoint, sink commit, idempotency store and external request outcome. An outbox, inbox, checkpoint and service idempotency key can complement each other, but each closes a particular gap. Write the failure case that remains after adding each mechanism.
For releases and repairs, preserve a source/transform/schema manifest and isolate rebuilt views. Rehearse restore, retention gaps and cutover fencing. A shared namespace with uncontrolled old/new writers can corrupt a perfectly computed backfill. Decide who owns quarantine repair, unknown remote outcomes and business reconciliation.
Make the design reviewable
Submit a topology, event contract, ownership map, state/clock/expiry table, replay manifest, failure matrix, resource budgets and observability plan. Include expected outputs for representative normal and boundary fixtures. Distinguish executed evidence from assumptions, model calculations and experiments still required on the real deployment.
A strong review is candid about limits. State the simulator’s role and choose real-broker/state/sink tests for the guarantees it cannot establish. Specify an owner and runbook for rollback, pause, repair and rebuild. In the final incident exercise, use the output and trace to support each claim in your explanation.
Think it through
Propose a production repair if the capstone’s late event c must eventually affect both finance and the dashboard. Identify three failure cuts, one retention bound and the next three real-deployment tests.
Show hints
Hint 1
Decide whether the dashboard revises old windows or consumes a separate correction stream.
Hint 2
Audit history and current query views need not have the same retention or output shape.
Hint 3
Choose tests that observe source, state and actual external effects at their claimed boundaries.
Show explanation
Define a retained identified history and an audited late-correction path, then choose revised/upserted dashboard windows or a versioned rebuild. Preserve event/revision identity and align state/tombstone/source retention with replay requirements. Test a source commit/publication failure, a task/source-state recovery boundary and an external effect/progress failure on the actual topology. Validate backfill/cutover fencing, missing/duplicate identities and reconciliation, rather than assuming the browser capstone established these guarantees.
How frameworks implement this
Use the course’s Bytewax execution and simulator evidence for the mechanisms actually observed. Apply Kafka, Flink, Spark, database and sink documentation to the chosen deployment/version. This is a production design exercise with explicit acceptance evidence, not a shipped distributed topology.
ReferencesPrimary sources for this chapter’s design case
Use these guides to check the framework or protocol contract discussed in this chapter. Moving “stable” or “current” guides can describe a different release; check the version used by your deployment. These readings do not execute the distributed frameworks they compare.
Kafka semantics
Flink checkpointing
Google SRE monitoring