Interview practice question
Preventing double spending in a wallet
System Design · Distributed Systems · Experienced
Users can spend from a wallet via mobile, web and API at the same time. How do you prevent the balance from going negative under concurrent requests?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Atomic conditional update (balance >= amount).
- Single-row transaction with lock.
- Ledger with constraint checks.
- Idempotency per request.
- Partition by wallet for serialisation.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.