- Learn
- Machine Learning
- ML System Design Case Studies
ML-M17
ML system design case studies
ML system design explained through eight case studies, from fraud detection to visual search, plus a repeatable framework for interviews and design reviews.
ML system design is turning a business decision into a machine learning system that makes it well, at scale, and keeps making it well after launch. Knowing algorithms is the smaller part. A real system starts with a decision, a metric that says whether it was made well, and labels that arrive late, noisy or biased. Only then come features, a model, a serving path with a latency budget, and the monitoring that keeps it honest.
A repeatable ML system design framework
Every case study here follows the same order, and it works for an ML system design interview too:
- Clarify the problem and the metric. What decision, for whom, and which business and offline metrics say it worked? See Framing ML problems for products.
- Data and labels. Where examples come from, how labels are produced, how late and how biased they are.
- Features. What is known at prediction time, how fresh it must be, and how training and serving compute it the same way.
- Model. A simple baseline first, then the model that fits the data and the latency budget.
- Offline evaluation. The metric that matches the decision, on a split that mirrors production.
- Serving and latency. Batch or real time, the request path, feature lookups and a budget for each step.
- Online evaluation. An A/B test on the business metric, because offline gains do not always survive real users. See Offline vs online evaluation and A/B tests.
- Monitoring and retraining. Drift, label delay, feedback loops and when to retrain. See Monitoring, drift and retraining.
The eight case studies
- Design a fraud detection system: rules plus a model under 100 ms, rare labels that arrive weeks later as chargebacks, and fraudsters who adapt.
- Design an ETA prediction system: a residual model on top of a routing engine, a real-time feature pipeline, and why you report P50 and P90 error.
- Design a feed ranking system: candidate generation, ranking and re-ranking for diversity, choosing the objective, and position bias.
- Design a search ranking system: query understanding, hybrid BM25 and embedding retrieval, learning to rank with NDCG, and click bias.
- Design an ad click-through-rate prediction system: hashed sparse ids, feature crosses, wide-and-deep and DCN models, and calibration because pCTR sets auction prices.
- Design a spam / content moderation classifier: a cascade of fast models, LLM classifiers and human review, with precision and recall set per policy.
- Design a demand forecasting system: global models, holidays and events, forecasts that add up from store to city, and prediction intervals for planning.
- Design a visual search system: cropping the object, image embeddings, an approximate nearest neighbour index, and keeping it fresh.
The same few patterns keep coming back in different forms: rules plus models, candidate generation plus ranking, and fast signals plus slow labels.
Lessons
- ML-17.01 Design a fraud detection system A fraud detection system scores each transaction in milliseconds before approving it. Advanced 22 min
- ML-17.02 Design an ETA prediction system An ETA system predicts arrival times. Advanced 20 min
- ML-17.03 Design a feed ranking system A feed ranking system retrieves candidate posts from many sources, scores them with a model predicting several engagement signals and combines those into a final ranking, then re-ranks for diversity and freshness. Advanced 22 min
- ML-17.04 Design a search ranking system A search ranking system understands the query, retrieves candidates with keyword and embedding search, and ranks them with a learning-to-rank model using query, document and user features. Advanced 22 min
- ML-17.05 Design an ad click-through-rate prediction system An ad click prediction system estimates the probability that a user clicks an ad, which feeds directly into auction prices. Advanced 20 min
- ML-17.06 Design a spam / content moderation classifier A content moderation system classifies text, images and video for policy violations. Advanced 18 min
- ML-17.07 Design a demand forecasting system A demand forecasting system predicts demand per product, store or area and time period so the business can plan inventory and staffing. Advanced 18 min
- ML-17.08 Design a visual search system A visual search system lets users find items by image. Advanced 18 min