KatInterview

ML-Driven Budget Pacing System for Programmatic Advertising

Machine LearningModel answer
HardModel answerMachine Learningml-system-designadsforecasting

Last updated

Design an end-to-end system that forecasts ad inventory and prices, dynamically paces campaign spend, and enforces hard budget caps across hundreds of thousands of concurrent campaigns.

Context

An advertising platform serves hundreds of thousands of active campaigns each day. Advertisers set a daily or lifetime budget and choose a bidding objective — for example, a target cost-per-acquisition (CPA), a target cost-per-click (CPC), or maximum reach. The platform participates in auctions on their behalf.

Without deliberate pacing, campaigns tend to exhaust their budgets in early-morning traffic surges when competition is low and inventory is cheap — but those impressions may be far less valuable than those available at peak hours. At the same time, pacing that is too conservative causes under-delivery, which means the advertiser does not get what they paid for.

Your task is to design a complete ML-based forecasting and budget pacing system that:

  • smooths spend across the day relative to where the highest-value impressions are;
  • adapts in near-real-time as actual spend diverges from the plan;
  • provides a hard, deterministic guarantee that no advertiser is ever billed above their budget, regardless of model errors or infrastructure lag.

Scale

  • 500,000 active campaigns per day
  • 5 billion auction opportunities per day (~60,000 QPS average, 150,000 QPS peak)
  • Pacing decisions must complete within 5 ms p99 on the live auction path
  • Pacing parameters must refresh every 1–5 minutes based on live spend

What to Cover

Structure your answer around these five areas:

  1. Architecture: How do the offline training pipeline, the near-real-time pacing control loop, and the live auction path relate to each other? What is the data flow and where does state live?

  2. ML Formulation: How do you forecast 24-hour inventory supply and clearing-price distributions per audience segment? What features do you use, what model architecture, and what loss function? How does the forecast feed into a pacing controller — specifically, what optimization framework governs the bid multiplier or throttle probability?

  3. Hard Budget Enforcement: Design a mechanism that makes budget overrun structurally impossible, independent of ML correctness. Walk through exactly how a campaign gets cut off when it approaches its limit.

  4. Training Data and Delayed Feedback: Ad conversions can arrive minutes to days after the auction. How do you build training sets without leaking future information, and how do you handle labels that have not yet arrived at training time?

  5. Experimentation and Monitoring: Pacing arms share the same auction marketplace, which breaks the standard A/B testing assumption of independent units. How do you run valid experiments? What metrics and drift signals do you monitor in production?

Hints

Hint 1

Start by separating concerns: ML controls *how* budget is spent (bid shaping), while a deterministic leasing layer controls *whether* a bid can proceed. These two paths should never share a code path at auction time.

Hint 2

For the pacing controller, think about the Lagrangian dual of a budget-constrained value-maximization problem. The optimal bid is proportional to value divided by (1 + λ), where λ is a per-campaign multiplier you update via gradient descent on the spend error.

Hint 3

Delayed conversion feedback means your training labels arrive after the fact. The standard fix is to close training partitions only after a fixed observation window has elapsed, and to use importance weighting or a survival model to handle examples whose label has not yet fully materialized.