download

ML System Design Interview: Framework, Questions and Case Studies

#12Updated October 21, 202617 min read4,494 words

The new feed gets more clicks. It also gets more hides, and users return less often the following week. The model may be predicting exactly what you taught it to predict. That's the uncomfortable part: better predictions can make a product worse when the target is a poor stand-in for what people need.

An ML system design interview lets you examine that gap. Start with a product goal, define what can be observed, choose data and a model, and explain how the result will be evaluated and served. Infrastructure matters too: a useful prediction arriving after the decision is no longer useful.

This guide covers seven steps, five cases (feed, search, ads, fraud and RAG), a full feed walkthrough, metrics, resources and practice. Make your assumptions examinable. Nobody can investigate the word "engagement." They can investigate which events count, when labels arrive and who bears the cost of a wrong prediction.


What is an ML system design interview?

It is a design round for machine learning engineers (MLEs), applied scientists and ML-focused software engineers. The interviewer names a product problem and you design the ML system behind it. It is not a whiteboard exercise in deriving backpropagation, and it is not a pure infrastructure round about load balancers and sharding either.

Published guidance and candidate descriptions cover different scopes:

CompanyWhat we knowSource type
MetaThe Software Engineer, Machine Learning loop includes coding, ML system design and behavioral interviews, each about 45 minutes. The design prompt is a real-world product such as ranking, recommendations or personalization. Interviewers score five areas: problem navigation, training data, feature engineering, modeling, and evaluation & deployment.Official preparation guide, checked October 20 (Meta ML onsite prep and its linked interview guide)
GoogleMLE onsites reportedly include coding, ML design, ML theory and behavioral rounds; candidates call design a major filter. Reported prompts include copyright-violation detection and GenAI systems.Candidate reports (Glassdoor, 2026)
AmazonApplied scientist loops reportedly include ML breadth, ML depth (often your own project), a design round, coding and a Bar Raiser; varies by team.Candidate reports (Glassdoor, LeetCode Discuss)
AI-first companiesPractice materials include RAG design with evaluation, cost and permissions; no frequency ranking is established here.Candidate reports, practice platforms, 2026

Treat everything outside official guides as indicative, and ask your recruiter whether your design round leans toward ML or infrastructure.


ML system design vs classic system design

System design preparation carries over in serving, latency, storage and failure handling. ML adds a learned decision whose quality depends on what you observe and how you collected it.

Classic system designML system design
Core questionHow do we store, move and serve data reliably at scale?What should we predict, from which data, and how do we know it works?
Typical promptDesign a URL shortener, a chat app, a rate limiterDesign feed ranking, fraud detection, a RAG assistant
Where depth goesStorage choices, partitioning, consistency, failure modesObjective and labels, features, model choice, evaluation, feedback loops
CorrectnessExplicit API, durability and consistency contracts, including acceptable stalenessInfrastructure contracts plus statistical model quality and offline/online gaps
Hard partsHot keys, replication lag, fan-outLabel delay, class imbalance, position bias, data leakage, drift
Success metricLatency, availability, throughputBusiness metric plus model metrics plus guardrails

The questions depend on one another. A feature computed after the event is unavailable at prediction time; a label may take weeks to mature before it is usable in training or evaluation. A better ranker may need features whose latency misses the budget. Move between the objective and its system.


A 7-step framework for an ML system design conversation

Plan for about 40 minutes of design, leaving time for your own questions at the end. The budget below is a guide, not a script. Interviewers will steer you into the parts they care about.

StepWhat to coverTime
1. Clarify the product goalWho the users are, what success means for the business, scale, latency, constraints~4 min
2. Frame it as an ML problemPrediction target, label definition, ML task type, why ML at all~4 min
3. Data and featuresData sources, how labels are collected, sampling, feature groups~7 min
4. Model and trainingBaseline first, then the main model; multi-stage architecture; training details~9 min
5. EvaluationOffline metrics, online A/B test, guardrail metrics~6 min
6. Serving and infrastructureOnline vs batch, latency budget, feature store, caching, cost~6 min
7. Monitoring and iterationDrift, retraining, feedback loops, failure modes, next steps~4 min

What each step needs in practice:

  1. Clarify. Ask questions that change the design: engagement, revenue or satisfaction? How many users and items? Latency budget? Do labels exist? Write your assumptions down, for example "500M daily users, under 200 ms".
  2. Frame. "Increase meaningful engagement" becomes predict P(like), P(comment) and P(share), and rank by a weighted combination. Name the task type and say whether ML is needed at all. Google's Rules of Machine Learning by Martin Zinkevich opens with the idea that a simple heuristic is fine until you have data.
  3. Data and features. Where labels come from, how late they arrive, how you sample. Group features into user, item, context and interaction. Show you can make an idea usable: consider normalization, smoothing and bucketing where raw counts mostly reflect age or exposure.
  4. Model. Baseline first (heuristic, logistic regression or gradient-boosted trees), then the main model and why. For large catalogs, use a multi-stage architecture: cheap retrieval narrows millions of items to hundreds, then a heavier ranker scores them, as in YouTube's 2016 RecSys paper (Covington et al.).
  5. Evaluate. One offline metric for the task, one online metric for the business goal, at least one guardrail, and how you would run the A/B test.
  6. Serve. Batch vs real-time predictions, latency per stage, a feature store with the same definitions for training and serving (to avoid skew), and the rollout: shadow mode, canary, A/B test.
  7. Monitor. Feature and label drift, broken upstream pipelines, feedback loops, retraining cadence, and what you would build next quarter.

5 common ML system design interview questions, with outlines

These five give you different decisions to practice. Variants such as "design YouTube recommendations", "design people you may know" or "design harmful content detection" reuse the same building blocks.

1. Feed or recommendation ranking

Start by asking which experience ranking should improve. A click is easy to observe; its meaning needs more care. Outline:

  • Objective: a weighted sum of predicted actions (like, comment, share) minus a penalty for P(hide).
  • Architecture: candidate generation → light ranker → multi-task ranker → re-ranking for diversity and integrity.
  • Hard parts: position bias, cold start, clicks vs long-term satisfaction.

The full walkthrough is below.

2. Search ranking

"Design search for an e-commerce site."

  • Framing: return the most relevant items for a query. Clarify relevance vs revenue and how much personalization is allowed.
  • Retrieval: lexical (BM25) plus dense embedding retrieval to catch synonyms, merged for example with reciprocal rank fusion (Cormack, Clarke and Büttcher, SIGIR 2009).
  • Ranking: learning to rank (LambdaMART-style boosted trees are a strong baseline), then a cross-encoder re-ranker on the top results if latency allows.
  • Labels: human relevance ratings for evaluation; clicks and purchases for training, corrected for position bias.
  • Metrics: NDCG@10 and MRR offline; search conversion, zero-result rate, query reformulation rate and abandonment online.

3. Ads click prediction

"Predict the probability that a user clicks an ad."

  • Why it matters: in many ad auctions, the predicted click-through rate is multiplied by the bid to rank ads, so the prediction directly affects price. That makes calibration as important as ranking quality.
  • Data: billions of impressions with a very low click rate. Downsample negatives, then recalibrate. Facebook's 2014 paper (He et al., Practical Lessons from Predicting Clicks on Ads at Facebook) gives the correction formula and shows accuracy dropping as training data gets older, so freshness matters.
  • Features: user, ad and advertiser history, context (placement, device, time) and their crosses. Historical features mattered most in that paper.
  • Model: logistic regression or trees as a baseline; deep models with embeddings and feature interactions in production; frequent updates.
  • Metrics: log loss or normalized cross-entropy (NE) and calibration offline; CTR, revenue per thousand impressions and advertiser ROI online, with user experience guardrails.

4. Fraud detection

