KatInterview

Design a Video Ad Insertion Platform for Streaming

System DesignModel answer
HardModel answerSystem Designadsreal-time-biddingstreaming

Last updated

Design a low-latency, fault-tolerant ad-insertion system for a live and on-demand video platform, covering decisioning, delivery, pacing, and measurement at scale.

Background

You are a senior engineer at a large video streaming platform serving both live events and on-demand content. The platform needs a dedicated ad-insertion system that can handle hundreds of millions of daily active users, real-time ad auctions, and live-stream spikes — all without ever stalling playback.

Task

Design the end-to-end ad-insertion platform for this service. Walk through your reasoning at each step: requirements gathering, API design, data model, architecture, and key technical deep dives.

Your design should address:

  • Ad formats and delivery modes — pre-, mid-, and post-roll ads; live vs. VOD; server-side vs. client-side insertion; VAST/OMID support.
  • Ad decision engine — how candidate ads are selected, ranked, and assembled into a break (pod) under 100 ms p99 latency at the edge.
  • Targeting and personalization — geo, device, demographic, and contextual signals; user segment lookups; brand safety.
  • Pacing and frequency control — budget pacing curves, frequency caps per user and per household, cross-device deduplication.
  • Programmatic demand — how to integrate with real-time bidding (RTB) exchanges alongside direct-sold campaigns.
  • Measurement — impression counting, quartile events (25/50/75/100%), clicks, and viewability.
  • Live stream thundering herd — how to handle 10M concurrent viewers all hitting the same mid-roll break within a 2-second window.
  • Fault tolerance and multi-region failover — what happens when a dependency is slow or unavailable.
  • Privacy compliance — how to handle GDPR/CCPA consent signals and limit-ad-tracking flags.
  • Experimentation — how to A/B test ad policies such as pod length, frequency caps, or auction logic.

Scale assumptions to work with

  • 100M daily active users; roughly 2B ad requests per day (~23K average QPS, ~100K peak for VOD).
  • Live spike scenario: 10M concurrent viewers reaching a mid-roll cue within ~2 seconds.
  • Beacon volume: ~6 measurement events per impression, 500K+ events/s at peak.
  • Target availability: 99.99%. The system must never block playback — fail open to a house ad or slate.
  • Active-active multi-region deployment.

What is expected

Treat this as a real design conversation. State your assumptions, propose concrete numbers and data structures, acknowledge trade-offs, and explain why you made each choice. A strong answer covers the full breadth of the problem and dives deep on at least the latency budget, the live-spike handling, and the pacing mechanism.

Hints

Hint 1

Start by separating two distinct problems: the ad decision problem (which ad wins?) and the ad delivery problem (how does it reach the player seamlessly?). These have very different latency and throughput characteristics.

Hint 2

The live thundering herd is the hardest scaling challenge. Think about what changes if you group viewers into cohorts and run one auction per cohort rather than one per viewer — and what you can precompute in the SCTE-35 lead time before the break begins.

Hint 3

A global lock for frequency capping and budget pacing won't meet your latency target. Consider what consistency guarantees you actually need: is slight over-delivery acceptable, and if so, what distributed counter design lets you trade perfect accuracy for speed?