System Design

Ad Budget Pacing

Design budget enforcement and pacing for an ad platform like Google Ads or Meta Ads.

Functional requirements

  • Advertisers set a daily budget per campaign (e.g., $500/day) that resets at midnight in their time zone; a campaign stops serving once the day's budget is spent.
  • On every ad request, the serving node decides which candidate campaigns in its auction are still eligible to serve given their remaining budget.
  • Spend is paced evenly across the day by default so a $500 budget is not gone by 9am; advertisers can opt into accelerated delivery.
  • Track each campaign's spend from the platform's spend signal stream (billable impression and click events with prices, produced by the existing click aggregation pipeline).
  • Advertisers can see spend so far today (updated within a minute) and can raise, lower, or pause a budget mid-day with effect within a minute.

Non-functional requirements

  • The eligibility decision is on the ad-serving hot path: p99 under 1ms per request for up to 200 candidates, answered from node-local state with no remote call.
  • Bounded overspend, not zero: availability of serving wins over exact enforcement, but overspend stays under 5% of a campaign's daily budget in normal operation, and the platform absorbs (never bills) spend beyond the budget.
  • Pacing must not starve delivery: a campaign with enough demand spends 90-100% of its budget by end of day.
  • Durability: the reconciled spend ledger billing reads is exact and durable (every billable event counted once, every billed dollar traceable to its events); serving counters may be approximate.
  • Availability: if the budget service or spend stream is unreachable, nodes keep serving on last known state for at least 5 minutes with overspend still bounded; budget changes and pauses reach every node within 60 seconds.

Scaling & constraints

  • 5,000 ad-serving nodes in 5 regions handle 2M ad requests per second at peak, each evaluating up to 200 candidate campaigns: ~400M eligibility checks per second.
  • 10M active campaigns with daily budgets from $5 to $5M; the top 1,000 produce ~30% of spend, and one hot campaign can spend $2,000 per minute.
  • The spend stream delivers ~1M billable events per second at peak (~200 bytes each), arriving p50 5 seconds and p99 30 seconds after the ad was served, up to 5 minutes late in a pipeline incident.
  • Billing truth arrives in hourly batches finalized 2 hours later, differing from the real-time estimate by 0.5-2% (invalid clicks removed, late events added).
  • About 500,000 campaigns are active in any 5-second window; a campaign's traffic can jump 10x within a minute (a TV spot airs).
  • Skew: 60% of each region's requests fall in a 6-hour window, and ~400,000 campaigns share the same midnight reset in the largest time zone.

Out of scope

  • Auction mechanics, bidding, and ad ranking (an auction module consumes the eligibility decision).
  • Click and impression counting, fraud filtering, and invalid-traffic removal (the existing aggregation pipeline produces the spend stream).
  • Invoicing, payment collection, and advertiser credit limits.
  • Campaign management UI and audience targeting.

Sign in to save your progress

AI design evaluation

Get a score, what your board does well, what to fix first, and what an interviewer would ask next.

Sign in to evaluate

Sign in to get AI feedback on your design.