Design an ads event reporting system
PinterestSoftware Engineer · OnsiteLast updated
This question tests the ability to design a high-throughput, fault-tolerant system for tracking ad interaction events, focusing on scalability, exactly-once processing, and analytical query performance.
Problem Statement
Design an ad event reporting system for a platform like Pinterest, where advertisers need to track user interactions (clicks, impressions, conversions) in real-time.
Functional Requirements
- Record ad events (e.g., event_id, ad_id, user_id, timestamp, event_type).
- Provide an API for advertisers to query historical event counts grouped by specific dimensions (e.g., daily clicks per ad_id).
Non-Functional Requirements
- Scale: Handle 500,000 events per second at peak.
- Latency: Data should be queryable for analytics within a few minutes of event occurrence.
- Correctness: Minimize data loss and handle duplicate events gracefully.
- Durability: Event data must be archived for long-term audits.
Scope
Design the ingestion pipeline, storage strategy, and processing layer. Address how the system handles the massive volume while ensuring data accuracy for billing purposes. You do not need to build the frontend dashboard.
Hints
Hint 1
Consider using a distributed message queue like Kafka to act as a buffer between the ingestion servers and the processing layer.
Hint 2
Decide whether to use a Lambda architecture (combining batch and stream processing) or a Kappa architecture to handle the requirements.
Hint 3
Think about how to handle deduplication at scale, specifically focusing on the trade-offs between storage costs and processing latency.
Follow-up questions
- How would you handle a scenario where event timestamps are significantly delayed due to network partitions?
- If advertisers require sub-second query latency for the last 60 minutes of data, how would you modify your storage architecture?
- How would you ensure that your system is resilient to a regional data center failure?
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.