HLDArena
HLD-114·Storage & Caching
Easy · 500 pts

SMS & Email One-Time Passcode (OTP) Verifier

Design a short-TTL one-time passcode generation and verification service handling sudden mobile re-authentication waves.

Max p99
≤ 35 ms
Availability
≥ 99.5%
Budget
≤ $2,150

Functional Requirements

  • FR-1POST /otp/send — Generates a 6-digit hashed code with 5-minute TTL and enqueues SMS/email dispatch.
  • FR-2POST /otp/verify — Validates submitted code and attempt count for phone_hash.
  • FR-3DELETE /otp/send/{phone_hash} — Supports tenant retention TTL expiry, rule updates, or stream cleanup while keeping recent rollup caches fresh.
  • FR-4Must remain available across a primary state store crash.

Workload Profile

Baseline Logins14,000 Verify RPS / 4,500 Issue Write RPS
Push Campaign Surge40,000 Read RPS / 14,000 Write RPS
Active Working Set5 GB active 5-minute OTP & attempt counters
Traffic DistributionBroadly distributed across phone_hash identities

Consistency Model

Short-lived TTL state replicated across multi-AZ nodes so login checks survive node faults.

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