HLDArena
HLD-101·Rate Limiting
Easy · 500 pts

Distributed API Rate Limiter & Quota Gateway

Design a low-latency ingress rate-limiting tier enforcing per-tenant sliding-window and token-bucket quotas across stateless API gateways without adding tail latency.

Max p99
≤ 25 ms
Availability
≥ 99.5%
Budget
≤ $4,900

Functional Requirements

  • FR-1POST /v1/check — Evaluates whether api_key has remaining quota in the current window and increments usage.
  • FR-2GET /v1/quota/{api_key} — Returns current remaining allowance and reset timestamp.
  • FR-3PATCH & DELETE /v1/check/{api_key} — Updates, revokes, or deletes api_key entries with bounded TTL or explicit cache/index invalidation.
  • FR-4Quota rules and counter state must remain available if a single state node crashes.

Workload Profile

Baseline Load18,000 Check RPS / 4,000 Counter Write RPS
Bot Surge Peak55,000 Check RPS / 12,000 Write RPS
Active Working Set4 GB hot sliding-window counters (40 GB rules/audit)
Traffic DistributionSkewed burst on abusive api_key tenants

Consistency Model

Bounded eventual consistency (< 1s window drift acceptable across gateway POPs; rule configs must be durably stored).

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
1,800 rps
Write RPS
400 rps
Key Distribution
Uniform (Low Skew)
Chaos Fault
None (Healthy Cluster)
Expected Pass CriteriaASSERTIONS
• Tail Latency: p99 ≤ 50 ms
• Availability: ≥ 99.5%
Valid end-to-end Client → Compute → Storage topology