HLDArena
HLD-319·Payments & Ledger
Hard · 1,500 pts

Global Card Payment Authorization & Idempotent Retry Engine

Design Stripe’s `Idempotency-Key` payment intent state machine ensuring client network retries NEVER double-charge a card even under database failover.

Max p99
≤ 115 ms
Availability
≥ 99.5%
Budget
≤ $8,600

Functional Requirements

  • FR-1POST /v1/payment_intents — Atomically acquires idempotency_key lock, executes state transition, and caches response.
  • FR-2GET /v1/payment_intents/{intent_id} — Returns authoritative authorization/capture status.
  • FR-3POST /v1/payment_intents/{idempotency_key}/reverse — Supports idempotent reversal/refund or campaign pause updates while keeping cached balances and deduplication keys consistent.
  • FR-4Zero duplicate charges on concurrent retries and zero lost authorizations on primary DB crash (RPO = 0).

Workload Profile

Baseline Checkout Load34,000 Status Read RPS / 7,500 Charge Write RPS
Cyber Monday Peak88,000 Read RPS / 24,000 Concurrent Charge RPS
Active Working Set26 GB 24-hour idempotency keys & active payment intents
Consistency GateStrict serializable idempotency CAS + RPO = 0 quorum durability

Consistency Model

Strict serializable `idempotency_key` lease/CAS + synchronous/quorum durability; zero double-charges.

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