HLDArena
HLD-304·Payments & Ledger
Hard · 1,500 pts

Real-Time Ad Click Attribution & Budget Pacing

Design an ad-tech click ingestion and real-time campaign spend-pacing pipeline preventing exhausted ad budgets from continuing to serve billable impressions.

Max p99
≤ 50 ms
Availability
≥ 99.5%
Budget
≤ $6,000

Functional Requirements

  • FR-1POST /v1/clicks — Deduplicates click_id events and increments live campaign spend.
  • FR-2GET /v1/campaigns/{campaign_id}/budget — Checked by ad-serving bidders before auction participation.
  • FR-3POST /v1/clicks/{campaign_id}/reverse — Supports idempotent reversal/refund or campaign pause updates while keeping cached balances and deduplication keys consistent.
  • FR-4Depleted campaign budgets must immediately reflect in pacing reads (read-after-write) even during storage brownouts.

Workload Profile

Baseline Auctions38,000 Pacing Read RPS / 16,000 Click Write RPS
Halftime Ad Flood95,000 Read RPS / 46,000 Click Write RPS
Active Working Set26 GB click dedup window & campaign budgets
Fault Scenario7x attribution storage tail-latency brownout in Wave 3

Consistency Model

Read-after-write budget visibility required so bidders stop serving paused/exhausted campaigns within seconds.

Design Write-up
0 boxes · 0 edges
0 words
Hidden Cases #4–#7 run automatically on Submit
Case 1: Smoke & API ContractInput Workload
Read RPS
2,000 rps
Write RPS
400 rps
Key Distribution
Uniform (Low Skew)
Chaos Fault
None (Healthy Cluster)
Expected Pass CriteriaASSERTIONS
• Tail Latency: p99 ≤ 100 ms
• Availability: ≥ 99.5%
Valid end-to-end Client → Compute → Storage topology