Data & storage / 10 / 11
Transactions
A wallet app moves money between two accounts. What breaks without a transaction, what breaks even with one when two servers write at once, and which isolation level or lock fixes each case.
- 14 min
- Intermediate
- 12 steps
- Wrong balances
- 0 /day
- Transfer p95
- 20 ms
- Retries
- 0 /min
- request
- reply
- redelivery
- duplicate
- lost
Numbers are a model scenario, not measurements
The real request
API 1 → DatabaseRequest
UPDATE accounts SET balance = balance - 50000
WHERE id = 'acc_42';1
UPDATE accounts SET balance = balance + 50000
WHERE id = 'acc_77';2
Response
UPDATE 13
UPDATE 1
acc_42— The sender. The first statement takes the money here.acc_77— The receiver. The second statement adds the money here.UPDATE 1— One row changed. Each statement is already saved for good the moment it returns.
Course: 42 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes