Back-of-Envelope Estimation
Back-of-envelope estimation provides quick calculations to justify design decisions and identify potential bottlenecks in system design.
Purpose
Estimation determines:
- Design feasibility
- Potential bottlenecks
- Technology selection
- Infrastructure sizing
Powers of Two
| Power | Exact Value | Approximation |
|---|---|---|
| 2^10 | 1,024 | ~1 thousand (KB) |
| 2^20 | 1,048,576 | ~1 million (MB) |
| 2^30 | 1,073,741,824 | ~1 billion (GB) |
| 2^40 | ~1 trillion (TB) |
Unit Conversions:
- 1 byte = 8 bits
- 1 KB = 1,000 bytes
- 1 MB = 1,000 KB
- 1 GB = 1,000 MB
Common Data Sizes
| Data Type | Size |
|---|---|
| char | 1 byte |
| int32 | 4 bytes |
| int64 / timestamp | 8 bytes |
| UUID | 16 bytes |
| Short string (username) | 20-50 bytes |
| URL | 100-200 bytes |
| 5-50 KB | |
| Image (compressed) | 200 KB - 1 MB |
| Video (1 min, compressed) | 5-50 MB |
Time Conversions
| Period | Seconds |
|---|---|
| 1 day | 86,400 (~100,000) |
| 1 month | 2.5 million |
| 1 year | 30 million |
Calculation: 1 million requests per day = 1,000,000 / 100,000 = 10 requests/second
Estimation Framework
Step 1: Clarify Scale
Define or estimate:
- Daily active users (DAU)
- Actions per user per day
- Data size per action
Step 2: Calculate Request Rate
Multiply daily active users by actions per user to get total daily requests. Divide by 86,400 seconds per day to get queries per second (QPS). Multiply QPS by 2-5 to estimate peak traffic, depending on traffic patterns.
Step 3: Calculate Storage
Multiply daily requests by data size per request to get daily storage. Multiply by 365 for yearly storage. Multiply by 5 for five-year projections.
Step 4: Calculate Bandwidth
Multiply QPS by average request size for incoming bandwidth. Multiply QPS by average response size for outgoing bandwidth.
Example: URL Shortener
Assumptions:
- 100M new URLs per month
- 10:1 read-to-write ratio
- Average URL length: 100 bytes
- Short code: 7 bytes
Write QPS: 100 million URLs per month divided by 2.5 million seconds per month equals approximately 40 writes per second.
Read QPS: 40 writes multiplied by a 10:1 read ratio equals 400 reads per second. At 3x peak, this becomes 1,200 reads per second.
Storage (5 years): 100 million URLs per month times 12 months times 5 years equals 6 billion URLs. Each entry requires 7 bytes (short code) plus 100 bytes (long URL) plus 8 bytes (timestamp), totaling 120 bytes per entry. 6 billion entries at 120 bytes equals approximately 720 GB.
Bandwidth: Write bandwidth: 40 requests per second times 100 bytes equals 4 KB/s. Read bandwidth: 400 requests per second times 120 bytes equals 48 KB/s.
Example: Social Media Feed
Assumptions:
- 500M DAU
- 5 feed views per user per day
- 20 posts per feed
- Each post: 1 KB text + 200 KB media reference
Read QPS: 500 million DAU times 5 feed views divided by 86,400 seconds per day equals approximately 29,000 requests per second. At 3x peak, this becomes 87,000 requests per second.
Bandwidth (outgoing): 29,000 requests per second times 20 posts per request times 1 KB per post (text only) equals approximately 580 MB/s. Media content requires separate CDN distribution.
Example: Chat Application
Assumptions:
- 100M DAU
- 50 messages sent per user per day
- Average message: 100 bytes
Message QPS: 100 million DAU times 50 messages per user divided by 86,400 seconds per day equals approximately 58,000 messages per second.
Daily storage: 100 million users times 50 messages times 100 bytes per message equals 500 GB per day. Annual storage requirement is approximately 180 TB.
Connection handling: With 10% of users online at any time, the system handles 10 million concurrent WebSocket connections. Each connection requires approximately 10 KB of memory, totaling 100 GB for connection state.
Latency Reference Numbers
| Operation | Time |
|---|---|
| L1 cache hit | 1 ns |
| L2 cache hit | 4 ns |
| Main memory | 100 ns |
| SSD random read | 100 us |
| HDD seek | 10 ms |
| Same datacenter round trip | 500 us |
| Cross-region round trip | 50-150 ms |
Memory access is approximately 100,000x faster than HDD seeks.
Throughput Reference Numbers
| Resource | Throughput |
|---|---|
| SSD sequential read | 500 MB/s |
| HDD sequential read | 100 MB/s |
| 1 Gbps network | 125 MB/s |
| 10 Gbps network | 1.25 GB/s |
| Single Redis instance | 100K ops/s |
| Single MySQL (simple queries) | 1-10K QPS |
| Single web server | 1-10K req/s |
Estimation Shortcuts
| Conversion | Formula |
|---|---|
| Daily to per-second | Divide by 100,000 |
| Monthly to per-second | Divide by 2.5 million |
| Peak multiplier | 2-5x average (3x default) |
| Storage buffer | Add 20-30% for indexes, metadata, replication |
Common Errors
- Missing peak load calculations - Systems must handle traffic spikes
- Ignoring replication - 3x replication requires 3x storage
- Missing metadata overhead - Indexes, timestamps, and IDs add storage
- Unit confusion - Verify bytes vs bits, seconds vs milliseconds
- Over-precision - Approximate values (e.g., "~50 GB") are appropriate for estimation