Day 3 A-Foundations 2026-09-29 ← All lessons

Back-of-the-envelope estimation: QPS, storage, availability

Days 1 and 2 justified every decision with a number. Nobody hands you those numbers in an interview — you are expected to produce them in two minutes from a few assumptions, out loud, without a calculator. This lesson is the arithmetic, the numbers worth memorising, and the shortcuts that make it fast.

86,400 ≈ 105Seconds in a day, rounded. The single most useful shortcut (§1)
150 msRound trip California ↔ Europe. 4.8 years on human scale (§2)
63%Of requests hit a slow backend at fan-out 100, even at p99 (§4)
~55 PBFive years of Twitter media, from four assumptions (§5)

Key points

Outcomes

01Convert a daily volume into a per-second rate in your head, using the 105 shortcut.
02Recall the latency hierarchy well enough to say which of two designs is faster without measuring.
03Compute the availability of a chain of dependencies, and of a redundant pair.
04Produce QPS, peak QPS, and five-year storage for an unfamiliar system from stated assumptions.
01

The shortcuts: how to do this without a calculator


Data volume is measured in powers of two, but you estimate in powers of ten, and the error is small enough to ignore. Learn both columns and the gap between them.

UnitExactUse this insteadError
1 KB210 = 1,024 bytes1032%
1 MB220 = 1,048,5761065%
1 GB230 ≈ 1.07 × 1091097%
1 TB240 ≈ 1.10 × 1012101210%
1 PB250 ≈ 1.13 × 1015101513%

A byte is 8 bits; one ASCII character is one byte. The error column is the price of the shortcut — well inside the uncertainty of your assumptions.

The four conversions worth memorising

These turn almost every “how many per second?” question into mental arithmetic:

ShortcutWhy it worksUse it for
86,400 s/day ≈ 105Off by 16%, which rounds away immediatelyEvery daily-volume-to-QPS conversion
1 M/day ≈ 12/s106 ÷ 105 = 10, then nudge upSmall products, per-feature rates
1 B/day ≈ 12,000/sSame ratio, three zeros upAnything at internet scale
peak ≈ 2× averageTraffic is not flat; evenings and launches concentrate itCapacity planning. Say the factor out loud — some interviewers want 3×
What to say out loud “I'll round 86,400 seconds to 105 — that's about 16% high, so my QPS comes out slightly low, and I'll note that. If the answer lands near a capacity boundary I'll redo it exactly; otherwise the rounding is well inside the error on my assumptions anyway.” Stating the direction of your error is what separates estimation from guessing.
Interview tip — the four habits Round aggressively. 3,472 is “about 3,500”, and nobody cares.  Write assumptions down where the interviewer can see them, because that is the part they are actually grading.  Label every unit. Most wrong answers are a missing ×1000, not bad reasoning.  Say the number out loud when you get it — “so about 7,000 QPS, which is one modest server tier, not a thousand machines” — because the interpretation is the point, not the digits.
02

Latency: the numbers, and the only way to remember them


Raw nanoseconds are impossible to hold in your head, because the range spans eight orders of magnitude. The trick is to multiply everything by one billion, turning nanoseconds into seconds. Suddenly the numbers are things you have intuitions about.

How to read: Each level is a place your data might live. Width is roughly capacity — the further down, the more room and the longer the wait. The right-hand column is the same number with every unit scaled up a billion times, which is the version you will actually remember.

closer and smaller real time × 1,000,000,000 L1 cache 1 ns1 second L2 cache 4 ns4 seconds main memory (RAM) 1 MB sequential read: 3 µs 100 ns1.7 minutes SSD random read 1 MB sequential read: 49 µs 16 µs4.6 hours spinning disk seek 1 MB sequential read: 825 µs 2 ms23 days network, California ↔ Europe same data centre round trip: 500 µs 150 ms4.8 years A disk seek is 20,000 memory reads. A trip across the Atlantic is 1.5 million.
Figures from Jeff Dean's “Latency numbers every programmer should know” (2010, revised 2020). The point is not the exact digits — it is the gaps between the rows.

The full list, on a log scale

L1 cache reference1 ns
Branch mispredict3 ns
L2 cache reference4 ns
Mutex lock/unlock17 ns
Send 2 KB over network44 ns
Main memory reference100 ns
Compress 1 KB (Zippy)2 µs
Read 1 MB from memory3 µs
SSD random read16 µs
Read 1 MB from SSD49 µs
Round trip, same data centre500 µs
Read 1 MB from disk825 µs
Disk seek2 ms
Round trip, CA ↔ Netherlands150 ms

📏 Log scale — each step right is roughly 10×. Bar length shows order of magnitude, not raw proportion.

Interview tip — what these numbers tell you to do Memory is fast, disk is slow — so cache aggressively, and prefer sequential reads to random ones (1 MB sequentially off disk costs less than half a single seek).  Compress before sending over the internet — compressing 1 KB costs 2 µs, and sending it across an ocean costs 150,000 µs. The compression is free by comparison.  Cross-region calls are enormous — a design that makes three sequential cross-ocean round trips has spent 450 ms before doing any work. Batch them, or move the data.
03

Availability: the nines, and the arithmetic nobody does


Availability is quoted as a percentage of time the system is up. Cloud providers' SLAs sit at 99.9% or above. The percentages look close together and the downtimes do not:

AvailabilityNameDown per dayDown per yearWhat this feels like
99%two nines14.4 min3.65 daysUsers notice weekly. Not acceptable for a paid product
99.9%three nines1.44 min8.77 hoursStandard cloud SLA. One bad afternoon a year
99.99%four nines8.64 s52.6 minNeeds redundancy everywhere and automated failover
99.999%five nines0.86 s5.26 minNo human can respond that fast. Everything must self-heal

Each additional nine divides downtime by ten and multiplies engineering cost by considerably more.

Try it: set how many services you call synchronously and how good each one is. Then tick the box to make every one of them a redundant pair.

services you must wait on to answer one request
drag for one to five nines
two independent copies: failure rates multiply
effective per dependency
99.9%
your ceiling
99.7%
the product of the chain
downtime per year
26 hours

Series multiplies availabilities; parallel multiplies failure rates. Knowing which one applies is most of the answer to “how would you improve availability?”

The part that is usually skipped: nines compose

Your service is not one thing. It is a chain of things, and availability multiplies down the chain — every dependency drags you below your weakest link, not down to it. Redundancy works the other way: two copies are unavailable only when both fail, so their failure probabilities multiply instead.

How to read: Top row — things you depend on, in series. Multiply the availabilities. Bottom row — redundant copies, in parallel. Multiply the failure rates, which is the same arithmetic pointed in a much friendlier direction.

in series — every dependency costs you auth service99.9% × database99.9% × payment API99.95% = 99.75% — worse than any one part about 22 hours down per year in parallel — redundancy pays compound interest replica A99% replica B99% = 99.99% — four nines from two cheap parts both must be down at once: 1% × 1% = 0.01% Only true if the two failures are independent. Same rack, same power: they are not.
Series: 0.999 × 0.999 × 0.9995 = 0.9975. Parallel: 1 − (0.01 × 0.01) = 0.9999. Both are one line of arithmetic, and knowing which one applies is most of the answer.

SLI, SLO, SLA, error budget — four words people use interchangeably

They are not synonyms, and mixing them up is the kind of precise misuse that reads badly.

TermWhat it isWho it is for
SLI — indicatorThe measurement. “Fraction of requests served in under 300 ms with a 2xx.”Engineers. It is a number you can graph.
SLO — objectiveThe target you set for that measurement. “99.9% over 30 days.”Your team. Internal, and deliberately stricter than the SLA.
SLA — agreementThe contract, with a penalty attached. “99.5%, or you get service credits.”Customers and lawyers. Always looser than the SLO, so you breach the internal target first and have room to react.
Error budget1 − SLO, spent rather than avoided. A 99.9% SLO is a budget of 43 minutes a month.Both. It converts reliability from an argument into arithmetic.

The error budget is the genuinely useful idea: it makes “should we ship this risky change?” answerable. Budget remaining → ship. Budget spent → the next sprint is reliability work. Nobody has to win a debate.

MTBF and MTTR — the cheaper lever Availability is roughly MTBF / (MTBF + MTTR) — mean time between failures over mean time to recover. Both improve it, but they cost very differently. Halving your failure rate means finding and fixing whole classes of bug. Halving your recovery time means better alerting, a faster rollback, and a runbook. Reducing MTTR is almost always the cheaper nine, and it is the answer interviewers are usually fishing for when they ask how you would improve availability. The corollary for design: prefer things that fail fast and recover automatically over things that fail rarely and need a human.
Gotcha — independence is an assumption, not a fact The parallel calculation only holds if the two replicas fail for unrelated reasons. Two instances in the same rack share a power supply and a top-of-rack switch. Two instances in the same availability zone share a building. Two instances running the same buggy build share the bug. Every one of those turns your 99.99% back into something close to 99%. When you claim redundancy, say what the copies do not share.
What to say out loud “My service calls three dependencies synchronously, so my ceiling is their product — about 99.75%, roughly 22 hours a year. If I need better than that, I either remove a dependency from the critical path by making it async, or I add a fallback so its failure degrades the response instead of failing it.” That sentence is a complete answer to “how would you improve availability?”
04

The tail: why averages lie once you fan out


Everything so far has been about averages. One more piece of arithmetic matters more than any of it, and it is the single most useful thing on this page for a deep dive.

Suppose a backend is fast: p99 of 10 ms — only one request in a hundred is slow. Now your service fans out to many of them in parallel and must wait for all the replies. The chance that at least one is slow is 1 − 0.99N:

1 backend call1%
10 calls in parallel9.6%
100 calls in parallel63%
500 calls in parallel99.3%

Probability that a request waits on at least one slow backend, given each backend has a p99 of 10 ms. Linear scale.

Read that third row again. With a fan-out of 100, the median user request now contains a slow call. Your service's p50 is governed by your backends' p99 — so a backend that looks perfectly healthy on its own dashboard is the thing making you slow. This is why large fan-out systems obsess over tail latency while small ones can ignore it, and why “the average is fine” is not a defence.

The standard responses, worth naming:

Interview line “Each shard is p99 10 ms, but I'm fanning out to 100 of them per query, so roughly two thirds of my requests touch at least one slow shard — my p50 is set by their p99. I'd either hedge after the p95, or serve partial results once 95% of shards have replied.” This is one of the highest-value things you can say in a deep dive, because almost nobody does the fan-out arithmetic out loud.

Dean & Barroso, “The Tail at Scale”, CACM 2013 — the source for hedged and tied requests, and for the observation that some latency variability is inherent and some is self-inflicted.

05

Worked example: size Twitter in two minutes


The classic. Four assumptions in, four numbers out. Watch where each shortcut from §1 gets used.

Assumptions — state these before calculating anything 300 M monthly active users · 50% use the product daily · 2 tweets per user per day · 10% of tweets carry media at ~1 MB · media retained for 5 years.

How to read: Start at the top with the only number you were given. Each arrow is one multiplication. The left branch gives you throughput, the right branch gives you storage — and both hang off the same intermediate figure, which is why you compute daily actives first.

300 M monthly activesthe one number you were given × 50% daily 150 M daily actives × 2 tweets each ÷ 105 seconds × 2 × 10% with media × 1 MB each ~3,500 tweets / secondaverage write rate 30 TB / daynew media × 2 for peak × 365 × 5 ~7,000 QPS at peakwhat you size the write tier for ~55 PBwhat you size storage for
Every box is one multiplication away from the box above it. If an interviewer disagrees with an assumption, you change one number and rerun the branch — which is exactly why you write the assumptions down first.
  1. Daily actives

    300 M × 50% = 150 M. Monthly-to-daily is almost always the first conversion; nothing else can be computed until you have it.

  2. Average write rate

    150 M × 2 tweets = 300 M tweets/day. Divide by 105 → 3,000/s. The true divisor is 86,400, so nudge up: ~3,500 tweets/second.

  3. Peak

    Double it: ~7,000 QPS. Say the factor aloud so the interviewer can push back if they want 3×.

  4. Media per day

    300 M tweets × 10% with media × 1 MB = 30 M MB = 30 TB/day. Watch the unit step: MB → TB is two jumps of 1,000.

  5. Five-year storage

    30 TB × 365 × 5 ≈ 54,750 TB ≈ 55 PB. Round the moment the leading digits stop changing.

Now interpret it — this is the part being graded

Numbers alone score nothing. The follow-through does:

Now change the assumptions

The real skill is not computing these once — it is re-running them when the interviewer says “actually, assume 10× the media.” Drag anything and watch which number becomes the constraint.

Try it: the defaults are the Twitter example above. Push media size to 5 MB and watch storage take over. Push read:write to 100 and watch the read path become the whole problem.

daily actives
150 M
writes / second
3.5 K/s
average
peak writes
6.9 K/s
what you size for
reads / second
35 K/s
storage / day
30 TB
storage, full retention
54.8 PB

The “mental arithmetic” line shows the 105 shortcut against the exact answer, so you can see how small the rounding error actually is at whatever scale you dial in.
Practise this shape The same five steps size almost anything. Try it on a photo-sharing app: 500 M MAU, 40% daily, 1 upload per user per week, 2 MB per photo, kept forever. Work out uploads/second, peak, and one year of storage before reading on — you have every shortcut you need. (Roughly 230 uploads/s, 460 at peak, and about 15 PB a year.)
Q&A

Check yourself


Estimation questions are never really about arithmetic. They are about whether you notice the number that was not given to you.

Q1“Design Instagram.” You state 500M DAU, 2 photo views each, and start sizing the write path. The interviewer says nothing. What did you get wrong?
  • 500M DAU is too high an assumption
  • Views are reads — you have sized the wrong path, and have not asked for the upload rate or the read:write ratio at all
  • You should have asked about video
✓ You conflated the read and write workloads. “2 photo views each” is a read figure; it tells you nothing about uploads, and uploads are what drive storage. The numbers you actually need are three: uploads/day (drives storage and write QPS), views/day (drives read QPS, cache sizing and CDN spend), and average object size. For a photo product the ratio is enormous — perhaps 1 upload per user per week against dozens of views per day, so reads outnumber writes by something like 1000:1, and essentially the entire design is a read-path design. Getting that ratio wrong by two orders of magnitude means you spend the interview on the wrong half of the system, which is a much more expensive error than being 20% off on any single figure. Use the §5 calculator: set read:write to 200 and watch which cell turns red.
Q2You estimate 500 TB of user photos. The interviewer asks: “how many servers?” What is wrong with answering “500 TB ÷ 10 TB per disk = 50 servers”?
  • Nothing — that is the correct calculation
  • It ignores replication, filesystem and headroom overhead, and — more importantly — capacity is rarely what determines the server count
  • Disks are larger than 10 TB now
✓ It ignores both the multipliers and the real constraint. The multipliers: 3× replication makes it 1.5 PB, you never run disks past ~70% full, and there is filesystem and metadata overhead — so the honest figure is 3–4× your raw estimate. The deeper point: storage systems are usually sized by throughput or IOPS, not capacity. If those 50 machines have to serve 100,000 reads/s and each disk does 200 random IOPS, you need far more spindles than capacity alone suggests — you end up buying servers for their IO and getting the capacity for free. Say both halves out loud: “raw capacity says 50, replication and headroom say ~175, but let me check the IOPS requirement because that usually dominates.” That sentence is the whole answer.
Q3Your service promises 99.95%. It calls auth (99.99%), a database (99.95%) and a recommendations service (99.5%), all synchronously. Can you meet the promise? If not, what is the cheapest fix?
  • Yes — your own code is highly available
  • No: the product is ~99.44%, about 49 hours a year. The cheapest fix is making recommendations non-blocking
  • No — add a redundant copy of each dependency
✓ No — 0.9999 × 0.9995 × 0.995 ≈ 0.9944, roughly 49 hours a year. You are already below your promise before writing a line of code. The cheapest fix is architectural, not infrastructural: recommendations is the weak link at 99.5%, and it is also the one dependency whose absence a user can survive. Wrap it in a timeout with a fallback — show popular items instead of personalised ones — and it leaves the availability calculation entirely, taking you to 0.9999 × 0.9995 ≈ 99.94%. The general principle is that a dependency only costs you availability if its failure fails your request. Timeouts with fallbacks, circuit breakers and async writes are all ways of converting a hard dependency into a soft one, and they cost nothing in hardware. Making every dependency redundant is the expensive path to the same place. Try it in the §3 calculator: three deps at three nines is 99.7%; two is 99.8%.
Q4Design A makes one cross-region call per request. Design B makes twelve same-data-centre calls. Which is faster, and what is the catch in the comparison?
  • A — fewer calls is always better
  • B, by roughly 25× (6 ms versus 150 ms) — but only if the twelve are independent and can run in parallel, and only for p50
  • They are comparable
✓ B, by about 25× — and the catch is tail latency. Twelve local round trips at 500 µs cost 6 ms; one Atlantic crossing costs 150 ms. Distance, not call count, is what you optimise. But two caveats a good interviewer will raise. (1) Sequential versus parallel: if the twelve calls are a dependency chain, you pay all twelve latencies in series; if they fan out in parallel you pay roughly the slowest one. (2) Tail amplification: if each local call has a p99 of 10 ms, the chance that at least one of twelve is slow is about 1 − 0.9912 ≈ 11%, so your p99 is dominated by the worst of the twelve rather than the average. This is why fan-out-heavy services obsess over tail latency and use hedged requests. “Chatty but local beats minimal but remote” is right at p50 and needs care at p99.
Q5Halfway through sizing, the interviewer says: “actually, assume ten times the traffic.” What should change in your design, and what should not?
  • Everything scales by ten — ten times the servers
  • Numbers scale linearly, but the architecture only changes where a 10× number crosses a threshold — and you should name which ones do
  • You need to start over with a different design
✓ Re-run the arithmetic, then say which thresholds got crossed. Most quantities scale linearly and are boring. What matters is the handful that cross a qualitative boundary: a dataset that fitted on one machine and now does not (you are sharding); a write rate that fitted a single primary and now does not (same); a working set that fitted in cache and now does not (hit rate collapses, and the database sees 10× the misses, not 10× the reads); a storage figure that moves from “a big disk” to “object storage and a CDN”. Equally important is what does not change: your stateless web tier just gets more boxes, your queue gets more consumers, your CDN does not care. The answer they are grading is “here are the two places my design breaks and here is what replaces them” — not a recomputed table. This is exactly what the §5 calculator is for: drag the sliders and watch which cell turns red first.
In practiceWhat production adds, and the questions that come next optional

This lesson covers the layer that decides an interview. Below it is the operational layer — the things that only show up once a system is running, and the questions that come if someone keeps pulling the thread. None of it is answered above.

Cost and capacity

  • Headroom planning: target utilisation, burst capacity, autoscaling lag, and pre-warming
  • Why cross-AZ and cross-region data transfer is often the surprise on the bill

Latency numbers

  • Where the TLS handshake, DNS lookup, and TCP slow start show up in a first-byte measurement

Terms used

QPS
Queries per second. Usually quoted as an average; always ask for or state the peak as well.
Peak QPS
The rate you actually size for. A factor of 2–3 over average unless you know better.
DAU / MAU
Daily and monthly active users. The DAU/MAU ratio is a standard product metric and a standard interview assumption.
Availability
Fraction of time the system serves requests successfully.
SLA
Service level agreement — the availability a provider contractually commits to.
Nines
Shorthand for availability: three nines is 99.9%, four is 99.99%.
Failure domain
The blast radius of one failure: a machine, a rack, a zone, a region. Redundancy only helps across domains.
Sequential vs random read
Reading adjacent bytes versus jumping around. On disk the difference is a factor of thousands.

What breaks next. You can now size a system and argue about its availability. What you cannot yet do is run the 45 minutes in which all of this is supposed to happen — when to ask questions, when to draw, when to stop designing and start defending. Day 4 is the structure that holds the whole interview together.

Source: System Design Interview, Ch. 2 — Power of two, Latency numbers, Availability numbers, Example: Twitter QPS and storage (pp. 1–10). Latency figures from Jeff Dean (2010, rev. 2020). The human-scale column, the shortcut table and the availability composition arithmetic are standard practice added here.