System Design Napkin Math
System Design Napkin Math
- Napkin math (also called back-of-the-envelope estimation) is a quick way to estimate requests per second, storage, and data transfer in a system design round.
- The goal is the right order of magnitude, not an exact number. Round aggressively, state your assumptions out loud, and use the result to justify design decisions.
Units to remember
| Unit | Power of 10 | Bytes |
|---|---|---|
| KB (kilobyte) | 10³ | 1,000 |
| MB (megabyte) | 10⁶ | 1,000,000 |
| GB (gigabyte) | 10⁹ | 1 billion |
| TB (terabyte) | 10¹² | 1 trillion |
| PB (petabyte) | 10¹⁵ | 1,000 TB |
- Thousand = 10³, million = 10⁶, billion = 10⁹.
- So multiplying a unit by a count is just adding exponents:
- 1 KB × 1 million = 10³ × 10⁶ = 10⁹ bytes = 1 GB
- 1 MB × 1 million = 10⁶ × 10⁶ = 10¹² bytes = 1 TB
- Interviews use decimal units. Binary units (1 KiB = 1,024 bytes) differ by only a few percent, which does not matter for napkin math.
Time to remember
| Period | Exact seconds | Napkin value |
|---|---|---|
| 1 day | 86,400 | ~10⁵ (100,000) |
| 1 month | ~2.6 million | ~2.5 × 10⁶ |
| 1 year | ~31.5 million | ~3 × 10⁷ |
- Rounding a day up to 100,000 seconds makes division easy and slightly underestimates the rate, by about 14%.
Step 1: Requests per second (RPS)
Assume 10 million daily active users (DAU), and each user makes 20 requests a day.
Requests per day = 10M users × 20 requests = 200M requests/day
Average RPS = 200M / 100K seconds ≈ 2,000 RPS
Peak RPS = 2,000 × 3 ≈ 6,000 RPS
- Traffic isn't flat: users are more active at certain hours. Assume peak is about 2–3× the average unless the problem says otherwise, and design for peak.
- Split reads and writes. Most products are read-heavy. If 1 in 10 requests writes data, that is ~600 writes/s and ~5,400 reads/s at peak. Reads can be scaled with caches and replicas; writes are harder to scale.
- Estimate servers: if one application server handles roughly 1,000 RPS for your workload (an assumption you should state), 6,000 peak RPS needs about 6 servers, plus spare capacity for failures and deployments.
Step 2: Storage
Assume 1 million photos are uploaded per day, 2 MB each.
Storage per day = 1M photos × 2 MB = 2M MB
= 10⁶ × (2 × 10⁶ bytes) = 2 × 10¹² bytes = 2 TB/day
Storage per year = 2 TB × 365 ≈ 730 TB/year
Upload bandwidth = 2 TB / 100K seconds = 20 MB/s
- Add replication: storing 3 copies for durability means ~2.2 PB per year of raw disk.
- Add metadata separately: photo ID, owner, timestamps, and captions might be ~1 KB per photo. That is 1 KB × 1M = 1 GB/day, tiny compared with the photos, which tells you photos belong in object storage (like Amazon S3) and metadata in a database.
- Multiply by the retention period (for example, 5 years ≈ 3.65 PB before replication) to discuss long-term growth.
Step 3: Network data transfer
Assume each user views 100 photos a day, and each displayed photo is about 200 KB (a compressed, resized version, not the 2 MB original).
Per user per day = 100 photos × 200 KB = 20,000 KB = 20 MB
All users = 20 MB × 10M users = 200 TB/day
Egress per sec = 200 TB / 100K s = 2 GB/s
- That is 100× the upload traffic (2 GB/s vs 20 MB/s): a heavily read-dominated system.
- Convert bytes to bits for network capacity: 2 GB/s × 8 = 16 Gbps on average, and around 48 Gbps at a 3× peak. Network links are rated in bits per second.
- That is more than a typical single server's network link can serve, and your users are spread around the world. So photos should be served through a CDN (Content Delivery Network), which caches them at edge locations close to users.
- Photo views also mean reads: 10M users × 100 views = 1 billion views/day ≈ 10,000 photo requests/s on average.
How to use it in an interview
- Clarify the inputs: DAU, actions per user, object sizes, read/write ratio, and retention.
- Calculate per day, then per second. Divide by 10⁵.
- Apply a peak factor (2–3×).
- Add multipliers: replication, metadata, and retention.
- Turn numbers into decisions: caching for heavy reads, sharding for large datasets, object storage for files, and a CDN for heavy egress.
- Sanity-check: if an answer seems surprisingly large or small, recheck the exponents.
Handy numbers to remember
- 1 day ≈ 100,000 seconds (10⁵).
- 1 KB × 10⁶ = 1 GB.
- 1 MB × 10⁶ = 1 TB.
- Peak ≈ 2–3× the average.
- Bytes × 8 = bits when comparing with network bandwidth.
Related: Bandwidth vs Latency