"Design a system that detects fraudulent card payments." This prompt is common at fintech, marketplaces and payments companies, and the same structure fits account-takeover, spam and fake-review detection.

  • Framing: score every transaction in real time, before authorization, and map the score to an action: approve, require extra verification, send to manual review, or decline. Clarify the available latency budget and the review team's capacity.
  • Labels: chargebacks and confirmed fraud reports, which arrive weeks to months later. That delay shapes everything: you train on older data, use manual review outcomes as faster labels, and watch for leakage from fields that are only filled in after fraud is confirmed.
  • Imbalance: fraud is a tiny fraction of transactions, so a model that approves everything looks 99%+ "accurate". Accuracy alone hides the behavior that matters at this imbalance.
  • Features: velocity counts (transactions per card, device or IP per minute, hour, day), deviation from the user's usual amount and location, device fingerprint, account age, merchant risk, and graph features linking cards, devices and emails shared across accounts.
  • Model: gradient-boosted trees as a strong, explainable baseline; graph models for fraud rings; anomaly detection for new attacks with no labels yet. Keep a rules layer for hard policy and instant response.
  • Decision layer: pick thresholds from a cost matrix, not from the model. An illustrative cost model could include unrecovered loss, fees, review costs and lost legitimate business. Liability and recovery depend on the product; the full transaction amount is not automatically the loss.
  • Feedback loop: blocked transactions have partly unobserved outcomes; review outcomes are selected too. Use available adjudicated outcomes and delayed feedback, and state what remains unidentifiable. An experiment changing payment decisions needs risk approval and bounded exposure; a holdout isn't an instruction to let suspicious payments through.
  • Metrics: PR-AUC, recall at a fixed false-positive rate, precision at the review team's capacity, and dollar-weighted fraud caught offline; fraud loss rate, false-decline rate and approval rate online.
  • Adversaries: fraudsters adapt once you block them. Use temporal evaluation, point-in-time features and matured labels; choose monitoring and retraining cadence for the observed change.

5. An LLM-powered feature or RAG assistant

"Design an assistant that answers employee questions from internal documents." Retrieval and generation fail in different ways, so evaluate them separately. Retrieval-augmented generation (RAG) was introduced by Lewis et al. at NeurIPS 2020; today the term covers any system that retrieves context and passes it to a language model.

  • Clarify: corpus size and formats, how often documents change, whether answers must cite sources, who may see which documents, latency target, and the cost per query the business accepts.
  • Ingestion: parse documents, split them into chunks, attach metadata (source, date, access permissions), embed the chunks, and update the index incrementally when documents change.
  • Retrieval: hybrid search (BM25 plus vector search), filtered by the user's permissions at query time, followed by a re-ranker on the top candidates. Query rewriting helps with follow-up questions in a chat.
  • Generation: a prompt that tells the model to answer only from the retrieved context, cite the sources, and say "I don't know" when the context does not contain the answer. The prompt and citations are behaviors to evaluate, rather than guarantees of truth or authorization.
  • Build vs adapt: start with prompting and retrieval. Fine-tune for format, style or a cheaper model, not to teach facts that change.
  • Evaluation: a golden set of questions with known answers and source passages. Measure retrieval recall@k separately from answer quality (faithfulness, relevance, correctness). If you use LLM-as-judge scoring, calibrate it against human ratings. Online: thumbs up/down, deflection rate, escalations.
  • Serving: time to first token, streaming and routing easy questions to a smaller model to control cost. Cache answers or passages with relevant permission context and recheck authorization when access or documents change. A citation does not establish that the current user may see the cited content.
  • Safety: prompt injection hidden in retrieved documents (OWASP LLM01:2025), leaks of documents the user may not see, PII in logs. If the assistant can take actions, add tool permissions and confirmation for risky ones.

Worked example: design a personalized news feed ranking system

A rehearsal walkthrough for about 40 minutes. The numbers are illustrative assumptions you would state in the interview, not facts about any company.

1. Clarify (4 min). "Is the goal time spent, or meaningful interactions? Are ads ranked in the same feed? How many posts can a user be eligible for?" Assume: 500M daily users, ~2,000 eligible posts per user per session from friends, groups and followed pages, feed must load in under 200 ms, and the company wants meaningful interactions rather than passive scrolling. Ads are out of scope.

