Design an ad click prediction system
PremiumML systemMedium
- CTR prediction
- Calibration
- Log loss
Quick answer
This ML system interview question asks you to design an ad click prediction system. Aim for a design that turns data into useful predictions in production, then explain the data, training, serving and monitoring. Interviewers want to see how you frame the problem, measure success and keep the model healthy after launch.
The problem
Design an ad click prediction system like the ones behind Google and Meta ads: a model that predicts the probability a user clicks each candidate ad, used by the auction to choose and price ads. The hard parts are calibrated probabilities (not just a good order), billions of training events a day and ads that change hourly.
The auction ranks candidates by bid × predicted click-through rate (pCTR) and charges advertisers per click. If pCTR is too high for some ads, they win auctions they should lose, users see worse ads and revenue drops, so the number itself must be right, not just the order.
What must an ad click prediction system do?
- Score candidates: For each ad request, return pCTR for up to 200 candidate ads.
- New ads: A brand-new ad gets a sensible pCTR from its first impression.
How well must it do it?
- Calibration: Sum of predicted clicks within ±2% of actual clicks overall and for each large advertiser.
- Latency: Scoring 200 candidates takes no more than 15 ms p99.
What scale should you design for?
Use these numbers in your estimates.
The scale numbers unlock with this questionUnlock
Key concepts
- CTR prediction
- Calibration
- Log loss
- Negative downsampling
- Feature hashing
- Online training
How you’ll practise
- Problem framing
- Data and labels
- Features and model
- Training and evaluation
- Serving and monitoring
- Wrap-up
Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.
What do interviewers look for?
In any ML system design round.
- Frames the product goal as a clear ML problem
- Defines offline and online success metrics
- Explains where the data and labels come from
- Separates training from serving and keeps features consistent
- Plans for drift, retraining and rollbacks
- Weighs model quality against latency and cost
Questions people ask about this interview question
- Which design type is this question?
- It is an ML system question. You design an ad click prediction system and explain your choices the way you would in an interview.
- Is this question asked at entry level?
- It is marked Medium. Entry-level engineers can practise it, but it expects you to reason about requirements and trade-offs, not only list components.
- What should I cover first?
- Start with the product goal, how success is measured and what data is available. Agree on scope with the interviewer before you design anything.
- Can I practise it for free?
- It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.
Related questions
Updated · Written by the SevyDevy team