HLDArena
HLD-404·Payments & Ledger
Expert · 2,000 pts

Idempotent Payment Ledger & Double-Entry Wallet

Design a mission-critical double-entry wallet and payment transfer engine surviving payday settlement bursts, client retry storms, and primary database node crashes with zero double-spends.

Max p99
≤ 130 ms
Availability
≥ 99.5%
Budget
≤ $8,200

Functional Requirements

  • FR-1POST /v1/transfers — Atomically debits sender wallet_id and credits recipient with idempotency_key deduplication.
  • FR-2GET /v1/wallets/{wallet_id}/balance — Returns authoritative available balance and recent ledger entries.
  • FR-3POST /v1/transfers/{wallet_id}/reverse — Supports idempotent reversal/refund or campaign pause updates while keeping cached balances and deduplication keys consistent.
  • FR-4Zero committed transfers may be lost (RPO = 0) and negative-balance race conditions must be impossible.

Workload Profile

Baseline Volume35,000 Balance Read RPS / 9,000 Transfer Write RPS
Payday Peak90,000 Read RPS / 34,000 Concurrent Transfer Write RPS
Active Working Set40 GB hot merchant & consumer wallet state
Availability TargetFinancial tier >= 99.5% availability across node crash

Consistency Model

Strict serializable balance mutation + RPO = 0 synchronous/quorum replication; zero double-debit or stale balance overdrafts.

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 ≤ 260 ms
• Availability: ≥ 99.5%
Valid end-to-end Client → Compute → Storage topology