Skip to content

    System Design

    Capacity Planning: Forecasts, Headroom and Failure Domains

    Turn a growth forecast into a fleet size with headroom, failure domains, dependency limits and lead time, using arithmetic you can rerun in Node.js.

    By Published 12 min read

    Share

    Standard lessonintermediateBackend System Design

    Before this: Capacity Planning and Cost: An Overview

    What you'll learn: By the end of this lesson you will be able to turn a growth forecast into a fleet size, keep headroom for a lost availability zone, find the dependency that runs out before the servers do, decide when to start ordering capacity given its lead time, and review a plan against what actually happened.

    A bakery owner does not decide on Friday night how much flour to buy. She knows the supplier delivers on Tuesdays, so the order has to be placed before she can see the weekend crowd. She also knows that if one oven breaks, the other still has to get the Saturday bread out.

    Capacity planning is that decision for software: how much of every resource must exist, and when must you ask for it, so that the busiest expected hour still meets its targets even when part of the system has failed. The capacity and cost lesson gave the overall method and the estimation lesson the back-of-envelope arithmetic. This lesson goes deeper on the parts that fail in practice: forecast error, failure domains, dependency limits and lead time.

    Verified on 2026-12-01 against the Google SRE book, the Kubernetes documentation, the HikariCP wiki and the AWS Service Quotas guide. The script on this page was run with Node.js v26.13.1. Every price, rate and capacity figure is illustrative.

    The core idea

    A capacity plan is a dated promise: by this date, with this forecast and these assumptions, the system can carry this load with this much spare room. It has four inputs and one output.

    • Demand forecast: peak requests per second, as a range, not a point.
    • Per-unit capacity: what one instance sustains while still meeting its latency target, measured not guessed.
    • Headroom policy: the utilisation you plan to run at, and which failures you must survive.
    • Lead time: how long it takes from "we need more" to "it is serving traffic".
    • Output: a fleet size now, a fleet size at each review date, and the date on which the next order must start.

    Three illustrations run through the lesson, each labelled:

    • Minimal example: one fleet-size formula with a utilisation target.
    • Realistic example: ShopStream browsing traffic over twelve months, with zones, a database and a lead time.
    • Failure example: the application tier scales and the database connection limit is crossed first.

    From forecast to fleet size

    The minimal example

    Minimal example (illustrative). A service must carry 1,000 requests per second at peak. One instance was load tested and sustains 250 requests per second at its latency target. Planning to run at 70 percent of that leaves 175 usable requests per second per instance.

    instances = ceil(1,000 / 175) = 6

    Two choices hide in that line. The utilisation target (70 percent) is a headroom policy: the Kubernetes horizontal pod autoscaler documents the same shape of arithmetic, desiredReplicas = ceil[currentReplicas * (currentMetricValue / desiredMetricValue)], where the desired metric value is your target. And the "250" is only meaningful if it was measured at the latency target; the load testing lessons cover how, and Little's Law and queueing intuition (a separate lesson in this module) explain why latency bends upward as utilisation approaches the limit.

    Plan the range, not the point

    A forecast is a guess about the future and the plan must show its sensitivity. Growth compounds, so a linear forecast under-predicts a service that grows by a percentage each month. With an illustrative 1,158 requests per second today and 6 percent growth per month, the compound forecast is 2,330 requests per second at month 12; a straight-line extension of the first month's increase gives about 1,990. The gap, 340 requests per second, is two more instances of 175 usable requests per second each, and that is the size of the mistake a wrong curve hides.

    Practical habits: forecast from business drivers (users, orders, a launch) rather than from the metric's own history alone; write down the growth assumption; and plan against a low, expected and high case so the review shows which case is tracking.

    Failure domains and N+1

    A failure domain is a set of things that fail together: one host, one rack, one availability zone, one region. Headroom is not only for traffic growth. It is also the spare capacity that lets the survivors carry the load when a domain is lost.

    Three zones, one lost: the survivors carry the loadLoad balancer to Zone A (50%); Load balancer to Zone B (50%); Load balancer to Zone C (none); Zone A to Database; Zone B to DatabaseLoad balancerLoad balancerZone A: 7 instancesZone A7 instancesZone B: 7 instancesZone B7 instancesZone C: 7 instances, lostZone C7 instances, lostDatabase: connection limitDatabaseconnection limit50%50%none

    Figure 1. Surviving the loss of one of three zones. How to read this: with seven instances in each of three zones, the two remaining zones hold fourteen. Each must carry half of the traffic, so the fleet was sized so that fourteen instances carry the peak at the planned utilisation.

    The rule for surviving one lost zone out of Z: size so that Z - 1 zones carry the peak, then multiply back up.

    per_zone = ceil(need / (Z - 1)), fleet = per_zone * Z

    For a need of 14 instances and three zones, per_zone = 7 and fleet = 21. Seven of every twenty-one instances are the price of surviving a zone loss, one third of the bill, which is why multi-region and disaster recovery and resilience patterns treat the requirement as an explicit business decision. With Z zones the spare share is one in Z. Two zones give the worst ratio, because surviving one lost zone needs a full duplicate of the fleet (half of it spare); four zones need a quarter of the fleet as spare and five a fifth.

    Where the real limit hides

    The scarcest resource sets the limit, and it is often not the one being scaled.

    • Dependency limits. An autoscaled tier multiplies connections to a shared database. HikariCP's pool-sizing page makes the point that "the question is not how big but rather how small", and gives a starting formula, connections = ((core_count * 2) + effective_spindle_count), with the caveat that sizing is specific to a deployment. Each new instance spends part of a fixed budget.
    • Resource requests. The Kubernetes scheduler uses a pod's resource request to place it on a node, so a request that is too high strands capacity and one that is too low overbooks a node. A CPU limit is enforced by throttling and a memory limit by an out-of-memory kill, which is not the same failure.
    • Quotas. Cloud accounts have service quotas. The AWS Service Quotas guide describes a default value per quota, some of them adjustable, and says increases "do take some time to review, process, and approve" and may be approved, denied or partly approved. A quota is therefore part of lead time.
    • Autoscaler behaviour. The Kubernetes autoscaler runs as a control loop (every 15 seconds by default), skips changes within a tolerance of 0.1 of the target, treats pods that are not yet ready conservatively when scaling up, and waits a stabilisation period (5 minutes by default) before scaling down. Autoscaling absorbs a smooth change. It does not cover a sudden spike, so the headroom you planned has to.

    The realistic example: ShopStream over twelve months

    Realistic example (illustrative). ShopStream's browsing peak at 10 million monthly active users is about 2,300 requests per second (the shared figure from the project brief). Assume that today's traffic is about half of that, 1,158 requests per second at peak, and that traffic grows 6 percent a month. An instance was measured at 250 requests per second at its latency target and is planned at 70 percent. Three zones, one may be lost. Each instance holds a database pool of 10 connections and the service may use 200 database connections (a budget agreed with the database owner).

    // capacity.mjs - every input is illustrative, not a benchmark.
    const startRps = 1158, growth = 0.06;   // peak rps today, growth per month
    const measured = 250, util = 0.7;       // rps per instance at its latency target; planned utilisation
    const zones = 3, pool = 10, dbBudget = 200;
    const usable = measured * util;
    const rpsAt = (m) => startRps * (1 + growth) ** m;
    const fleetFor = (rps) => Math.ceil(Math.ceil(rps / usable) / (zones - 1)) * zones;
    
    console.log("month  peak_rps  need  fleet  db_conns  fits_db");
    for (const m of [0, 3, 6, 9, 12]) {
      const rps = rpsAt(m), fleet = fleetFor(rps);
      console.log(`${m}  ${Math.round(rps)}  ${Math.ceil(rps / usable)}  ${fleet}  ${fleet * pool}  ${fleet * pool <= dbBudget ? "yes" : "NO"}`);
    }
    let m = 0;
    while (fleetFor(rpsAt(m)) === fleetFor(startRps)) m += 0.01;
    console.log(`fleet of ${fleetFor(startRps)} is outgrown at month ${m.toFixed(2)}`);
    console.log(`with a 6 week lead time, order by month ${(m - 6 / 4.345).toFixed(2)}`);
    const left = (fleetFor(rpsAt(12)) / zones) * (zones - 1);
    console.log(`month 12, one zone lost: ${left} instances, ${(rpsAt(12) / (left * measured) * 100).toFixed(1)}% of measured capacity`);

    Output of running the script with Node.js v26.13.1:

    month  peak_rps  need  fleet  db_conns  fits_db
    0  1158  7  12  120  yes
    3  1379  8  12  120  yes
    6  1643  10  15  150  yes
    9  1956  12  18  180  yes
    12  2330  14  21  210  NO
    fleet of 12 is outgrown at month 3.26
    with a 6 week lead time, order by month 1.88
    month 12, one zone lost: 14 instances, 66.6% of measured capacity

    Read the output in four steps. The fleet moves in steps of three because it is rounded per zone. The first order must start about month 1.9, not month 3.3, because six weeks of lead time (illustrative) come before the date the fleet is outgrown. The month 12 row shows the surprise: 21 instances fit the traffic but 210 connections exceed the 200 budget, so the plan fails on the database before it fails on compute. And with one zone lost, the remaining 14 instances run at 66.6 percent of measured capacity, inside the 70 percent target.

    flowchart LR accTitle: Lead time decides the order date accDescr: A timeline of four steps. The forecast crosses the capacity of the current fleet at a known date. Lead time before that date is when the order must start. Capacity must be live and verified before the crossing date. The review after the crossing compares forecast with actual. F["Forecast crosses
    current capacity"] --> L["Subtract lead time:
    quota, order, rollout, test"] L --> O["Order start date"] O --> V["Capacity live and
    verified before crossing"] V --> R["Review: forecast
    against actual"]

    Figure 2. Work backward from the date capacity runs out. How to read this: the date that matters is not when the fleet is outgrown but the earlier date when the order must start, which is the crossing date minus every step in the lead time, including quota approval.

    The planning loop

    The Google SRE book describes traditional capacity planning as four steps: collect demand forecasts, devise build and allocation plans, review and sign off on the plan, and deploy and configure resources. It adds that this is a cycle that never ends, since "assumptions change, deployments slip, and budgets are cut". Google teams moved toward what the book calls intent-based capacity planning, in which a service's needs and dependencies are encoded as parameters ("specify the requirements, not the implementation") instead of a fixed request such as a number of cores in a cluster. Most teams do not need a solver; the useful part is writing the intent down, such as "survive one zone lost at the forecast peak".

    Capacity planning loopForecast to Measure; Measure to Plan; Plan to Order; Order to Review; Review to ForecastForecast: low, expected, highForecastlow, expected,highMeasure: per-instance limitMeasureper-instancelimitPlan: fleet, zones, limitsPlanfleet, zones,limitsOrder: after lead timeOrderafter lead timeReview: forecast vs actualReviewforecast vsactual

    Figure 3. The loop that never ends. How to read this: every review feeds the next forecast. A plan that is written once and never compared with actual traffic is a guess with a date on it.

    Trade-offs

    Choice Gain Cost Wrong when
    Lower utilisation target More room for spikes and forecast error More instances to pay for Load is smooth and well understood
    Survive a zone loss The service stays within targets after a zone failure Roughly a third more capacity with three zones The business accepts degraded service in a zone failure
    Reactive autoscaling alone Cost follows demand Delay and limits on scaling speed Spikes arrive faster than new capacity
    Scheduled scaling for known events Capacity is live before the load Needs an accurate event calendar The traffic is unpredictable
    Order early Safe against lead-time surprises Idle capacity for longer Capacity can be added in minutes
    A larger shared database budget Application tier can scale further Cost and failure blast radius grow Pool size is the real bottleneck

    In practice: the quarterly capacity review at ShopStream

    This is an educational scenario on ShopStream with illustrative numbers.

    This is a realistic scenario, not a case history.

    The situation

    ShopStream's browsing service has grown steadily and the team plans capacity by comparing the current peak with a fleet limit each quarter. A marketing push is planned for month 4, and the platform team wants to know whether the existing fleet carries it.

    Starting architecture

    Twelve instances across three zones (four per zone), a database with a 200 connection budget for this service and a pool of 10 per instance. The fleet is sized for the current peak with one zone lost. Autoscaling adjusts replicas between 12 and 15 on CPU.

    Options considered

    Option Gain Cost Wrong when
    A. Rely on autoscaling to 15 No change The cap at 15 and connection budget are the real limits The push exceeds the cap
    B. Raise the cap and order capacity at month 1.9 Live before the push Idle capacity for a few weeks The push is cancelled
    C. B plus a smaller pool and a read replica for browsing Removes the database ceiling Two changes to verify The team cannot test both before the push

    The decision

    Option B, plus a measured pool reduction from 10 to 8 connections per instance (illustrative; the team sizes it with a load test, not by feel). The forecast table says the 12 instance fleet is outgrown at month 3.26, and the push is at month 4, so the order starts at month 1.9 after the six-week lead time.

    Rollout and verification

    Raise the quota first, then add instances a zone at a time. After each step, check latency against the SLO and confirm database connections per instance. At the end, load test at the forecast peak with one zone drained and compare against the 66.6 percent figure from the plan.

    The 2 a.m. failure

    At 02:00 a zone has an outage while a nightly batch job is also running. The page reads "Database connections at 100%". The surviving zones start extra instances to cover the load, and each new instance opens its pool.

    sequenceDiagram accTitle: A zone loss exhausts database connections accDescr: One zone fails and the autoscaler starts replacement instances in the remaining zones. Each new instance opens its connection pool. The database reaches its connection limit, new instances cannot connect, and request errors rise although CPU in the application tier is low. participant Z as Zone A fails participant S as Autoscaler participant I as New instances participant D as Database Z->>S: capacity drops S->>I: start instances in other zones I->>D: each opens a pool of connections D-->>I: connection limit reached, refuse Note over I,D: errors rise while application CPU stays low

    First checks: compare database connections in use with the budget, and instances ready against instances starting. Mitigation: cap the autoscaler's maximum so total pools fit the budget and pause the batch job. Follow-up: budget connections per service as a capacity input in the plan, and alert on connection use at 80 percent (illustrative), the same idea as the quota utilisation measure in the Service Quotas guide.

    Architect's notes

    • Plan in ranges and publish which case is tracking at each review.
    • Measure the per-instance limit at the latency target; never copy a number from another system.
    • Write the failure assumption into the plan: "one zone lost at forecast peak".
    • Treat limits as inputs: quotas, pools, file descriptors and licence counts belong in the same table as CPU.
    • Reduce lead time where you can: pre-approved quotas and tested launch templates move the order date closer to the crossing date.
    • Close the loop: record forecast against actual every cycle and use the error to adjust the next growth assumption.

    Common mistakes

    • Planning from the average instead of the peak of the busiest expected period.
    • Sizing for the normal state only, so a zone loss pushes the survivors past their limit.
    • Letting an autoscaler open more connections than the database can hold.
    • Ignoring lead time and quotas, then discovering both in the week of a launch.
    • A linear forecast for compound growth.
    • Never reviewing the plan against what happened.

    Key takeaways

    • A plan is a forecast range, a measured per-instance limit, a headroom policy and a lead time.
    • Fleet size is ceil(peak / usable), then multiplied up so the survivors carry the peak after a failure-domain loss.
    • With Z zones, surviving one zone loss needs ceil(need / (Z - 1)) * Z instances.
    • The first limit to run out is often a dependency, a pool or a quota, not CPU.
    • The order date is the crossing date minus the lead time.
    • The loop of forecast, plan, order and review never ends; compare forecast with actual every cycle.

    Practice exercises

    Exercise 1 (30 min). Change the script's growth to 4 percent and 8 percent a month. For each, find the month the 12 instance fleet is outgrown and the order date with a six-week lead time.

    Exercise 2 (45 min). Set zones = 2 and then zones = 4. Compare the fleet sizes at month 12 and explain the overhead of surviving one zone loss in each case.

    Exercise 3 (1 hour). Add a second dependency to the model, a cache with a 5,000 operation per second budget (illustrative), and find which of compute, database connections or cache is exhausted first.

    Official documentation

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments