DEV Community

designbench.dev
designbench.dev

Posted on Originally published at designbench.dev

Back-of-the-envelope estimation for system design interviews: size a 200M-user photo app in five minutes

The interview question: "Design a photo-sharing app for 200 million daily users." Before you draw a single box, the interviewer expects you to put numbers on it.

Back-of-the-envelope estimation is not about being right to three decimal places. It is about getting the order of magnitude right, fast and out loud, so you know which problems are real: one database or a hundred, one network link or a CDN. Here is how to do it, round by round, using the same numbers as the Designbench estimation lesson, where every step is interactive.

Round 1: Why bother with rough numbers?

Interviewer: Why not just start designing?

You: Because the numbers decide the design. 200 requests per second fits on one database; 200,000 does not. 7 TB fits on a few machines; 500 PB needs an object store. Two minutes of arithmetic tells me which problems deserve the next 40 minutes.

Round 2: Know what is fast and what is slow

Interviewer: Before the math, how long do things actually take?

You: I keep a short ladder in my head. Each rung is roughly 100 to 1,000 times slower than the one before:

Operation Real time If 1 ns were 1 second
L1 cache reference 1 ns 1 second
Read from main memory (RAM) 100 ns under 2 minutes
SSD random read 100 µs about a day
Round trip inside a datacenter 500 µs almost 6 days
Hard disk seek 10 ms nearly 4 months
Round trip California ↔ Netherlands 150 ms almost 5 years

The latency ladder on Designbench
The latency ladder on Designbench, scaled so 1 ns is 1 second.

What that means for design:

  • Memory beats disk, which is why caches exist. See Caching and CDNs.
  • Network hops add up. Ten sequential service calls inside one datacenter cost about 5 ms before any real work happens.
  • Distance is physics. You cannot optimise away 150 ms across an ocean; you move the data closer with a CDN or another region. See Replication.

The figures are approximate, from the classic "latency numbers every programmer should know" list. Hardware has moved some of them, but the ratios are what matter.

Round 3: The shortcuts that do most of the work

You: Five facts cover almost every interview:

  • A day is about 10⁵ seconds (86,400). So 1 million requests a day is about 12 per second, and 1 billion a day is about 12,000 per second.
  • A year is about 3 × 10⁷ seconds (31.5 million).
  • Peak is 2–3× the average for a normal daily cycle. Launches, sales and live events can be 10–100×.
  • Size units step by 1,000: KB, MB, GB, TB, PB.
  • Little's law: requests in flight = arrival rate × time each request takes.

Round 4: Size the photo app, one number at a time

Interviewer: Go ahead. 200 million daily users.

You: I'll state my assumptions first; stop me if one is off. Each user makes 20 requests a day, 5% of requests are uploads of about 500 KB, and we keep photos for 5 years.

Step Math Result
Requests per day 200M × 20 4 billion
Average per second 4B ÷ 86,400 ≈ 46,000
Peak per second × 3 ≈ 139,000
App servers 139K ÷ 5K per server ≈ 28
New data per day 200M uploads × 500 KB 100 TB
Storage, 5 years, 3 replicas 100 TB × 365 × 5 × 3 ≈ 548 PB

The photo-app sizing story on Designbench
The photo-app story on Designbench, step 8 of 8.

That last number changes the design. Photos go to an object store such as S3, not a database. Metadata (who uploaded what, and when) lives in a database that stays small by comparison.

Round 5: Go one step further than most candidates

Interviewer: Anything you'd add?

You: Three numbers most candidates skip:

  • Headroom. Servers at 100% fall over. At a 70% utilisation target, 139K ÷ (5K × 0.7) ≈ 40 servers, plus a spare in each zone.
  • Bandwidth. About 95% of requests are reads. If an average read serves 200 KB (mostly thumbnails), peak egress is 132K × 200 KB ≈ 26 GB/s, about 210 Gbps. That is a CDN problem, not an app-server problem. Uploads add about 7,000 per second × 500 KB ≈ 3.5 GB/s of ingress.
  • Concurrency. QPS is not the number of connections. By Little's law, 139K requests per second that each take 100 ms means only about 14,000 in flight at once. Long-lived WebSocket connections are a separate number again.

Round 6: Practise on any system

The estimator on Designbench runs the same chain for any inputs. With its defaults (100M daily users, 10 requests each, 1% writes of 0.5 KB, kept 5 years) you get:

  • Average about 11.6K per second, peak about 34.7K
  • At peak, about 34.4K reads and 350 writes per second
  • 5 GB of new data a day, about 9 TB over 5 years, about 27 TB with 3 replicas
  • About 7 app servers at 5K QPS each, and about 3,500 requests in flight

The estimator on Designbench
The estimator on Designbench with its URL shortener preset. Move any slider and every number updates.

Notice the shape: a read-heavy system where writes are tiny. That points to caches and read replicas, not sharding. Reads scale with caches and replicas; writes scale only with sharding, batching or doing less work. See Sharding.

Round 7: Say it in 60 seconds

"Assume 200M daily users making 20 requests each: 4 billion a day, about 46K per second on average and about 140K at peak, so 30 to 40 app servers with headroom. 5% are 500 KB uploads, so 100 TB of new photos a day, about half an exabyte over 5 years with 3 copies. That means an object store and a CDN for reads, with a metadata database that stays small. The first thing to break is read bandwidth, so the CDN comes first."

Common mistakes

  • Sizing for the average. Say which peak you are designing for.
  • Confusing QPS with concurrency. Use Little's law.
  • Forgetting replicas and overhead. Three replicas triple storage; indexes, metadata and free space add another 30–100%.
  • Ignoring bandwidth. For media, bytes per second run out long before CPU does.
  • Treating reads and writes the same. They scale in different ways.
  • False precision. "11,574 QPS" invites "why?". Say "about 12K" and name the assumptions behind it.

Practise it

Step through the photo-app story, race the latency ladder and play with the estimator in Back-of-the-envelope math on Designbench, part of the free first chapter. Then size real systems: a URL shortener and a news feed.

Top comments (0)