TExcelTAD
Home › System Design › Back-of-the-Envelope Estimation

Back-of-the-Envelope Estimation

Before choosing a database or counting servers, you need rough numbers: how many requests per second, how much storage, how much bandwidth. Engineers call this a back-of-the-envelope estimate because it should fit on the back of one. The goal is the right order of magnitude, not three significant digits. Knowing that you need "about 10,000 writes per second" rather than "about 100" changes the whole design.

Handy numbers

Quantity Value Rounded for mental maths
Seconds per day 86,400 ~100,000 (10^5)
Seconds per month ~2.6 million 2.5 × 10^6
Seconds per year ~31.5 million 3 × 10^7
1 KB / 1 MB / 1 GB / 1 TB / 1 PB 10^3 / 10^6 / 10^9 / 10^12 / 10^15 bytes powers of 1,000
1 million requests per day ~12 per second divide by 10^5

Tip: "Per day ÷ 100,000 ≈ per second" is the single most useful trick. 50 million requests a day is about 500 per second (the exact value is 579).

From users to requests per second

The usual chain is: daily active users → actions per user per day → requests per day → average per second → peak per second. Traffic is not flat over a day, so multiply the average by a peak factor (2 to 3 is common; 10 for flash sales or live events).

python · try it yourself
def qps(daily_users, actions_per_user, peak_factor=2):
    per_day = daily_users * actions_per_user
    average = per_day / 86_400
    return average, average * peak_factor

# A photo app: 20 M daily users, each views 50 photos and uploads 0.2 per day
read_avg, read_peak = qps(20_000_000, 50)
write_avg, write_peak = qps(20_000_000, 0.2)

print(f"reads : avg {read_avg:9,.0f}/s  peak {read_peak:9,.0f}/s")
print(f"writes: avg {write_avg:9,.0f}/s  peak {write_peak:9,.0f}/s")
print(f"read:write ratio = {read_avg / write_avg:.0f}:1")
reads : avg    11,574/s  peak    23,148/s
writes: avg        46/s  peak        93/s
read:write ratio = 250:1

Twenty-three thousand peak reads per second is far beyond one database server, so caching and replicas are needed. Ninety-three writes per second, on the other hand, is easy for a single primary database.

Storage

Storage = items per day × size per item × days kept × replication factor. Remember metadata and the payload, and that replicas multiply the raw total.

python · try it yourself
UNITS = ["B", "KB", "MB", "GB", "TB", "PB"]

def human(n_bytes):
    value = float(n_bytes)
    for unit in UNITS:
        if value < 1000 or unit == UNITS[-1]:
            return f"{value:,.1f} {unit}"
        value /= 1000

uploads_per_day = 20_000_000 * 0.2       # 4 M photos/day
photo_bytes = 2_000_000                   # 2 MB average after compression
metadata_bytes = 500                      # id, owner, caption, timestamps
years, replicas = 5, 3

per_day = uploads_per_day * (photo_bytes + metadata_bytes)
total = per_day * 365 * years * replicas

print("new data per day :", human(per_day))
print("5 years, 3 copies:", human(total))
print("metadata only    :", human(uploads_per_day * metadata_bytes * 365 * years))
new data per day : 8.0 TB
5 years, 3 copies: 43.8 PB
metadata only    : 3.6 TB

The metadata is small enough for a regular sharded database, while the photos themselves clearly belong in object storage (lesson Blob and Object Storage). This kind of split is typical: estimation tells you which data goes where.

Bandwidth and servers

Bandwidth is requests per second × bytes per response. Server count is peak load ÷ what one server handles, plus headroom so that losing a machine doesn't overload the rest.

python · try it yourself
import math

read_peak = 23_148            # photo views per second (from above)
photo_kb = 200                # feed shows a 200 KB resized version
egress_gbps = read_peak * photo_kb * 1000 * 8 / 1e9

per_server_rps = 2_000        # measured capacity of one app server
headroom = 0.7                # run servers at most 70% busy
servers = math.ceil(read_peak / (per_server_rps * headroom))

print(f"egress at peak : {egress_gbps:.1f} Gbit/s")
print(f"app servers    : {servers} (+1 spare per zone recommended)")
egress at peak : 37.0 Gbit/s
app servers    : 17 (+1 spare per zone recommended)

About 37 Gbit/s of images is why photo apps serve images from a CDN rather than from their own app servers.

A reusable estimator

Put the chain into one function and you can explore "what if" questions in seconds: what if users double, what if photos get bigger?

python · try it yourself
def estimate(name, dau, reads_per_user, writes_per_user, item_bytes, years=5, peak=2):
    sec = 86_400
    read_qps = dau * reads_per_user / sec * peak
    write_qps = dau * writes_per_user / sec * peak
    storage_tb = dau * writes_per_user * item_bytes * 365 * years / 1e12
    print(f"{name:<14} peak reads {read_qps:>9,.0f}/s  peak writes {write_qps:>7,.0f}/s  storage {storage_tb:>8,.1f} TB")

estimate("url shortener", 10_000_000, 10, 0.1, 500)
estimate("chat app",      50_000_000, 100, 40, 200)
estimate("photo app",     20_000_000, 50, 0.2, 2_000_000)
url shortener  peak reads     2,315/s  peak writes      23/s  storage      0.9 TB
chat app       peak reads   115,741/s  peak writes  46,296/s  storage    730.0 TB
photo app      peak reads    23,148/s  peak writes      93/s  storage 14,600.0 TB

Common mistakes

  • Forgetting the peak. Averages hide the evening rush; size for peak.
  • Mixing bits and bytes. Network speeds are in bits per second; multiply bytes by 8.
  • Too much precision. Round aggressively and state your assumptions. "About 600 QPS" is better than "578.7 QPS".
  • Forgetting replication and indexes. Real storage is often 3x to 5x the raw data.

Test yourself

Roughly how many requests per second is 100 million requests per day?

  1. About 12
  2. About 120
  3. About 1,200
  4. About 12,000

Why multiply the average QPS by a peak factor?

  1. To account for replication
  2. Traffic is uneven during the day, and the system must survive the busiest hour
  3. To convert bytes into bits
  4. Because caches miss sometimes

A service sends 1,000 responses per second of 1 MB each. What is the egress bandwidth?

  1. 1 Gbit/s
  2. 8 Gbit/s
  3. 1 Mbit/s
  4. 125 Mbit/s