Course contents 32 / 35

32 / 35 · The Data System

Architecture and cost

Choose a design for a ten-minute freshness objective and account for compute, data movement and replay.

The shop wants a dashboard that usually stays within ten minutes of sales, with a daily total that can be corrected after a late arrival. Its current hourly job finishes in two minutes. Faster execution alone cannot make an event that arrived just after the job started appear within ten minutes. It first has to wait for the next job.

Write down the result and its deadline#

Measure freshness at the dashboard, from source readiness to visibility. A separate completeness measure states which store inputs have been accounted for. Recent results can be provisional. The daily report can be finalized under an explicit cutoff, then corrected by a versioned backfill. This separates an early answer from the later handling of out-of-order input. The Dataflow model describes this tension among correctness, latency and cost. Akidau et al., 2015

Compare three designs on a toy workload. Assume data are ready on arrival, there is no queue in the normal case, and publication time is included in the execution time. An hourly batch can wait almost 60 minutes and then run for two. A five-minute incremental batch waits at most five and runs for two. A continuously running job has a modeled processing and publication budget of three minutes. These numbers are design assumptions, so they do not establish a latency percentile.

DesignNormal-case bound in the modelFreshness objective
Hourly batch62 minutesMisses 10 minutes
Five-minute incremental batch7 minutesFits
Continuous processing3 minutesFits
Figure

Freshness includes waiting for work to start

Freshness includes waiting for work to startHourly batches take up to 62 minutes. Five-minute batches take up to seven. Continuous processing has a three-minute budget in this model.Hourly batch60 min wait + 2 min workFive-minute batch5 min wait + 2 min workContinuous processing3 min processing budget
At the same two-minute execution time, the scheduled interval changes the delay seen at the dashboard.

Pay for the work you actually do#

At five-minute intervals there are 24⋅60/5=28824 \cdot 60 / 5 = 288 runs a day. If a run uses four vCPUs for two minutes, the modeled daily compute is

288⋅4⋅2/60=38.4 vCPU hours.288 \cdot 4 \cdot 2 / 60 = 38.4\ \mathrm{vCPU\ hours}.

A continuously allocated two-vCPU job uses 24⋅2=4824 \cdot 2 = 48 vCPU hours a day. The first design does less modeled CPU time. It could still cost more if it repeatedly reads large files, keeps cluster capacity allocated between runs or writes many small outputs that need compaction. The continuous job pays for state, checkpoint traffic and idle capacity. Spark Structured Streaming is one example of a system that can run a streaming query as a series of micro-batches. Apache Spark, Structured Streaming

Keep storage, transferred bytes, compute time and operational effort as separate terms. An input retention window also buys recovery options. If the log retains a day, a three-day replay needs another source. If recoverable input is available, the repair still needs spare throughput beyond the current arrival rate.

Check the assumptions under load#

The seven-minute bound assumes every batch finishes before the next interval. If batches that arrive every five minutes take six minutes each on the same worker, backlog grows by one minute per interval until conditions change. Under parallel execution a slow partition can hold up publication even if the average task is fast. Systems at scale have to measure the tail and its effect on the complete response. Dean and Barroso, 2013

For this modeled shop, five-minute incremental batches meet the objective without continuously allocated compute. Verify the actual publication delay, data coverage and time to replay a missed interval before committing to that design. A tighter objective, unpredictable input or a long recovery can change the choice.

Next#

The core route ends with a design tied to a result, its freshness and its recovery. Data Vault begins the optional branches with a different question. How can an integration layer retain the identities and histories reported by several source systems?

References#

  1. Tyler Akidau et al. The Dataflow Model. A Practical Approach to Balancing Correctness, Latency, and Cost in Massive-Scale, Unbounded, Out-of-Order Data Processing. PVLDB, 8(12), 2015. Explains the trade-off between early results, completeness and cost.
  2. Apache Spark. Structured Streaming Programming Guide. Describes the micro-batch execution model.
  3. Jeffrey Dean and Luiz André Barroso. The Tail at Scale. Communications of the ACM, 56(2), 74–80, 2013. Explains how component latency tails affect a service’s response.