Chapter 2 · System Design Fundamentals

Back-of-the-Envelope Estimation

Rough maths you can do on the back of a napkin, for traffic, speed, storage, and network usage. In under a minute it tells you whether a design is even possible — and which part of it is going to be the real problem.

Open the companion slides
Reading time ~13 min Prerequisites Chapter 1 Audio 🔊 Hinglish read-aloud Next A Framework for System Design Interviews →

An estimate is not a prediction. It is a sanity check. It tells you whether you need one server or a thousand, which part of the system will cost the most, and whether the design is quietly assuming something that can't happen. The whole skill is one move done over and over: break a vague question into a chain of small numbers you can defend, multiply them together, and round generously at every step.

Primary source

Alex Xu, System Design Interview (Vol. 1), Chapter 2; the latency ladder traces back to Jeff Dean's "Numbers Everyone Should Know." Companion deck: slides — jump to any slide with the Slide N chips.
Go deeper: the interactive "Latency Numbers Every Programmer Should Know" — drag the year slider and watch the ladder shift.

Why estimate at all Slide 2

The same ten minutes of maths pays off in four different situations. And in an interview, the final number matters far less than whether you can get to one calmly.

In interviews

It shows you can take a vague question and split it into users, requests, data size, and copies — then talk your way to a total you can defend.

In production

It stops you buying far more servers than you need, or far fewer. It also shows you which part of the system will dominate the bill.

In planning

If a rough sketch already needs 80 PB of memory, the design is wrong. Much better to find that out in a meeting than three months into building it.

In conversation

Numbers settle arguments. "It feels slow" turns into "the slowest 1% of requests take 240 ms and we promised 80 ms" — and now the team knows what to do.

Powers of two Slide 3

Learn these once and storage maths becomes something you can do in your head. For rough work, just treat each binary step as the nearest round decimal number. Even after multiplying three of them together, you're only off by a few percent.

2^10
1,024
Kilo · KiB ≈ 10³
2^20
~1.05 M
Mega · MiB ≈ 10⁶
2^30
~1.07 B
Giga · GiB ≈ 10⁹
2^40
~1.10 T
Tera · TiB ≈ 10¹²
2^50
~1.13 Q
Peta · PiB ≈ 10¹⁵
Binary vs decimal

1 KB is 1,000 bytes. 1 KiB is 1,024 bytes — about 2.4% more. That gap widens as the units get bigger, reaching roughly 10% by the time you're talking terabytes. For rough estimates you can treat them as the same thing. When you're buying disks or reading a cloud bill, you can't.

The latency ladder Slide 4

These are worth learning by heart, at least roughly. They let you spot a design that assumes something impossible — like calling 50 different services one after another and still answering the user quickly.

OperationApprox timeRelative scale
L1 cache reference~0.5 ns
Main memory (RAM) read~100 ns
SSD random read (NVMe)~100 µs
Round-trip inside a datacenter~500 µs
Spinning-disk (HDD) seek~10 ms
Cross-region RTT (EU ↔ US-East)~80 ms
Cross-continent RTT (EU ↔ APAC)~200 ms
The reflex to keep

Memory is about 100× faster than an SSD. An SSD is about 100× faster than a spinning hard disk. Talking to another machine in the same data center lands somewhere between memory and SSD. Talking to another region costs you tens of milliseconds that no amount of clever code will remove — light travels through fibre at only about two-thirds of its speed in a vacuum, and that sets a hard floor for every hop across the planet.

The nines, and what they cost Slide 5

"Availability" is the percentage of time your system is up, and people count it in nines: 99.9% is "three nines". Each extra nine is roughly 10× harder to reach. Past three nines, most outages stop coming from broken hardware and start coming from deploys, config changes, and human mistakes. At that point the money goes into better process, not more spare machines.

AvailabilityAnnual downtimePer monthPer day
99% two nines~3.65 days~7.2 h~14.4 min
99.9% three nines~8.77 h~43.8 min~86 s
99.95%~4.38 h~21.9 min~43 s
99.99% four nines~52.6 min~4.3 min~8.6 s
99.999% five nines~5.26 min~26 s~0.86 s
Service A 99.9% × Service B 99.9% × Service C 99.9% = effective ~99.7% downtime ~26 h/yr
Availability multiplies, and it only goes down. If a request has to pass through three services that are each up 99.9% of the time, the best it can do is 0.999³ ≈ 99.7% — that's a jump from about 9 hours of allowed downtime a year to about 26. Every extra service you have to wait on makes your headline number worse.
Watch out · you have less room for error than you think

