Back-of-the-Envelope Math That Actually Matters
On this page
- Why Napkin Math Before Architecture
- Reference Numbers Worth Memorizing
- Time
- QPS from DAU
- Storage sizes (decimal: KB = 10³ bytes)
- Latency budget (rough)
- The Core Formulas
- Worked Example: URL Shortener
- Step 1 — Write QPS
- Step 2 — Read QPS
- Step 3 — Storage
- Step 4 — Bandwidth
- Step 5 — What the numbers imply
- Worked Example: Payment System
- Step 1 — Write TPS
- Step 2 — Storage
- Step 3 — Bandwidth
- Step 4 — What the numbers imply
- When Math Changes Your Design
- Read-heavy → cache first
- Write-heavy → queue and partition
- Storage dominates → lifecycle and tiering
- Bandwidth dominates → edge and compression
- Common Estimation Mistakes I Made
- Forgetting peak multiplier
- Using 86,400 instead of 100,000
- Ignoring replication and indexes
- Confusing one user's action with one server request
- Treating write QPS like read QPS
- Precision theater
- Skipping the sanity check
- Key Takeaways
- Test Your Understanding
Back-of-the-Envelope Math That Actually Matters
In a URL shortener design review, we burned most of the hour on whether the redirect path should be gRPC or REST. Nobody had written down redirects per second, bytes per row, or read vs write volume. You cannot pick a sensible shape until those orders of magnitude exist.
Back-of-the-envelope math is not spreadsheet precision. It is rounding on purpose: enough to see whether you need a cache, a shard key, or a queue before you name microservices. A system at 10 writes/sec and 10,000 reads/sec looks nothing like one at 5,000 writes and 5,000 reads — interviewers ask for estimates because that gap drives architecture.
Below: shortcuts I reuse (including ~100K seconds per day), the formulas, two worked passes (URL shortener and payments), when the numbers flip decisions, and mistakes that still trip me up.
Intended audience: developers who draw boxes first and math second, plus anyone prepping for system design interviews where estimates must change the diagram.
Prerequisites:
- Performance Metrics: Latency, Throughput, and Percentiles
- How to Approach Any System Design Problem — clarify requirements and scope before you estimate
Why Napkin Math Before Architecture
Requirements tell you what to build. Napkin math tells you what kind of system can hold it.
Without numbers, every design looks the same: load balancer, app servers, database, cache. With numbers, differences jump out:
| If your math says… | You probably need… |
|---|---|
| Read QPS ≫ write QPS (100:1+) | Aggressive caching, read replicas, CDN for static assets |
| Storage >> RAM on one machine | Sharding or object storage, not one Postgres row store |
| Write QPS in the thousands+ | Async pipelines, partitioning, batching |
| Bandwidth in Gbps | Edge caching, compression, fewer round trips |
You are not forecasting revenue. You are ruling out wrong exponents — thousands vs millions, or one Postgres instance holding ten years of video. A few minutes of multiplication has saved me from weeks of re-architecture.
Loading diagram…
Reference Numbers Worth Memorizing
Round aggressively. Powers of ten beat false precision.
Time
| Unit | Exact | Napkin round |
|---|---|---|
| 1 minute | 60 s | ~60 s |
| 1 hour | 3,600 s | ~4K s |
| 1 day | 86,400 s | ~100K s |
| 1 month | ~2.6M s | ~2.5M s |
| 1 year | ~31.5M s | ~30M s |
The ~100K seconds per day shortcut is the one I use most. It turns "500 million requests per day" into "5,000 QPS average" in one step.
QPS from DAU
average QPS = (DAU × actions per user per day) / 100,000
Example: 50M DAU, each user generates 20 requests/day:
QPS_avg = (50M × 20) / 100K = 1B / 100K = 10,000
Peak QPS: multiply average by 2–3× unless you have traffic curves. Social products often spike higher during events; B2B SaaS is flatter. When unsure, say "peak ≈ 3× average" and note the assumption.
Storage sizes (decimal: KB = 10³ bytes)
| Size | Bytes | Napkin |
|---|---|---|
| 1 KB | 10³ | short text field |
| 1 MB | 10⁶ | small image, JSON blob |
| 1 GB | 10⁹ | ~1M rows × 1 KB |
| 1 TB | 10¹² | large index or years of logs |
| 1 PB | 10¹⁵ | video platform territory |
Per-object storage = sum of fields you persist (strings, IDs, timestamps, indexes). Don't forget replication factor (3× for three copies) and headroom (~20–30% for growth).
Latency budget (rough)
| Operation | Order of magnitude |
|---|---|
| L1 cache / in-process | ~1 ns – 100 ns |
| RAM lookup | ~100 ns |
| SSD random read | ~100 µs |
| Same-datacenter RPC | ~1 ms |
| Cross-region round trip | ~50–150 ms |
If your p99 SLA is 200 ms and one request fans out to ten cross-region calls, the math already says you're in trouble — before you pick a database brand.
The Core Formulas
Keep these on the envelope:
QPS_avg = total requests per day / 100,000
QPS_peak ≈ QPS_avg × 2 (or × 3)
storage = objects × bytes per object × replication × (1 + headroom)
bandwidth = QPS × bytes per response (ingress + egress separately)
read:write = read QPS / write QPS (drives cache vs write path design)
Objects over time:
total objects = new objects per day × retention days
If you never delete, retention = product lifetime in days.
Worked Example: URL Shortener
Size a Bitly-class URL shortener. State assumptions out loud in an interview:
| Assumption | Value |
|---|---|
| Daily active users (DAU) | 100M |
| New short URLs per DAU per day | 0.1 (one new link every 10 days) |
| Redirect clicks per DAU per day | 5 |
| Average long URL + metadata stored | 500 bytes |
| Short code + indexes overhead | 100 bytes |
| Total per mapping | ~600 bytes |
| Retention | 5 years |
| Read:write ratio (check) | should be ≫ 1 |
Step 1 — Write QPS
new URLs per day = 100M DAU × 0.1 = 10M/day
write QPS_avg = 10M / 100K = 100 writes/sec
write QPS_peak ≈ 100 × 3 = 300 writes/sec
One hundred sustained writes per second is modest. A single well-tuned relational database can handle this — writes are not the first bottleneck.
Step 2 — Read QPS
redirects per day = 100M DAU × 5 = 500M/day
read QPS_avg = 500M / 100K = 5,000 reads/sec
read QPS_peak ≈ 5,000 × 3 = 15,000 reads/sec
Read:write ratio ≈ 5,000 / 100 = 50:1 (round to 100:1 in conversation — same design conclusion: read-dominated).
Step 3 — Storage
URLs over 5 years = 10M/day × 365 × 5 ≈ 18B mappings (round: ~20B)
raw storage = 20B × 600 bytes ≈ 12 TB
with 3× replication ≈ 36 TB
with 25% headroom ≈ 45 TB
~45 TB across the cluster — too big for one disk, fine for a sharded key-value or SQL store. This is where math tells you to plan a shard key (e.g. hash of short code) early, not after the table hits a wall.
Step 4 — Bandwidth
Redirect response is tiny — mostly an HTTP 302 with a Location header (~500
bytes including headers):
egress_avg = 5,000 QPS × 500 bytes ≈ 2.5 MB/sec (~20 Mbps)
egress_peak = 15,000 × 500 bytes ≈ 7.5 MB/sec (~60 Mbps)
Bandwidth is not the constraint here. Read QPS and storage are.
Write path ingress (client sends long URL ~500 bytes):
ingress_peak ≈ 300 × 500 bytes ≈ 150 KB/sec (negligible)
Step 5 — What the numbers imply
| Estimate | Implication |
|---|---|
| 50–100:1 read:write | Cache hot short codes — most redirects should never hit disk |
| 15K peak read QPS | In-memory cache (Redis/Memcached) + DB fallback; consistent hashing if cache is clustered |
| ~45 TB total | Shard by short code; don't rely on vertical scale |
| 300 peak writes/sec | Single write primary or small partitioned write path is fine |
| Low bandwidth | Skip CDN for redirects unless geo-latency dominates; focus on cache hit rate |
That sequence — assumptions, QPS, storage, bandwidth, then levers — is the whole napkin pass. The full URL shortener case study (base62, schema, cache-aside) builds on top; do this math first.
Worked Example: Payment System
Same formulas on a write-heavy, correctness-critical system. Full design: Design a Payment System (coming soon).
Assumptions (state out loud):
- 50M card transactions per day
- ~100 bytes per transaction event; ~200 bytes per user record (stored once)
- Peak traffic ≈ 2.5× average
- ~130 bytes average API response
Step 1 — Write TPS
txn/sec_avg = 50M / 100K = 500 TPS
txn/sec_peak ≈ 500 × 2.5 = 1,250 TPS (round: ~1,400)
Five hundred sustained payment events per second is real money — not URL-redirect volume. Correctness and idempotency matter more than raw QPS here.
Step 2 — Storage
txn storage/day = 50M × 100 B ≈ 5 GB/day
5 years of events (no delete) ≈ 5 GB × 365 × 5 ≈ 9 TB raw txn rows
ledger entries (similar size) ≈ another ~9 TB
with replication + indexes → plan tens of TB; partition by time + merchant_id
Payment data has retention and audit requirements — you don't TTL ledger rows like cache entries.
Step 3 — Bandwidth
ingress_peak ≈ 1,400 × 100 B ≈ 1.1 Mbps
egress_peak ≈ 1,400 × 130 B ≈ 1.5 Mbps
API bandwidth looks modest. The hidden cost is PSP webhooks, settlement files, and reconciliation batches — multiply headroom for ops traffic.
Step 4 — What the numbers imply
| Estimate | Implication |
|---|---|
| ~1,400 peak TPS | Horizontal scale orchestration tier; PSP latency dominates p99, not CPU |
| 5 GB/day events | Time-partitioned tables; async capture pipeline acceptable |
| Tens of TB over years | Ledger is append-only; archive cold partitions; never "delete for space" |
| Low API bandwidth | Bottleneck is PSP round-trips + fraud checks, not NIC — design for timeout/idempotency |
Unlike the URL shortener (cache-first), payments are write-correctness-first: napkin math tells you to budget for ledger retention and reconciliation jobs, not a CDN.
When Math Changes Your Design
Same formulas, different conclusions:
Read-heavy → cache first
When read QPS is two orders of magnitude above write QPS, caching is part of the product, not a late optimization. The URL shortener above at 15K peak read QPS without cache is 15K disk touches per second. At 90% hit rate the database sees ~1.5K — different ops story.
Ask: What fraction of reads are repeats? Trending links skew hot; long-tail links are cold. Both affect cache sizing.
Write-heavy → queue and partition
Imagine 500 writes/sec average, 1.5K peak, each write triggers fan-out to 10K followers (Twitter-like post). Suddenly you're not sizing one insert — you're sizing millions of downstream writes per second on the fan-out path. Math forces a choice: fan-out on write vs fan-out on read (coming soon), batching, or hybrid for celebrity accounts.
Storage dominates → lifecycle and tiering
1B users × 2 KB profile row = 2 TB — fits one machine. Add 10 photos × 2 MB each per user and you're at 20 PB — object storage (S3), not rows in Postgres. Math pushes you to tiering: metadata in DB, blobs in object store, thumbnails on CDN.
Bandwidth dominates → edge and compression
Video at 1M concurrent streams × 5 Mbps ≈ 5 Tbps egress. You don't solve that with a bigger app server — you need CDN, adaptive bitrate, and regional caches. CDN and edge caching exists because the bandwidth line crossed first.
Run the numbers, find what dominates (QPS, storage, or bandwidth), design there first, then revisit.
Common Estimation Mistakes I Made
Forgetting peak multiplier
I divided daily totals by 86,400 and called it done. Traffic is not uniform — evenings, launches, and holidays concentrate load. Always state peak ≈ 2–3× average (or justify a different factor).
Using 86,400 instead of 100,000
Exact seconds are fine in a spreadsheet. In an interview, 100K saves mental math and keeps you talking. Being within 15% is the point.
Ignoring replication and indexes
Raw data size is a floor. 3× replication for durability, plus indexes (often 20–50% of table size), plus headroom — skipping these underestimates disk by 5×.
Confusing one user's action with one server request
One page load can fan out to 10–30 internal calls. User-facing QPS × fan-out is backend QPS. I sized an API gateway for ~1K QPS once; the mesh behind it needed ~20K because I counted browser requests only.
Treating write QPS like read QPS
Writes often need strong consistency, fsync, conflict resolution — they're more expensive per operation. A database that cheerfully serves 50K read QPS may struggle at 5K sustained writes.
Precision theater
Five minutes to get 17,234 QPS instead of "~17K" is the wrong use of interview time. They want assumptions and reasoning, not accountant mode.
Skipping the sanity check
If you arrive at 10 PB for a todo app or 10 QPS for Twitter, re-read assumptions. Orders of magnitude off usually mean a formula or unit error (per day vs per second, MB vs GB).
Key Takeaways
- Math before service names — QPS, storage, bandwidth rule out bad shapes early.
- ~100K seconds per day and
QPS_avg = daily requests / 100K; peak ≈ 2–3× average unless you have a reason. - Storage = objects × bytes × replication × headroom; count indexes and retention.
- Read:write ratio — 100:1 reads pushes cache and replicas ahead of write micro-opts.
- Design for the dominant bottleneck first; other pieces often follow.
- Assumptions out loud — DAU, actions per user, object size, retention — before the diagram debate.
- Round hard — direction matters, not finance-grade precision.
Before I draw boxes for "design X," I try to write read QPS, write QPS, total storage, peak bandwidth. Often that already implies cache, shard key, or queue.
Test Your Understanding
Previous: How to Approach Any System Design Problem
Next in series: Drawing System Diagrams That Expose Trade-offs
Happy coding!