Topic map · 8 stages

ML system design in eight stages, from problem framing to monitoring

ML system design prompts sound like product requests: design a feed ranker, flag fraudulent payments, suggest replies in a chat app. Candidates tend to spend most of their time on the model. Interviewers and production incidents both focus elsewhere: what the model predicts, where the labels come from, which features exist at prediction time, and how anyone will know after launch whether it helped.

This page is for engineers preparing for an ML system design round and for anyone who has to defend a design in a review at work. It takes the production ML part of the Concept map (Navigator) and puts it in the order you would use it in a 45 to 60 minute round. Each stage explains the mechanism, the usual tradeoff and a mistake that shows up often, and links the 40 concepts it relies on so you can open each one in the map. All of that is free. The System Design bundle, with its modules, practice and assessments, and Peer mock interviews come with the Career membership.

The order matters because each decision constrains the next one. A label that arrives 30 days after the prediction changes how you split data, which features are safe to use, how often you can retrain and what you can monitor in real time.

Who this is for: Engineers who can train a model and now need to design the system around it. It assumes basic supervised learning and some experience writing production code.

Concept evaluations are free with an account where reviewed questions are available. Module lessons and lesson assessments come with membership. See the Career+ opening offer below. Existing purchases and gifts retain their original terms.

The map

The path, in order

Each stage builds on the one before it. Each stage links to its published lessons. Concept links open the free concept map and show how the ideas connect.

Frame the decision and choose metrics

Start from the decision the model will drive and the cost of each kind of error. Then pick offline and online metrics that agree with each other, plus a guardrail.

Write the decision down before anything else: which surface, which user, how often, and what happens when the model is wrong. "Detect fraud" becomes "score each card authorization in under 100 ms and choose between approve, decline and step-up verification." That sentence already tells you the label (chargebacks), the latency budget, and the asymmetry: a false decline costs a sale and some customer trust, while a missed fraud costs the chargeback. Ask for scale early (requests per second, catalog size, number of users), because it decides if you can afford to score every item or have to retrieve candidates first.

Metrics come in layers. The business metric (revenue, retention, fraud losses) is what the company cares about, but it moves slowly and has many causes. The online metric you can read in an A/B test (click-through rate, completed purchases, false decline rate) sits closer to the model. The offline metric (log loss, AUC, NDCG@10, recall at a fixed precision) is what you can compute on held-out data in minutes. Say how the three connect, and name at least one guardrail that must not get worse, such as p99 latency, complaint rate or the share of impressions going to new creators.

The classic failure is optimizing a proxy that drifts away from the goal. A feed trained only on clicks learns that clickbait works, so click-through goes up while satisfaction and retention go down. Naming the proxy, describing how it could fail, and proposing a mitigation (a weighted score over several outcomes, a separate quality model, or a guardrail with a hard threshold) is one of the clearest ways to show you have run a system like this.

Loading stage lessons…

Concepts to explore

Decide where labels come from

Every supervised system needs a precise definition of the right answer and a way to collect it. Implicit feedback is cheap and biased, human labels are cleaner and slower.

Labels usually come from implicit feedback, human annotation or weak supervision. Implicit feedback (clicks, purchases, watch time, chargebacks) is plentiful and free, but it only exists for what the current system chose to show. Human annotation gives cleaner targets for things users never signal directly, like policy violations, at a cost per label and with disagreement between raters that you need to measure. Weak supervision combines rules, heuristics and existing models into noisy labels that are often good enough to train a first version.

Define the label precisely, including the event, the window and the unit. "Purchase within 7 days of the impression, attributed to the last click" is a label. "Conversion" on its own is a word that three teams will implement three ways. Some labels mature late: a chargeback can arrive weeks after the transaction, so the newest rows in a training set look legitimate only because their outcome is not known yet. Either wait out a label maturation window before using a row, or model the delay explicitly.

Logged feedback carries the old system's biases. Items shown in the first slot collect more clicks partly because of the slot, and items that were never shown have no labels at all. Common fixes are logging the display position and using it as a training feature (set to a fixed value at serving time), randomizing a small slice of traffic to collect less biased data, and weighting examples by the inverse of how likely they were to be shown.

Loading stage lessons…

Concepts to explore

Build features that exist at prediction time

A feature is only valid if the serving system can compute the same value, from the same information, at the moment it makes the prediction.

Feature families repeat across problems. There are entity features about the user and the item, context features such as time, device and location, and interaction features such as the user's click rate on this category over the last 7 days. Counts and rates over time windows carry much of the signal in ranking and fraud models. High-cardinality IDs go in as learned embeddings or hashed buckets, and raw text or images usually go in as embeddings from a pretrained encoder.

