SkillSprout
Chapter 1 · Lesson 4
Beginner
9 min read

Back-of-the-Envelope Estimation

Overview

Estimation means doing rough, rounded arithmetic to learn how big a system must be. Interviewers do not check your decimals. They check whether you can turn "50 million users" into "about 20,000 requests per second and 70 terabytes a year" and then say what that means for the design. This lesson gives you the powers of two, a latency cheat sheet, the formulas for requests per second and storage, and three fully worked examples.

Detailed Notes

What Is It?

Back-of-the-envelope estimation is quick, approximate calculation, named after doing sums on the back of an envelope. You use a few given assumptions plus well-known constants to compute QPS, storage, bandwidth and number of servers.

Terms you need:

  • QPS (queries per second, also RPS, requests per second): how many requests hit the system each second. Peak QPS is the busiest moment, average QPS is over a whole day.
  • DAU (daily active users): distinct users who use the product in a day.
  • Throughput: amount of work completed per second, such as requests or megabytes.
  • Bandwidth: amount of data moved per second, such as 200 MB/s.
  • Capacity: how much load a machine or system can handle.

Why Do We Need It?

Numbers tell you which problems are real. Compare:

  • 100 requests per second: one small server and one database are enough, so complex distributed design would be overengineering.
  • 100,000 requests per second: you need many servers, caching, and partitioned storage.

The same feature has completely different designs at those scales. Estimation also reveals whether the system is read-heavy (many more reads than writes, so cache) or write-heavy (many more writes, so queues and partitioned storage), and whether bandwidth or storage is the limiting resource. Doing this out loud shows maturity: you size before you design.

How Does It Work?

Powers of two and data sizes

Computers count in powers of two. Memorize these rounded values:

PowerExact valueApproxName
2^101,0241 thousand1 KB (kilobyte)
2^201,048,5761 million1 MB (megabyte)
2^301,073,741,8241 billion1 GB (gigabyte)
2^40about 1.1 trillion1 trillion1 TB (terabyte)
2^50about 1.1 quadrillion1 quadrillion1 PB (petabyte)

So each unit is 1,000 times the previous one in an estimate. Typical object sizes: a character is 1 byte, a tweet-like text about 300 bytes, a database row 0.5-1 KB, a web photo 200 KB to 2 MB, a minute of compressed video 5-50 MB.

Latency numbers cheat sheet

Latency is the time one operation takes. These rounded values (order of magnitude, not exact for your hardware) let you judge designs:

Latency Cheat Sheet (Order of Magnitude)
Estimation

Request load

100 nsmain memory read
baseline
100 usSSD random read
1,000x memory
0.5 msround trip in a data center
5x SSD
10 mshard disk seek
20x data center
150 msround trip across oceans
15x disk seek

Cache in memory

~0.1 ms

a Redis-style lookup incl. network hop

Cache hot data instead of querying the database

Same-region call

~1 ms

service to service or database

Limit sequential calls; 10 calls is about 10 ms

Cross-region call

100-200 ms

user to far data center

Use a CDN and regional deployment
Key point. Memory is about 1,000x faster than SSD; a cross-ocean round trip is about 1,000,000x slower than memory.

Each step to the right is roughly 10 to 1,000 times slower. Exact values depend on hardware.

The pattern to remember: memory is about 1,000 times faster than an SSD, and a disk seek or a trip across an ocean is about 100,000 times slower than memory. The consequences: keep hot data in memory (cache), avoid unnecessary network hops, do one big sequential read rather than many random ones, and do not make users wait on cross-region calls.

Time conversions

A day has 86,400 seconds. Use 100,000 (10^5) in interviews; the error is under 15% and the division is trivial. A month is about 30 days (about 3 million seconds with this rounding), so divide monthly totals by 30 to get a daily figure. A year is 365 days, about 30 million seconds (the exact value is 31.5 million).

Core formulas

text
Average QPS   = requests per day / 100,000
Peak QPS      = average QPS x peak factor (2 to 5; use 3)
Storage/day   = new records per day x bytes per record
Storage total = storage/day x 365 x years kept (x replication factor)
Bandwidth     = QPS x bytes per request
Servers       = peak QPS / QPS one server handles (then add headroom)

Replication factor means how many copies you keep for safety; three copies triple the raw storage. Headroom means spare capacity so servers are not running at 100%; planning for about 50% utilization is common.

Worked example 1: a chat app

Assume 50 million DAU, each sending 40 messages a day, 100 bytes per message.

text
Messages per day  = 50M x 40            = 2 billion
Average QPS       = 2B / 100,000        = 20,000 per second
Peak QPS          = 20,000 x 3          = 60,000 per second
Storage per day   = 2B x 100 bytes      = 200 GB
Storage per year  = 200 GB x 365        = 73,000 GB, about 73 TB
With 3 copies     = 73 TB x 3           = about 220 TB per year

So what: 60,000 writes per second is far beyond one database, so we must partition (split data across machines); 73 TB a year of text is manageable with a partitioned store and tiering of old data.

Worked Example: Chat App Load
Estimation

Request load

50Mdaily users
given
2Bmessages / day
x 40 each
20K/saverage QPS
/ 100,000 s
60K/speak QPS
x 3 peak factor

Storage per year

73 TB

200 GB/day x 365 (100 bytes/message)

Partition and move old data to cheaper tiers

With 3 copies

~220 TB

73 TB x 3 replicas

Budget raw capacity, not just logical size

Servers at peak

~60

60K / 2,000 per server = 30, doubled for headroom

Spread across zones for failure tolerance
Key point. 60,000 writes per second means the message store must be partitioned; the data volume itself is modest.

From 50 million users to storage and QPS in five lines of arithmetic.

Worked example 2: a photo-sharing app

Assume 10 million DAU, 1 photo uploaded per user per day on average, 2 MB each, and a read ratio of 20 views per upload.

text
Uploads per day   = 10M x 1             = 10M
Upload QPS        = 10M / 100,000       = 100 per second (peak 300)
Storage per day   = 10M x 2 MB          = 20 TB
Storage per year  = 20 TB x 365         = 7,300 TB, about 7.3 PB
Upload bandwidth  = 100/s x 2 MB        = 200 MB/s average
View QPS          = 100 x 20            = 2,000 per second

So what: 20 TB a day is far too much for a database, so photos go to cheap object storage (a service that stores large files by key); 2,000 view requests per second are easy, but photos are large, so a CDN must absorb that bandwidth: 2,000/s x 2 MB is 4 GB/s of egress otherwise.

Worked example 3: how many servers?

Assume the API receives 30,000 peak QPS and one server handles 1,000 QPS.

text
Servers needed   = 30,000 / 1,000       = 30
Target 50% load  = 30 / 0.5             = 60 servers
Across 3 zones   = 20 servers per zone

If one zone fails, 40 servers remain, carrying 30,000 / 40 = 750 QPS each, which is 75% of capacity. Fine: the headroom pays off exactly in a failure.

How to do it well

  1. State assumptions first and round aggressively (2 billion, not 1.93 billion).
  2. Write units on every line to catch mistakes (bytes versus bits, per day versus per second).
  3. Estimate from users to requests to data, in that order.
  4. End with a "so what" for each number: partition, cache, queue, CDN, or "ignore, it is small".
  5. Sanity check: if your result says one server should store the whole internet, an assumption is wrong.

Interview tip. Common mistakes: forgetting the peak factor, mixing bits and bytes (network speeds are often in bits), dropping three zeros, spending ten minutes on precision, and producing numbers that never change the design.

Interview discussion. "I will round a day to 100,000 seconds. 2 billion messages a day is 20,000 per second on average, and I'll plan for 3x peak, about 60,000. That is well beyond one database, so I'll partition the message store."

Real-World Example

A team plans a launch for a ticketing site. Marketing says 1 million people may arrive within 10 minutes (600 seconds). That is about 1,700 arrivals per second; if each page load makes 5 calls, it is about 8,500 QPS, ten times normal traffic. The estimate tells the team to add a waiting room (a queue that admits users gradually) and pre-scale servers instead of discovering the problem live.

System Design Example

For the URL shortener, 500 million links per month gives about 200 writes per second and, at 100 reads per write, 20,000 reads per second and 60,000 at peak. Thirty billion links at 500 bytes is 15 TB. Those numbers justify three decisions: cache the reads, partition 15 TB across machines, and ignore bandwidth because redirects are tiny. Every design lesson follows this pattern.

Trade-off thinking. More precision costs time and rarely changes the design. Rounding up is safer than rounding down for capacity (underestimating means an outage), but over-rounding wastes money. State your margin: "I'll assume 3x peak and revisit if the interviewer has real traffic data."

Key Interview Takeaway

Use 100,000 seconds per day, a peak factor of 3, and round numbers. Know the latency ladder (memory, SSD, network, disk, cross-ocean). Compute QPS, storage and servers, and finish every figure with the design decision it causes.

Common Interview Questions

Finished this lesson?

0 of 44 lessons done · 0% of the course