Prevent Duplicate Payments Under High Load
You are designing a payment-processing service for a company that charges customer cards, such as a payroll or billing platform. Under high load, the same logical payment can be submitted multiple times due to client double-clicks, request timeouts with retries, mobile app reconnections, or internal message redelivery.
Design a system that ensures the same logical payment is charged at most once, even with duplicated requests, service crashes, network failures, or heavy concurrent load.
Your design should address:
- How payment requests are made idempotent to recognize retries as the same operation.
- How concurrent duplicate requests are serialized so only one charge occurs.
- How retries after timeouts or partial failures are handled, especially when the charge might have succeeded but the response was lost.
- How to coordinate with an external payment provider that may or may not support idempotency keys.
- The data model, locking strategy, and uniqueness guarantees for preventing duplicates.
- How to monitor, detect, and recover from stuck or ambiguous payments.
AI interview prep
Core dilemma
Ensuring exactly-once payment processing in a distributed system prone to network failures, retries, and concurrent requests, while balancing correctness with acceptable latency and operational complexity.
4 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Prevent Duplicate Payments Under High Load
You are designing a payment-processing service for a company that charges customer cards, such as a payroll or billing platform. Under high load, the same logical payment can be submitted multiple times due to client double-clicks, request timeouts with retries, mobile app reconnections, or internal message redelivery.
Design a system that ensures the same logical payment is charged at most once, even with duplicated requests, service crashes, network failures, or heavy concurrent load.
Your design should address:
- How payment requests are made idempotent to recognize retries as the same operation.
- How concurrent duplicate requests are serialized so only one charge occurs.
- How retries after timeouts or partial failures are handled, especially when the charge might have succeeded but the response was lost.
- How to coordinate with an external payment provider that may or may not support idempotency keys.
- The data model, locking strategy, and uniqueness guarantees for preventing duplicates.
- How to monitor, detect, and recover from stuck or ambiguous payments.