Load/Bearing
Fundamentals · 01 of 22

Back-of-the-envelope estimation

Before you draw a single box, work out how much traffic, data and bandwidth you are designing for.

A design for 100 requests per second and a design for 100,000 requests per second look nothing alike. The first fits on one server. The second needs load balancers, caches, replicas and probably shards. So the first five minutes of any design should go to arithmetic, not architecture.

You don't need precision. You need the right order of magnitude, so you know whether a component is comfortable, close to its limit, or hopeless.

From users to requests per second

Start from people and work toward machines. The formula almost every estimate uses:

average RPS = daily active users × actions per user per day ÷ 86,400 peak RPS = average RPS × peak factor (usually 2–10×)

There are 86,400 seconds in a day. Round it to 100,000 and the mental math gets easy: one million requests a day is about 12 per second, and one billion a day is about 12,000 per second.

A worked example

Say you're designing a photo feed with 10 million daily users. Each user loads about 20 feed pages and posts 2 photos a day.

QuantityMathResult
Reads per day10M × 20200M
Average read RPS200M ÷ 86,400≈ 2,300/s
Peak read RPS (×3)2,300 × 3≈ 7,000/s
Writes per day10M × 220M
Peak write RPS (×3)20M ÷ 86,400 × 3≈ 700/s

Two facts fall out straight away. The system is read-heavy (10:1), so caching and read replicas will matter more than write scaling. And 700 writes per second is within reach of one well-tuned database, so you probably don't need sharding on day one.

Storage and bandwidth

The same arithmetic sizes your disks and your network. If each photo record is 1 KB of metadata and the image itself is 500 KB:

metadata: 20M writes/day × 1 KB = 20 GB/day ≈ 7 TB/year images: 20M writes/day × 500 KB = 10 TB/day ≈ 3.6 PB/year egress: 7,000 reads/s × 50 KB thumbnail ≈ 350 MB/s ≈ 2.8 Gbit/s

Now you know the images belong in object storage behind a CDN, not in the database, and that serving them from your own servers would need serious network capacity.

Numbers worth memorising

These are rounded orders of magnitude. Real hardware varies, but the ratios between rows are what matter.

OperationRough time
L1 CPU cache reference~1 ns
L2 CPU cache reference~4 ns
Read from main memory100 ns
Random read from SSD~100 µs
Round trip inside a data centre~0.5 ms
Cache GET over the network (Redis, Memcached)~1 ms
Indexed database query1–10 ms
Round trip, US East ↔ Europe~80 ms
Round trip, US ↔ Australia~150–200 ms

Each step down the table is 10 to 1,000 times slower than the one above. L1 is about 100 times faster than main memory, memory is about 1,000 times faster than SSD, and SSD is far faster than going across the planet. Those ratios explain why caches and CDNs exist.

Capacity of common building blocks

Ballpark throughput for one node of each, assuming simple requests:

Averages lie: think in percentiles

If 99 requests take 10 ms and one takes 2 seconds, the average is about 30 ms, which describes nobody's experience. Percentiles describe it better. p95 is the latency 95% of requests beat, and p99 is the latency 99% beat. A page that makes 20 backend calls hits the p95 of at least one of them most of the time, so the tail is what users feel.

Leave headroom

Never size a component to run at 100% at peak. Response time climbs steeply as utilisation approaches 1 (see load balancing for the math). A common target is 60–75% at expected peak, which leaves room for spikes and for losing a machine.

In the game: one app server handles 1,000 req/s and one database handles 1,500 reads/s and 600 writes/s. The level brief gives you peak traffic and the read share, so you can do the same arithmetic before placing anything. In Flash Sale, comparing peak writes (~950/s) with average writes (under 500/s) is the whole puzzle.

Interview checklist

Practise it

Level 1: Hello, World

Put this into practice against live traffic. Your progress in the game is saved in your browser.

Play level 1

Further reading