You win back some of what those extra services cost you by caching answers, retrying failed calls, and still returning something useful when one part is down. But the room for error is small: 99.95% availability allows only about 22 minutes of downtime per month, and a single bad deploy can eat half of it.

QPS — from users to load Slide 6

QPS means queries per second — how many requests hit your system every second. Start from how many users you have, multiply by how much each one does, then account for the fact that traffic is not spread evenly through the day. The average tells you how many servers you need to run normally. The peak tells you how much spare capacity you need for the busiest evening of the week.

DAU 5 M × actions / day 20 ÷ seconds / day 86,400 = avg QPS ~1,160 / s ×3 peak ~3.5k/s
The two numbers people forget are how often each user acts and how much busier the peak is than the average. A day has 86,400 seconds ≈ 10⁵, which is worth committing to memory.

Peak is 2–5× the average

Most consumer apps get 2–5× their daily average at the busiest hour. A chat app rises gently. A live sports stream spikes brutally.

Count reads and writes separately

Apps that read 10× more than they write need a very different design from ones that read 100× more. Never lump them together.

Plan for double

Size for the traffic you expect in 12–18 months, not today's. Buying slightly too much is cheap. Rebuilding the system in a panic is not.

Carry both numbers to the end

The average and the peak answer different questions and cost very different amounts. Keep both all the way through to your final answer.

Storage — four multipliers Slide 7

Forget any one of these and your answer will be roughly ten times wrong.

storage/year = items/day × avg_size × 365 × replicas × retention_years

Size the typical item and the big ones

A "post" might be 400 bytes of text on average, but carry a 2 MB photo. Break it down: text, metadata, attachments, indexes. Then add 20–30% for the overhead of storing it.

Copies: ×3, often more

Most databases keep 3 copies of everything in one region. Add a copy in another region for disaster recovery and you're at 4–6×. Erasure coding wins some space back, but costs CPU and speed.

Growth stacks on itself

If both your user count and the amount each user stores are growing, storage grows by the two multiplied together. Three years of 1.5× growth is 3.4×, not 4.5×.

The costs nobody counts

Indexes add another 30–80%. Logs are often bigger than the data they describe. And backups multiply the whole figure all over again.

Bandwidth — QPS × payload Slide 8

The maths here is easy. The catch is that data flowing in and data flowing out are rarely equal — and it's the data flowing out of the cloud that lands on your bill.

egress_Bps = read_QPS × avg_response_size
ingress_Bps = write_QPS × avg_request_size
Watch out · bits vs bytes

A network card sold as "10 Gbps" moves 10 gigabits per second, which is only about 1.25 GB of actual data per second — and less once you subtract protocol overhead and encryption. Plan on getting 60–70% of the advertised number when you're busy. Mixing up bits and bytes makes you wrong by a factor of 8, and it is by far the most common mistake.

Reading usually costs far more than writing

A video site receives about 1 MB per upload but sends about 500 MB per view — 500× more out than in. Messaging apps are roughly balanced. Search takes tiny queries and returns tiny answers, but does it constantly.

Where the bill hides

Inside one availability zone, network traffic is essentially free. Between zones it costs cents per GB. Between regions, or out to the public internet, it costs many times more. So estimate outbound traffic by where it's going.

Worked example: a social feed Slide 9

A Twitter-like app called Quill. We'll work out how much storage it needs, how many reads per second it serves, and how much data it sends out, all for the home timeline.

1 · Inputs
DAU = 40 M · posts/user/day = 0.5 · reads/user/day = 30 · post = 350 B text + 80 B meta
2 · Writes/s
40e6 × 0.5 / 86,400 ≈ 230/s avg · peak ×3 ≈ 700/s
3 · Reads/s
40e6 × 30 / 86,400 ≈ 13.9k/s avg · peak ×3 ≈ ~42k/s
4 · Raw storage
20M posts/day × 430 B ≈ 8.6 GB/day × 365 ≈ 3.1 TB/yr
5 · With ×3 replicas + indexes
3.1 TB × 3 × 1.5 ≈ ~14 TB/yr durable
6 · Peak read egress
42k/s × 12 KB/page ≈ ~500 MB/s ≈ 4 Gbps (before images)
Conclusion
Storage turns out to be tiny (~14 TB/yr). The thing that shapes this design is the sheer number of reads, not the data size — so it needs a cache holding the posts of the most-followed accounts.

