Constraints / Goals
DSP only (no exchange)
Target: 1M ad requests/sec
End-to-end DSP latency budget: ~100ms
Pricing model: CPM
Hard requirement: no advertiser or campaign overspend
Targeting / Campaign Fetch
I modeled targeting (geo, interests, etc.) using Redis + Roaring Bitmaps.
Fetching candidate campaigns alone:
Redis: ~1000 RPS at ~8ms (local machine, not cloud)
Aerospike: ~200–400 RPS at ~10ms
This is only campaign fetching, not bidding or scoring.
Budget / Wallet Model
Advertiser has a wallet
Campaign has:
Total budget
Daily budget
Daily spend tracking
Overspend is not acceptable (even a small % matters at scale).
Budget Control Approaches Considered
Splitting daily budgets into hourly buckets
Rate limiting via:
Token bucket
PID controllers
These reduce overspend but don’t guarantee correctness under bursty traffic.
Recently considering micros (integer currency units) to reduce rounding errors.
Open Questions
At 1M QPS, how do people actually enforce budget guarantees in production?
Soft overspend with reconciliation?
Hard atomic checks in the hot path?
Is Redis bitmap–based targeting viable at this scale, or does everyone eventually:
Pre-materialize campaign sets?
Push logic into memory / C++?
How do you balance:
Strict budget enforcement
Low latency
High throughput without introducing global locks or cross-region contention?
Is “no overspend ever” a realistic requirement, or is bounded error the industry norm?
I’m less interested in textbook answers and more in what has actually worked (or failed) in production.