Back-of-the-envelope estimation

In one sentence

Order-of-magnitude arithmetic (latency, QPS, storage, tokens/s) done in two minutes to decide whether a design is feasible and which component dominates, before anyone builds anything.

Analogy: A contractor paces a room, says "about 40 m², so roughly 30 boxes of tiles" and only then orders. Off by 10% is fine; off by 10× is not.

Requests become tokens and then GPUs; the same request count drives storage. Each arrow is one multiplication you can say out loud.

How it works

  • Latency: count hops on the critical path; each rung down (memory, SSD, network) is ~100× slower or more.
  • Traffic: DAU × requests per user ÷ 86,400 s gives average QPS; multiply by 2–5× for peak.
  • Storage = items per day × bytes × retention × replication factor; bandwidth = QPS × payload size.
  • For LLMs count tokens: GPUs = peak output tokens/s ÷ tokens/s per GPU measured at your SLO, plus headroom.
  • Round hard (86,400 ≈ 10⁵), say every assumption aloud and sanity-check the result against something known.

Check yourself

Answer to mark it learned; your answers aren't scored.

Your chat feature runs well at ~300 peak QPS with ~200-token prompts. A new RAG feature expects the same QPS, so the capacity plan reuses the chat GPU fleet as is. RAG prompts are ~20k tokens. What's wrong with the plan?

Go deeper

Back-of-the-envelope calculator Interactive labLatency ladder Interactive lab
Full explanation

Back-of-the-envelope estimation is rough arithmetic that gets the power of ten right for latency, throughput, storage and cost. That power of ten decides the architecture: one Postgres box or a sharded cluster, 4 GPUs or 400.

The recipe:

  1. Latency — memorize the ladder: main memory is ~100× slower than L1, an SSD random read ~100–1,000× slower than memory, a cross-continent round trip ~300× slower than one inside a datacenter. Count the hops on the critical path.
  2. Traffic — DAU × requests per user ÷ 86,400 s = average QPS. Multiply by 2–5× for peak.
  3. Storage — items/day × bytes × retention × replication factor.
  4. Bandwidth — QPS × payload size. Watch bits vs bytes (×8).

For LLM systems, count tokens, not requests. Peak tokens/s = peak QPS × tokens per request, with prefill (input) and decode (output) sized separately; decode is usually the bottleneck. Then GPUs = peak output tokens/s ÷ tokens/s per GPU, where the per-GPU figure is measured at your latency SLO, plus headroom. See GPU memory math for whether the model fits at all and Token economics & cost estimation for the bill.

Round aggressively (86,400 ≈ 10⁵), say every assumption out loud, and sanity-check the result against something you know.

Code Capacity estimate for an LLM chat feature
pythonCapacity estimate for an LLM chat feature
import math

SECONDS_PER_DAY = 86_400  # ~1e5 for mental math

def peak_qps(dau: int, req_per_user: float, peak_factor: float = 3.0) -> float:
    return dau * req_per_user / SECONDS_PER_DAY * peak_factor

def gpus_needed(qps: float, out_tokens: int, tok_s_per_gpu: float,
                target_util: float = 0.7) -> int:
    # Decode dominates. tok_s_per_gpu must be MEASURED at your p95 latency SLO:
    # it swings by an order of magnitude with model, batch size and context length
    return math.ceil(qps * out_tokens / (tok_s_per_gpu * target_util))

def storage_tb(req_per_day: float, bytes_each: int, days: int, replicas: int = 3) -> float:
    return req_per_day * bytes_each * days * replicas / 1e12

dau, rpu = 1_000_000, 10
qps = peak_qps(dau, rpu)                                      # ~116 avg -> ~347 peak
gpus = gpus_needed(qps, out_tokens=500, tok_s_per_gpu=2_500)  # assumption from a load test
tb = storage_tb(dau * rpu, bytes_each=2_000, days=365)        # chat turns kept 1 year
print(f"peak {qps:.0f} QPS, {gpus} GPUs, {tb:.0f} TB/yr")      # peak 347 QPS, 100 GPUs, 22 TB/yr
Real example

A product team wants an assistant for 1M DAU, 10 messages each. That's 10M requests/day ÷ 86,400 ≈ 116 QPS, ~350 QPS at a 3× peak. At ~500 output tokens per reply, peak decode is ~175k tokens/s. If a load test shows one GPU sustaining ~2,500 tokens/s within the p95 latency target, that's 70 GPUs busy, **~100** at 70% target utilization. Storage is small: 2 KB per turn × 10M × 365 × 3 replicas ≈ 22 TB/year. Conclusion in two minutes: the GPUs are the cost and the risk; the database is not.

Trade-offs +3 · −3

+ You gain

  • Kills infeasible designs in two minutes, before anyone writes a design doc.
  • Shows which component dominates cost and latency, so you optimize the right one.
  • Makes assumptions explicit, so people challenge the inputs instead of the conclusion.

− You pay

  • Only gets the order of magnitude; it never replaces a load test.
  • One bad input (peak factor, tokens per request) shifts the answer by 5–10×.
  • Per-GPU throughput depends heavily on model, batch size and context length, so it must be benchmarked.

Use it when

At the start of every design and interview question: before picking a database, a shard count or a GPU fleet, and whenever one number decides the architecture.

Avoid it when

As a substitute for load tests or real capacity planning. Once you have production traffic and benchmarks, use the measured numbers.

Numbers to know 5
  • L1 cache ~1 ns · main memory ~100 ns · SSD random read ~16–100 µs.
  • Round trip: same datacenter ~0.5 ms; California ↔ Netherlands ~150 ms.
  • 1 day = 86,400 s ≈ 10⁵ s, so 1M requests/day ≈ 12 QPS average.
  • 2¹⁰ ≈ 10³ (KB), 2²⁰ ≈ 10⁶ (MB), 2³⁰ ≈ 10⁹ (GB), 2⁴⁰ ≈ 10¹² (TB): thousand, million, billion, trillion.
  • Rule of thumb: 1 token ≈ 4 characters ≈ 0.75 English words.
Common pitfalls 4
  • Sizing for the average day: peak hours run 2–5× higher, and launches or batch jobs spike further.
  • Counting requests instead of tokens: a 20k-token RAG prompt is ~100× the prefill work of a 200-token chat turn.
  • Using a vendor's peak tokens/s instead of throughput measured at your latency SLO and context length.
  • Forgetting replicas, indexes and backups: stored bytes are a multiple of raw bytes (×3 for replication alone).
Interview questions 2

Answer out loud first, then reveal.

Estimate the GPUs needed to serve a chat assistant to 1M daily users.Show answer

I'd state assumptions first: 10 messages per user per day, ~500 output tokens per reply, 3× peak. That's 10M requests a day, about 116 QPS average and ~350 at peak, so ~175k output tokens per second. Then the one number I won't guess: per-GPU throughput for our model at our p95 latency target. Say a benchmark gives 2,500 tokens/s: 70 GPUs busy, ~100 with 30% headroom, before redundancy across zones. Next I'd check how much routing easy turns to a smaller model cuts that.

An agent turn makes 8 sequential tool calls to a service in another region. What latency do you expect?Show answer

Before any model time, 8 cross-region round trips at ~70–150 ms each is roughly 0.6–1.2 s of pure network, plus each tool's own work and the LLM calls between them. That's why I count hops on the critical path first. I'd co-locate the tools with the agent runtime, run independent calls in parallel and batch reads, which brings the network part down to a few milliseconds. Latency numbers tell you where the time goes before a profiler does.