MSD0062 Ads Ranking System

When a user opens Facebook or Instagram, Meta’s ad system has a few tens of milliseconds to decide which ads fill the slots in the feed, chosen from millions of active campaigns. Unlike organic ranking, the score must combine the advertiser’s bid with predicted click-through rate (pCTR), predicted conversion rate (pCVR), and ad quality signals, so the platform maximizes long-term revenue without degrading the user experience.

The system runs a real-time auction per impression, calibrates predicted probabilities so that a pCTR of 0.05 really means 5 percent of similar impressions click, respects advertiser budgets and frequency caps, and suppresses low-quality or misleading ads. It must serve in under 50 milliseconds per impression, handle billions of impressions per day, and retrain continuously on fresh click and conversion data.

How would you design this system? Cover the ad candidate retrieval architecture, the CTR/CVR prediction model (logistic regression vs GBDT vs deep learning), the calibration strategy (Platt scaling vs isotonic regression vs temperature scaling), the auction mechanism (first-price vs second-price vs Vickrey-Clarke-Groves), budget pacing and frequency capping, and how you evaluate ads ranking quality beyond revenue.

Line-art scene: a person opening a feed with one ad slot, a question mark between the slot and a stack of ten million campaigns each carrying a bid, with a stopwatch showing 50 ms

The Problem: one feed slot, millions of eligible campaigns with different bids and budgets, and under 50 milliseconds to decide who fills it and what they pay.

Answer

The design is a cascaded funnel feeding a per-impression auction: targeting filters plus approximate nearest-neighbour retrieval cut millions of campaigns to about ten thousand, a cheap ranker keeps a few hundred, a heavy multi-task deep model predicts pCTR and pCVR for those, and the auction ranks by expected value per impression. Two decisions dominate everything else. First, the probabilities must be calibrated in absolute terms, not merely well ordered, because the bid is multiplied by them and prices are derived from them. Second, budgets and fatigue are handled by a closed-loop pacing controller and serving-time frequency counters rather than by the model, so spend stays smooth and the ranking model keeps a single clean objective.

(1) Cascaded Retrieval: hard targeting and budget-eligibility filters run first, then embedding retrieval over the remaining inventory; the funnel is 10^{7} \to 10^{4} \to 500 \to 1 per request.
(2) Multi-Task Deep Ranker: one network with shared sparse embeddings and separate pCTR and pCVR heads, replacing the historical logistic-regression-on-GBDT-leaves stack while keeping trees for the light ranker.
(3) Calibration As A First-Class Stage: per-slice isotonic regression on recent traffic, monitored by expected calibration error, because relative probability biases across ads or slices distort ranking and second-price payments.
(4) Total-Value Auction: rank by bid times predicted action rate minus a quality penalty, bill second-price style so the winner pays the minimum needed to keep its position.
(5) Pacing And Caps Outside The Model: a PID controller adjusts a per-campaign bid multiplier toward the daily budget curve, and a low-latency counter store enforces frequency caps at serving time.
(6) Continuous Retraining: impressions joined with clicks and delayed conversions stream into hourly incremental refreshes, with an exploration budget so new ads can earn data.

Ads ranking pipeline: ad request, targeting and retrieval, light ranker, heavy CTR/CVR model, then calibration, auction, pacing and caps, and ad delivery, with a training pipeline consuming logs and refreshing the models

Figure 1: The serving funnel: each stage uses a progressively more expensive model on far fewer candidates (10M to 10k to 500 to 1), and every delivered impression flows back as training data.

Clarify Before Designing:
(1) Bid Types: are advertisers bidding per click, per conversion, or on value-based lookalike objectives, and do we owe them an outcome guarantee such as cost-per-result?
(2) Slot Structure: one ad per request or several slots per session, and are ads interleaved with organic content (which makes the opportunity cost an organic post, not another ad)?
(3) Latency And Slot Count: is the 50 ms budget end to end including retrieval, or only model inference, and how many ads must be scored inside it?
(4) Conversion Signal: what is the attribution window and how much conversion feedback is delayed or lost to privacy restrictions on third-party signals?
(5) User Experience Constraint: what is the hard limit on ad load and negative feedback (hide-ad rate, reports), and is it a constraint or part of the objective?
(6) Advertiser Mix: what fraction of spend comes from a few large advertisers versus a long tail of small ones, since that decides how much cold-start exploration matters?


Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *