Back-of-Envelope
Math
In an interview, you don't need a calculator. You need approximations. Is this system handling 100 RPS or 100,000 RPS? The design changes completely.
Powers of Two (The Cheatsheet)
Data Volumes
"If you need to store 1 MB per user for 1 Million users..."
(2^20 × 2^20 = 2^40)
Standard Numbers
Seconds in a Day
86,400
Round to ~100,000 (10^5) for easy math.
Char Size
2 Bytes
UTF-16 (Java/JS) often uses 2 bytes. ASCII is 1.
UUID Size
16 Bytes
Standard 128-bit identifier.
Long / Int64
8 Bytes
Standard ID size in databases.
Latencies
- RAM: ~100ns
- SSD: ~100µs
- Region Roundtrip: ~150ms
Estimating QPS
Start with DAU (Daily Active Users).
Divide by seconds in a day (~10^5)
50,000,000 / 100,000 = 500 QPS
Don't forget Peak QPS
Traffic isn't flat. Usually multiply average by 2x - 5x for peak.
Estimating Storage
The Formula
Example: Chat app storing messages for 5 years.
- Message: 100 Bytes
- Volume: 50M msgs/day
- Time: 5 Years (~2000 days)
Estimating Bandwidth
Ingress (Incoming)
Uploads, Write requests.
Egress (Outgoing)
Downloads, Read responses. Usually much higher.
Practice: Twitter Feed
Assumptions
- • 200M DAU
- • 5 reads / user / day
- • 1 write / user / day (tweet)
- • Tweet size: 1KB (text + metadata)
- • Media: 1MB (avg)
- • 10% of tweets have media
Write QPS
200M / 10^5 = 2,000 QPS
Read QPS
1B / 10^5 = 10,000 QPS
Media Storage (Day)
200M tweets × 10% × 1MB
= 20M × 1MB = 20 TB / day