Design an ads data model
NetflixSoftware Engineer · OnsiteLast updated
This problem tests your ability to design a scalable, reliable data schema for an advertising platform that must support high-throughput event ingestion and real-time analytical queries.
Design an Ads Data Model
Netflix is introducing an ad-supported tier and needs a robust data architecture to manage ad campaigns, targeting rules, and the massive stream of performance events (impressions, clicks, and skips).
Requirements
Functional Requirements:
- Store campaign metadata: Advertiser info, budget, creative assets, and targeting criteria.
- Ingest ad-interaction events: Each event includes
event_id,user_id,ad_id,timestamp,event_type(impression/click/skip), anddevice_metadata. - Support reporting: Advertisers need dashboards showing performance metrics aggregated by day, ad, and creative group.
Non-Functional Requirements:
- High write availability for event ingestion (billions of events per day).
- Low-latency retrieval for campaign metadata during ad selection.
- Data consistency for budget management (preventing overspending).
Your Task
- Define the core data entities and their relationships.
- Propose a storage strategy: Explain how you would separate the OLTP data (campaign state) from the OLAP data (event stream/analytics).
- Outline the data pipeline: How do raw events transition into an analytics-ready format?
- Address scale: Discuss your partitioning strategy for the event data and how you would handle event deduplication.
Hints
Hint 1
Consider using a relational database for campaign metadata to ensure ACID compliance for budget tracking.
Hint 2
For the massive event stream, evaluate the trade-offs between using a NoSQL store versus a data lake architecture (e.g., S3/Parquet).
Hint 3
Think about using a lambda or kappa architecture to bridge the gap between real-time monitoring and historical reporting.
Follow-up questions
- How would you handle late-arriving events that occur when a user is offline?
- How would you evolve your schema if an advertiser wants to add complex, custom targeting attributes to their campaign?
- If an ad campaign suddenly goes viral, how would you prevent a 'hot partition' issue in your event storage?
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.