2. Frame (4 min). Predict several actions per (user, post) pair: P(like), P(comment), P(share), P(dwell > 10 s), and P(hide or report). Rank by a value score:

"TEXT"
score = w1·P(like) + w2·P(comment) + w3·P(share) + w4·P(dwell) − w5·P(hide)

This is a multi-task ranking problem, but the weights still need a product decision. Suppose the candidate with more predicted interactions also has a higher predicted hide rate. For this design, I'd give hides enough weight to push it down the list and test that choice, even if it costs some clicks. A click-heavy feed can be very good at giving people something they regret opening.

3. Data and features (7 min). Labels come from impression logs: each post shown is an example, and each action is a label. Only count impressions that were actually on screen. Features:

GroupExamples
UserAge of account, activity level, topic interests (embedding), device
PostType (photo, video, link), age, author, text and image embeddings, early engagement rate
User × authorPast interactions with this author, friendship strength, last interaction time
ContextTime of day, session depth, connection speed

Watch for position bias: placement affects whether an item is noticed. Log exposure, position and the selection policy so you can investigate how the old ranker's preferences shaped the training data.

For a deeper discussion, Google's Rules of ML describe training with a positional feature and using a common value at serving; that still needs evaluation for confounding from the old ranker and user behavior. Propensity weighting needs a credible observation model and exposure to the items being compared. Controlled randomization can help estimate exposure effects; very small propensities make weighting noisy.

Use temporal evaluation together with point-in-time feature joins. A like count updated after the prediction can leak future information despite a time-based split. Define label windows and handle outcomes that haven't had time to mature.

