Back-of-Envelope Estimation

Preview — 3 of 10 questions

A system stores 10 billion user sessions, each 500 bytes. Approximately how much storage is required?

javascript
Powers of 2 reference table (memorize these!):
  2^10 = 1,024         1 thousand   (Kilo)
  2^20 = 1,048,576     1 million    (Mega)
  2^30 = ~1 billion    1 billion    (Giga)
  2^40 = ~1 trillion              (Tera)

Calculation:
  10 billion sessions × 500 bytes
  = 10 × 10^9 × 500 bytes
  = 5,000 × 10^9 bytes
  = 5,000 GB
  = 5 TB

Quick mental model:
  1 byte × 1 million records = 1 MB
  1 byte × 1 billion records = 1 GB
  500 bytes × 1 billion records = 500 GB
  500 bytes × 10 billion records = 5,000 GB = 5 TB 

Storage sizing rule of thumb:
  Characters in a tweet (280)  ~0.3 KB
  Small JSON object  ~1 KB
  User profile  ~1-10 KB
  High-res photo  ~3-5 MB
  4K video (1 min)  ~375 MB
A500 GB
B5 TB
C50 TB
D500 TB

A backend service calls 3 sequential dependencies: (1) L1 cache read, (2) local disk read, (3) a request to a service in another region (150ms RTT). What dominates the total latency?

javascript
Latency numbers (order of magnitude  commit to memory):

L1 cache access:          ~1 ns       (0.001 µs)
L2 cache access:          ~4 ns
RAM access:               ~100 ns     (0.1 µs)
Read 1 MB from RAM:       ~250 µs
SSD random read:          ~100 µs     (100× slower than RAM)
HDD random read:          ~10 ms      (100× slower than SSD!)
Read 1 MB from disk:      ~1 ms       (SSD)  20ms (HDD)
Send 1 KB over 1 Gbps LAN: ~10 µs
Same-datacenter round-trip: ~0.5 ms
Cross-region round-trip:   ~150 ms    (NY to London)

Our 3 operations:
  L1 cache:          ~0.000001 ms
  Disk read:         ~0.1 ms
  Cross-region call: ~150 ms        dominates 99.99%

Total:  150 ms

Key insight:
  Network across regions >> disk >> RAM >> CPU cache
  150ms >> 1ms >> 0.0001ms
   Never make synchronous cross-region calls in user-facing paths
   Cache aggressively, keep heavy data reads local
AThe L1 cache read, because it involves CPU cycles.
BThe disk read, which takes about 1ms.
CThe cross-region network request at ~150ms — it is orders of magnitude slower than the others.
DAll three contribute roughly equally.

Twitter has 500 million daily active users. On average, each user views their feed 5 times per day, and each feed load fetches 20 tweets. Estimate the reads per second (RPS).

javascript
Step 1: Daily reads
  500M users × 5 views/day × 20 tweets/view
  = 500M × 100
  = 50 billion reads/day

Step 2: Convert to per-second
  Seconds in a day: 24 × 60 × 60 = 86,400
  
  50,000,000,000 / 86,400  578,703 RPS  580,000 RPS

Estimation template:
  1. Total daily actions = users × actions_per_user
  2. Peak QPS = (daily actions / 86,400) × 2- (peak factor)
  
  Read/write ratio matters:
  Twitter: reads >> writes (celebrity tweets reach millions)
   Need read-optimized architecture (heavy caching, CDN, fan-out)

Peak vs average:
  Traffic isn't uniform — plan for 3× average as peak
  578,000 × 3 = ~1.7M peak RPS for Twitter reads
A~580 RPS
B~5,800 RPS
C~58,000 RPS
D~580,000 RPS

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.