End-to-End ML System Design Questions
Designing a complete machine learning system from problem to production. Covers the components and architecture of a production ML system, data flow from ingestion to serving, scalability, and integration of models into a larger product. Emphasizes the whole-system design tradeoffs that appear in ML system-design interviews.
During a long distributed training run, one worker intermittently falls behind and the whole job slows down. The model, code, and data have not changed. What would you inspect first, and what mitigation would you try to keep the run moving?
Sample Answer
What I would inspect first
I would start with per-step timing on the slow worker versus the rest of the cluster. If the code, model, and data are unchanged, a single lagging worker is usually a host or systems issue, not an ML issue.
Checks in order
- GPU utilization and memory bandwidth on the slow node
- Data loader wait time and local disk throughput
- CPU steal, thermal throttling, and noisy neighbors
- Network errors, packet drops, and collective communication logs
- Kernel and container logs for retries or hardware faults
Mitigation
If the worker is clearly abnormal, I would cordon it, move the job to a fresh node, and keep the training moving. If the slowdown comes from input starvation, I would reduce preprocessing on that host, increase local caching, or lower dataloader contention.
Worked example
If most workers take 180 ms per step but one takes 420 ms and spends 250 ms waiting on input, the bottleneck is the input path, not the model.
The goal is to isolate the bad actor quickly and avoid letting one slow node stall the whole synchronous job.
During a distributed training run, GPU utilization sits at 20% while CPU utilization is pinned at 80% and the data-loading queue is empty. What's your first hypothesis, and how would you confirm it?
Sample Answer
Direct answer
The first hypothesis is that the input pipeline, not the model or the GPU, is the bottleneck: the CPU-side work that prepares each batch (decoding, augmentation, tokenization, collation) can't produce batches fast enough to keep the GPU fed, so the GPU sits idle waiting while the CPU is maxed out doing that preparation. This is different from a disk/network stall (which would show LOW CPU, workers blocked on I/O rather than pinned on compute) and different from a distributed-training straggler problem (which shows up as uneven step times across ranks, not a single job's own GPU sitting idle next to a saturated CPU).
Structured elaboration
Reading the three signals together. GPU utilization at 20% says the accelerator is idle most of the time. CPU pinned at 80% says something on the host is doing real, sustained work, not waiting. An empty data-loading queue, combined with those two, is the tell: it means the CPU-side workers are being drained by the training loop as fast as they can fill it, and still can't build up a buffer, they are running at their ceiling and that ceiling is below what the GPU can consume. An empty queue on its own can look "healthy" on a dashboard; it only means starvation once you also see the GPU idle and the producer maxed out.
Why this points at CPU-bound preprocessing specifically, and not I/O. If the stall were disk or network I/O, the CPU would typically be LOW while workers block waiting on reads, not pinned. Pinned CPU is the signature of compute-bound work happening in the data pipeline itself: image decode and resize, text tokenization, feature crossing, or other per-sample transforms that are often single-threaded Python work per worker process.
Why this is not the distributed-straggler pattern. A straggler problem is about variance ACROSS workers/ranks in a multi-node synchronous job, one rank finishing slower than the others repeatedly. It doesn't explain a single node's own accelerator sitting idle while its own CPU is maxed and its own queue is empty; that is a local producer/consumer imbalance, a different layer of the system entirely.
How to confirm it.
- Break down step time with a framework profiler (for example the PyTorch profiler or a TensorFlow Profiler trace) into "waiting for data" versus "on-device compute." A large data-wait fraction confirms the hypothesis directly.
- Run an isolation test: swap the real dataset for a synthetic generator producing randomly-initialized tensors of the same shape, skipping real decode/augment. If GPU utilization jumps toward its ceiling, the pipeline (not the model) was the limiting factor.
- Check worker configuration: number of data-loader worker processes versus available CPU cores, prefetch depth, and whether workers persist across epochs. Too few workers relative to per-sample CPU cost is the most common root cause.
- Identify the specific expensive stage (decode, augment, tokenize) rather than stopping at "the pipeline is slow"; the fix differs by stage.
Worked example
Reason through the throughput math, not a wall-clock measurement. Suppose (illustrative numbers, not measured) the GPU can consume one batch's worth of preprocessed data every 4 ms once it arrives (a throughput ceiling of 250 samples/sec-equivalent), and a single CPU worker needs 8 ms to prepare one sample-equivalent (a throughput of 125 samples/sec). For the queue to stay non-empty, the combined worker throughput must at least match the GPU's consumption rate:
W×8ms1≥4ms1⇒W≥2If the job is configured with a single data-loading worker (W=1), that single misconfiguration fully explains the observed pattern: the one worker is pinned doing 125 samples/sec of work while the GPU, capable of 250 samples/sec, drains the queue as fast as it fills and then idles. Raising the worker count toward the CPU core count (or reducing per-sample CPU cost by moving augmentation onto the GPU, e.g. with a GPU-side data-loading library, or by precomputing static features once instead of per-epoch) is the concrete next step to test.
Trade-offs & pitfalls
Adding data-loader workers has a ceiling: once you've used all available CPU cores, more workers just add contention, not throughput; past that point the fix is reducing per-sample CPU cost, not adding workers. The common wrong turn here is assuming the GPU or model architecture is at fault and reaching for a bigger GPU or mixed-precision training, when the accelerator was never actually the bottleneck. Also worth naming explicitly: multi-node straggler mitigation (re-sharding, speculative workers, elastic training) is real and useful, but it solves a different failure mode than this one, jumping straight to distributed-training fixes here is solving the wrong layer of the stack.
Tell me about a time you had to get a model training or serving system to scale, but the technically best fix was too expensive, too risky, or too slow to ship. How did you align product, infra, and ML stakeholders on the tradeoff, and what was the outcome?
Sample Answer
Situation
At a previous company, our model-serving path was starting to miss peak traffic goals. The technically best fix was a larger architecture change that would have required new infra, more testing, and a long rollout.
Task
I needed to protect the launch window without taking on too much risk, while still giving product and infra a path to a better long-term solution.
Action
- I benchmarked the current system and the proposed redesign with ML, infra, and product partners.
- I framed the tradeoff in business terms: short-term SLO protection versus longer-term efficiency.
- We agreed on a two-step plan. First, ship safer improvements like batching and capacity tuning. Second, schedule the bigger rewrite for a later milestone.
- I kept everyone aligned with a simple scorecard: latency risk, engineering effort, and user impact.
Result
We met the near-term deadline without a risky rewrite, and the team bought time to design the deeper fix properly. The key lesson was that the right answer is often not the best technical answer in isolation, but the best sequence of changes for the business.
Explain why dataset versioning and lineage matter for a production model, and how you'd let someone reconstruct exactly what data a model in production was trained on, six months after the fact.
Sample Answer
Direct answer
Versioning and lineage matter because a production model is a claim about correctness that can only be re-examined, debugged, or audited if you can point to the exact data behind it. Reconstructing that six months later requires an immutable, addressable chain, captured automatically at training time, of the raw data snapshot, the feature-transformation code version, and the exact training configuration, tied together under one identifier in a model registry.
Structured elaboration
Three concrete reasons this matters:
- Debugging: when a production model misbehaves, the fastest diagnostic is comparing current serving data to the exact data it trained on, which only works if that training data is still identifiable.
- Compliance and audit: regulated domains (credit, hiring, healthcare) may require showing exactly what data trained a decision-making model, sometimes long after the fact.
- Safe iteration: retraining or rolling back needs a known-good prior state to diff against or revert to; without lineage, "roll back" means guessing.
What needs to be captured at training time, not reconstructed after the fact:
- A content-addressed or timestamped snapshot of the raw training data, not a live pointer to a table that keeps changing underneath you.
- The exact version of the feature-transformation code (a source-control commit hash or equivalent).
- The training configuration: hyperparameters and random seed.
- The resulting model artifact, all tied together under one version identifier in a model registry entry.
Reconstruction, six months later, concretely: given a model version identifier, the registry entry resolves to the training data snapshot's storage location (which must not have been deleted or overwritten under retention policy) and the code commit. Checking out that commit and rerunning the deterministic feature pipeline against that exact snapshot should regenerate the same training set. If the underlying source data is mutable (a source table updated in place), lineage additionally has to capture when the snapshot was taken relative to that source, since "the table" is not a stable reference on its own, only a point-in-time copy of it is.
Worked example
Suppose a model registry entry for a fraud model records: a data-snapshot path, a code commit hash, a random seed of 42, and a feature-definition version. Reconstructing it six months later, on today's date, looks like this:
- Confirm the snapshot still exists under the retention policy. If retention is set to 400 days and the snapshot is roughly 6 months (about 180 days) old, it is safely inside the window and has not been purged.
- Check out the recorded code commit.
- Re-run the feature pipeline at the recorded feature-definition version against that snapshot with the recorded seed.
- Compare the output's row count and a stored checksum against what the registry recorded at training time.
If the checksum matches, the reconstruction is exact, not merely plausible. If it doesn't match, that mismatch is itself the useful signal: something in the chain (an unpinned dependency, a transformation that wasn't actually deterministic) broke reproducibility, which is precisely the failure this design exists to catch.
Trade-offs & pitfalls
- A common wrong turn is versioning the model artifact but not the data: that lets you reload old weights, but not explain or regenerate why they are what they are.
- Storing a pointer to "the current production table" instead of an immutable snapshot silently breaks reconstruction the moment that table is updated in place; this is the single most common lineage failure in practice.
- Keeping every historical snapshot indefinitely at full resolution has a real, ongoing storage cost; the usual resolution is a retention window sized to the longest realistic audit or debugging need, with older snapshots summarized (schema and statistics) rather than kept byte for byte.
- Lineage that is captured retroactively, guessed from logs after the fact, is much weaker than lineage captured automatically at training time; if capture requires a manual step, it will eventually be skipped under deadline pressure.
What is label and feature skew in a training dataset, and what would you actually do about it before it quietly biases a model?
Sample Answer
Direct answer
Label skew is when the distribution of labels in a training set doesn't match the real population the model will be scored against, for example a fraud model trained on data artificially balanced to 10% positive when real traffic is 0.5% positive. Feature skew is when an input feature's distribution at training time differs from what the model actually receives at serving time, for example a feature computed from batch logs during training but computed live, with a different lookback window, during serving. Both quietly bias a model because it learns decision boundaries calibrated to a distribution it will never actually see in production, and nothing about training loss or offline accuracy flags this on its own.
Structured elaboration
Sources of label skew: sampling procedures that oversample positives for training convenience; selection bias in which examples get a label at all (only labeling transactions a human analyst chose to review, which already correlates with what made them look suspicious); and label lag, where positive labels for recent examples haven't arrived yet, making recent data look artificially clean.
Sources of feature skew: two different code paths computing "the same" feature for training versus serving (this specific case is called training-serving skew); the feature's real-world distribution genuinely shifting over time between when training data was collected and when the model serves; and default or fallback values behaving differently online, where serving substitutes a placeholder for a missing value that training data never actually contained.
What to actually do about it:
- Compare training-set label prevalence against a recent, unbiased sample of the true population prevalence, not just the labeled set itself, and correct for known sampling procedures explicitly (reweight examples inversely to their sampling probability, or recalibrate the model's output probabilities against the true base rate) rather than trusting the training set's balance at face value.
- Compute per-feature distribution statistics on both the training set and a live production sample, using the exact same feature-computation code for both, and diff them on a recurring schedule, so a divergence reflects a real shift rather than a code-path bug.
- Audit where labels come from before trusting them, specifically checking whether the labeling process was itself conditioned on an earlier automated or human decision. This is the surest way label skew hides, since it never shows up as a data-quality problem, only as a silently wrong modeling assumption.
Worked example
Consider a fraud model with a true production positive rate of 0.5%. Suppose the training set keeps all positives and downsamples negatives to reach a 10% positive rate for training convenience. In a random 100,000-transaction sample, the true rate implies about 100,000×0.005=500 positives and 99,500 negatives. To reach a 10% training positive rate while keeping all 500 positives, negatives must be reduced to n such that:
500+n500=0.10⇒500=0.10×(500+n)⇒5000=500+n⇒n=4500
So negatives go from 99,500 down to 4,500, a keep-rate of 4500/99500≈4.52%. If the model's raw output is used directly against a fixed business threshold, its probabilities will be systematically too high, since they're calibrated to a 10% base-rate world, not the true 0.5% one. Since positives were fully retained (keep-rate 1.0) and negatives were kept at rate s≈0.0452, the standard correction for this kind of downsampling rescales the raw score back to the true base rate:
pcorrected=s⋅pmodel+(1−pmodel)s⋅pmodel
If a transaction scores pmodel=0.5 under the training-calibrated model, the corrected probability is:
pcorrected=0.0452×0.5+0.50.0452×0.5=0.52260.0226≈0.0432
So a transaction that looks like a coin flip under the training distribution is really only about 4.3% likely to be fraud in the true population, which is the concrete reason applying a naive 50% cutoff directly to raw model output, without this correction, over-flags a large share of legitimate transactions.
Trade-offs & pitfalls
- Validating against a holdout drawn from the same skewed training process doesn't catch label skew at all; the validation set needs to reflect the true population, or be explicitly reweighted to it, not just be a random split of the same biased sample.
- The correction above assumes negatives were downsampled uniformly at random; if the downsampling was non-random (keeping whichever negatives were easiest to log), the correction's assumption breaks and the fix silently fails.
- Feature skew caused by two independent code paths is not fixed by any statistical correction; it needs a single shared feature-computation path, not a calibration formula.
- Chasing an exact match between training and production prevalence is itself a trap in genuinely rare-event problems: forcing training data down to the true base rate can leave too few positive examples for the model to learn from at all, so downsampling combined with an explicit, documented correction is usually the better choice than pretending the imbalance doesn't exist.
Unlock Full Question Bank
Get access to all 21 End-to-End ML System Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.