Design an ML Forecasting and Pacing System for Ad Bidding
LinkedInMachine Learning Engineer · Technical ScreenLast updated
Design an ad forecasting and budget pacing architecture that combines predictive ML with deterministic budget guardrails to optimize campaign delivery across non-stationary traffic.
Scenario
On a major professional social network, advertisers run targeted campaigns (e.g., Sponsored Content, Job Posts) with specific daily or lifetime budgets and bidding objectives (e.g., target CPA, target CPC, or maximum delivery). Without intelligent pacing, campaigns often exhaust their budgets early in the morning during non-optimal traffic spikes, missing valuable impressions later in the day. Conversely, overly conservative pacing results in budget under-delivery.
Design an end-to-end ML forecasting and budget pacing system that smooths delivery throughout the day, optimizes advertiser ROI, and deterministically prevents budget overspend.
Requirements
Functional Requirements
- Traffic & Price Forecasting: Forecast inventory volume and clearing price distributions per audience segment over a 24-hour horizon.
- Dynamic Pacing Strategy: Dynamically compute pacing parameters (such as bid multipliers or auction participation probabilities) per campaign to spend the budget evenly or proportional to high-value opportunities.
- Deterministic Budget Enforcement: Guarantee zero budget overrun at the advertiser level regardless of ML errors or prediction lag.
- Time-Correctness & Delayed Feedback: Train forecasting and conversion models without lookahead bias, accounting for delayed attribution (e.g., clicks and conversions happening minutes to days later).
- Fallback & Safety: Automatically revert to safe heuristics during model inference failures or sudden auction market drift.
Non-Functional Requirements
- Scale: 500,000 active daily campaigns; 5 billion auction opportunities per day (~60,000 QPS average, 150,000 QPS peak).
- Auction Latency: Bid modification and pacing checks during the live auction must execute in under 5 ms (p99).
- Update Frequency: Pacing coefficients should refresh every 1 to 5 minutes based on live spend tracking.
Discussion Points
Your proposal should address:
- High-Level Architecture: Separation between the offline ML training pipeline, the near-line pacing control loop, and the online real-time bidding path.
- ML Formulation: Feature engineering, loss formulation, and model architecture for supply/price forecasting, alongside the feedback control mechanism (e.g., PID controller, dual-gradient descent) for pacing.
- Deterministic Guardrails: Architecture of the real-time budget counter and kill-switch mechanism decoupled from ML scoring.
- Data Pipeline & Calibration: How to handle delayed attribution labels without leaking future states, and how to calibrate pacing parameters.
- Experimentation & Monitoring: Strategy for A/B testing pacing algorithms in a shared auction marketplace and detecting distribution drift.
Hints
Hint 1
Decouple the statistical pacing parameter generator (e.g., bid multiplier or throttling probability) from the deterministic spend ledger to guarantee hard budget enforcement.
Hint 2
Model pacing as a constrained optimization problem where an ML model forecasts the market landscape while a control loop (like dual-gradient descent or PID) dynamically adjusts the spend rate.
Hint 3
Use point-in-time joins and observation windows to train models on historical auctions without leaking delayed conversion feedback.
Follow-up questions
- How do you design an A/B experimentation framework for pacing algorithms without violating the SUTVA assumption (i.e., avoiding auction cannibalization between test and control)?
- If your forecasting service experiences a 15-minute network partition, what deterministic fallback policies prevent campaigns from immediately exhausting their remaining budgets?
- How do you adapt pacing strategies for campaigns with very small budgets ($5/day) versus enterprise campaigns ($100k/day) where variance in win rates differs dramatically?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.