HLD-211·Messaging & Queues
Medium · 1,000 ptsSaaS Usage-Based API Metering & Spend Aggregator
Design a high-throughput usage metering pipeline counting billable API tokens and compute units per tenant while serving real-time billing dashboard queries.
Max p99
≤ 60 ms
Availability
≥ 99.5%
Budget
≤ $5,100
Functional Requirements
- FR-1POST /usage/events — Ingests idempotent usage records keyed by tenant_id and request_id.
- FR-2GET /usage/{tenant_id} — Returns current billing-period consumption and spend alerts.
- FR-3PATCH & DELETE /usage/events/{tenant_id} — Updates, revokes, or deletes tenant_id entries with bounded TTL or explicit cache/index invalidation.
- FR-4Must buffer heavy batch inference bursts and isolate 6x storage compaction brownouts.
Workload Profile
Baseline Metering22,000 Read RPS / 14,000 Event Write RPS
Batch Inference Surge70,000 Read RPS / 38,000 Write RPS
Active Working Set24 GB rolling billing-period counters & dedup keys
Traffic DistributionSkewed consumption on large enterprise tenant_id accounts
Consistency Model
Bounded eventual dashboard rollup (< 5s) acceptable; billable usage events must never be dropped.
Solutions Locked
Sign in and either achieve AC or complete 3 official submissions on this question to inspect community diagrams and writeups.
Loading solutions...
Submission History (0)Select to replay
No submissions yet
Click Submit in the top bar to evaluate against all 7 judge cases and save each run here.
Design Write-up
0 boxes · 0 edges
0 words