Back-of-the-Envelope Estimation
Back-of-the-Envelope Estimation — Interview Cheat Sheet
Practice sheet for capacity math in SD interviews. Built after the URL Shortener mock (2026-07-20) where a 10× error appeared twice — once in records/year, once left stale in storage after the input was fixed. This sheet exists to kill that habit.
0. The One Discipline That Prevents 90% of Estimation Failures
The interviewer stops trusting every number the moment one doesn't foot. Two rules:
- Write the exponent explicitly, every time. Not "100M × 365." Write
10⁸ × 365 ≈ 3.65 × 10¹⁰. Powers of ten are where everyone's error rate spikes — slow down there, not on the multiply. - When you correct any input, re-run every calc that consumed it before moving on. The classic failure: fix "36.5B → 365B" on the board but leave storage at the old "18 TB." One stale number poisons the whole board.
Say your numbers back as powers of ten out loud: "ten-to-the-eight per day, times three-six-five, is three-six-five times ten-to-the-ten." The verbal check catches the slip the mental math misses.
1. Powers of Ten — Memorize Cold
| Name | Value | Symbol |
|---|---|---|
| Thousand | 10³ | K |
| Million | 10⁶ | M |
| Billion | 10⁹ | B / G |
| Trillion | 10¹² | T |
| Quadrillion | 10¹⁵ | P |
Multiplying/dividing = add/subtract exponents. 10⁸ / 10⁵ = 10³. That's the whole trick for QPS.
2. Time — The Numbers That Convert Per-Day to Per-Second
| Interval | Seconds | Round to |
|---|---|---|
| 1 day | 86,400 | 10⁵ (really 8.64×10⁴) |
| 1 month | ~2.6M | 2.5 × 10⁶ |
| 1 year | ~31.5M | 3 × 10⁷ |
Recipe — X per day → X per second: divide by 10⁵.
100M/day = 10⁸ / 10⁵ = 10³ = 1,000/s(precise: 1,157/s — the round-down is fine, say so)
Recipe — X per day → X per year: × 365 ≈ × 3.65 × 10².
100M/day × 365 = 10⁸ × 3.65×10² = 3.65 × 10¹⁰ = 36.5 B/year← the number that got fumbled in the mock. Per YEAR is 36.5B, per 10yr is 365B.
Peak factor: multiply average QPS by 2–3× for peak. State it; don't design to the average.
3. Data Sizes
| Unit | Bytes |
|---|---|
| 1 char (ASCII) | ~1 B |
| 1 KB | 10³ B |
| 1 MB | 10⁶ B |
| 1 GB | 10⁹ B |
| 1 TB | 10¹² B |
| 1 PB | 10¹⁵ B |
Typical record-field sizes (for estimating row size):
| Field | Size |
|---|---|
| Bool / small int | 1–4 B |
| Long / timestamp (epoch) | 8 B |
| UUID | 16 B |
| Short code (7 char) | 7 B |
| Tweet / short text | ~140–280 B |
| URL (long) | ~100–500 B (use 400–500 B conservative) |
| Metadata blob | ~100–500 B |
Storage recipe: records × bytes/record. Do records as a power of ten first, then multiply.
365 × 10⁹ records × 500 B = 1.8 × 10¹⁴ B = 182 TB
4. Base62 Keyspace (URL shortener / ID length)
| Length | Value | ~Power |
|---|---|---|
| 62⁵ | 916 M | ~10⁹ |
| 62⁶ | 56.8 B | ~5.7×10¹⁰ |
| 62⁷ | 3.52 T | ~3.5×10¹² |
| 62⁸ | 218 T | ~2.2×10¹⁴ |
Pick length so keyspace ≫ total records over retention. 62⁷ (3.5T) vs 365B needed → ~10× headroom → 7 chars. 62⁶ (57B) < 365B → 6 fails.
5. Latency Numbers Every Programmer Should Know (rounded)
| Operation | Time |
|---|---|
| L1 cache reference | 0.5 ns |
| Main memory reference | 100 ns |
| Mutex lock/unlock | 25 ns |
| Compress 1 KB | 3 µs |
| Send 1 KB over 1 Gbps network | 10 µs |
| SSD random read | 150 µs |
| Round trip within datacenter | 500 µs |
| Read 1 MB sequentially from SSD | 1 ms |
| Disk seek | 10 ms |
| Read 1 MB from disk | 20 ms |
| Packet round trip CA ↔ Europe | 150 ms |
Interview use: memory is ~1000× faster than SSD, SSD ~100× faster than disk seek, cross-continent RTT ~150 ms. That's why caches exist and why you don't cross an ocean to resolve 7 characters.
6. Availability — The Nines
| Availability | Downtime / year | Downtime / day |
|---|---|---|
| 99% | 3.65 days | 14.4 min |
| 99.9% ("three nines") | 8.76 hours | 1.44 min |
| 99.99% ("four nines") | 52.6 min | 8.6 s |
| 99.999% ("five nines") | 5.26 min | 0.86 s |
7. Powers of Two (when sizing bits / IDs / memory)
| Power | ≈ Value |
|---|---|
| 2¹⁰ | ~10³ (K) |
| 2²⁰ | ~10⁶ (M) |
| 2³⁰ | ~10⁹ (G) |
| 2³² | 4.3 × 10⁹ (IPv4 space, unsigned int max) |
| 2⁴⁰ | ~10¹² (T) |
| 2⁶⁴ | 1.8 × 10¹⁹ (Snowflake / bigint) |
8. The 5-Step Recipe (do it in this order, every time)
- Traffic → writes/day → writes/s (÷10⁵) → reads/s (× read:write ratio) → peak (× 2–3).
- Storage → records over retention (writes/day × 365 × years) → × bytes/record.
- Bandwidth → QPS × payload size. (Usually trivial — say so and move on.)
- Cache → hot-set size (Pareto: ~20% of keys). Sanity vs total RAM per node.
- Special sizing → keyspace / ID length / shard count as the problem demands.
Announce each subtotal. If you correct step 1, re-do steps 2–4.
9. Worked Example — URL Shortener @ 100M writes/day (done right)
This is the mock, computed cleanly. Use it as the template.
TRAFFIC
Writes: 100M/day = 10⁸ / 10⁵ s = 1,000/s (precise 1,157; peak ×3 ≈ 3K/s)
Reads: 100:1 = 10¹⁰/day = 10⁵/s = 100,000/s (peak ×3 ≈ 300K/s)
→ All design pressure is on the READ path. Say this sentence.
RECORDS
Per year: 10⁸ × 365 = 3.65 × 10¹⁰ = 36.5 B/year
Per 10yr: × 10 = 3.65 × 10¹¹ = 365 B ← the number to get right
CODE LENGTH (base62)
Need > 365B codes.
62⁶ = 57B < 365B → 6 FAILS
62⁷ = 3.5T / 365B ≈ 10× headroom → 7 chars ✅
STORAGE
365 × 10⁹ records × 500 B = 1.8 × 10¹⁴ B = 182 TB
(small enough to fit on a handful of nodes → shard for throughput, not capacity)
BANDWIDTH
Read: 10⁵/s × 500 B = 5 × 10⁷ = 50 MB/s (trivial)
Write: 10³/s × 500 B = 5 × 10⁵ = 500 KB/s (trivial)
CACHE (Pareto 80/20)
Cache hot code→URL only (~400 B, drop metadata).
Few hundred M hot entries × 400 B ≈ 150–200 GB Redis, cache-aside + LRU.
Note: the canonical [[Design a URL Shortener]] note uses a 10M/day assumption (→ 9 TB / 5 yr). This worked example uses 100M/day (the mock's number). Both are internally consistent — the point is the method, not the specific scale. Always restate the assumption you picked.
10. Self-Drill (redo cold, under 4 min each, exponents written out)
- Twitter feed: 500M DAU, each posts 2 tweets/day, each tweet read 100×. Tweets/s? Reads/s? Storage/year at 300 B/tweet?
- Chat app: 50M DAU, 40 messages/user/day, 100 B/message. Messages/s at peak? Storage/year?
- Video platform: 1M videos uploaded/day, avg 100 MB each. Storage/day? /year? Egress if each watched 1000× at 5 MB streamed?
- Rate limiter: 1B requests/day across the fleet. Requests/s? If each counter is 16 B and you track per-user for 100M users, memory?
- URL shortener redo: the Section 9 numbers, from scratch, no peeking. Check every power of ten.
Grading rule (self): any single 10× slip = fail the drill, redo it. That's the whole point.
Cross-links
- [[Design a URL Shortener]] — worked capacity section (Section 3) uses this method
- [[Design a Unique ID Generator]] — bit-budget / keyspace math
- [[Design a Distributed Key-Value Store]] — storage + replication sizing
- [[Rate Limiter]] — counter memory sizing