Capacity planning: forecasting, headroom and N+1, load testing, and back-of-envelope estimation

Demand → work per request → resource per unit → units → redundancy and headroom. Plan for peak, and state the bottleneck before the machine count.

Read the briefing
About 3 min to read 7 drills

What to remember

  1. 86,400 seconds in a day. 1M requests/day ≈ 12 QPS average, and peak is 3-5× that.
  2. Plan for peak plus the failure case, not the average. N+1 across three zones lands your target around 60-65% utilisation.
  3. Operate below the knee, not near the ceiling. The knee is where latency starts rising; the ceiling is where errors start.
  4. A load test against an empty database measures nothing. Request mix, payload size, cache hit ratio and data volume dominate the result.
  5. Name the bottleneck resource before the number. 'About 20 machines, bounded by memory' beats a precise number with no mechanism.

The big picture

Capacity planning answers "how many machines, and how do you know?" It combines forecasting from peak demand, headroom rules like N+1, load tests that find the knee and the ceiling, and back-of-envelope estimation that turns a product requirement into a machine count. Interviewers love it because you cannot fake the arithmetic and every number you state invites a follow-up.

The mental model

Demand → work per request → resource per unit of work → units needed → redundancy and headroom. Do it in that order, state each number with its justification, round aggressively, and name the bottleneck resource before you name a machine count. Then check the answer against something you know (an existing service's throughput, a hardware constant).

In depth

Forecasting and headroom

Plan against peak, not average: a service that averages 12 QPS and peaks at 60 must be sized for 60 plus growth plus the failure case. Forecast from the trend in peak over the last several months, plus known events (launches, marketing, seasonal cycles, in crypto: airdrops, listings, network upgrades), and re-check the forecast against actuals monthly so the model is corrected rather than trusted.

Headroom turns a forecast into a target utilization. N+1 means the service still serves peak with one unit (machine, zone, region) gone; N+2 covers a second failure or a failure during maintenance. Concretely, if peak needs 6 machines of work, N+1 across 3 zones means each zone can lose its share without the rest exceeding their limit, which usually lands the steady-state target at 50–70% utilization. A fleet running at 90% at peak is already overloaded, because the first failure redistributes its load onto machines with no room. Lead time matters too: plan far enough ahead to acquire capacity (cloud minutes, bare-metal weeks) plus a margin.

Load testing: the knee and the ceiling

A load test's deliverable is a number per unit and the resource that limits it. Ramp load until latency starts rising sharply (the knee, usually where queueing begins) and then until errors appear (the ceiling); operate below the knee, not near the ceiling. Traffic must be production-shaped: the same request mix, payload sizes, cache hit ratio, and data volume, because a test against an empty database or a 100% cache hit rate measures nothing useful. Watch saturation metrics during the ramp (run queue, PSI, disk queue, connection pool waits, GC pauses) to name the bottleneck rather than guessing. Beware the load generator becoming the bottleneck, and the coordinated omission bias in many tools, which flatters latency percentiles.

Back-of-envelope constants and NALSD

Memorize a handful of constants so estimation is fast: a day is 86,400 s (so 1M requests/day ≈ 12 QPS average, with peaks 3–5×); 1 Gbps ≈ 125 MB/s; spinning disk ≈ 100 IOPS and ~150 MB/s sequential; SATA SSD ≈ 100k IOPS; NVMe ≈ 500k+ IOPS and GB/s; RAM access ~100 ns, SSD read ~100 µs, same-region RTT ~1 ms, cross-continent RTT ~100 ms; a well-written service handles on the order of 10k simple requests/second per modern server-class machine. NALSD (non-abstract large system design) is the discipline of going from requirements to numbers: QPS and bytes per request → storage, memory, and bandwidth totals → machines per bottleneck resource → redundancy and headroom → a stated cost. Say the assumption out loud, round to one significant figure, and name which resource ran out first; interviewers score the reasoning, not the precision.

Myths and facts

Myth: Plan capacity for average load; autoscaling handles the rest.

Fact: Autoscaling has a reaction time and a limit; plan for peak plus failure, and let autoscaling handle variance within that.

Myth: A fleet at 90% utilization is efficient.

Fact: It has no room for the first failure; utilization targets exist to absorb redistribution and spikes.

Myth: Load testing with a synthetic uniform workload is good enough.

Fact: Request mix, payload sizes, data volume, and cache hit ratio dominate the result; unrepresentative tests give unrepresentative numbers.

Myth: The ceiling from a load test is the capacity number.

Fact: Operate below the knee where latency is still flat; the ceiling is where errors start, not a target.

Myth: Estimation questions want precise numbers.

Fact: They want stated assumptions, correct orders of magnitude, and the named bottleneck.

How pros do it

  • Forecast peak with growth and known events; compare forecast to actuals monthly.
  • Set utilization targets from the redundancy requirement (N+1/N+2 across zones), not from a feeling.
  • Load test with production-shaped traffic; report knee, ceiling, and the limiting resource.
  • Estimate in the order demand → work → resource → units → redundancy, stating assumptions.
  • Recheck capacity before known demand events and after any efficiency change; keep a lead-time buffer for hardware.

Questions people ask

What utilization should we target?

Derive it rather than quote it: whatever leaves room for your failure model plus spikes. With N+1 across three zones the survivors carry 1.5× their share, so roughly 60% at normal peak; latency-critical services often lower. Saying where the number comes from is the answer.

How precise should an estimation answer be?

One significant figure with stated assumptions; 'about 20 machines, bounded by memory' beats a false-precision 17.4.

How do I size for a launch with no history?

Estimate from comparable events and the funnel (users × actions × requests), size to the high end, add rate limiting and shedding as the safety net, and prepare a scale-up plan.

Autoscaling means I do not need capacity planning, right?

You need it more: quotas, node pool ceilings, warm-up time, and downstream dependencies all cap what autoscaling can do.

How do I find the bottleneck in a load test?

Watch saturation signals as you ramp: run queue and PSI for CPU, disk queue depth, connection pool wait time, GC pauses, and lock contention; the first to saturate is the answer.

Further reading

Drills · 7

Answer in your head, or out loud, before you reveal. Mark each one: "Again" brings it back, "Got it" counts on your desk.

1 Design round

Size the fleet for a public RPC service: 300 million requests/day, peak 5× average, 70% of calls are cheap reads served from a cache, 25% hit an archive node (average 40 ms of node CPU), 5% are heavy historical queries (400 ms). Responses average 4 KB. Give machine counts, the bottleneck, redundancy, and bandwidth, stating every assumption.

  • Three availability zones; must serve peak with one zone lost.
  • Archive nodes are expensive; justify their count separately from the stateless tier.
In short

A strong answer computes about 17,500 peak QPS and about 525 backend cores, names archive CPU as the bottleneck, and picks a utilisation target that survives losing one of three zones.

A strong answer covers
  • Average QPS from 300M/86,400 ≈ 3,500; peak ≈ 17,500 QPS, stated.
  • Work split: ~12,250 cached, ~4,375 archive at 40 ms, ~875 heavy at 400 ms.
  • Backend CPU-seconds/second: 4,375×0.04 ≈ 175 plus 875×0.4 ≈ 350, ≈ 525 cores at peak; machines from cores per node at a stated utilisation target (e.g. 525 ÷ (32 × 0.6) ≈ 28, so ~30 across three zones).
  • Redundancy derived from the failure model and counted once: with three zones and one lost, survivors carry 1.5× their share, so a ~60–65% utilisation target at normal peak keeps them under their limit — not a 60% target and a separate (N−1)/N divisor stacked on top; N+1 stated for the stateless tier too.
  • Bandwidth: 17,500 × 4 KB ≈ 70 MB/s ≈ 560 Mbps egress at peak, plus headroom; note 1 Gbps ≈ 125 MB/s.
  • Bottleneck named (archive CPU) and the cheapest lever identified (cache hit ratio, method-level limits on heavy queries).
  • Assumptions and rounding stated; a cost or count sanity check at the end.
What a strong answer does
  • estimation: Full chain with stated assumptions: QPS, per-class work, CPU-seconds, machines, headroom for zone loss, bandwidth, and a named bottleneck.
  • judgment: Separates tiers, notes that 5% heavy queries dominate backend cost, proposes levers (cache ratio, per-method limits, dedicated pool for heavy queries).
  • communication: Assumption → number → implication at each step, rounded to one significant figure, ending with the bottleneck and the sanity check.
Why

NALSD answers are scored on the chain of stated assumptions, the named bottleneck, redundancy arithmetic that matches the failure model, and a final sanity check.

The common mistake

Treating all requests as equal, or stating a machine count before naming the resource that runs out first. Here 5% of traffic is two thirds of the cost, and archive CPU is the bottleneck.

Read the docs

2 Quick recall

Quick one: a million requests a day is roughly what average QPS?

In short

About 12 QPS: one million divided by the 86,400 seconds in a day.

Accepted

about 12 · 12 · ~12

Why

A day is 86,400 seconds, so 1,000,000 ÷ 86,400 ≈ 11.6 — call it 12 QPS average — and peak is typically 3–5× that, so 40–60 QPS. Say the constant as you use it: the interviewer is checking that you can get from a daily figure to a per-second one without a calculator, because every sizing question starts there.

3 Pick the strongest answer

Quick sizing: a service takes 43 million requests a day and its peak runs about 4× average. Roughly what peak QPS are you designing for?

  1. Cannot be estimated without the latency distribution. Throughput sizing starts with QPS; latency comes in when you compute concurrency.
  2. About 500 QPS: the daily average is what you size for. Sizing for average guarantees failure at peak.
  3. About 2,000 QPS: 43M ÷ 86,400 ≈ 500 QPS average, times 4 at peak. Daily requests ÷ 86,400 gives average; multiply by the peak factor.
  4. About 43,000 QPS. That divides by 1,000 rather than the 86,400 seconds in a day.
In short

About 2,000 QPS: 43 million divided by 86,400 seconds is about 500 QPS on average, times 4 at peak.

Why

86,400 is the constant to memorize. From peak QPS you get concurrency via Little's law (concurrency = QPS × latency), then machines from per-machine throughput, then headroom for the failure model.

Read the docs

4 Pick the strongest answer

A stateless service runs across 3 zones and must keep serving peak if one zone is lost. What utilisation do you run it at during normal peak, and why that number?

  1. It depends only on the autoscaler's maximum. Autoscaling helps if capacity exists to scale into and the reaction time is fast enough; the zone loss is instantaneous.
  2. 33%, one third for each zone. Unnecessarily expensive; two thirds of capacity carrying full load is the requirement.
  3. About 60–65%: losing one of three zones moves its traffic onto the other two, so each must be able to run at roughly 1.5× its normal load without exceeding its safe limit. 2/3 of capacity must carry 100% of load, so normal utilization must be at or below ~66% of the safe limit.
  4. 90%, since Kubernetes will reschedule the pods. Rescheduling needs somewhere with room; at 90% there is none.
In short

About 60 to 65%, because two zones must be able to carry all the traffic when the third is lost.

Why

Headroom is arithmetic from the failure model: with N zones and a requirement to lose one, the target is (N−1)/N of the safe per-unit limit, minus a margin for spikes and for the safe limit being below the knee.

Read the docs

5 Read the output

Where are the knee and the ceiling, and what is the bottleneck?

rps    p50(ms)  p99(ms)  errors/s  cpu%   pool_wait(ms)
 200      12       38       0       28       0
 400      13       41       0       47       0
 600      14       46       0       61       1
 800      19      120       0       68      22
1000      41      380       0       71      95
1200     140     1400      18       73     310
  1. No bottleneck; the service scales linearly to 1000 rps. p99 grew 8× between 600 and 1000 rps.
  2. The load generator is the bottleneck. Nothing suggests it; the server-side pool wait explains the latency.
  3. Knee around 800 rps (p99 jumps from 46 ms to 120 ms while CPU is only 68%), ceiling around 1200 rps where errors start. The bottleneck is the connection pool: pool_wait climbs with latency while CPU stays flat, so add or tune pool capacity rather than machines. Latency rises with queueing, not with CPU; the saturation signal names the resource.
  4. Knee at 1200 rps where errors appear; the bottleneck is CPU at 73%. The knee is where latency degrades, well before errors; 73% CPU is not saturation.
In short

The knee is near 800 rps, the ceiling near 1,200 rps, and the connection pool is the bottleneck because pool wait grows while CPU stays flat.

Why

This is the shape interviewers want you to read: latency knee first, errors later, and a saturation metric that identifies the resource. Capacity is then quoted below the knee, for example 600–700 rps per instance, with the note that fixing the pool would move it.

Read the docs

6 Scenario: what do you do next?

Marketing announces a campaign in three weeks expected to bring 10× normal traffic for two days. Your service currently peaks at 60% CPU across 20 machines in three zones, with a hard quota of 40 machines in the region and a 6-minute autoscaling warm-up.

Step 1. First step?

  1. Enable autoscaling with a high maximum and trust it. A 6-minute warm-up cannot follow a launch spike, and the quota still caps it.
  2. Tell marketing the date is not possible. Premature; the analysis has not been done.
  3. Request a quota increase to 400 machines immediately. Before knowing the number; and quota alone does not prove the service scales.
  4. Turn the campaign into numbers: expected peak QPS, request mix (are the new users doing the expensive thing?), and duration; then compute machines needed at the current per-machine capacity and compare against the 40-machine quota. Capacity work starts by converting a claim into demand and comparing it to a ceiling you actually have.

Step 2. 10× peak needs roughly 120 machines at today's efficiency; quota is 40 and the load test shows the knee is well below your assumed per-machine capacity. What do you do with three weeks?

  1. Add a queue in front and let requests wait. Unbounded queueing turns overload into unbounded latency; bounded shedding is the safe version.
  2. Only optimize; a 3× efficiency gain in three weeks is achievable. Optimistic and unverified; do not bet a launch on it alone.
  3. Only raise the quota and add machines. 10× on an unimproved service is expensive and still fails if the bottleneck is downstream.
  4. Work both sides: raise the quota and pre-warm capacity for the window, and reduce per-request cost (caching, cheaper paths, per-method limits) with a load test after each change; add shedding and rate limits so exceeding the plan degrades instead of collapsing, and agree a fallback with marketing (staged launch or queue). Capacity, efficiency, and graceful degradation together, with a business fallback.

Step 3. The campaign happens. What did you set up beforehand to know it worked?

  1. Assume success if there are no pages. Shedding may be hiding a capacity miss that the forecast review would catch.
  2. Watch the dashboards during the launch. Watching is not a plan; thresholds and actions must exist beforehand.
  3. Pre-agreed SLIs and dashboards for the window, alerts on saturation and shed rate, a scale-up runbook, a load test result that matches the plan, and a post-event review comparing forecast to actuals to correct the model. Verification before, during, and after, with the forecast corrected for next time.
In short

Turn the campaign into numbers and compare them to the quota, then raise quota and cut cost per request, then set up shedding and a post-event review.

Why

Demand events are where forecasting, headroom, efficiency, and graceful degradation meet. Interviewers want the conversion of a marketing claim into numbers, the recognition of quota and warm-up as real ceilings, and a fallback that protects users.

Read the docs

7 Find what's broken

A team sends you this capacity plan before a launch. Which three lines make it unsafe?

# capacity-plan.md (excerpt)
Traffic: average 500 QPS; plan to 500 QPS.
Machines: 500 QPS / 700 QPS per machine (load test) = 1 machine, round up to 2.
Load test: single GET /health endpoint, empty database, 100% cache hit, 1 minute ramp.
Headroom: run at 85% CPU; autoscaling handles bursts (max 3 nodes, 4 minute warm-up).
Growth: revisit in a year.
Failure model: one machine can be lost; the other absorbs the traffic.
In short

Three lines are unsafe: planning to average traffic, a load test on an empty database, and 85% CPU that cannot survive losing one of two machines.

What's broken
  • Line 2: Planning to average traffic ignores peaks that are typically 3–5× higher.
  • Line 4: The load test measures a health endpoint against an empty database with a perfect cache, so 700 QPS per machine is fiction.
  • Line 5: 85% CPU leaves no room for the stated failure model, and autoscaling with a 4-minute warm-up and a 3-node ceiling cannot cover an instant machine loss.
Why

Rounding up to two machines is fine, revisiting yearly is weak but not unsafe, and the failure model itself is stated correctly; the danger is that the other three lines make that failure model unachievable.

Read the docs

Next lesson Incident management: roles, severity, mitigation before root cause, and communication
Drill · Capacity planning
0:00

Loading…