Interview Critical: Every system design interview starts with capacity estimation. Master these calculations to ace the first 5 minutes and build credibility.
The Art of Estimation
Good estimates arenβt about being exactβtheyβre about:- Showing structured thinking
- Understanding orders of magnitude
- Identifying bottlenecks early
- Making reasonable assumptions
π§ Numbers You Must Memorize
Time Constants
Copy
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TIME REFERENCE CARD β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Seconds in a day: 86,400 β 100,000 (10^5) β
β Seconds in a month: 2.6 million β 2.5 Γ 10^6 β
β Seconds in a year: 31.5 million β 30 Γ 10^6 β
β β
β Quick Conversion: β
β β’ 1 day = 86,400s β 10^5 s β
β β’ 1 week = 604,800s β 6 Γ 10^5 s β
β β’ 1 month = 2.6Ms β 2.5 Γ 10^6 s β
β β’ 1 year = 31.5Ms β 3 Γ 10^7 s β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Latency Numbers (Jeff Deanβs Famous List)
Copy
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LATENCY NUMBERS (2024) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β L1 cache reference 0.5 ns β
β L2 cache reference 7 ns β
β Main memory (RAM) reference 100 ns β
β Send 1KB over 1 Gbps network 10 ΞΌs β
β SSD random read 100 ΞΌs (0.1 ms) β
β Read 1 MB sequentially from memory 250 ΞΌs β
β Round trip same datacenter 500 ΞΌs (0.5 ms) β
β Read 1 MB sequentially from SSD 1 ms β
β HDD seek 10 ms β
β Read 1 MB sequentially from HDD 20 ms β
β Send packet CA β Netherlands β CA 150 ms β
β β
β Rule of Thumb: β
β β’ Memory: 100 ns = 10^-7 s β
β β’ SSD: 100 ΞΌs = 10^-4 s β
β β’ Network (same DC): 1 ms = 10^-3 s β
β β’ Network (cross-continent): 100 ms = 10^-1 s β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Data Size Reference
Copy
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA SIZE REFERENCE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1 char (ASCII) 1 byte β
β 1 char (UTF-8, avg) 2-3 bytes β
β 1 Integer (32-bit) 4 bytes β
β 1 Long/Timestamp (64-bit) 8 bytes β
β 1 UUID 16 bytes β
β β
β Tweet (280 chars + metadata) ~500 bytes - 1 KB β
β Average web page 2-5 MB β
β Average photo (compressed) 200 KB - 2 MB β
β Average short video (1 min) 10-50 MB β
β HD Video (1 hour) 1-4 GB β
β β
β Memory Tiers: β
β β’ 1 KB = 10^3 bytes β
β β’ 1 MB = 10^6 bytes β
β β’ 1 GB = 10^9 bytes β
β β’ 1 TB = 10^12 bytes β
β β’ 1 PB = 10^15 bytes β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Capacity Numbers
Copy
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SERVER CAPACITY REFERENCE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Single Web Server: β
β β’ Simple API: 1,000 - 10,000 QPS β
β β’ Complex API: 100 - 500 QPS β
β β’ Concurrent connections: 10K - 100K β
β β
β Database Server: β
β β’ MySQL/Postgres simple queries: 1,000 - 5,000 QPS β
β β’ MySQL/Postgres complex joins: 100 - 500 QPS β
β β’ Redis in-memory: 100,000+ QPS β
β β’ Cassandra write-heavy: 10,000+ QPS β
β β
β Message Queue: β
β β’ Kafka per partition: 10,000+ msg/sec β
β β’ RabbitMQ per queue: 1,000 - 10,000 msg/sec β
β β
β Network: β
β β’ 1 Gbps = 125 MB/s β
β β’ 10 Gbps = 1.25 GB/s β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Estimation Formulas
Query Per Second (QPS)
Copy
# Basic QPS Formula
QPS = (Daily_Active_Users Γ Actions_Per_User_Per_Day) / Seconds_Per_Day
# With Peak Factor (typically 2x-3x average)
Peak_QPS = QPS Γ Peak_Factor
# Example: Instagram-like app
# 500M DAU, 20 feed views/day, Peak 3x
QPS = (500M Γ 20) / 86,400
= 10B / 86,400
β 10B / 100K
= 100,000 QPS
Peak_QPS = 100,000 Γ 3 = 300,000 QPS
Storage Estimation
Copy
# Storage Formula
Daily_Storage = Users Γ Actions_Per_Day Γ Size_Per_Action
Yearly_Storage = Daily_Storage Γ 365
Total_Storage = Yearly_Storage Γ Years Γ Replication_Factor
# Example: Twitter-like app
# 200M DAU, 2 tweets/day, 500 bytes/tweet, 3x replication, 5 years
Daily = 200M Γ 2 Γ 500 bytes = 200 GB
Yearly = 200 GB Γ 365 = 73 TB
Total = 73 TB Γ 5 Γ 3 = 1.1 PB
Bandwidth Estimation
Copy
# Bandwidth Formula
Bandwidth = QPS Γ Average_Response_Size
# Example: Video streaming
# 100K concurrent users, 5 Mbps per stream
Total_Bandwidth = 100K Γ 5 Mbps = 500 Gbps
# For a service:
# 10K QPS, 100 KB average response
Bandwidth = 10K Γ 100 KB = 1 GB/s = 8 Gbps
π― Step-by-Step Estimation Framework
Step 1: Identify Key Metrics
Copy
For any system, estimate these:
1. QPS (read and write separately)
2. Storage requirements
3. Bandwidth requirements
4. Memory requirements (for caching)
Step 2: Make Assumptions Clear
Copy
"Let me make some assumptions..."
Users:
β’ Total users: X
β’ Daily Active Users (DAU): Y% of X
β’ Concurrent users: Z% of DAU
Actions:
β’ Actions per user per day: N
β’ Read:Write ratio: R:W
Data:
β’ Average data size: S bytes
β’ Retention period: T years
Step 3: Round Smartly
Copy
Good rounding (powers of 10):
β’ 86,400 β 100,000 (10^5)
β’ 31,536,000 β 30,000,000 (3 Γ 10^7)
β’ 2.6M β 2.5M or 3M
Always round to make mental math easier!
π₯ Practice Problems
Problem 1: Design a URL Shortener
Work through the estimation
Work through the estimation
Given assumptions:Read QPS:Storage (5 years):Short URL Length:
- 100M new URLs per month
- 10:1 read-to-write ratio
- 5 years of data retention
- Average URL: 500 bytes
Copy
100M URLs / month
= 100M / (30 days Γ 24 hours Γ 3600 seconds)
= 100M / 2.6M seconds
β 100M / 3M
β 33 QPS
Peak (3x): ~100 QPS
Copy
10:1 ratio = 10 Γ 33 = 330 QPS
Peak: ~1000 QPS
Copy
URLs = 100M Γ 12 months Γ 5 years = 6 Billion URLs
Storage = 6B Γ 500 bytes = 3 TB
With 3x replication: 9 TB
Copy
62 characters (a-z, A-Z, 0-9)
62^6 = 56 billion combinations (enough for 6B URLs)
62^7 = 3.5 trillion (very safe)
β Use 7 characters for safety
Problem 2: Design Twitter
Work through the estimation
Work through the estimation
Given assumptions:Timeline Read QPS:Storage (5 years):Timeline Fanout:
- 500M total users
- 200M DAU
- Average user follows 200 people
- 10% of users tweet daily
- Average tweet: 500 bytes
- Read:Write ratio: 50:1
Copy
Tweets/day = 200M Γ 10% Γ 2 tweets = 40M tweets
Write QPS = 40M / 86,400 β 40M / 100K = 400 QPS
Peak: 1,200 QPS
Copy
Timeline views = 200M DAU Γ 5 views = 1B views/day
Read QPS = 1B / 86,400 β 1B / 100K = 10,000 QPS
Peak: 30,000 QPS
Copy
Daily tweets: 40M Γ 500 bytes = 20 GB
Yearly: 20 GB Γ 365 = 7.3 TB
5 years: 36.5 TB
Media (10% with images):
4M images Γ 1 MB = 4 TB/day = 7.3 PB over 5 years
Copy
Celebrity with 50M followers:
1 tweet β 50M timeline updates
This is the "celebrity problem" β hybrid approach needed
Problem 3: Design YouTube
Work through the estimation
Work through the estimation
Given assumptions:Video Upload QPS:Storage (per year):Bandwidth:
- 2B monthly active users
- 500M DAU watching videos
- Average video watch: 5 min, 5 videos/day
- 500K creators uploading daily
- Average video: 10 min, 100 MB (compressed)
Copy
Views = 500M Γ 5 videos = 2.5B views/day
View QPS = 2.5B / 86,400 β 2.5B / 100K = 25,000 QPS
Peak: 75,000 QPS
Copy
Uploads = 500K / 86,400 β 6 uploads/second
Peak: 20 uploads/second
Copy
Videos/year = 500K Γ 365 = 182.5M videos
Storage = 182.5M Γ 100 MB = 18.25 PB/year
Multiple resolutions (4x): ~75 PB/year
Copy
Concurrent streams: 50M users
Average bitrate: 5 Mbps
Total: 50M Γ 5 Mbps = 250 Pbps
Need massive CDN infrastructure!
Problem 4: Design WhatsApp
Work through the estimation
Work through the estimation
Given assumptions:Storage (5 years):Concurrent Connections:
- 2B users total
- 500M DAU
- Average: 50 messages/day/user
- Average message: 200 bytes
- 5% with images (100 KB avg)
Copy
Messages/day = 500M Γ 50 = 25B messages
QPS = 25B / 86,400 β 25B / 100K = 250,000 QPS
Peak: 750,000 QPS
This is why WhatsApp uses Erlang for concurrency!
Copy
Text: 25B Γ 200 bytes = 5 TB/day
Images: 25B Γ 5% Γ 100 KB = 125 TB/day
Total: 130 TB/day = 47 PB/year = 235 PB over 5 years
Copy
500M DAU, 20% online at any time = 100M concurrent
WebSocket connections are long-lived!
π Interview Tips
Doβs β
Copy
1. State assumptions CLEARLY
"I'll assume we have 100 million DAU..."
2. Round numbers for easier math
"I'll round 86,400 to 100,000..."
3. Work through calculations out loud
"So that's 100 million divided by 100,000..."
4. Sanity check your answers
"Let me verify: 1 PB seems reasonable for 5 years..."
5. Identify bottlenecks early
"At 300K QPS, we'll definitely need caching..."
Donβts β
Copy
1. Don't be overly precise
Bad: "That's 11,574.074 QPS"
Good: "About 12K QPS, let's say 15K with buffer"
2. Don't skip the estimation
It shows you understand scale!
3. Don't forget peak traffic
Usually 2x-3x average, more during events
4. Don't forget replication
Storage usually needs 3x for fault tolerance
5. Don't confuse MB and Mb (megabytes vs megabits)
1 MB = 8 Mb
π Quick Reference Tables
Scale Levels
| Scale | DAU | QPS | Storage/Year | Complexity |
|---|---|---|---|---|
| Small | 100K | 10-100 | 100 GB | Single server |
| Medium | 10M | 1K-10K | 10 TB | Multi-server |
| Large | 100M | 10K-100K | 100 TB | Distributed |
| Massive | 1B+ | 100K+ | 1 PB+ | Global infrastructure |
Common Patterns by QPS
| QPS | Architecture | Examples |
|---|---|---|
| < 100 | Single server | Small SaaS apps |
| 100-1K | Load balancer + servers | Medium businesses |
| 1K-10K | + Caching layer | Social apps |
| 10K-100K | + Sharding + CDN | Large platforms |
| 100K+ | Global distribution | FAANG scale |
Storage Growth Rates
| Data Type | Per Item | Daily (10M users) | Yearly |
|---|---|---|---|
| Text message | 200 B | 20 GB | 7 TB |
| Tweet | 500 B | 50 GB | 18 TB |
| Photo | 500 KB | 500 TB | 182 PB |
| Video (1 min) | 50 MB | 5 PB | 1.8 EB |
π Estimation Template
Use this template in interviews:Copy
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ESTIMATION TEMPLATE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. USERS β
β Total: _______ DAU: _______ Concurrent: _______ β
β β
β 2. TRAFFIC β
β Actions/day/user: _______ β
β Total/day: _______ β
β QPS: _______ / 86,400 = _______ β
β Peak QPS (Γ3): _______ β
β β
β 3. STORAGE β
β Size per item: _______ β
β Items/day: _______ β
β Daily storage: _______ β
β Yearly storage: _______ β
β 5-year storage: _______ β
β With replication (Γ3): _______ β
β β
β 4. BANDWIDTH β
β Response size: _______ β
β Bandwidth = QPS Γ Size = _______ β
β β
β 5. MEMORY (Cache) β
β Hot data %: _______ β
β Cache size: _______ β
β β
β 6. KEY INSIGHTS β
β Read:Write ratio: _______ β
β Primary bottleneck: _______ β
β Scaling strategy: _______ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