4. Model (9 min). Two stages:

  • Candidate generation: use the stated universe of roughly 2,000 posts from friends, groups and followed pages. A light model can narrow this to roughly 500. Broader recommendations would add a retrieval source and change scope; agree on that before adding a two-tower retriever for an unstated catalog.
  • Ranking: a deep multi-task network with shared lower layers and one output head per action, trained with a binary cross-entropy loss per head. Sparse features such as author IDs go through embedding tables.
  • Re-ranking: rules and a light model for diversity (don't show five posts from the same author in a row), freshness, and integrity filters for misinformation or policy violations.

A daily training job is an initial assumption; labels, drift and cost should determine the cadence. Shared layers may help related tasks reuse information, but can cause negative transfer. Compare per-head quality, calibration and serving cost with separate models. The multi-task literature discusses cases where unrelated tasks hurt one another.

5. Evaluation (6 min). Offline: ROC-AUC, normalized cross-entropy and calibration per head (the outputs are combined by weights), NDCG on the final list. Online: an A/B test with meaningful interactions per user as the primary metric; guardrails on hide rate, weekly return rate and latency. I'd reject a click lift that breaches the hide-rate guardrail or harms weekly return. That means waiting long enough to observe return behavior, beyond the novelty period, before calling the new weights an improvement.

6. Serving (6 min). Fetch candidates (~30 ms), fetch features from an online feature store (~20 ms), score ~500 posts in batches (~60 ms), re-rank and return. Precompute user embeddings in batch; compute post embeddings at creation. Share feature definitions between training and serving. The 30+20+60 ms assumptions consume 110 ms of the 200 ms end-to-end target, leaving 90 ms for re-ranking, transport and other work. Measure tail latency, queuing and parallel calls; this is not a measured latency distribution. If it fails, test fewer candidates, cheaper features or a lighter ranker against quality.

7. Monitoring and next steps (4 min). Monitor feature distributions, predictions and calibration per head, and business metrics. A sudden drop in a feature's coverage usually means an upstream pipeline broke. The model learns only from posts it already ranked high, so reserve a little exploration traffic. Next: long-term satisfaction signals (surveys) and better cold-start for new posts.

You won't cover every bullet. When the interviewer pulls you toward one area, follow them and go deep there.


Evaluation metrics: offline and online

Evaluation gives the design something falsifiable. Connect the offline metric to the online one, and say why they might disagree.

Problem typeOffline metricsOnline metricsGuardrails
Binary classification (fraud, spam, harmful content)Precision, recall, F1, PR-AUC alongside ROC-AUC and operating-point costs under heavy imbalance, recall at a fixed false-positive rateFraud loss rate, false-decline rate, user reports, appeal rateApproval rate, review queue size, latency
Click / conversion prediction (ads)Log loss, normalized cross-entropy, calibration (predicted clicks ÷ observed clicks, ideally close to 1), ROC-AUCCTR, conversion rate, revenue per thousand impressionsAd load, user hide rate, advertiser ROI
Ranking (feed, search, recommendations)NDCG@k, MRR, MAP, recall@k for retrieval, per-head AUCEngagement per user, session length, conversion, retentionDiversity, creator coverage, hide rate
Retrieval for RAGRecall@k and MRR on a golden set of question → source passagesRate of "no answer found", citation clicksPermission leaks (should be zero)
LLM generationFaithfulness/groundedness to retrieved context, answer relevance, correctness vs reference, LLM-as-judge scores calibrated against human labelsThumbs up/down, task resolution or deflection rate, escalationsTime to first token, cost per query, safety violations

Two definitions worth knowing exactly, both from Facebook's 2014 ads paper:

  • Normalized cross-entropy (NE): the model's average log loss per impression divided by the log loss you would get by always predicting the average click-through rate. Lower is better, and below 1 means the model beats the baseline.
  • Aggregate calibration check in that paper: predicted clicks divided by observed clicks. A ratio near 1 can hide opposite errors in different groups or score bands. Examine reliability curves and slices too. A ranking metric like AUC ignores calibration, which is why AUC alone is not enough for ads.

Why offline and online disagree: offline data was collected by the old model (selection bias), and offline metrics miss long-term effects such as user fatigue. Say this before the interviewer asks.


Common mistakes in ML system design interviews

  1. Jumping to the model in minute two, before the objective and labels exist. It leaves later choices without an objective to serve.
  2. A vague label. "Engagement" is not a label. "Clicked within 30 seconds of an on-screen impression" is.
  3. Ignoring data collection: where labels come from, how late they arrive, who pays for human labels.
  4. Random splits on time-dependent data. Use temporal splits plus point-in-time features and matured label windows; changing the split alone cannot remove leakage.
  5. Accuracy on imbalanced data. Report precision and recall at an operating point.
  6. Only offline metrics, with no A/B test or guardrails.
  7. No baseline. A simple model sets the bar and often ships first.
  8. Skipping serving and monitoring. A model that misses the latency budget or drifts silently is a failed design.
  9. LLM systems with no evaluation plan. "We'll check answers manually" doesn't scale.
  10. Not driving. Say what you will cover, then cover it.

How to prepare for a machine learning system design interview

A realistic plan for an engineer who already knows ML basics:

WeekFocusOutput
1Fundamentals: overfitting and regularization, losses, embeddings, boosted trees, transformers, metricsNotes per topic
2Framework and building blocks: two-stage ranking, feature stores, A/B tests, position bias, calibrationYour own quick reference
3Case studies: feed, search, ads, recommendations, each in 40 minutesFour timed designs
4Fraud, harmful content, a RAG assistant, LLM evaluation and costThree timed designs
5–6Mock interviews out loud, with a timer4–6 mocks

Practical tips:

  • Practice on real products. Meta's guide suggests taking a well-known app and asking how ML would improve one feature, such as replacing a rule-based friend recommender.
  • Practice out loud. Reading case studies is not the same as producing one under time pressure.
  • Prepare your own project deep dive. Many ML loops ask you to walk through an ML project you shipped: data, model choices, metrics, what failed. Meta's guide suggests outlining two or three major projects before the behavioral round.

ML system design quick reference

Quick version:

"TEXT"
1. CLARIFY    (~4 min)  Business goal · users & scale · latency · constraints · assumptions
2. FRAME      (~4 min)  Prediction target · exact label · task type · baseline without ML
3. DATA       (~7 min)  Sources · label delay · sampling · user/item/context/interaction features
4. MODEL      (~9 min)  Baseline → main model · retrieval → ranking → re-ranking · loss · retraining
5. EVALUATE   (~6 min)  Offline metric · online A/B metric · guardrails · why they can disagree
6. SERVE      (~6 min)  Batch vs real-time · latency per stage · feature store · rollout · cost
7. MONITOR    (~4 min)  Drift · broken pipelines · feedback loops · exploration · next steps

Check where relevant: position bias · imbalance · point-in-time features/labels · calibration
LLM/RAG extras: golden set · retrieval recall@k · faithfulness · permissions · prompt injection · cost/query

Machine learning system design books and resources

Choose for the problem you want to understand; these books cover different parts of the work.

ResourceAuthor(s)Publisher, yearWhat it is
Machine Learning System Design InterviewAli Aminian, Alex XuByteByteGo, 2023Interview-focused. An overview chapter plus 10 case studies, including visual search, YouTube video search, harmful content detection, video and event recommendation, ad click prediction, personalized news feed and people you may know
Generative AI System Design InterviewAli Aminian, Hao ShengByteByteGo, 2024The companion book for generative systems: 10 case studies such as Smart Compose, a ChatGPT-style assistant, RAG, and text-to-image and text-to-video generation
Designing Machine Learning SystemsChip HuyenO'Reilly, 2022Production ML end to end: data, features, training, deployment, monitoring and infrastructure. Based on her Stanford course
AI Engineering: Building Applications with Foundation ModelsChip HuyenO'Reilly, 2025Building on foundation models: prompting, RAG, fine-tuning, agents, evaluation, and inference cost and latency
Machine Learning System Design: With end-to-end examplesValerii Babushkin, Arseny KravchenkoManning, 2025From problem framing and metrics to deployment and maintenance; includes interview tips
Rules of Machine LearningMartin ZinkevichGoogle for Developers (free)Practical best practices for ML engineering, many of them directly usable in interviews
CS 329S: Machine Learning Systems DesignChip HuyenStanford course, first taught 2021Course notes and slides published online

Papers worth knowing by name: Deep Neural Networks for YouTube Recommendations (Covington, Adams and Sargin, RecSys 2016), Practical Lessons from Predicting Clicks on Ads at Facebook (He et al., 2014), and Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Lewis et al., NeurIPS 2020).


