27 · Back-of-the-Envelope Estimation

Part 0 · Foundations · ⏱️ ~20 min read · Prerequisites: None (Foundational)


🏢 Real-world case studies: how Google (Jeff Dean's latency rules) & Netflix (capacity planning for 260M subscribers) execute real-world estimations, in REAL_WORLD_EXAMPLES.md.


🧒 The 30-second version

Back-of-the-envelope estimation is the art of rapidly calculating system scale (QPS, memory, disk storage, network bandwidth) before writing a single line of architecture. It is not about finding the exact decimal; it is about finding the order of magnitude (10 RPS vs 10,000 RPS; 10 GB vs 10 TB).


🍕 Everyday analogy: Planning a Wedding Banquet

Imagine planning a wedding:

Back-of-the-envelope estimation gives you the exact ballpark to pick the right server size, database tier, and caching budget.


🧩 The Problem It Solves

Without back-of-the-envelope estimations:

  1. Architectural Over-Engineering: A candidate proposes a multi-datacenter Kafka cluster with Cassandra sharding for a service receiving 5 requests/minute.
  2. Catastrophic Under-Provisioning: A team provisions a standard <span class="math-inline">20/mo SQL database for a service expected to ingest50\text{ GB of telemetry logs per second}$, causing Day 1 production crashes.
  3. Interview Disqualification: Top-tier tech companies (Google, Meta, Amazon) explicitly score candidates on whether they can calculate QPS, storage growth, and RAM sizing in under 3 minutes.

🔢 The Cheat Sheet: Powers of 2 & 10

Hardware Latency & Scale Reference

Power of 2 Exact Bytes Approximate (Powers of 10) Standard Unit Real-World Context
210 1,024 1 Thousand (103) 1 KB Small JSON API response
220 1,048,576 1 Million (106) 1 MB High-res thumbnail / photo
230 1,073,741,824 1 Billion (109) 1 GB 1 hour of SD video stream
240 1,099,511,627,776 1 Trillion (1012) 1 TB Standard server NVMe SSD
250 1,125,899,906,842,624 1 Quadrillion (1015) 1 PB Daily YouTube upload ingestion
260 1,152,921,504,606,846,976 1 Quintillion (1018) 1 EB Total storage of global cloud providers

⏱️ Latency Numbers Every Software Engineer Must Know

Original figures compiled by Google Senior Fellow Jeff Dean, updated for modern NVMe hardware:

Operation Real-World Time Scaled to Human Time (1ns = 1s)
L1 CPU Cache Reference 0.5 ns 0.5 seconds (A single heartbeat)
Branch Mispredict 5 ns 5 seconds
L2 CPU Cache Reference 7 ns 7 seconds
Mutex Lock / Unlock 25 ns 25 seconds
Main Memory (RAM) Reference 100 ns 1.6 minutes
Compress 1KB with Snappy 2,000 ns (2 μs) 33 minutes
Read 1MB Sequentially from Memory 5,000 ns (5 μs) 1.4 hours
Read 1MB Sequentially from NVMe SSD 10,000 ns (10 μs) 2.8 hours
SSD Random Read (NVMe) 20,000 ns (20 μs) 5.5 hours
Send 1KB Packet over 1Gbps LAN 10,000 ns (10 μs) 2.8 hours
HDD Spinning Disk Seek 10,000,000 ns (10 ms) 4 months!
Round Trip Time (RTT): US to Europe 150,000,000 ns (150 ms) 5 years!

The Core Architectural Takeaways:

  1. RAM is 100,000× faster than disk seeks: Keep hot data in cache.
  2. Sequential disk I/O matches network speed: Log-structured storage (Kafka, LSM-trees) is fast because it uses sequential disk writes.
  3. Cross-region network latency dominates everything: Avoid synchronous cross-datacenter round-trips on write paths.

📐 The Master Estimation Template

Whenever an interviewer gives you a design problem:

1. Traffic (QPS) Math

Average QPS = (DAU × Requests per user) / (86,400 seconds)
Average QPS ≈ (Total Daily Requests) / (100,000)

2. Storage Estimation Math

Daily Storage = Daily Writes × Average Payload Size
5-Year Storage = Daily Storage × 365 × 5 ≈ Daily Storage × 2,000

3. Memory (Cache Sizing) Math: The 80/20 Rule

RAM Required = Daily Read Volume (Bytes) × 0.20

💻 Try It Yourself

The companion script demo.py is an interactive estimation tool that takes DAU, read/write ratios, and payload sizes to generate complete infrastructure sizing reports in milliseconds.

Run it directly in your terminal:

python demo.py

🌍 Where You'll See It in Production


🎯 Top 5 Interview Questions & Deep Answers

Q1: "How do you quickly estimate QPS from Daily Active Users (DAU) in an interview?"

💡 Click to reveal the ideal senior engineering answer

State your assumptions clearly:

  1. "Assume 100M DAU and each user makes 10 requests per day."
  2. Total requests = 1 Billion requests/day.
  3. Divide by 100,000 seconds (rounding 86,400):
Average QPS ≈ (1,000,000,000) / (100,000) = 10,000 QPS
  1. Apply peak multiplier (2×):
Peak QPS = 10,000 × 2 = 20,000 QPS

Interviewers reward fast, clean arithmetic over struggling with exact decimals.


Q2: "Estimate the storage required for Twitter over 5 years."

💡 Click to reveal the ideal senior engineering answer
  1. Assume 300M DAU. 100M users post 2 tweets/day = 200M tweets/day.
  2. Each tweet is 280 chars + metadata (User ID, timestamp) ≈ 500 bytes.
  3. Assume 20% of tweets contain an image (200 KB):
    • Text storage: 200M × 500B = 100 GB/day.
    • Media storage: 40M × 200 KB = 8,000 GB/day = 8 TB/day.
    • Total daily storage ≈ 8.1 TB/day.
  4. 5-Year Storage:
8.1 TB × 365 × 5 ≈ 8.1 TB × 1,825 ≈ 14.8 Petabytes

Q3: "How do you size the RAM needed for a Redis caching tier?"

💡 Click to reveal the ideal senior engineering answer

Apply the 80/20 Pareto rule:

  1. Calculate daily read volume. If daily active data volume is 5 TB.
  2. To satisfy 80% of reads from RAM, you need:
5 TB × 0.20 = 1 TB of RAM
  1. Account for Redis memory overhead (pointers, hash tables, slab allocation) ≈ 25% extra buffer:
Total RAM ≈ 1 TB × 1.25 = 1.25 TB
  1. Provision four 256 GB or eight 128 GB Redis cluster instances.

Q4: "Why is sequential disk access comparable in speed to RAM access?"

💡 Click to reveal the ideal senior engineering answer

Disk latency is dominated by physical seek times (moving the mechanical head or initializing NAND flash row buffers). Once the initial seek occurs, hardware controllers read contiguous blocks at the physical bus bandwidth limit (up to 3–7 GB/s on PCIe 4.0 NVMe). Sequential disk access bypasses seek overhead, which is why log-structured engines (Kafka, LSM-trees) achieve near-RAM write throughput on standard disks.


Q5: "Estimate the network egress bandwidth for YouTube."

💡 Click to reveal the ideal senior engineering answer
  1. Assume 1 Billion hours of video watched per day.
  2. Average bitrate across mobile and desktop: 2.5 Mbps.
  3. Continuous egress bandwidth:
Bandwidth = (1,000,000,000 hrs × 3600s × 2.5 Mbps) / (86,400s) ≈ 104 Terabits per second (Tbps)
  1. With a 98% CDN cache offload, origin egress drops to only ≈ 2 Tbps.

📚 Go Deeper