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
≤ $8,800

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.

Relevant practice for

Click an item in Inventory above, or press B to add a component, double-click to name, C to connect.

Design Write-up

Write under ### Architecture for Diagram to take that up directly

Compulsory section · if not written yet, Diagram reads from the start of your write-up.
Architecture: required·FRs mentioned: 0/4·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