FAQ

What is machine learning system design?

Machine learning system design is the work of turning a product problem into a production ML system. It covers the objective, data and labels, features, the model, evaluation, serving and monitoring. In interviews, it is a 45-minute round where you design such a system out loud.

How is ML system design different from system design?

Classic system design is about storing and serving data reliably at scale. ML system design is about what to predict, which data to learn from, and how to measure whether it works. Model behavior and serving constraints jointly determine whether the system is useful; the conversations overlap.

How do I prepare for a machine learning system design interview?

Review ML fundamentals, learn a step-by-step framework, then write out 8–10 case studies under a 40-minute timer: feed ranking, search, ads, recommendations, fraud detection and a RAG assistant. Finish with mock interviews out loud. The sample four-to-six-week plan assumes familiarity with ML; adapt it to your starting point and role.

Which ML system design prompts are useful to practice?

Feed or video recommendation, search ranking, ads, fraud or harmful-content detection, people you may know and a RAG assistant exercise different choices about objectives, labels, serving and evaluation. Pick cases relevant to the role.

What is "MLE system design"?

It is shorthand for the ML system design round in machine learning engineer (MLE) interviews. Some companies give MLEs both an ML design round and a classic system design round, so ask your recruiter which one you will get.

How do I approach a fraud detection system design question?

Clarify the latency budget and the actions available (approve, verify, review, decline). Then cover delayed labels, heavy class imbalance, velocity and graph features, a gradient-boosted baseline, thresholds set from a cost matrix, time-based evaluation with PR-AUC, and adversarial drift.

Is there an ML system design quick reference?

Use the seven-step quick reference and metrics table above as a reference while you practice a case.

How do I learn machine learning system design as a software engineer?

Start with production ML rather than theory: Designing Machine Learning Systems or Google's Rules of Machine Learning, then two-stage ranking and A/B testing, then practice the framework on products you use daily.