Scenario
You are designing a backend service that stores and updates user account balances (like a wallet/bank ledger). The system must be highly reliable and correct.
Requirements
-
Support operations:
-
Deposit
funds
-
Withdraw
funds (must reject if insufficient funds)
-
Transfer
funds between two accounts (atomic: both sides succeed or neither does)
-
GetBalance(accountId)
-
Correctness is critical
:
-
No lost updates, no double-spend, no negative balance (unless explicitly allowed).
-
Operations may be retried by clients; must handle
idempotency
.
-
High availability
with clear consistency guarantees.
-
Handle high write throughput (many concurrent transactions).
-
Provide auditability: ability to explain how a balance was derived.
Deliverables
Describe:
-
Data model and storage choice
-
API design (including idempotency)
-
Concurrency/consistency approach
-
Replication/failover strategy
-
How you would scale (sharding/partitioning)
-
Key metrics and failure modes