Capacity Planning Basics: Will It Hold on Sale Day?
Your shop's yearly sale starts at 10 a.m. on Friday, when the marketing email reaches every customer at once. Will checkout hold, or time out at the worst moment? Answering that in advance is capacity planning: estimating how much computing a service will need, and having it ready before the demand arrives. This lesson works through the numbers.
Know your current numbers
Start from measurements, not hunches. You need three numbers, and your monitoring's metrics, numbers stored over time, provide most of them:
- Peak requests per second (req/s): the highest request rate, measured over a short window such as one minute at the busiest time. Plan for the peak, not the average: 3 million requests a day averages about 35 per second, but if most arrive in the evening, the busiest minute runs several times higher.
- Resource use at peak: how busy CPU, memory, disk, network and database connections are, each as a share of what is available, called utilisation. The first to run out is the bottleneck, and it sets your limit.
- How much one server can safely handle: the highest rate at which a server still meets the latency and error SLOs from lesson 4. Past it, requests queue inside the server and latency climbs steeply, often well before CPU reads 100 percent. Your busiest days give a first estimate, and a load test measures it.
Forecast demand: growth, events and a safety multiple
A forecast is your best estimate of future demand. Google's SRE book separates organic growth, the steady rise as more people use the product, from inorganic growth, jumps caused by events such as launches and marketing campaigns. A sale-day forecast combines three parts:
- Organic growth: how the peak grew over past months, extended forward.
- Planned events: sale days, launches, a TV advert, which the trend cannot show. Compare last year's event with a normal day, and ask the people planning this one.
- A safety multiple: an extra factor, such as 1.25, for the unknown, like a sale that goes viral.
With illustrative numbers: today's normal peak is 360 req/s, growing about 10 percent a quarter, so expect about 400 by the sale. Last year's sale peaked at twice a normal day, giving 800. The safety multiple of 1.25 turns that into a planning figure of 1,000 req/s.
In the chart, notice two gaps above the demand line: a small one on sale day, which is your headroom, and a large one on every other day, which you pay for without using.
Add headroom and survive one failure
As lesson 7 showed, headroom is spare capacity kept free so a service copes with surprises while more arrives. Say you plan to use at most 70 percent of each server's safe limit, keeping 30 percent spare. The diagram turns that into a server count and checks it against a failure.
Always round up: with 9 servers, each would run at 74 percent of its limit, past the target.
The second check is N+1: if N servers can carry the peak, run at least one more, so the service survives losing any one of them to a crash or an update. Here N is 7, because 1,000 ÷ 150 is 6.7, rounded up, and the plan has 10. Losing one leaves 9 × 150 = 1,350 req/s, so the headroom already covers it.
N+1 matters most for small fleets. With an illustrative peak of 200 req/s, the headroom rule gives 200 ÷ 105 = 1.9, so 2 servers. Lose one and the survivor faces 200 req/s against a safe limit of 150. N is 2 here, so N+1 means 3 servers.
The count covers only the app servers. Shared parts do not grow with them: every order still writes to one database primary (lesson 7), and if the cache from lesson 8 fails or starts empty, the database takes the full load. Size each shared part the same way.
Validate with a load test, and mind lead times
A load test sends artificial traffic at a controlled, rising rate to a copy of the service while you watch latency and errors. It turns an estimate such as 150 req/s into a measurement, and often finds an unexpected bottleneck, such as a database connection limit.
Run it in steps, for example 10 minutes each at 50, 100, 150 and 200 req/s, against a copy built like production with realistic data, and include a run with an empty cache. The safe limit is the highest step that still meets your SLOs. Tools such as Grafana k6, Locust and Apache JMeter generate the traffic; use them only on systems you own.
Lead time is how long capacity takes to arrive after you decide you need it. Physical servers can take weeks or months to order, deliver and install. In the cloud, each account has quotas, limits on how much of a resource it may run. Raising one is a request that may be approved in minutes or take days, and a region can run short of a popular machine type.
So your forecast must look further ahead than your longest lead time, a step Google's SRE book calls mandatory. For a sale six weeks away, request quota increases now; many providers also let you reserve capacity in advance. Then provision the servers, meaning set them up ready for traffic, before the day. Autoscaling still helps on the day, but only up to its configured maximum and your quota.
Make it a routine
Traffic, code and prices keep changing, so capacity planning is a loop, not a project. In the flowchart, notice the dashed arrow back to the start: each review feeds fresh measurements into the next plan.
Each quarter, compare the forecast with what really happened. If the peak beat the forecast by 30 percent, find out why: a missed event, a popular new feature, or slower code that lowered the per-server limit.
Review cost too: capacity only about 25 percent used on normal days, as in the chart, is mostly money spent on nothing. Remove the extra servers after the sale, or let autoscaling shrink the fleet between peaks; Cloud Cost Basics explains the bill.
Check yourself
Your service averages 40 req/s across a day, and one server safely handles 150. Why is one server still not enough?
The average hides the peak, which can be several times higher, and one server has no spare: a single crash or update takes the service down. Size from the peak, then add headroom and N+1.
You double the app servers, but the load test still fails at the same rate. What does that tell you?
The bottleneck is not the app servers but something shared that did not grow, such as the database or its connection limit. More servers only help when servers are the limit.
The sale is three weeks away and your plan needs twice your current cloud quota. Why ask today rather than in sale week?
Quota increases and reserved capacity have lead times, possibly days, and a region can run short of machines. A request made too late leaves you with a plan but not the servers.
Go deeper
- Capacity Planning in the Cloud Era: predictive autoscaling, rightsizing and cloud pricing models, for when you rent capacity by the hour.