Back-of-the-envelope estimation

Topic 8 of 8 in Week 2: Scaling, traffic and estimation12 min readBeginnerFree course

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

A back-of-the-envelope cheat sheet. Powers of two: 2 to the 10 is about a thousand (KB), 2 to the 20 about a million (MB), 2 to the 30 about a billion (GB), 2 to the 40 about a trillion (TB), 2 to the 50 about a quadrillion (PB). Time: a day is 86,400 seconds, about 10 to the 5; a month about 2.6 million seconds; a year about 31.5 million seconds, about 3 times 10 to the 7; 1 million requests a day is about 12 per second and 1 billion a day about 12 thousand per second. Typical sizes: an ID or timestamp 8 bytes, a short text post about 1 KB, a compressed photo 200 KB to 2 MB, one minute of HD video about 50 MB. Worked example: 10 million photos a day at 500 KB is 5 TB a day; over 5 years about 9 PB, or 27 PB with 3 copies. Precision doesn’t matter, but a wrong order of magnitude does.

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

  1. State assumptions: users, actions per user, sizes, retention. If the interviewer gives none, choose round numbers.
  2. Traffic: requests per day → average QPS → peak QPS (×2 to ×3, more for spiky products). Split reads and writes.
  3. Storage: new items per day × size, then × days retained × number of copies.
  4. Bandwidth: QPS × response size, for both incoming and outgoing traffic.
  5. Servers or memory: peak QPS ÷ capacity per server; working set size ÷ memory per cache node.
  6. 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:

Text
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:1

Storage:

Text
per day : 10^8 posts × 1 KB = 100 GB/day
5 years : 100 GB × 365 × 5 ≈ 180 TB
3 copies: ≈ 550 TB

Bandwidth (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.

Exercise

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.

Text
(a) Reads:
(b) Uploads:
(c) Storage:
(d) Bandwidth:
(e) Conclusion:

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.