Design Candidate Retrieval Over Millions of Active Ads
Last updated: November 29, 2026
Quick Overview
Before the heavy ads ranker runs, Meta must pick a few thousand eligible ads per request from millions of active campaigns. Design the retrieval stage, including targeting filters, embedding retrieval and budget awareness.
Meta
November 29, 20260
0
0 solved
Before the heavy ads ranker runs, Meta must pick a few thousand eligible ads per request from millions of active campaigns. Design the retrieval stage, including targeting filters, embedding retrieval and budget awareness.
Ads retrieval is the first stage of the ads funnel and sets the ceiling for ranking quality. Interviewers check that you handle hard targeting constraints, learned relevance retrieval, freshness of new campaigns and the latency budget.
What the Interviewer Expects
- Separates hard eligibility filters from learned relevance retrieval
- Uses a two-tower user and ad embedding with ANN lookup
- Indexes targeting attributes for fast eligibility filtering
- Accounts for budget pacing and frequency caps at retrieval time
- Measures retrieval recall against what the full ranker would pick
Key Topics to Cover
How to Approach This
- Start by mapping the business objective to a concrete ML objective and metric.
- Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
- Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
- Address the serving latency budget and whether batch or real-time inference is needed.
- Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
- How do you retrieve a brand new ad with no engagement history?
- How do you make sure small advertisers are not starved by retrieval?
- How do you measure the recall loss from retrieval?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice ML System Design ProblemsSample Answer
Requirements
- Millions of active ads, each with targeting (location, age, interests, custom audiences), budget and schedule.
- Per request, return about 2k to 5k candidates in under 30 ms.
- Downstream: early-sta...
High-Level Design
- Eligibility: inverted index from targeting attributes to ads (country, age bucket, gender, language, interest ids, custom audience membership). For the user's attributes, intersect posting list...