Design an Ads Bidding, Pacing, and Forecast Platform
Design an online bid and budget-pacing path backed by a rule-based pacer and a versioned machine-learning forecast pipeline with a safe fallback.
Problem statement
Design an advertising bidding system that paces an active campaign's budget across its delivery interval. For this exercise, a campaign has a stable ID, budget, delivery interval, bid ceiling, and version; each eligible auction opportunity asks for one decision and receives either no-bid or a bid bounded by the campaign. A rule-based pacer is the accepted baseline and must choose a target spend curve over delivery time, adapting boundedly to under-delivery or traffic spikes without spending beyond durable budget authority. A stable decision identity reserves bounded campaign budget, and a stable outcome event finalizes actual spend or releases unused reservation so retries, duplicates, and reordered outcomes do not double count or commit spend above the campaign budget. Add a machine-learning forecast pipeline that derives versioned forecasts of future opportunity and cost conditions from auction, decision, and outcome evidence, validates and publishes immutable forecast versions, and lets compatible serving nodes use them. If a forecast is absent, stale, incompatible, or unavailable, serving falls back to the rule-based pacer rather than failing open. For this exercise, assume up to 100,000 bid decisions per second globally, a p99 decision latency below 50 ms, 99.99% monthly availability for the online decision path, and an immutable compatible forecast published at least hourly and treated as stale after two hours. Explain how these authored targets drive partitioning, state placement, publication, and fallback. Creative storage and rendering, user-profile construction, organic ranking, advertiser invoicing, and payment settlement are outside scope.
What to build
- An authorized operator can publish and inspect versioned campaign budget, delivery-interval, and bid-ceiling inputs used by serving.
- The serving path can return one retry-safe no-bid or bounded-bid decision while reserving the decision's bounded budget exposure.
- A stable auction outcome can finalize spend or release unused reservation exactly once without allowing committed spend to exceed the campaign budget.
- A pipeline can build, validate, version, publish, and monitor pacing forecasts, while serving uses only compatible forecasts and falls back to the rule-based pacer when needed.
At scale
- The online path must support up to 100,000 bid decisions per second globally with p99 decision latency below 50 ms and 99.99% monthly availability.
- Concurrent decisions for one campaign share a finite budget, so the design must bound reservation and settlement races and define behavior under uncertain state.
- Forecast construction is asynchronous relative to serving; publish an immutable compatible forecast at least hourly, treat forecasts older than two hours as stale, and retain a rule-based online fallback.
- The throughput, latency, availability, cadence, and staleness values are authored exercise assumptions rather than reported source facts.