Design a highly reliable account balance system
Capital OneSoftware Engineer · OnsiteLast updated
This question evaluates a candidate's ability to architect a highly reliable transactional account-balance service, testing competencies in data modeling and storage choice, API design for idempotency, concurrency and consistency mechanisms, replication/failover, partitioning for scale, and auditability.
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
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.