HLDArena
HLD-133·Caching & Consistency
Easy · 500 pts

Passwordless Magic-Link Login & Single-Use Token Verifier

Design a Slack / Notion-style passwordless sign-in service that issues hashed 15-minute magic-link tokens, dispatches transactional login emails asynchronously, and atomically redeems links on click.

Max p99
≤ 36 ms
Availability
≥ 99.5%
Budget
≤ $2,900

Functional Requirements

  • FR-1POST /auth/magic-link/send — Generates cryptographic token hash, enforces per-email rate limits, and enqueues outbound email delivery.
  • FR-2POST /auth/magic-link/verify/{token_hash} — Atomically marks unexpired token consumed and mints an authenticated user session.
  • FR-3DELETE /auth/magic-link/pending/{email_hash} — Invalidates older unclicked links when a user requests a fresh login link.
  • FR-4Must guarantee one-time link redemption without blocking user HTTP requests on third-party SMTP latency.

Workload Profile

Normal Sign-In Flow14,000 Session/Status Read RPS / 2,400 Link Issue & Verify Write RPS
Newsletter Campaign Click Surge42,000 Read RPS / 6,800 Write RPS
Active Working Set6 GB live 15-minute token hashes & per-email cooldown counters
Consistency GateRead-after-write token consumption + async email queue decoupling

Consistency Model

Read-after-write on token_hash consumption and session creation so email link scanners or double-clicks never mint duplicate sessions.

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