Highlights

Contents

Part IX
09

Case study: score to report

We reconcile capture, computation, storage, and publication into one design. A pipeline is complete only when changes and failures have a trace. We will count Heron’s input, follow a corrected total, rebuild history, and defend the final architecture.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1OLTP vs OLAP2Batch processing3Stream processing4Event time, windows,watermarks5ETL, ELT, warehouses, andlakes6CDC and materializedviews7Checkpoints andexactly-once8Spark and Flink9Case study: score toreport

#Section 33Follow one accepted record

The score service accepts event c with red contribution 4 at event time 2. Its source transaction commits, and CDC or a durable publication path makes the change available with identity and source position. Validation checks its schema. The processor routes red to its state owner and assigns the event-time window [0,5).

That window’s red sum changes from 2 to 6. The pipeline publishes a versioned view update under the sink’s recovery contract. Later red contribution 1 belongs to [5,10), making that window’s red total 1 while the running red sum becomes 7. The time-window view and running view are different queries over the same source.

COMMIT c (RED +4, TIME 2) FLOWS INTO WINDOW [0,5), WHERE RED GOES FROM 2 TO 6COMMIT c (RED +4, TIME 2) FLOWS INTO WINDOW [0,5), WHERE RED GOES FROM 2 TO 6commit cred +4, t = 2captureposition 843window [0,5)red 2 → 6publishred = 6, v2cthe running total (7) and the window total (6) are separate outputs
Figure 17.33Computed illustrative event c trace. The running red total and five-second window totals are separate outputs.

A viewer reading the analytical table sees its result version and freshness boundary. If event c arrives late under the window policy, the output may be corrected or routed to repair. If it repeats after failure, identity and the compatible checkpoint/sink protocol prevent a second contribution. The architecture now explains the failure as well as the arrow.

#Section 34Count input, storage, and state

Twenty events per second produce 1,728,000 daily records. At two hundred payload bytes each, that is 345,600,000 bytes per day. Thirty days retains 10,368,000,000 payload bytes. Three total copies produce 31,104,000,000 payload bytes before formats, indexes, snapshots, and output tables.

A one-day deduplication registry holding thirty-two raw identity bytes per event would contain 55,296,000 bytes before lookup and runtime overhead. That is a distinct state workload, not part of the event payload calculation. Decide whether exact identity retention is required for that horizon or whether a versioned keyed effect supplies a smaller correctness boundary.

1,728,000 EVENTS/DAY: 10.368 GB OVER 30 DAYS, 31.104 GB AS 3 COPIES1,728,000 EVENTS/DAY: 10.368 GB OVER 30 DAYS, 31.104 GB AS 3 COPIESdaily input1,728,000 events345,600,000 B30 dayslogical payload10,368,000,000 Bthree copiesphysical payload31,104,000,000 Bone-day ids32 B each55,296,000 Bthe dedupe registry is operator state, a separate workload
Figure 17.34Computed illustrative counts. Format, metadata, runtime overhead, checkpoint copies, and other outputs are separate.

The history can contain corrections and schema versions, so payload byte counts alone do not define query meaning. A reader needs the row type and transformation contract as well as the storage size. Keeping identity and capture metadata adds physical bytes but supplies the information that deduplication, auditing, and repair use after a failure.

A thousand sixty-four-byte state values hold 64,000 raw bytes, while windows, dedup IDs, and joins may need much more. State sizes follow retained information and horizon. Measure serialized checkpoints and restoration time under actual schemas. Raw arithmetic explains where the budget comes from, but it cannot predict every runtime overhead.

#Section 35Rebuild history without harming the live job

A corrected transform needs seven days of source history. At twenty records per second, that is 12,096,000 records. At an assumed two thousand records per second, the backfill takes 6,048 seconds before contention and publication work. A backfill computes previously available history under a stated transformation and output boundary.

Run it with controlled resource allocation so it does not starve live processing. Write another output generation or identified ranges and reconcile overlap with the ongoing stream. Reusing the live additive sink without distinguishing backfill identity can double historical contributions. Source versions and result generation boundaries must decide which output becomes authoritative.

7 DAYS = 12,096,000 RECORDS ÷ 2,000/S = 6,048 S OF REPROCESSING7 DAYS = 12,096,000 RECORDS ÷ 2,000/S = 6,048 S OF REPROCESSING7 days of history2,000/sgen 13write a new generation, isolate its resources from live processing,then switch readers once it reconciles
Figure 17.35Computed illustrative backfill duration. Live input continues and competes for resources unless isolated.

Reconciliation checks row counts, key totals, selected records, source progress, and the intended correction behavior. Counts alone cannot prove semantic correctness because a duplicated contribution and a missing one can cancel. Use small known traces and representative source samples, including deletes, late data, and repeated events.

#Section 36Defend the complete pipeline

The transactional source owns accepted changes. CDC or durable publication captures them at a named position. Controlled raw storage retains repairable inputs under privacy limits. A chosen batch or stream processor validates, groups, joins, and aggregates. A warehouse or controlled lake table publishes query-oriented results under a generation or version boundary.

The design states source snapshot handoff, schema evolution, lateness, deletes, duplicate effects, checkpoint restoration, sink compatibility, retained logs, backfill admission, and result freshness. It has a bounded repair path for bad records rather than an infinite retry loop. Each component’s purpose is connected to a query or failure requirement.

FOUR FAILURES, HOW THE PIPELINE NOTICES, AND WHAT IT DOESFOUR FAILURES, HOW THE PIPELINE NOTICES, AND WHAT IT DOESduplicateidentity / versionretry-safe effectlate eventwatermark policyupdate or repairschema errorvalidationquarantine + fixsource gapcapture positionsnapshot + replaya dropped record needs a recorded reason
Figure 17.36Illustrative failure contract. Every branch preserves progress information and an explicit disposition.