System Design · 01. Foundations · 10 min · Beginner

Napkin Math

Estimate traffic, storage and servers before you design anything.

In short

From 10 million daily users we got 2,315 reads a second on average, 6,944 at the peak, about 110 TB of photos a year, a 60 GB cache and 26 app servers.

The recipe: write down assumptions, use round numbers, convert per day to per second, multiply by a peak factor, count storage and bandwidth, divide by what one machine can do, then check the result a second way.

Key ideas

  • You want the right order of magnitude (10, 100, 1,000), not the exact digit. (step 1)
  • Photos and video dominate storage. Count them first; the rest is usually small by comparison. (step 5)
  • Always round up and add a spare. Capacity at 100% means queues and slow p99. (step 8)

Good to know

  • Memory beats SSD, SSD beats a network call, and a network call beats an ocean. Design to touch the faster ones more. (step 2)
  • Trick: 1 million requests a day is about 12 a second. Memorise that and scale from it. (step 3)
  • Caching a small slice cuts load a lot. This is the same hit-rate effect you meet in the Caching lesson. (step 7)

Watch out

  • Events (a sale, a live match) can spike 10 times or more. Pick the factor for your product and say it out loud. (step 4)
  • Bytes versus bits is a classic slip: 1 GB/s is 8 Gbit/s. (step 6)
  • The common errors: a missing x1,000 (KB vs MB), bits versus bytes, and forgetting the peak factor. (step 9)
10M daily users26 app serversCache60 GBPhoto storage110 TB/yrDatabase1,389/s

Key numbers

Peak QPS
6,944/s
Storage per year
110 TB
App servers
26

Terms

Napkin math
A quick estimate with round numbers, used to find the size of a system before designing it.
Order of magnitude
How many digits a number has: 10, 100 or 1,000 times; the goal of a rough estimate.
Latency numbers
Round figures for how long memory, SSD, network and disk operations take.
QPS (queries per second)
How many requests a system receives or serves each second.
Peak factor
The multiple of the average traffic you design for, often 2 to 3 times.
Storage estimate
Items per day × size of each item × days kept × copies.
Bandwidth
Data moved per second, in bits: bytes per second times 8.
80/20 rule
A small share of the data, about 20%, serves most of the reads, about 80%.
Capacity headroom
Running servers well below full load so bursts and failures do not cause queues.