Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Competitive Ad Exclusion Service

Design a sharded serving-time service that prevents configured competitor ads from appearing too close together for one viewer and movie.

Problem statement

Design a service that enforces advertiser-configured competitive exclusion windows. When evaluating an advertisement for a viewer and movie, the service must prevent the candidate advertiser's ad from being shown when a configured competitor has a committed impression inside the applicable interval.

The design must address sharding and a potentially long delay between the first eligibility check and the eventual impression.

For this exercise, assume each immutable policy version is directional: it names an owner advertiser, a competitor advertiser, a movie scope, and a trailing exclusion duration. A committed competitor impression for the same viewer and movie starts that window; symmetry requires a separately published mirror rule.

An eligibility request uses a stable request ID and may return a short-lived token, but the impression must be revalidated and committed against current authoritative state before rendering. Concurrent incompatible commits must not both succeed.

For this exercise, assume one million eligibility requests and one hundred thousand impression commits per second globally, ten billion active viewer-movie keys per day, exclusion windows up to seven days, and eligibility tokens valid for at most thirty minutes.

Healthy in-region eligibility should complete within 30 milliseconds at p99, policy activation should reach healthy serving nodes within 60 seconds, and acknowledged commits must survive one availability-zone failure. Return an explicit unavailable outcome when authoritative state is uncertain.

Retain decision audit data for thirty days. Ad ranking, auctions, targeting, creative storage, billing, identity resolution, and consent collection are outside scope.

What to build

  1. Authorized advertisers can publish, activate, and inspect immutable directional competitive-exclusion policy versions.
  2. The ad server can idempotently obtain an allowed-token, excluded, or unavailable result for a candidate advertiser, viewer, and movie.
  3. The caller can commit an impression only after current authoritative revalidation, or cancel an unused token, with retries converging on one result.
  4. Authorized operators can inspect the policy versions, conflict evidence, permit lifecycle, and terminal outcome for debugging and reconciliation.

At scale

  • For this exercise, assume one million eligibility requests and one hundred thousand impression commits per second globally, with ten billion active viewer-movie keys per day.
  • For this exercise, target 30 milliseconds p99 for healthy in-region eligibility and propagate activated immutable policy versions to healthy serving nodes within 60 seconds.
  • For this exercise, exclusion windows are at most seven days, eligibility tokens are valid for at most thirty minutes, and decision audit data is retained for thirty days.
  • For this exercise, acknowledged impression commits survive one availability-zone failure, and uncertain authoritative state returns unavailable rather than allowing a render.