Design an Audience Membership Cache for Ad Targeting at Auction Time
Last updated: November 29, 2026
Quick Overview
Design how Meta's ad delivery checks, for each impression opportunity, which of thousands of candidate ads' custom and lookalike audiences include the current user, using a cache that answers membership quickly for billions of users and millions of audiences.
Meta
November 29, 20260
0
0 solved
Design how Meta's ad delivery checks, for each impression opportunity, which of thousands of candidate ads' custom and lookalike audiences include the current user, using a cache that answers membership quickly for billions of users and millions of audiences.
Ads at Meta are targeted to custom audiences (advertiser-uploaded lists, website visitors) and lookalikes, and the auction must evaluate eligibility in milliseconds. The interviewer checks inverted data layout (user to audiences instead of audience to users), memory-efficient encodings, update propagation, and consistency with audience deletion or opt-outs.
What the Interviewer Expects
- Choose the user-to-audiences inverted index for the hot path
- Estimate memory and propose compact encodings
- Propagate audience updates with acceptable delay
- Enforce removals and privacy opt-outs quickly
- Shard and replicate for low-latency reads near ad servers
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- Would a Bloom filter per audience work? What are its failure modes?
- How do you handle an advertiser uploading a list of 50 million users?
- How fast must a user's opt-out from ad personalization take effect?
- How would you handle audiences defined by real-time rules like visited the site in the last hour?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: given user U and candidate ads (each with include and exclude audiences), return which ads U is eligible for. Audiences come from uploads (matched to users), pixel events (rules over t...
High-Level Design
Offline and streaming pipelines compute audience membership and write it into an audience membership store keyed by user: U -> sorted list of audience ids (with expiry times for rule-based audie...