2. Back-of-Envelope Estimation
1
The picture to keep in your head2
2.1 Why estimate at all?3
2.2 Which units and sizes should you know?4
2.3 What time shortcuts make the maths easy?5
2.4 Which latency numbers should every developer know?6
2.5 How do you turn daily users into requests per second?7
2.6 Why does the read/write ratio matter?8
2.7 Why size for the peak, not the average?9
2.8 How do you estimate storage over the years?10
2.9 How do you estimate bandwidth?11
2.10 How much memory does the cache need?12
2.11 How many servers do you need?13
2.12 How do you round, and how do you know you're not way off?14
Memory card and where the analogy breaks15
Practice: five levels16
Interview questions17
Solutions18
Sources19
Code lab2. Back-of-Envelope Estimation
2.2 Which units and sizes should you know?
3 min read+10 XP
At the wedding: You think in useful units: a plate per guest, a kilo of rice per 10 people, a sack is 25 kilos. Nobody counts grains.
In the system: You need a ladder of units, each 1,000 times bigger than the last:
| Unit | Bytes (decimal, used in estimates) | Close power of 2 |
|---|---|---|
| KB (kilobyte) | 1,000 | 2¹⁰ = 1,024 |
| MB (megabyte) | 1,000,000 (a million) | 2²⁰ ≈ 1.05 million |
| GB (gigabyte) | a billion | 2³⁰ ≈ 1.07 billion |
| TB (terabyte) | a trillion | 2⁴⁰ ≈ 1.1 trillion |
| PB (petabyte) | a thousand trillion | 2⁵⁰ ≈ 1.13 thousand trillion |
Why both columns? Memory and computers count in powers of 2 (1 KB = 1,024 bytes). Estimates use round thousands. The gap is under 13% even at PB, which never changes a design decision, so use 1,000 and move on.
Sizes worth knowing by heart:
| Thing | Rough size |
|---|---|
| One character of English text (ASCII) | 1 byte |
| An integer | 4 bytes |
| A long integer or a timestamp | 8 bytes |
| A UUID | 16 bytes |
| A short text message or a database row of metadata | 100 bytes to 1 KB |
| A compressed photo | a few hundred KB to a few MB |
The last two rows depend on the product, so say your assumption out loud: "I'll assume 2 MB per uploaded photo."
Memory code: "King Midas Gave Tea Parties." KB, MB, GB, TB, PB. Each one is a thousand times the last.