“Design a model-serving system that predicts whether a user will click an ad.”
Assume the system receives an eligible candidate set and scores it before an ad-selection service chooses what to show. We will design click prediction and its learning loop, not a complete auction or billing platform. Suppose peak traffic is 10,000 requests per second with 100 candidates per request and a 50 ms scoring budget. All figures are illustrative.
01. Clarify what the probability means
Define the target as a click on a rendered impression within a documented attribution window. Clarify whether the model predicts at a known placement or before a final position is chosen. Position affects exposure, so training labels must match the intended serving context.
The output estimates P(click | candidate, user context, placement context). It is not the probability that an ad causes an incremental purchase. Click prediction, conversion attribution, and causal incrementality are different tasks.
Track probabilistic quality and product outcomes separately. A selector optimizing only clicks may favor misleading creative, so negative feedback and advertiser outcomes belong in the broader product evaluation.
02. Join impressions to outcomes
Record a unique impression ID, candidate and campaign IDs, context, placement, feature versions, and model version. Join clicks to impressions, deduplicate repeated events, and wait for the label window before treating an impression as a negative.
Use past engagement aggregates, candidate content, placement, and permitted user-context features. Avoid future campaign totals and post-impression interactions. Restrict access and retention to match the purpose of the data.
If negatives are sampled for training efficiency, preserve or correct their sampling weights and validate calibration on representative traffic. A balanced training sample does not imply a 50% deployment click rate.
03. Establish a baseline and serving pipeline
Begin with regularized logistic regression over sparse categorical and numerical signals. Compare richer interaction models against that baseline only after the data and label joins are reliable.
Compute request-level features once, reuse cached ad features, and score candidates in batches. The assumed load implies one million candidate evaluations per second, so benchmark model operations and feature-fetch overhead separately.
Use a deadline and an explicit fallback scorer for missing or slow dependencies. Keep model, feature schema, and calibration mapping compatible across releases.
04. Check ranking and calibration
Use held-out log loss and calibration diagnostics alongside discrimination metrics. Segment by placement, campaign age, device, and traffic source. A good global average can hide systematic overprediction for new campaigns.
Suppose ad A has estimated click probability 0.02 and a value of 3 units per click, while B has probability 0.04 and value 1. Their simple expected values are 0.06 and 0.04. This explains why probability scale can affect ordering in a downstream value calculation. It is not a complete auction formula.
Run a controlled rollout with guardrails. Logged impressions come from the previous selection policy, so offline estimates are affected by exposure. Claims about alternative policies require appropriate experimental or counterfactual assumptions.
Connected fundamentalRanking well is not the same as predicting probabilities ↗
Learn how to measure and fit calibration.
05. Defend the operating choices
“A new campaign has no click history.”
Use content and context features, explicit missing-history handling, and a controlled exploration policy. Avoid interpreting missing history as poor performance.
“CTR rises but advertiser value falls.”
Validate attribution and cohort mix, then inspect whether clicks became less valuable or more misleading. A click model cannot alone define the product's objective.
“Why not retrain on every event?”
Online updates can adapt quickly but complicate label delay, reproducibility, rollback, and feedback loops. Compare their benefit with a reliable batch cadence before adding that complexity.
Using unrendered candidates as negative impressions, ignoring sampling-induced calibration changes, or presenting click prediction as causal conversion lift.
Your answer in one minute
“I would define the impression and click window, build reliable event joins, and start with a regularized baseline. I would batch candidate scoring under a deadline, evaluate probabilities and cohorts, and keep selection policy separate from the model. Calibration, cold starts, and exposure bias would be explicit parts of the design.”
Sources & further reading
McMahan et al.: Ad Click Prediction, a View from the Trenches is a historical production paper, not a specification of current ad systems. Architecture and numerical examples here are original teaching proposals.
Continue your preparation
Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.