Back-of-the-envelope estimation
Overview
Interviewers often ask, “Roughly how much storage will this need?” or “How many servers?”. They aren’t checking your arithmetic; they want to see whether you can turn a vague product into numbers that drive decisions. This lesson gives you the shortcuts and a method you can run in three minutes.
The cheat sheet
Also worth remembering from week 1: memory reads take about 100 ns, SSD reads about 100 µs, a round trip within a data centre about 0.5 ms and a cross-continent round trip about 100 ms.
The method
- State assumptions: users, actions per user, sizes, retention. If the interviewer gives none, choose round numbers.
- Traffic: requests per day → average QPS → peak QPS (×2 to ×3, more for spiky products). Split reads and writes.
- Storage: new items per day × size, then × days retained × number of copies.
- Bandwidth: QPS × response size, for both incoming and outgoing traffic.
- Servers or memory: peak QPS ÷ capacity per server; working set size ÷ memory per cache node.
- Conclude: say what the numbers mean for the design.
Rounding rules
- Use powers of ten: 86,400 becomes 10⁵, 2.6 million becomes 2.5 × 10⁶.
- Keep one or two significant figures: 11,574 QPS is “about 12,000”.
- Carry units carefully: bytes vs bits (×8), per second vs per day.
- Multiply exponents: 10⁸ users × 10 actions = 10⁹ actions.
It’s fine to be off by 20–30%. It’s not fine to be off by 1,000× because of a units mistake.
Worked example: a short-text social app
Assumptions: 100 million DAU. Each user reads 100 posts a day and writes 1 post a day. A post is about 1 KB including metadata. Keep posts forever; plan for 5 years; 3 copies.
Traffic:
reads = 100M × 100 = 10^10 per day → 10^10 / 10^5 = 10^5 = 100,000 QPS average
writes = 100M × 1 = 10^8 per day → 10^8 / 10^5 = 1,000 QPS average
peak (×3): ~300,000 read QPS, ~3,000 write QPS; read/write ratio 100:1Storage:
per day : 10^8 posts × 1 KB = 100 GB/day
5 years : 100 GB × 365 × 5 ≈ 180 TB
3 copies: ≈ 550 TBBandwidth (outgoing): 300,000 reads/s × 1 KB ≈ 300 MB/s ≈ 2.4 Gbit/s at peak, before images.
Servers: if one app server handles ~1,000 QPS, peak reads need ~300 app servers, plus ~30% headroom and spare capacity for a zone failure.
Cache: if the hottest 20% of a day’s posts are read most, that’s 20 GB a day; even a week’s worth fits in a modest Redis cluster.
Conclusions:
- The system is heavily read-dominated → caching and precomputed feeds are central.
- 550 TB doesn’t fit on one database → shard the posts table (week 3).
- 3,000 writes/s at peak is manageable but beyond a comfortable single primary on cheap hardware → plan to shard writes too.
Other useful estimates
- Memory for a cache: number of hot items × item size × overhead (×1.5–2 for data structures).
- Connections: concurrent users for chat or streaming; a single server can often hold tens of thousands to a few hundred thousand idle connections.
- ID space: how many IDs over the system’s lifetime? 7 characters of base62 give 62⁷ ≈ 3.5 trillion combinations, plenty for a URL shortener.
- Cost: storage per GB-month and egress per GB can make or break media-heavy products.
Doing it in an interview
- Keep it short: two or three minutes, on the side of the whiteboard.
- Estimate only what affects decisions. If writes are 10 per second, don’t calculate their bandwidth.
- Narrate: “I’ll assume a peak of three times average.”
- Use the results later: “Since storage is half a petabyte, we need sharding” is the payoff that shows why you estimated.
- Sanity-check: compare with known systems or with what one machine can do (week 1).
Recap
Back-of-the-envelope estimates turn requirements into traffic, storage, bandwidth and capacity numbers. Use powers of ten, round boldly, keep units straight and state assumptions. The goal isn’t precision; it’s finding the order of magnitude that tells you whether one database is enough, whether you need a CDN, and where the design will strain first.
Estimate a photo-sharing app
Estimate for a photo-sharing app: 200 million daily active users; each user views 50 photos a day; 2% of users upload one photo a day; an average photo is 1 MB after compression, and you also store a 50 KB thumbnail. Keep everything for 5 years, with 3 copies. Estimate (a) average and peak read QPS, (b) upload QPS, (c) storage added per day and total after 5 years, (d) peak outgoing bandwidth if each view downloads the 1 MB photo, and (e) one design conclusion from the numbers.
(a) Reads:
(b) Uploads:
(c) Storage:
(d) Bandwidth:
(e) Conclusion:(a) Reads: 200M x 50 = 10 billion views/day. 10^10 / 10^5 s = ~100,000 views/s
on average (more precisely ~116k). Peak ~2-3x: ~250,000-300,000/s.
(b) Uploads: 200M x 2% = 4 million/day = ~46 uploads/s average, ~100-150/s at peak.
(c) Storage: 4M x (1 MB + 50 KB) = ~4.2 TB/day.
5 years: 4.2 TB x 365 x 5 = ~7.7 PB; with 3 copies ~23 PB.
(d) Bandwidth: 250,000 views/s x 1 MB = 250 GB/s = ~2 Tbit/s at peak.
(e) Conclusions:
- Photo bytes must come from a CDN; no origin cluster should serve 2 Tbit/s.
- Storage is petabytes: use object storage, not a database, for the images.
- Reads outnumber uploads ~2,500:1, so cache metadata heavily.
- Uploads are modest; a write-friendly metadata store handles ~150/s easily.Summary
- Estimate to make decisions, not to be precise: round aggressively and keep only one or two significant figures.
- A day is about 10⁵ seconds: 1 million per day ≈ 12 per second, 1 billion per day ≈ 12,000 per second.
- Storage = items per day × size × retention × replication; bandwidth = requests per second × response size.
- Server count ≈ peak QPS ÷ QPS per server, plus headroom and spare capacity for failures.
- Say assumptions out loud, write the numbers down and use them to justify design choices.