Design an ads audience targeting system
NetflixSoftware Engineer · Technical ScreenLast updated
This problem evaluates your ability to design a high-scale, low-latency system for filtering user profiles against complex, dynamic advertising audience segments.
Problem Statement
Design a service that determines in real-time whether a specific user belongs to one or more advertising audiences. Advertisers define audiences based on user attributes (e.g., location, watch history, device type, subscription tier) and behavioral events.
Requirements
- Functional: Provide an API endpoint
is_in_audience(user_id, audience_id)that returns a boolean. - Functional: Support asynchronous ingestion of user attribute updates and audience definition changes.
- Non-Functional: The system must handle millions of concurrent users with sub-50ms latency for membership checks.
- Non-Functional: Support complex boolean logic in audience definitions (e.g., "Users in 'US' AND ('Action' genre fans OR 'New Subscribers')").
Scale
- 300 million active users.
- 50,000 active audience segments.
- Peak load: 100,000 requests per second for membership checks.
Your Answer Should Include:
- High-level architecture diagram and service components.
- Data model strategy (storage for user profiles vs. audience definitions).
- Mechanism for keeping the audience membership state up-to-date.
- Discussion on handling "cold-start" scenarios and query optimization techniques.
Hints
Hint 1
Consider pre-computing membership caches or using Bitsets/Roaring Bitmaps to represent audience sets.
Hint 2
Think about whether to push user-attribute updates to audience segments or pull audience definitions into a local service cache.
Hint 3
Use a publish-subscribe model to propagate changes in audience criteria across your distributed service nodes.
Follow-up questions
- How would you handle a scenario where an advertiser updates an audience definition that currently contains millions of users?
- How would you ensure data privacy and PII compliance when storing and processing user attribute data?
- If the latency budget decreases to 5ms, what changes would you make to the architecture?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.