Worked example: photo sharing Slide 10

A photo app called Pebble. Here the photos themselves dominate both storage and outbound traffic — the exact opposite shape from Quill.

1 · Inputs
DAU = 8 M · uploads/user/day = 0.4 · views/user/day = 60 · photo + thumbs ≈ 2.4 MB
2 · Daily new bytes
3.2M uploads/day × 2.4 MB ≈ ~7.7 TB/day
3 · Annual storage, replicated
7.7 TB × 365 × 3 ≈ ~8.4 PB/yr (+ ~10% metadata)
4 · Views/s
8e6 × 60 / 86,400 ≈ 5.6k/s avg · peak ×4 ≈ ~22k/s
5 · Peak egress
22k/s × ~310 KB/view ≈ ~6.8 GB/s ≈ 55 Gbps
Conclusion
You need petabytes of object storage, with older photos moved to cheaper tiers. The outbound traffic makes a CDN essential, and it has to serve most requests from its own cache. The upload side is trivial by comparison — a few dozen workers cover it.

Where envelope math goes wrong Slide 11

Rules that keep you honest Slide 12

Round hard

One meaningful digit is plenty. "About 50k QPS" is exactly the right level of precision for this kind of work.

Give a range

"Somewhere between 8 and 12 PB" is honest about what you don't know, and gives the person reviewing it something concrete to argue with.

Check the answer against reality

If your maths says one machine handles 10 million requests a second, or that a region needs 50 PB of memory, stop. Compare it to a real system you know.

Show your inputs

The value of an estimate is the list of assumptions behind it. Anyone should be able to change one number and redo the whole thing in 30 seconds.

The point of all this

You are not trying to be right to four decimal places. You are trying to be right within a factor of two, and fast enough to try five different "what if we…" scenarios before lunch.

Active recall

Cover the answers. Say each number out loud before you tap to check.

For mental math, 2¹⁰, 2²⁰, 2³⁰ ≈ which powers of ten?
Round each binary step to a decimal one.
2¹⁰ ≈ 10³ (a thousand), 2²⁰ ≈ 10⁶ (a million), 2³⁰ ≈ 10⁹ (a billion). Even after multiplying three of them together you're only off by a few percent, which is fine for rough work.
Roughly how much faster is RAM than SSD, and SSD than HDD?
Same ratio twice.
~100× each. RAM ~100 ns, SSD ~100 µs, HDD seek ~10 ms. Same-DC network (~500 µs) sits between RAM and SSD.
How much annual downtime does 99.9% allow?
"Three nines."
~8.8 hours/year (~43.8 min/month). Each extra nine is ~10× less downtime and ~10× harder to reach.
Seconds in a day, and why it matters?
It's the QPS denominator.
86,400 ≈ 10⁵. You divide (users × actions/day) by it to get average QPS, then multiply by a 2–5× peak factor.
A "10 Gbps" link delivers how many bytes per second?
Bits, not bytes.
~1.25 GB/s (÷8), and less after overhead — plan ~60–70% usable. Confusing bits and bytes is an 8× error.
The storage formula — name all five multipliers.
In order.
items/day × avg_size × 365 × replicas × retention_years. Forgetting replication, indexes, or growth is the usual reason estimates are 5–10× low.

Check yourself

Q1 A NIC is rated "10 Gbps." Roughly how much payload per second is that?
Why: Divide bits by 8: 10/8 = 1.25 GB/s, and less after overhead. Bits-vs-bytes is the classic 8× mistake.
Q2 Compared with the previous one, each additional nine of availability is roughly…
Why: Each nine cuts allowed downtime ~10×. Past three nines, the limiting factor becomes deploys and human error, not hardware.
Q3 How many seconds are in a day (the QPS denominator)?
Why: 60 × 60 × 24 = 86,400 ≈ 10⁵. Divide daily actions by it for average QPS.
Q4 To turn raw daily data into a yearly storage figure, you must also multiply by…
Why: Replication (×3+), indexes (+30–80%), and compounding growth are usually 5–10× the raw figure — the most common omission.
Q5 In the Quill social-feed example, what turned out to be the design driver?
Why: Storage came out tiny (~14 TB/yr), but reads peaked at about 42,000 per second. Serving that many reads — and caching the most-followed accounts — is what the design has to be built around.