Design real-time ad impression and spend tracking
Design Real-time Ad Impression and Spend Tracking
You are tasked with building a backend system for an ad server. This system's primary role is to track ad impressions (view counts) and spend in near real-time, enabling the ad server to make immediate decisions about ad delivery. Specifically, the system must support an ad server that evaluates up to 10,000 candidate ads per user request, requiring current impression and spend counters to filter and score these ads. The ad server's request path must maintain low latency, ideally in the single-digit to tens of milliseconds for counter retrieval. The system needs to handle high query-per-second (QPS) rates for both event ingestion and read traffic. Accuracy of counters is critical for budget enforcement, and you should clarify acceptable data freshness and consistency models.
Requirements:
- Event Collection: Record an event for each ad view, including at least
ad_id,campaign_id,user_id(optional),timestamp, and any fields necessary for spend computation. - Near Real-time Decisioning: Support an ad server evaluating up to 10,000 candidate ads per request, requiring up-to-date impression and spend counters.
- Latency: Ad server request path for fetching counters should be low-latency (single-digit to tens of milliseconds).
- Scale: Handle high QPS for both event ingestion and read traffic.
- Correctness: Counters must be accurate enough for budget enforcement; clarify acceptable freshness and consistency.
Deliverables:
Design the end-to-end system, including:
- APIs for event ingestion and ad server reads.
- Data model.
- Storage and streaming components.
- Efficient serving of counters for 10,000 ads per request.
- Strategies for handling duplicates, retries, and late events.
- Monitoring and failure recovery mechanisms.
AI interview prep
Core dilemma
Balancing the need for extremely low-latency counter reads for ad serving against the high volume and potential eventual consistency of impression/spend event ingestion.
3 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design real-time ad impression and spend tracking
Design Real-time Ad Impression and Spend Tracking
You are tasked with building a backend system for an ad server. This system's primary role is to track ad impressions (view counts) and spend in near real-time, enabling the ad server to make immediate decisions about ad delivery. Specifically, the system must support an ad server that evaluates up to 10,000 candidate ads per user request, requiring current impression and spend counters to filter and score these ads. The ad server's request path must maintain low latency, ideally in the single-digit to tens of milliseconds for counter retrieval. The system needs to handle high query-per-second (QPS) rates for both event ingestion and read traffic. Accuracy of counters is critical for budget enforcement, and you should clarify acceptable data freshness and consistency models.
Requirements:
- Event Collection: Record an event for each ad view, including at least
ad_id,campaign_id,user_id(optional),timestamp, and any fields necessary for spend computation. - Near Real-time Decisioning: Support an ad server evaluating up to 10,000 candidate ads per request, requiring up-to-date impression and spend counters.
- Latency: Ad server request path for fetching counters should be low-latency (single-digit to tens of milliseconds).
- Scale: Handle high QPS for both event ingestion and read traffic.
- Correctness: Counters must be accurate enough for budget enforcement; clarify acceptable freshness and consistency.
Deliverables:
Design the end-to-end system, including:
- APIs for event ingestion and ad server reads.
- Data model.
- Storage and streaming components.
- Efficient serving of counters for 10,000 ads per request.
- Strategies for handling duplicates, retries, and late events.
- Monitoring and failure recovery mechanisms.