03. Back-of-the-Envelope Estimates

Learning goals

By the end of this lesson you will be able to:

  • Roughly estimate QPS, storage, and bandwidth
  • Use simple powers of 10 without a calculator panic
  • Spot which part of a system will hurt first (reads, writes, or disk)
  • Use numbers to justify cache, CDN, queues, or sharding

Why this lesson exists (in plain English)

Imagine someone says: β€œDesign Instagram.”

Without numbers, you might draw 20 fancy boxes. With numbers, you might discover:

  • Writes are few β†’ one database is fine
  • Reads are huge β†’ you need cache
  • Photos are huge β†’ you need S3 + CDN, not Postgres BLOBs

Back-of-the-envelope estimates = rough math on a napkin (or whiteboard) to find the real bottlenecks.

Interview tip: interviewers care more about clear assumptions + order of magnitude than exact answers. Saying β€œabout 3,000 QPS” is better than silence.


A simple way to think about it

Ask only three questions:

QuestionWhat you calculateWhy it matters
How busy is the API?QPS (requests/sec)Do we need more servers / cache?
How much data do we keep?Storage (GB/TB)Disk size, DB choice, backups
How much data moves on the wire?Bandwidth (MB/s)CDN, NICs, cost

Everything else is a variation of these three.


Cheat sheet β€” numbers to memorize

You do not need precision. Round freely.

Time

ThingApproximate valueEasy memory trick
Seconds in a day86,400 β‰ˆ 10β΅β€œabout 100,000”
Seconds in a monthβ‰ˆ 2.5 million30 Γ— 86,400
Seconds in a yearβ‰ˆ 31 million β‰ˆ 3Γ—10⁷—

Size

UnitApprox bytesEveryday feel
1 KB10Β³a short paragraph / small JSON
1 MB10⁢a photo thumbnail / short song clip
1 GB10⁹a movie compressed a bit / big DB table
1 TB10ΒΉΒ²a large disk / serious data lake slice
1 PB10ΒΉβ΅β€œcompany-scale” storage

Traffic shortcuts

1 QPS   β‰ˆ 86,000 requests/day   β‰ˆ 2.5 million / month
10 QPS  β‰ˆ 860,000 / day
100 QPS β‰ˆ 8.6 million / day
1,000 QPS β‰ˆ 86 million / day

Latency intuition (bonus)

StoreTypical latency
Memory / Redis~0.1–1 ms
SSD disk read~0.1–1 ms (local) to a few ms
Network inside DC~0.5–2 ms
Cross-regiontens–hundreds of ms

You rarely compute latency in estimates, but it explains why cache helps.


Step 1 β€” Estimating QPS (how busy?)

QPS = Queries Per Second = how many requests hit your servers each second.

Formula

Average QPS β‰ˆ (DAU Γ— actions per user per day) / 86,400

Peak QPS β‰ˆ Average QPS Γ— peak factor

Peak factor is usually 2Γ— to 5Γ— (lunch, evenings, launches, cricket final).

Worked example A β€” Twitter-like home feed

Assumptions (say them out loud in an interview):

  • 200 million daily active users (DAU)
  • Each user opens the app 5 times/day and loads the feed once per open
Feed requests / day = 200M Γ— 5 = 1 billion
Avg QPS = 1,000,000,000 / 86,400 β‰ˆ 11,600 QPS
Peak (3Γ—) β‰ˆ 35,000 QPS

What this tells you: feed reads are a big deal β†’ cache timelines, CDN for media, many read replicas.

Worked example B β€” URL shortener redirects

Assumptions:

  • 100 million redirects/day
  • Creates are only 1 million/day
Redirect avg QPS = 100M / 86,400 β‰ˆ 1,160 QPS
Create avg QPS   = 1M / 86,400 β‰ˆ 12 QPS
Peak redirects (4Γ—) β‰ˆ 4,600 QPS

What this tells you: system is read-heavy (~100:1). Optimize redirect path with Redis. Don’t over-engineer the create path.

Worked example C β€” small startup chat app

Assumptions:

  • 50,000 DAU
  • Each sends 20 messages/day
  • Each also fetches inbox 10 times/day
Message sends / day = 50k Γ— 20 = 1M  β†’ write QPS β‰ˆ 12
Inbox loads / day   = 50k Γ— 10 = 500k β†’ read QPS β‰ˆ 6
Peak writes (5Γ— during evening) β‰ˆ 60 QPS

What this tells you: one solid backend + Postgres is plenty for MVP. WebSockets matter more than sharding.

Quick QPS practice table

Try filling the last column yourself, then check:

Product vibeDAUActions/user/dayAvg QPS (approx)
Local cafe app2,00032,000Γ—3/86k β‰ˆ 0.07 β†’ basically idle
College portal20,00010β‰ˆ 2 QPS
Mid-size SaaS500,00020β‰ˆ 115 QPS
Big social100M10β‰ˆ 11,600 QPS

Step 2 β€” Estimating storage (how much disk?)

Formula

Storage β‰ˆ number of new records Γ— size per record Γ— how long you keep them

Don’t forget: indexes, replicas, and backups often 2×–3Γ— the β€œraw” size.

How big is one record? (useful guesses)

DataRough size
User profile row1–2 KB
Tweet / chat message text0.5–1 KB
URL mapping row0.5 KB
JSON event (analytics)0.5–2 KB
Compressed photo100 KB–2 MB
HD photo2–5 MB
Short video (1 min)5–50 MB
HD movie1–5 GB

Worked example D β€” WhatsApp-like text messages

Assumptions:

  • 1 billion messages/day
  • Average message 100 bytes text + 400 bytes metadata β‰ˆ 500 bytes
  • Keep 2 years of history
Per day  = 1B Γ— 500 B = 500 GB/day
Per year = 500 GB Γ— 365 β‰ˆ 180 TB/year
2 years  β‰ˆ 360 TB raw
With replicas/indexes (~3Γ—) β‰ˆ 1 PB order of magnitude

What this tells you: messaging storage is serious β†’ shard by conversation/user, cold storage for old messages, maybe separate media store.

Worked example E β€” Instagram-like photos

Assumptions:

  • 100 million DAU
  • 10% upload 1 photo/day β†’ 10M photos/day
  • Average photo stored (after compression + variants) β‰ˆ 500 KB effective new bytes
  • Keep forever (5 years for estimate)
Per day = 10M Γ— 500 KB = 5 TB/day
Per year β‰ˆ 5 TB Γ— 365 β‰ˆ 1.8 PB/year
5 years β‰ˆ 9 PB (before redundancy)

What this tells you: never put photos in MySQL. Use object storage (S3) + CDN. DB only stores metadata (photo_id, s3_key, user_id).

Worked example F β€” URL shortener storage (small!)

Assumptions:

  • 100M new links/month
  • 500 bytes/row
  • Keep 5 years
Per month = 100M Γ— 500 B = 50 GB
Per year  = 600 GB
5 years   = 3 TB raw β†’ ~6 TB with indexes

What this tells you: storage is easy; redirect QPS + cache is the real topic.


Step 3 β€” Estimating bandwidth (how fat is the pipe?)

Formula

Bandwidth β‰ˆ QPS Γ— average response size

(Also estimate upload bandwidth separately if users send big files.)

Worked example G β€” feed API (JSON only)

Assumptions:

  • Peak feed QPS = 35,000
  • Each response β‰ˆ 50 KB JSON
35,000 Γ— 50 KB = 1,750,000 KB/s β‰ˆ 1.75 GB/s β‰ˆ ~14 Gbps

What this tells you: many app servers + maybe response caching. Still lighter than shipping images through your API.

Worked example H β€” serving images without CDN (bad idea)

Assumptions:

  • 10,000 image views/sec at peak
  • Average image 200 KB
10,000 Γ— 200 KB = 2,000,000 KB/s β‰ˆ 2 GB/s β‰ˆ ~16 Gbps from origin

What this tells you: put a CDN in front. Origin should mostly see cache misses.

Upload bandwidth example β€” video

Assumptions:

  • 100,000 users upload a 50 MB video each day
Daily ingest = 100k Γ— 50 MB = 5 TB/day
Avg upload rate = 5 TB / 86,400 β‰ˆ 58 MB/s β‰ˆ ~0.5 Gbps average
Peaks can be many times higher β†’ need direct-to-S3 uploads

Putting it together β€” full mini case studies

Case 1: Pastebin

AssumptionValue
Creates5M / day
Reads50M / day
Avg paste size10 KB
Retention1 year
Write QPS β‰ˆ 5M/86400 β‰ˆ 58
Read QPS  β‰ˆ 50M/86400 β‰ˆ 580
Peak reads (4Γ—) β‰ˆ 2,300

Storage/year β‰ˆ 5M Γ— 365 Γ— 10 KB β‰ˆ 18 TB

Design implication

FindingDecision
Writes lowSimple API + DB fine
Reads higherCache hot pastes
Storage largeBody in S3, metadata in DB

Case 2: Ticket booking (flash sale)

AssumptionValue
Tickets on sale50,000
Interested users hammering2,000,000 in 10 minutes
Each user retries checkout ~5 times
Requests in 10 min β‰ˆ 2M Γ— 5 = 10M
Seconds = 600
Effective QPS β‰ˆ 10M / 600 β‰ˆ 17,000 QPS spike

Design implication: queue + rate limit + hold seats. Average daily QPS is irrelevant β€” the spike is the product.

