ML SYSTEM DESIGN (DEEP DIVES) · INTERVIEW QUESTION
Design an ads CTR prediction and auction system for a major web property (100k QPS, 50ms budget).
🔴 advanced · Ads / CTR
Hint: Calibration matters as much as discrimination; delayed feedback; cold-start; pacing; deep CTR architectures.
Answer
1. Problem Formulation
"Predict click-through rate for sponsored ads." The business goal is revenue, not raw CTR.
Clarifying questions:
- Scale? ~100k auctions/sec peak, ~20 ads per auction. Latency budget: 50 ms for the full auction including model scoring.
- Auction type? Assume CPC bids and quality-adjusted generalized second-price (GSP). Rank by bid_per_click × pCTR (plus explicitly defined quality rules). A simplified click price is the next eligible score divided by the winner's pCTR, subject to reserves and auction rules. Expected revenue uses that payment, not the bid. For CPA bids, a separate value score could be bid_per_acquisition × pCTR × pConversion_given_click; do not mix bid units.
- Objective? Expected revenue per auction = Σ pCTR(ad) × bid(ad) for ranking. But long-term, also advertiser ROI (otherwise advertisers churn) and user experience (otherwise users tune out).
- Constraints? Cold-start for new ads/campaigns (no historical CTR). Privacy: post-ATT/Privacy Sandbox, much less device-level signal. Fairness/policy: no discriminatory targeting on protected attributes.
Why ML? CTR varies by orders of magnitude across (user, ad, context). Rules cannot capture this. ML beats hand-tuned rules by ~10× in revenue.
ML framing: binary classification (click / no-click), but the use of the prediction is in a ranking + bidding system, so calibration is as important as discrimination.
2. Metrics
Offline:
- Log-loss (proper scoring rule, rewards calibration).
- Calibration plots and expected calibration error per decile — uncalibrated CTR breaks the auction.
- AUC as a secondary check on ranking quality.
- Relative improvement on log-loss vs production — typical wins are 0.1–0.5%, which translate to meaningful revenue.
Online:
- Revenue per mille (RPM).
- CTR (sanity), conversion rate, return on ad spend (ROAS) for advertisers.
- Guardrails: ad density per session (don't over-show), user-reported "irrelevant ad" rate, advertiser churn.
Trade-off: pure CPC bid × pCTR may favor clickbait. Use explicit quality and satisfaction constraints and monitor conversion value; changing to a conversion-based objective requires declaring its bid units and corresponding pricing rule.
This is the opening of a longer walkthrough. Read the full answer in the topic explorer, free.
Likely follow-up: How do you handle delayed clicks in the training pipeline without bias?
Related questions
- Design a YouTube-scale video recommendation system serving billions of users.
- Design a production RAG system for an enterprise knowledge assistant (10TB docs, 50k employees, ACL-aware).
- Design a real-time payment fraud detection system (10k+ TPS, 100ms decision budget, delayed labels).
- Design X (Twitter) home timeline ranking — including in-network and out-of-network candidate sources.
- Design a visual search system (Pinterest-style) over 5B+ images with sub-500ms p95 latency.