Part 2 of 8 · 1 min read
Scope and numbers
How many database nodes?
Think of a bank's internal ledger. Each transfer takes money from one book page and adds the same amount to another. If a clerk writes only the first line and the lights go out, money has vanished.
Questions and the answers assumed here (from the book's sample talk).
- Which operation? Balance transfer between two wallets on the platform.
- Speed? 1 million transfers per second.
- Correctness? Transactional guarantees are required, and results must be verifiable later.
- Availability? 99.99 per cent.
- Foreign exchange? Not covered.
Requirement for audits. Reconciliation (Level 12, page 4) only shows that numbers disagree and cannot say how a difference arose. So the design should be reproducible: any past balance can be rebuilt by replaying the data from the start.
Numbers.
- 99.99 per cent availability allows 0.01 per cent of a year: 365 × 24 × 60 × 0.0001 = about 52.6 minutes of downtime.
- A transactional database node handles about 1,000 transactions per second (the book's assumption). 1 million transfers per second would need 1,000 nodes.
- But each transfer is two writes: take from one account and add to another. So the system must handle 2 million writes a second, and 2,000 nodes.
- If one node could do 10,000 writes a second, 200 nodes would do. The more each node can do, the lower the cost. So a design goal is to raise per-node throughput.
Reproducibility
A system is reproducible when any past state can be rebuilt exactly from the recorded history.
Example: replaying all transfers from the start of the year gives the same balance for account A as the system showed on 1 March.
Check yourself: 1. Why does a transfer count as two writes? 2. How many nodes at 5,000 writes a second per node? 3. What does reproducibility give an auditor?