Case 3: Ride sharing location updates

AssumptionValue
Concurrent drivers online100,000
GPS update every4 seconds
Write QPS β‰ˆ 100,000 / 4 = 25,000 location writes/sec

Design implication: don’t write every ping to Postgres as a row forever. Use Redis GEO / in-memory + sampled history.

Case 4: YouTube-like watch traffic (simplified)

AssumptionValue
DAU50M
Videos watched / user / day5
Avg bytes streamed / watch (adaptive)80 MB
Watches/day = 50M Γ— 5 = 250M
Bytes/day β‰ˆ 250M Γ— 80 MB = 20,000 TB = 20 PB/day egress 😱

Design implication: almost all bytes must come from CDN, not your origin. Your estimate just proved why Netflix/YouTube are CDN companies as much as app companies.


Read vs write β€” always compute the ratio

Read:Write ratio β‰ˆ read QPS : write QPS
RatioTypical systemLean toward
100:1URL shortener, CDN originsCache, replicas
10:1Social feedCache + async fanout
1:1Chat send β‰ˆ receiveCareful with both paths
1:10Logging / metricsQueues, append stores

When is one machine not enough?

Rough beginner guardrails (not laws):

Resourceβ€œStill OK on one strong boxβ€β€œStart planning scale-out”
Simple API QPS< a few thousand> 10k sustained, or spiky
DB writes (single primary)< a few hundred–~1k TPSMulti-thousand writes/sec
DB size< a few TBMany TB + heavy indexes
Outbound bandwidth< 1 Gbps comfortableMulti-Gbps sustained

If your napkin math crosses these lines, mention replicas, cache, shard, queue, or CDN in the HLD β€” with a reason tied to the number.


A 5-minute interview recipe

Use this every time:

  1. Clarify DAU / actions (guess if needed, say you’re guessing)
  2. Compute avg QPS β†’ apply peak factor
  3. Estimate record size Γ— volume Γ— retention β†’ storage
  4. QPS Γ— payload size β†’ bandwidth (especially media)
  5. Read:write ratio β†’ pick cache / queue / shard story
  6. Circle the bottleneck in one sentence

Example one-liner:

β€œ~4k peak redirect QPS and 100:1 reads β†’ Redis cache in front of Postgres; storage is only a few TB so sharding can wait.”


Common beginner mistakes

  1. Fake precision β€” β€œQPS = 1,157.407” β†’ just say ~1,200
  2. Forgetting peaks β€” averages hide Black Friday
  3. Putting media size into the DB estimate β€” metadata β‰  video bytes
  4. Ignoring retention β€” 1 day of logs β‰  5 years of logs
  5. Designing Kafka on day one for 5 QPS β€” numbers should drive complexity

Practice problems

Try these before opening the answers.

Practice 1

DAU = 5 million. Each user makes 8 API calls/day. Peak factor = 3.
What is peak QPS?

Practice 2

A chat app stores 200 million messages/day at 1 KB each. Keep 90 days.
Approx raw storage for 90 days?

Practice 3

An image CDN edge sees 20,000 requests/sec, 150 KB average.
Approx bandwidth?

Practice 4

E-commerce: 100k orders/day, each order write hits DB once. Are writes the bottleneck?

Answers

1. Requests/day = 5M Γ— 8 = 40M β†’ avg QPS β‰ˆ 40M/86400 β‰ˆ 460 β†’ peak β‰ˆ 1,400 QPS.

2. Per day = 200M Γ— 1 KB = 200 GB β†’ 90 days β‰ˆ 18 TB raw (plus indexes/replicas in real life).

3. 20,000 Γ— 150 KB = 3,000,000 KB/s β‰ˆ 3 GB/s β‰ˆ ~24 Gbps.

4. Write QPS β‰ˆ 100k/86400 β‰ˆ 1.2 QPS β€” trivial. Catalog reads and payment latency matter more than order write volume.


Check your understanding

  1. Roughly how many requests/day is 1,000 QPS?
  2. Why multiply by a peak factor?
  3. DAU = 1M, each uploads a 2 MB photo once/day β€” daily ingest?
  4. Name one system that is storage-heavy but write-QPS-light.
Answers
  1. β‰ˆ 1,000 Γ— 86,400 β‰ˆ 86 million/day.
  2. Traffic is uneven; capacity must cover busy hours / events.
  3. 1M Γ— 2 MB = 2 TB/day.
  4. Pastebin / photo metadata systems / analytics cold store β€” many answers work if justified.

Recap

  • Estimates exist to find bottlenecks, not to impress with arithmetic
  • Master three tools: QPS, storage, bandwidth
  • Round bravely; state assumptions
  • End with: β€œSo the hard part is X, therefore we add Y.”

Next: Clients, Servers & APIs