Leakage is the expensive mistake in this stage, because it makes offline numbers look excellent and then vanishes in production. The usual cause is a join that attaches a feature value computed after the prediction timestamp, for example a user's lifetime purchase count as of today attached to an impression from last month. A point-in-time join reads every feature as of the event time. Split train and test by time as well: with a random split, rows from the same user and the same week land on both sides, and the model gets credit for patterns it could not have known at prediction time. A single feature that is far more predictive than everything else is worth checking for leakage before you celebrate.

Freshness is a cost decision. A daily batch job is cheap and fine for slow-moving features like account age. Clicks in the last 30 minutes need a streaming pipeline and an online store with low read latency, which is more infrastructure to build and operate. A feature store keeps one definition per feature and serves it to offline training (historical values) and to the online model (latest value), which is the usual way to keep the two consistent.

Loading stage lessons…

Concepts to explore

Choose a model shape that fits the budget

Start with a simple baseline, then pick the architecture that the latency budget and the number of items allow. Large catalogs need a retrieval stage before ranking.

State a baseline first: a popularity ranker, a rules system, or logistic regression on a handful of strong features. It gives you a number to beat and a fallback for when the main model is down. Gradient-boosted trees are a strong default for tabular problems like fraud or churn and are cheap to serve. Neural models start to pay off with large data volumes, many sparse ID features or unstructured inputs such as text and images.

When you have to rank millions of items in tens of milliseconds, you cannot run a heavy model on every item. Recommenders and search systems use a funnel. Candidate generation, often a two-tower model whose item embeddings sit in an approximate nearest-neighbor index plus a few heuristic sources, returns hundreds to a few thousand items. A heavier ranker with user and item cross features scores those, and a final reranking step applies business rules, diversity and deduplication. The YouTube recommendations paper from 2016 describes this two-stage design and is still a good reference for it.

Many products optimize several outcomes at once: click, long watch, like, report. A multi-task model with shared layers and one output head per outcome is usually cheaper to serve than separate models, and the final ranking score is a weighted combination you can tune through experiments. For rare positives such as fraud, training on downsampled negatives is common, but correct the predicted probabilities afterward so that thresholds and expected-value calculations downstream still mean what they say.

Loading stage lessons…

Concepts to explore

Evaluate offline and know its limits

Offline evaluation should mirror how the model will be used: split by time, use metrics that match the decision, and read the slices before trusting the average.

Split by time. Train on weeks 1 to 8, validate on week 9, test on week 10. Random splits leak future behavior into training and overstate performance for anything with trends or seasonality. Then match the metric to the decision: precision and recall at the operating threshold for a classifier that triggers an action, NDCG or recall@k for a ranked list, and calibration (reliability curves, expected calibration error) whenever the score is used as a probability, as in ad auctions or expected-loss calculations.

Averages hide regressions. Break results down by slice: new and returning users, countries, device types, popular and long-tail items. A model that improves overall while getting worse for new users can hurt growth for months before anyone notices. Error analysis on a sample of the worst mistakes usually points to the next improvement faster than another hyperparameter sweep, because it tells you whether the problem is labels, features or the objective.

Expect a gap between offline and online results. Offline data was collected under the old model, so a new model that would surface different items is judged on labels it never had a chance to earn. Feedback effects, latency differences and feature skew widen the gap further. Use offline evaluation to decide which candidates deserve an online test, and let the online experiment decide what ships.

Loading stage lessons…

Concepts to explore

Serve predictions within a latency budget

Decide between batch and online inference, then fit feature lookups, model calls and post-processing into a budget measured at the 99th percentile.

If predictions can be computed ahead of time, such as a daily list of recommended products per user or nightly churn scores, batch inference is simpler and cheaper: write the results to a key-value store and read them at request time. Online inference is needed when the prediction depends on request context, like the search query, the current cart or the transaction being authorized. Many systems mix the two, precomputing candidates in batch and ranking them online.

Budget latency at the 99th percentile, since users and upstream services feel the slow requests and the mean hides them. Split the budget across feature fetch, candidate retrieval, model scoring and business logic. When the model is too slow, the usual options are scoring fewer candidates, a smaller model trained by distillation from the large one, quantization, batching requests on a GPU, or caching scores for popular items. Each option gives up some quality or freshness for speed, so say which one you pick and why.

Training-serving skew is the serving-side version of leakage. The model was trained on features computed by a batch job, the online service recomputes them in different code with slightly different null handling or time zones, and predictions shift without any error being raised. Sharing one feature definition, logging the exact features used at serving time and training on those logs removes most of it. Also define a fallback: what the product shows when the model or the feature store times out.

Loading stage lessons…

Concepts to explore

Launch in steps and run an online experiment

Ship a new model through a shadow deployment, then a canary, then a randomized A/B test, with a rollback plan written before launch.

A shadow deployment runs the new model on live traffic and logs its outputs without acting on them. It catches crashes, latency regressions and differences between offline and online feature values with no user exposure. A canary then sends a small share of real traffic, often a few percent, to the new model, with automatic rollback if error rate or latency crosses a threshold you set in advance.

The decision to ship comes from a randomized experiment. Choose the primary online metric and the guardrails before the test starts, compute the sample size needed to detect the smallest effect you care about, and run for full weekly cycles so weekday patterns do not bias the result. Watch for interference: in marketplaces and social products, treated users can change what control users see, which is why some teams randomize by region or by time slot instead of by user.

Write the rollback plan before launch. Keep the previous model version in the model registry along with the feature definitions it expects, so reverting is a configuration change. Rollback gets harder when the new model writes state that the old one cannot read, such as new embeddings, caches or user profiles, so call that out in the design.

Loading stage lessons…

Concepts to explore

Monitor the system and decide when to retrain

Monitor inputs, predictions and outcomes, treat drift alerts as a reason to investigate, and plan for the loop between the model and its own training data.

Monitoring works in layers. Service health (errors, latency, throughput) pages the on-call engineer. Data checks catch broken pipelines: null rates, schema changes, a feature that suddenly reads zero everywhere. Prediction monitoring tracks the score distribution and the share of positive decisions. Outcome monitoring compares predictions with labels once they arrive, which for delayed labels can mean days or weeks later. A sudden drop in model quality is often an upstream data bug, so check the data layer first.

Drift detection compares recent feature or score distributions with a reference window, using statistics such as the population stability index or a Kolmogorov-Smirnov test. An alert is a prompt to look. Seasonality, a marketing campaign and a pipeline bug can all trigger one. Concept drift, where the relationship between inputs and the label changes (fraudsters adapting to your rules, for example), only becomes visible once labels arrive, which is why outcome monitoring matters even when input distributions look stable.

Retraining cadence follows from how fast the world changes and how fast labels arrive. Ads and feeds often retrain daily or continuously, while many fraud and churn models retrain weekly or monthly. Each retrained model should pass the same offline evaluation and a short canary before replacing the current one. Plan for feedback loops as well. A recommender trains on clicks it caused, so without some exploration traffic it narrows toward what it already shows and new items never collect enough data to compete.

Loading stage lessons…

Concepts to explore

Outcomes

What you will be able to do

  • Turn a vague prompt like "design a feed ranker" into a decision statement with a label definition, an offline metric, an online metric and at least one guardrail.
  • Find leakage and training-serving skew in a proposed pipeline and fix them with point-in-time joins, time-based splits and logged serving features.
  • Sketch a retrieval and ranking funnel for a large catalog and explain roughly how many items each stage handles and why.
  • Fit a design into a p99 latency budget by choosing between batch and online inference, distillation, caching and scoring fewer candidates.
  • Plan a launch with a shadow deployment, a canary and an A/B test, including the guardrails you check and the rollback path.
  • Design monitoring that tells pipeline bugs apart from real drift, and pick a retraining cadence that matches how quickly labels arrive.
The learning bundle

The ML system design bundle

Follow a system decision from framing and labels through point-in-time features, model and retrieval choices, evaluation, serving, release and monitoring. The bundle includes the design modules and the technical lessons needed for those decisions, including distributed failures and experiment gates.

You can read every module title here. Lessons open with their listed membership level. The bundle brings together worked examples, practice and reviewed assessments.

Browse the bundle

Loading the published module list…

Annual membership

Memberships that include this learning path

An ML system design round tests judgment you have to explain out loud, so the Career membership is the plan built for it. It opens the System Design bundle along with every other published career and technical module, and adds Peer mock interviews, where another member plays the interviewer in a system design room and asks the follow-up questions while you design. If you already run these systems at work and want technical depth more than interview practice, the Technical membership opens the learning paths behind most concepts on this page for 12 months: Recommender Systems, ML Evaluation, and ML Libraries and Platforms, which has a module on shadow, canary and blue-green deployment. The System Design bundle itself is not part of Technical.

Loading current plans and prices…

Questions about ML system design »

Keep exploring
References

Sources and further reading

See all topic maps