Made by systemdesign.academy, the site with 984 interactive system design and AI engineering lessons.
See all 150 questions in this pack10 sections, in the order the PDF prints them. The answers are in the PDF; 5 are free below.
The ML lifecycle (12)
1.What are the stages of the ML lifecycle, and which stage do teams most often forget? junior
2.When should you not use machine learning for a problem? junior
3.Why do you start with a simple baseline before training a complex model? junior
4.How do you turn a vague goal like "reduce churn" into an ML problem with a label, a prediction time and a metric? mid
5.Why can a model improve the offline metric but not the business metric, and how do you connect the two? mid
6.How do you choose the decision threshold for a classifier in production? mid
7.What is a feedback loop in an ML system, and when does it become harmful? mid
8.A model scores 95% accuracy offline but users say it is useless. What do you check first? midfree below
9.How do you estimate whether an ML project is worth building before you build it? senior
10.Labels arrive weeks late (for example loan default). How do you train and evaluate? senior
11.When should a model be retrained: on a schedule, on drift, or on a drop in performance? senior
12.What should an ML platform team own, and what should product ML teams own? staff
Data pipelines and data quality (14)
13.What is the difference between batch and streaming data pipelines for ML? junior
14.What is data validation, and which checks would you run on a training dataset? junior
15.ETL or ELT for ML data: which do you choose and why? junior
16.What is label noise, and how much does it hurt a model? junior
17.What is a data contract, and how does it stop a silent model failure? mid
18.How do you version datasets so you can reproduce a model trained six months ago? mid
19.How do you handle late-arriving events in a streaming feature pipeline? mid
20.A column is 30% missing. How do you impute it so training and serving stay consistent, and when does the missingness itself carry signal? mid
21.When is synthetic data useful for ML, and when is it dangerous? mid
22.You fixed a bug in a feature pipeline. How do you backfill safely? senior
23.Data lake, data warehouse or lakehouse: where should ML training data live? senior
24.How do duplicate records inflate offline metrics, and how do you find them? senior
25.How do you make a data pipeline idempotent so a retry never double-counts? senior
26.How would you monitor data quality for 500 tables that feed 40 models? staff
Features and feature stores (16)
27.What is a feature, and what makes a feature useful? junior
28.How do you encode categorical features, and what breaks with one-hot encoding at high cardinality? junior
29.Online store vs offline store: what does each hold and serve? junior
30.What is a feature store, and which problems does it solve? mid
31.What is point-in-time correctness, and how does a wrong join leak the future? mid
32.Write a point-in-time join in pandas. mid
33.How do you compute sliding-window features like "transactions in the last hour" for both training and serving? mid
34.What do you do when a feature is missing at serving time? mid
35.How do you use embeddings as features, and how do you store and serve them? mid
36.What is target encoding, and how does it leak the label? mid
37.What causes training-serving skew, and how do you prevent it? senior
38.How stale can a feature be, and how do you measure freshness? senior
39.How do you version a feature definition and backfill it without breaking running models? senior
40.How do you decide which features to keep when each one costs latency and money? senior
41.Build or buy a feature store (Feast, Tecton, Databricks, SageMaker): how do you decide? staff
42.Design a feature platform shared by a real-time fraud model and a daily churn model. staff
Training at scale (13)
43.What is the difference between data parallelism and model parallelism? junior
44.How do you train on a dataset that does not fit in memory? juniorfree below
45.How do data-parallel workers keep their model copies in sync? mid
46.What is gradient accumulation, and when do you use it? mid
47.What is mixed-precision training, and why does it speed training up? mid
48.What happens to the number of steps and the learning rate when you increase the batch size? mid
49.How do you estimate the GPU memory needed to train a model? mid
50.Tensor parallelism vs pipeline parallelism: how does each split a model? senior
51.How do ZeRO and FSDP cut memory per GPU? senior
52.A long distributed training job dies at hour 20. How do you make training fault tolerant? seniorfree below
53.Your 8-GPU job is only 30% faster than 1 GPU. How do you find the bottleneck? senior
54.How do you run hyperparameter search efficiently (random search, Bayesian optimization, early stopping)? senior
55.How do you plan the compute budget and cluster size for a training run? staff
Experiment tracking and reproducibility (11)
56.What should you log for every training run? junior
57.Why can the same code train two different models, and how do you make training reproducible? junior
58.How does an experiment tracker such as MLflow organize runs, parameters, metrics and artifacts? junior
59.What changes when a notebook experiment becomes a production training pipeline? junior
60.Two runs differ by 0.3 points of AUC. How do you know the difference is real? mid
61.What is data lineage, and why do auditors ask for it? mid
62.When must you use a time-based split instead of random k-fold cross-validation? mid
63.How do you avoid overfitting to the validation set when you run hundreds of experiments? senior
64.An auditor asks you to rebuild the model that was live 18 months ago, and your rerun gives different predictions. How do you find out why, and what would have prevented it? senior
65.Build an offline evaluation system for a ranking model whose logs come from the current model. How do you make its numbers trustworthy? senior
66.Design a promotion gate that blocks a bad model automatically. staff
Model registry, packaging and versioning (11)
67.What is a model registry, and what does it store? junior
68.What is inside a saved model file? junior
69.Pickle, joblib, ONNX, TorchScript or safetensors: how do you choose a model format? mid
70.Why does a model break when a library version changes, and how do you prevent it? mid
71.How do you package a model as a container for serving? mid
72.What is a model signature, and why enforce it at serving time? mid
73.What do ONNX export and int8 quantization change for size, speed and accuracy? mid
74.How should you version models, and what counts as a breaking change? senior
75.A new model is hurting users. How do you roll back in minutes? senior
76.Why is loading a pickled model from an untrusted source dangerous? senior
77.Design model governance for a regulated bank: approvals, lineage and audit. staff
Serving and inference (17)
78.Batch prediction or online prediction: how do you choose? junior
79.What is a latency budget, and how do you split it across one request? junior
80.What sits in the request path when you serve a model behind an API? junior
81.When should you cache predictions, and when is caching wrong? junior
82.What is model distillation, and why use it for serving? junior
83.Why do teams track p99 latency instead of average latency? mid
84.How does request batching on a GPU trade latency for throughput? midfree below
85.What is a cold start in model serving, and how do you avoid it? mid
86.How do you work out the cost per 1,000 predictions? mid
87.On-device inference vs server inference: what changes? mid
88.How does Little's law help you size a serving fleet? mid
89.How do you set timeouts and fallbacks so a slow model does not break the product? senior
90.How do you load test a model service honestly? senior
91.How do you serve many models on one machine? senior
92.How do you serve a model that needs features from five services within 50 ms? senior
93.CPU or GPU for inference: how do you decide? staff
94.Design an inference platform for 200 models with different latency needs. staff
Deployment, testing and CI/CD (16)
95.Your shadow model disagrees with production on about 12% of requests. Is that good or bad, and what do you do next? junior
96.What is a canary release for a model? junior
97.Shadow, canary or A/B test: when do you use each? junior
98.What does CI/CD for ML look like compared with normal software CI/CD? junior
99.How do you run an A/B test for a new ranking model? mid
100.What is a multi-armed bandit, and when is it better than an A/B test? mid
101.Which tests should an ML pipeline have? mid
102.Blue-green or canary for models: what are the trade-offs? mid
103.How do you test a model before release beyond overall accuracy? mid
104.What is a kill switch for a model, and how do you route users between model versions? mid
105.How do deployment and monitoring change when the model in your ML system is an LLM? senior
106.Your continuous-training pipeline promoted a worse model at 3 a.m. How did it get through, and which guards would you add? senior
107.How do you change a model's input schema without breaking clients? senior
108.What is interleaving for ranking experiments, and why is it more sensitive than an A/B test? senior
109.The canary looked fine, but revenue fell a week after full rollout. What happened and how do you prevent it? staff
110.How do you keep releases safe when an organization ships 50 models a month? staff
Monitoring and drift (14)
111.What can go wrong with a model after it is deployed? junior
112.What do you monitor on a model in its first week, before any labels arrive? junior
113.Data drift, concept drift and label drift: what is the difference? junior
114.How do you measure drift with PSI, KL divergence or a KS test? mid
115.Drift alarms fire every day but the model is fine. What is wrong? mid
116.How do you monitor a model when the labels arrive late? mid
117.What belongs on a dashboard for a production model? mid
118.How do you check that a model's probabilities stay calibrated over time? mid
119.How do you detect training-serving skew in production? senior
120.How do you set alert thresholds for model metrics without alert fatigue? senior
121.The model returns predictions, but they are garbage. How do you catch silent failures? senior
122.How do you monitor fairness across user segments in production? senior
123.Drift detected: how do you decide whether it actually hurts the model? staff
124.Design monitoring for a credit-risk model whose labels take 90 days. staff
ML system design (26)
125.Design a product recommendation system. What are the stages from millions of items to ten? mid
126.How do you handle cold start for new users and new items? mid
127.Design the ranking stage of an e-commerce search engine. mid
128.Where do training labels for search ranking come from? mid
129.Design an ETA prediction system for a food delivery app. mid
130.How does a two-tower model retrieve candidates, and how is it served? senior
131.How do you evaluate a recommender offline, and why can offline wins fail online? senior
132.What is position bias in recommendation and search logs, and how do you correct for it? senior
133.Design a real-time card fraud detection system. senior
134.Fraud is 0.1% of payments. How do you train on such imbalanced data, and how do you turn scores from a down-sampled model back into real probabilities? senior
135.Which metrics do you use for a fraud model? senior
136.Pointwise, pairwise and listwise learning to rank: what is the difference? senior
137.How do you measure search quality, and how do you link it to business metrics? senior
138.Which features matter for delivery ETA, and how do you compute them in real time? senior
139.Which loss and metric suit ETA prediction, and why does lateness matter more than earliness? senior
140.After launch, how do you evaluate ETA predictions and catch regressions by city? senior
141.How do you design a content moderation system that combines models and human review? senior
142.Design demand forecasting for a quick-commerce dark store (SKU x store x hour). staff
143.Design a video recommendation system for 100 million daily users. staff
144.Fraudsters adapt to your model. How do you keep up? staff
145.How do a rules engine and an ML model work together in fraud detection? staff
146.Search must answer in 200 ms with an ML ranker. How do you design for that budget? staff
147.When is a cheaper, less accurate model the right choice? staff
148.Design click-through-rate prediction for ads on a social feed. staff
149.An online model metric dropped 8% overnight. How do you debug it? stafffree below
150.One global model or many per-segment models: how do you decide? staff
Bar chart for a model that always says no on 1,000 cases with 50 positives: accuracy 0.95, recall 0.0 and balanced accuracy 0.5, the coin-flip level.
Why it is asked: A classic debugging question: the interviewer wants a calm, ordered checklist starting with the most likely cause.
First check what 95% is being compared with: if only 5% of cases are positive, a model that always says "no" also scores 95% accuracy while catching nothing.
Accuracy is the share of all predictions that are right. When one class is rare, accuracy hides failure. With 50 positives in 1,000 cases, the always-no model scores 0.95 accuracy, 0.0 recall (it finds none of the positives) and 0.5 balanced accuracy (the average recall over both classes, where 0.5 is coin-flip level).
My checks, in order:
1. Class balance and the right metric. Compare with the always-majority baseline. Use precision (of the cases we flag, how many are real), recall (of the real cases, how many we flag), or precision in the top k if users only see a short list.
2. Leakage. Does a feature contain the answer, such as a "refund_issued" field when predicting fraud? Are rows from the same customer in both train and test? Leakage gives high offline scores that vanish live.
3. Training-serving skew. Is a feature computed differently in production, missing, or arriving late? Compare the live input distribution with the training one.
4. Offline data versus real use. Was the test set old, from one region, or cleaner than what users send?
5. The user's real task. "Useless" may mean the errors land on the cases users care about most, such as large orders. Read 50 real failures and slice the errors by segment.
Only after these checks would I change the model itself.
What the interviewer listens for
Accuracy on an imbalanced label can equal the do-nothing baseline.
Recall, precision and balanced accuracy expose it.
Leakage and training-serving skew are the next suspects.
Check that the test set looks like real usage.
Read real failures before touching the model.
Follow-ups the interviewer may ask
Which metric would you report for a 1% positive rate? Hint: precision and recall at the operating threshold, or average precision (area under the precision-recall curve).
How do you detect leakage quickly? Hint: look for a single feature with near-perfect importance, and check feature timestamps against the prediction time.
How do you compare live inputs with training inputs? Hint: per-feature statistics or PSI (population stability index, a score of how far a distribution has moved) between the training sample and a recent serving sample.
Common mistakes
Trusting accuracy without checking the class balance.
Retraining a bigger model before ruling out data problems.
Asking users for vague feedback instead of reading specific failures.
Architecture from 2,000 shards (512 GB) on Amazon S3 through PyTorch DataLoader workers into a 10,000-sample shuffle buffer of about 1 GB in RAM, which feeds random batches to the GPU.
Why it is asked: Real datasets are larger than RAM. The interviewer checks that you know streaming, sharding and how shuffling still works.
Stream the data from disk or object storage in small pieces, so only a few batches are in memory at any moment.
How it works:
- Store the dataset as many files called shards, for example 2,000 Parquet or WebDataset files of 256 MB each, 512 GB in total, on object storage such as S3.
- A data loader (code that reads data and turns it into batches) opens a few shards at a time. Several worker processes read and decode in parallel while the GPU trains on the current batch. This overlap is called prefetching.
- Shuffle in two steps. First, shuffle the order of the shards every epoch (one full pass over the data). Then pass samples through a shuffle buffer: a pool of, say, 10,000 samples from which each batch is drawn at random. With 100 KB samples that buffer uses about 1 GB of RAM, not 512 GB.
- For classic models in scikit-learn, use models (estimators) with partial_fit, such as SGDClassifier, which learn from one chunk at a time. Or use Spark or Dask, which split the work across many machines.
A shuffle buffer gives an approximate shuffle, not a perfect one. If the files are sorted, for example one class or one day per file, a small buffer still feeds the model long runs of similar samples, and training becomes unstable. Mix the rows when you write the shards, and make the buffer large enough.
What the interviewer listens for
Shard the data into many files on disk or object storage and stream them.
Worker processes read and decode ahead of the GPU (prefetching).
Shuffle shard order each epoch plus a shuffle buffer; only the buffer lives in RAM.
For classic ML: partial_fit, or a distributed engine such as Spark or Dask.
Mix rows when writing shards; sorted shards defeat a small buffer.
Follow-ups the interviewer may ask
How big should the shuffle buffer be? Hint: large compared to how many similar rows sit together in a shard; mixing at write time lets it be smaller.
The GPU sits idle waiting for data. What do you do? Hint: more loader workers, prefetch, pre-decoded or smaller formats, faster storage.
How do you resume mid-epoch after a crash? Hint: save the shard list and position (or the sampler state) in the checkpoint.
Common mistakes
Loading the whole dataset into a pandas DataFrame and adding RAM until it fits.
Streaming files in a fixed order with no shuffle, so the model sees one class or one day at a time.
Using one huge file, which cannot be read in parallel or split across workers.
Lifelines for scheduler, trainer and S3 checkpoint store: the trainer saves shards and a manifest, a node dies at hour 20, the scheduler restarts all ranks, and the trainer loads the latest manifest and resumes.
Why it is asked: Jobs on many GPUs fail often, from bad nodes to network faults. The interviewer checks that you save the full training state safely and restart without a human.
Save checkpoints often enough that a crash loses only a little work, write them so a half-written one can never be loaded, and let the scheduler restart the job and resume on its own.
A checkpoint is a saved snapshot of everything needed to continue exactly: the model weights, the optimizer state, the learning-rate schedule, the step number, the random number generator states and the data loader position. Weights alone are not enough; resuming with a fresh optimizer causes a loss spike and a different run.
How it works:
- Every N steps, each rank (one training process, usually one per GPU) writes its share of the state to durable storage such as S3. Sharded, asynchronous saving (torch.distributed.checkpoint) keeps the GPUs from waiting.
- Write to a temporary path and write a small manifest file last. A checkpoint counts only when its manifest exists.
- On spot or preemptible GPUs (cheaper GPUs the cloud can take back with short notice), catch the termination notice and save a checkpoint at once; elastic launchers such as torchrun can resume on fewer nodes instead of waiting for a spare.
- In a synchronous job one dead GPU stops every rank, so the scheduler (Kubernetes, Slurm, or torchrun with --max-restarts) restarts the whole job, ideally with a spare node.
- On start, the script always loads the latest complete checkpoint.
How often? Young's rule of thumb sets the interval to the square root of 2 x save time x mean time between failures. With a 2-minute save and one failure a day, that is about 76 minutes: you lose about 38 minutes of work per crash and spend about 2.6% of the run saving.
What the interviewer listens for
Checkpoint the full state: weights, optimizer, scheduler, step, RNG states, data position.
Atomic save: temporary files plus a manifest written last, keep the last few checkpoints.
Automatic restart of all ranks by the scheduler, and resume-from-latest on every start.
Interval from Young's rule, sqrt(2 x save time x MTBF): about 76 minutes for a 2-minute save and daily failures.
Prove it with a failure drill, not by assuming it works.
Follow-ups the interviewer may ask
How do you keep saving from stalling the GPUs? Hint: copy state to CPU memory, then upload in a background thread; shard the save across ranks.
What if the data loader position is not saved? Hint: the model sees some samples twice and skips others; save the sampler state or the epoch and step offset.
How do you handle a node that keeps failing? Hint: health-check nodes before start, drain the bad one, and restart on a spare.
Common mistakes
Saving only the model weights, then restarting with a fresh optimizer and learning-rate schedule.
Overwriting one checkpoint file in place, so a crash during save destroys the only copy.
Two panels from the stated model of 8 ms plus 0.5 ms per item: a batch of 1 takes 8.5 ms for about 118 predictions per second, a batch of 32 takes 24 ms for about 1,333 per second.
Why it is asked: Batching is the main lever for GPU serving cost. The interviewer checks that you know why it works, where it stops helping, and how to tune it against a latency target.
Batching makes each request wait a little longer so the GPU can do far more work per second. A forward pass has a fixed cost (launching GPU kernels, the small programs the GPU runs, and reading the weights from memory) that is paid once per batch, so sharing it across many requests raises throughput, while each request now waits for the whole batch.
A simple stated model shows the shape. Assume one forward pass takes 8 ms plus 0.5 ms per item:
- batch 1: 8.5 ms, about 118 predictions per second
- batch 8: 12 ms, about 667 per second
- batch 32: 24 ms, about 1,333 per second
Going from 1 to 32 gives 11.3 times the throughput for 2.8 times the batch time. Throughput can never pass 2,000 per second (one item every 0.5 ms), so the gains flatten while latency keeps rising.
Latency also includes waiting for a batch to form. Dynamic batching, offered by servers such as NVIDIA Triton and TorchServe, collects requests until the batch is full or a short maximum wait, for example 2 to 5 ms, runs out, then runs what it has. At low traffic the timer caps the extra delay; at high traffic batches fill fast.
To tune it, fix the latency SLO (service level objective, the target you promise) first, then raise the maximum batch size and wait time while p99 stays under it, and stop when throughput stops rising. For large language models, continuous batching goes further: new requests join a running batch at each generation step instead of waiting for the batch to finish.
What the interviewer listens for
Fixed per-batch cost is shared, so throughput rises with batch size.
Batch time and queue wait rise, so per-request latency grows.
Gains flatten near the per-item limit (here 2,000 per second).
Dynamic batching: max batch size plus max wait; tune against p99.
LLMs use continuous batching at each generation step.
Follow-ups the interviewer may ask
Why does batching help less on a CPU? Hint: less parallel hardware sits idle at batch 1, so the fixed cost share is smaller; it can still help.
What limits batch size on a GPU? Hint: memory for activations (and, for LLMs, the KV cache that stores attention values for the text so far) and the latency target.
Different input lengths in one batch? Hint: padding wastes compute; bucket by length or use continuous batching.
Common mistakes
Maximizing batch size without a latency target.
Forgetting the queue wait while a batch fills.
Expecting throughput to grow forever with batch size.
A hand-drawn decision chain of questions: metric data correct, deploy in last 24 hours, one segment only, inputs drifted or stale; each yes or no branch leads to an action such as fix logging, roll back first, client or region bug, or fix the feature pipeline, ending at checking the world and then the model.
Why it is asked: Production incidents test judgment under pressure. The interviewer looks for an ordered search that rules out cheap explanations first and restores service quickly.
Treat it as an incident: confirm the drop is real, find what changed, narrow it to a segment, check the inputs, and only then suspect the model. A sudden overnight drop usually has a sudden cause, such as a release or a broken pipeline, while model decay tends to be gradual.
1. Is the metric right? Check the logging and dashboard pipeline: late or missing event data, a changed metric definition, a tracking bug in a new app version, missing or duplicated partitions. Compare with an independent source, such as orders in the transactions database.
2. What changed in the last 24 hours? List every deploy: model version, serving code, feature pipeline, config, thresholds, new experiments, and upstream services. If the drop starts exactly at a deploy, roll back first and investigate after.
3. Where is the drop? Slice by platform, app version, country, traffic source, new versus returning users, and fallback rate. An 8% drop that sits entirely in one app version is a client bug; a drop spread evenly points to data or model inputs.
4. Are the inputs healthy? Compare today's feature distributions and null rates with last week's; check feature freshness, and whether online values match offline values for the same entity (training-serving skew). A stale or empty feature is a frequent cause.
5. Did the world change? Holidays, a marketing campaign bringing new kinds of users, an outage at a partner. Compare with the same day last week.
6. Then the model: score yesterday's traffic with the previous and current model to compare.
Throughout: keep a written timeline and, afterward, add an automatic check so the same cause alerts next time.
What the interviewer listens for
Verify the metric pipeline before touching the model.
Correlate with deploys; roll back first if one lines up.
Slice to localize the drop.
Check feature health, freshness and skew.
External causes, then the model; add a check afterward.
Follow-ups the interviewer may ask
How do you know if it is seasonal? Hint: compare with the same weekday last week and the same period last year, and with a holdout group.
No deploy, no segment, inputs look fine: what next? Hint: look at upstream product changes and traffic mix, then compare model versions offline on yesterday's data.
How do you prevent a repeat? Hint: automatic checks on null rates, freshness and per-segment metrics, with alerts tied to deploys.
Common mistakes
Retraining immediately without knowing the cause.
Debugging the model for hours while a recent deploy sits un-rolled-back.
Trusting the dashboard without checking the logging pipeline.
Data and feature pipelines, training at scale, registries, serving, monitoring, drift and CI/CD for ML.
150 questions and 193 diagrams, each with why it is asked, a full answer, what the interviewer listens for, follow-ups, common mistakes and a diagram. By Roni Das.