The interview problem

Practice prompt

Score 100 million product records every night within four hours. Inputs vary in size, some records are invalid and workers may be interrupted. Publish a complete, reproducible result dataset that downstream systems can consume without combining partial attempts. Explain capacity planning, retries and deadline recovery.

Original ML system-design practice, not a reported interview. Scale and costs are hypothetical. Primary technical reference retrieved September 27, 2026.

1. Define completion before scheduling work

Freeze an input manifest with object versions, record identities, schema and expected counts. Pin the model artifact, preprocessing code, feature snapshot and inference configuration. A job is a computation over that immutable specification, not a query against whatever data happens to be newest when a worker starts.

Every input needs an explicit disposition: prediction, documented permanent rejection or unresolved failure. Agree whether the customer accepts a dataset containing a bounded number of permanent rejections. A job with missing outputs is not complete merely because all currently running workers have exited.

Define the four-hour deadline from accepted, validated input to published output. Reserve time for loading models, validating results and publication. If upstream input arrives late, do not quietly redefine the deadline after the fact.

2. Separate the job controller from inference workers

The control plane validates a manifest, creates deterministic partition identities and tracks attempts in a durable state store. A scheduler issues partition leases to workers. Workers load the pinned bundle, read their assigned immutable input and write results to attempt-specific object paths.

A worker reports an output manifest containing input partition identity, attempt generation, model version, output checksums, record counts and rejection counts. The controller validates it and conditionally selects one winning attempt. A worker whose lease expired cannot overwrite a newer accepted result.

The data plane can execute a partition more than once. Logical publication selects one accepted output per partition; this is not a promise of exactly-once physical computation. Orphaned attempt objects are removed later after checking that no published or active manifest references them.

3. Partition for both parallelism and recovery

Do not put the entire dataset in one indivisible input file and assume more workers will help. Some managed systems assign work at object boundaries. Make enough independently schedulable partitions to occupy the fleet and absorb skew, while avoiding millions of tiny objects.

Partition by estimated work, not only by row count. A long product description may cost far more than a short one. Use historical token lengths, image dimensions or measured runtime to create balanced groups. Keep an oversized-record lane with separate limits so a few pathological inputs do not stall otherwise healthy partitions.

Inside a partition, group compatible records into inference microbatches under memory and token budgets. Preserve stable record IDs through sorting and bucketing. Joining outputs to inputs by incidental completion order is fragile when retries or variable-length processing reorder results.

4. Work backward from the deadline

Suppose representative benchmarks show 2,000 records/s per worker while actually processing, and a planning factor of 70% accounts for expected loading, I/O and ordinary inefficiency. Reserve 30 minutes of the four-hour deadline for validation and finalization, leaving 12,600 seconds.

Planned capacity per worker is 2,000 × 0.70 × 12,600 = 17.64 million records. The arithmetic minimum is ceil(100 million / 17.64 million) = six workers. Six provide 105.84 million records of planned capacity, only 5.84% above demand. That is little protection against correlated interruption or a badly underestimated long-record tail.

Eight workers give 141.12 million records of planned capacity. Under the same assumptions, processing time is 100 million / (8 × 1,400) ≈ 8,929 seconds, or 2.48 hours, plus finalization. These are planning estimates, not probabilistic deadline guarantees. Benchmark the real input mix and stress the slowest partitions.

5. Retry failures at a useful boundary

Use bounded retries with backoff for transient reads, worker interruptions and temporary inference-service errors. Do not retry malformed input indefinitely. Emit a typed permanent-rejection record with enough safe metadata for correction, and keep its denominator visible in reporting.

Suppose partitions contain one million records. At 2,000 records/s of active processing, one partition takes 500 seconds, about 8.33 minutes. A failed attempt can waste nearly that much completed work. Partitions of 100,000 records reduce this active-compute retry window to 50 seconds but increase scheduling and object overhead tenfold.

Choose partition size from measured overhead, interruption rate and skew. If checkpointing inside partitions is justified, checkpoint stable record ranges and accepted result fragments; resume only against the same input and model specification. Changing the model halfway through a resumed job creates a mixed-version dataset unless the product explicitly requests that behavior.

6. Publish through one complete manifest

Before publication, verify that every expected partition has exactly one selected output, that IDs cover the intended inputs and that all outputs use the pinned model and schema. Counts alone cannot prove coverage: one missing record and one duplicate preserve the total. Use partition-level identity/range checks or a suitable exact reconciliation mechanism.

Write an immutable job result manifest listing the chosen objects and their checksums. Then atomically advance the dataset's current-version pointer using a conditional operation that enforces the intended ordering of jobs. A late older job must not replace a newer published snapshot.

Consumers read one manifest version and only the objects referenced by it. They must not glob an output prefix while attempts are still being written. Failed validation leaves the previous published version available and the new job visibly incomplete. Keep publication metadata and input lineage so a later investigation can reproduce the decision.

7. Respond to deadline risk before it is too late

Estimate remaining work from unfinished partitions and their size classes, not merely the percentage of partitions marked done. A last large partition can dominate completion time. Alert when estimated remaining duration plus finalization reserve exceeds time left.

Scale workers only if parallel work and downstream I/O capacity remain available. Speculative execution of an unusually slow partition may help, but duplicate attempts still need one-winner publication and can worsen a shared bottleneck. Separate queue delay, model loading, data access and active compute in diagnostics.

Agree fallback behavior in advance: keep yesterday's version, publish a clearly labeled partial dataset only under an explicit contract, or miss the deadline while preserving completeness. Never silently relabel partial output as complete. Expose stale-data age to downstream owners.

8. Evaluate quality and cost together

With a hypothetical worker cost of $3/hour, eight workers running for 2.48 hours cost about $59.52 in worker time. The 2.48-hour estimate already includes the planning allowance for loading and ordinary inefficiency. This price excludes any additional provisioning delay, finalization compute, storage, transfer, retry overruns and minimum billing granularity. It is not a current cloud price quote. Compare total cost per accepted prediction and deadline attainment across actual runs.

Validate prediction distributions, rejection rates and a labeled quality sample alongside mechanical completeness. A complete dataset produced with a broken tokenizer is still wrong. Test interruption after output upload but before status update, duplicate attempts, input mutation, corruption and an older job finishing after a newer one.

Foundation: derive the six-worker lower planning bound. Senior: explain one-winner publication under retries. Staff: balance deadline risk, skew and cost without hiding partial completion.

Score 0–2 each for immutable inputs, partitioning, capacity assumptions, publication correctness and deadline policy.

Sources and next steps

The controller, publication protocol, workload calculations and failure examples are original. They are a proposed architecture, not claims about every managed batch service's guarantees.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.