Resource estimation examples
medium 30 minFive complete estimates, each from the given facts to a decision: a timeline, a URL shortener, video streaming, chat and a shop.
See it run
Five systems, the same sums, five different limits.
Operations
Timeline
500 million users read 100 posts ten times a day and write one.
Step 1 of 5
Reads
| Sum | Working | Result |
|---|---|---|
| Reads | 500M × 10 / 86,400 | 58K/s, peak 174K |
| Writes | ||
| Storage | ||
| Bandwidth | ||
| Machines |
5 billion a day: 58,000 a second, 174,000 at peak.
Step 1: Reads
reads = 500_000_000 * 10 / 86_400writes = 500_000_000 * 1 / 86_400stored = 500_000_000 * 1_000 * 365 * 5out = reads * 100 * 1_000 * 8servers = ceil((reads + writes) * 3 / 700) + 1- Limit
- Reads
- You leave with
- Prepared timelines
Ten requests read per request written, but a thousand posts. Say which you mean.
In the real world
The same resource estimation examples doing real jobs. Pick one and step through it.
Five systems with similar sums, limited by different things.
Step 1 of 5
Timeline
| System | Peak | Storage | Limit |
|---|---|---|---|
| Timeline | 174K reads/s | 2.7 PB | fan-out reads |
| Short links | |||
| Video | |||
| Chat | |||
| Shop |
Many reads, each gathering a hundred posts.
Step 1: Timeline
Common mistakes
The bugs interviewers watch for, with the fix beside each.
Trusting the brief
criticalGiven facts can contradict each other. A second method finds it in ten seconds.
Wrongpeak = 1_000_000 # as givenRightpeak = users * hours / 24 * 3assert peak < 2 * given, "ask"Counting messages, not deliveries
majorA group message is one write and many sends. Gateways feel the sends.
Wrongload = messagesRightload = messages * (group - 1)Forgetting the peak for machines
majorThe average is never the hour in which a system falls over.
Wrongservers = average / capacityRightservers = ceil(peak / (capacity * 0.7)) + 1Stopping at the total
criticalA thousand orders a second on a thousand products is easy. On one product it is a queue.
Wrongok = orders < database_limitRightok = orders_for_hottest < 1 / lock_time
Interview tips
How to explain it
- Same sums every time.
- Find which result no machine can carry.
- End each sum with a part or with nothing.
Memory trick: the class trip
- How many people.
- How fast through the gate.
- Luggage, road, rest stops.
Quick guesses
- Media: bandwidth and storage.
- Live: connections.
- Sale: one row. Text: usually nothing.
Say out loud
- What you assume.
- Which facts disagree.
- What you decide not to compute.