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.
Video lesson · Chapter 1 of 6
A timeline amplifies a write
Same sums, five different answers
1:20Reel coming soon
Theory
Read or listen first. About 1 min.
What it is
Resource estimation turns what people do with a product into what its machines need: requests a second, terabytes, gigabits a second, open connections, servers.
The same handful of sums is used each time. What changes is which of them matters. Video is a bandwidth problem, chat is a connection problem, a link shortener is a read problem, and a flash sale is a problem of one row that everybody wants.
Why it exists
Reading about estimation is not enough; the skill is choosing which facts to multiply. Worked examples show the choice as well as the arithmetic.
They also show how estimates fail. Given facts can contradict each other, and only a check with a second method reveals it. One of the examples below does exactly that.
A short history
1909
Agner Krarup Erlang publishes a first paper on telephone traffic, "The theory of probabilities and telephone conversations": how many lines does an exchange need for the calls that arrive?
1961
John Little proves that the average number in a system is the arrival rate times the average time spent, the law used below to count viewers.
2016
Google's Site Reliability Engineering book describes capacity planning from the intent of a service instead of from a list of machines.
Words to know
- DAU, MAU
- Daily and monthly active users.
- Read to write ratio
- How many reads happen for each write. Say whether you count requests or items.
- Concurrent users
- People using the service at the same moment.
- Replication factor
- How many copies are kept, often three.
- Bitrate
- Bits of video or audio a second.
- PoP
- Point of presence: a place where a content network keeps servers.
- Flash sale
- A sale that starts at a set moment, so people arrive together.
How it works
Step through the idea, or press Play.
Facts. Users, what each does, how big, how long kept
Understand it
Start here
One trip, five questions
A school plans a day out. One trip raises several questions, and each needs its own sum. How long the coaches take at the gate says nothing about the luggage. A system is the same: traffic, storage, bandwidth and machines are separate sums about one product.
Different questions need different sums.
The checklist
Six steps for any system
- 1
Clarify users and behaviour
Daily or monthly users? What does each do, how often?
- 2
Compute reads and writes
Separately. They lead to different parts.
- 3
Take the peak
Three times average on an ordinary day. For a sale, count the people who arrive.
- 4
Work out storage
New items × size × time kept, with and without copies.
- 5
Work out bandwidth
Peak × response size × 8.
- 6
Count machines
Peak / (capacity × 0.7), rounded up, plus one spare.
From facts to the limit
Multipliers to start with
| Situation | Multiplier | Remember |
|---|---|---|
| Ordinary peak | 3 × average | An assumption until you have a graph |
| Sale or viral event | often said to be 10 × | Better: people / seconds between their requests |
| Copies of data | 3 × | Say storage both ways; object stores keep their own copies |
| Spare capacity | plan at 70%, plus one machine | Instead of a 1.5 or 2 times guess |
Example 1
A timeline service
Given: 500 million daily users, 10 timeline views each, 100 posts a view, 1 new post per user, 1 KB a post, kept 5 years, peak three times average.
| Sum | Working | Result | So |
|---|---|---|---|
| Reads | 500M × 10 / 86,400 | 58,000/s, peak 174,000/s | timelines are prepared and cached |
| Writes | 500M / 86,400 | 5,800/s, peak 17,400/s | past one database: split |
| Storage | 500 GB a day × 365 × 5 | 913 TB, 2.7 PB with 3 copies | partition posts |
| Bandwidth | 58,000 × 100 KB | 5.8 GB/s, 46 Gb/s; peak 139 Gb/s | compress, send fewer posts first |
| Machines | 191,000 / 700 | 273, plus one spare: 274 | at an assumed 1,000/s each |
Two ratios, not one
Example 2
A URL shortener
Given: 100 million new links a month, 100 reads for each write, 500 bytes a record, kept 10 years.
| Sum | Working | Result | So |
|---|---|---|---|
| Writes | 100M / 2.6M s | 40/s (38.6) | any database |
| Reads | × 100 | 4,000/s, peak 12,000/s | a cache in front; links rarely change |
| Links | 100M × 12 × 10 | 12 billion | length of the code |
| Storage | 12B × 500 B | 6 TB, 18 TB with copies | one large database still holds it |
| Bandwidth | 12,000 × 500 B | 6 MB/s, 48 Mb/s | nothing depends on it |
How long is the code?
Example 3
Video streaming
Given: 100 million daily users, 1 million viewers at once at peak, 5 Mb/s, 10,000 new videos a day of 1 GB, 5 qualities, 1 hour watched per user a day, kept forever.
| Sum | Working | Result | So |
|---|---|---|---|
| Bytes out | 1M × 5 Mb/s | 5 Tb/s | a content network, not our servers |
| New storage | 10,000 × 1 GB × 5 | 50 TB a day, 18 PB a year | object storage, cold tier for old videos |
| Uploads | 10 TB / 86,400 | 116 MB/s, 930 Mb/s | easy; transcoding is the work |
| Places | 5 Tb/s / 100 Gb/s | 50 PoPs at full use | at an assumed 100 Gb/s each |
Little's law on the viewers
Five qualities do not weigh five times the top one. With bitrates of 8, 5, 2.5, 1 and 0.5 Mb/s the whole set is 17 / 8 = 2.1 times the largest file: about 21 TB a day instead of 50. The sum above is a safe upper bound; say so.
Where the numbers push the design
Example 4
Chat
Given: 500 million daily users, 50 messages each of 100 bytes, 5% carry an image of 200 KB, groups of 10 on average, kept 5 years, 100 million people connected at once.
| Sum | Working | Result | So |
|---|---|---|---|
| Messages | 25B / 86,400 | 290,000/s, peak 870,000/s | split by conversation |
| Deliveries | × 9 if all go to groups of 10 | up to 2.6M/s, peak 7.8M/s | fan-out is the real load |
| Gateways | 100M / (100,000 × 0.7) | 1,429, plus one: 1,430 | 1,000 would be full, with no spare |
| Memory | 100,000 × 20 KB | 2 GB a gateway | memory is not the limit |
| Text | 25B × 100 B | 2.5 TB a day | a store made for many writes |
| Images | 1.25B × 200 KB | 250 TB a day | object storage |
One message, nine deliveries
Keep everything, or not?
Example 5
A shop
Given: 50 million daily users, 20 page views each, 100 million products of 10 KB, 5 images of 500 KB each, 5 million orders a day, 10 times the average in a flash sale.
| Sum | Working | Result | So |
|---|---|---|---|
| Pages | 1B / 86,400 | 11,600/s; sale 116,000/s | cache product pages |
| Orders | 5M / 86,400 | 58/s; sale 580/s | one database in total, but see below |
| Product data | 100M × 10 KB | 1 TB | one database |
| Images | 100M × 5 × 500 KB | 250 TB | object storage and a content network |
| Search index | 2 to 3 × the data, assumed | 2 to 3 TB | a few search nodes |
Count people instead of guessing 10 times
Compare
Five systems, five limits
| System | Peak requests | Storage | Bytes out | Limit |
|---|---|---|---|---|
| Timeline | 174,000/s | 2.7 PB with copies | 139 Gb/s | reads and fan-out |
| URL shortener | 12,000/s | 18 TB with copies | 48 Mb/s | read rate, mildly |
| Video | few | 18 PB a year | 5 to 63 Tb/s | bandwidth |
| Chat | 870,000/s | 461 PB, or 12 PB | 69 Gb/s of images in | connections, media kept |
| Shop | 116,000/s | 250 TB of images | 9 Gb/s of page text | one hot product |
What each one taught
Timeline
Say which ratio you mean: requests or items.
Shortener
A famous product can be a small system.
Video
Check given facts against each other.
Chat
How long to keep data is the biggest lever.
Shop
Totals hide a hot spot.
All
Stop when no decision is waiting.
Which limit is it?
Word for word
Saying it aloud
A photo app in two minutes
Interviewer
A million people upload two photos a day. Size it.
You
Two million uploads a day is 20 a second by the shortcut, about 70 at peak. So uploads need no special design.
You
At 500 KB each that is 1 TB a day, 365 TB a year. So object storage, and I would ask if originals are kept.
You
If each person views 100 photos, 100 million a day is 1,200 a second, 3,500 at peak, times 500 KB is 1.7 GB a second, 14 Gb/s. So a content network and smaller images.
Interviewer
And the metadata?
You
Two million rows of 1 KB is 2 GB a day, 730 GB a year. So one database. I am done unless you want servers.
Check the facts with a second method
users, hours = 100_000_000, 1average = users * hours / 24peak = average * 3print(f"viewers at once: {average:,.0f} average, {peak:,.0f} peak")print(f"bytes out: {peak * 5 / 1e6:.1f} Tb/s (given: 1M viewers, 5 Tb/s)")Summary
The whole topic in one minute.
For every system: clarify users and behaviour, compute reads and writes, take the peak, then storage, bandwidth and machines, and stop when nothing else decides anything.
The limit differs: timelines need precomputed reads and split storage, short links need a cache, video needs a content network and a check of concurrent viewers, chat needs gateways and deletion of media, and a sale needs protection for one hot row. Always check given facts against each other.
- Same sums, different limit: find the limit.
- Reads, writes, deliveries: count what really happens.
- Check facts with a second method.
- Retention and product rules save more than machines.
- A fine total can hide one hot row.