Capacity Forecasting
Capacity forecasting estimates future workload and the resources needed to serve it. Reliable forecasts combine representative measurements, expected workload changes, tested safe capacity, and explicit headroom for uncertainty.
Capacity forecasting estimates the resources a service will need over a future period. For a Python backend, this may mean instances, CPU, memory, database connections, storage, or network throughput. The aim is to have enough capacity for expected demand without provisioning far more than is useful.
Start with measurements that reflect real constraints: traffic volume and shape, latency, error rates, resource utilization, queue depth, and database load. Use representative peak periods as well as averages; a service can meet its daily average and still fail during a short spike. Include known changes such as product launches, scheduled jobs, or traffic seasonality.
Translate expected workload into resource demand using observed or tested capacity. For example, if one instance safely handles a measured number of requests per second at a chosen utilization target, estimate the instance count by dividing projected peak traffic by that usable capacity and rounding up. This is an estimate, not a guarantee: bottlenecks, failover needs, and dependencies can change the result.
Forecasts should state their time horizon, assumptions, and uncertainty. Compare predictions with actual usage regularly, investigate forecast error, and revise the model when workload patterns or application behavior change. Keep headroom for bursts and failures, and validate important assumptions with load tests rather than relying only on extrapolation.
Key points
- Forecast future workload over a stated time horizon, then translate it into resource requirements.
- Use peak and percentile behavior as well as averages.
- Base resource estimates on measured or load-tested safe capacity.
- Include assumptions, uncertainty, headroom, and known workload changes.
- Compare predictions with actual demand and revise the forecast.
Interview questions
How would you forecast capacity for a backend service?
I would collect time-series measurements for traffic, latency, errors, CPU, memory, database load, and queues, paying attention to peak periods rather than only averages. I would identify workload drivers and known changes, then forecast demand over a defined horizon using a method suited to the data, such as a baseline trend plus seasonality. I would translate demand into resources using load-test or production measurements of safe capacity per unit. Finally, I would include headroom, document assumptions, and compare forecasts with actuals to recalibrate.
Why can forecasting from average CPU utilization lead to an outage?
I would not rely on averages alone, because a short burst can violate latency or availability goals even when average utilization looks low. I would inspect high-percentile demand and relevant peak windows, and account for burst duration, concurrency, and autoscaling delay. If bursts are unpredictable, I would use headroom, queueing, rate limits, or other protections, then validate behavior under burst conditions. The right safety margin depends on the service's latency and availability objectives.
How would you determine the safe capacity of one service instance?
I would first define the resource and the workload shape, since requests per second alone may not capture expensive endpoints or background work. I would load test representative traffic and measure throughput, latency, errors, and resource use at different concurrency levels. I would identify the point where the latency or error objective is no longer met, then choose a safe operating target below that point. That gives a more useful capacity estimate than treating peak throughput as sustainable capacity.
How would you choose between a simple trend and a seasonal forecasting model?
A trend extrapolation is simple and can work over a short horizon when growth is steady, but it misses seasonality and structural changes. A seasonal model can represent recurring daily or weekly patterns when enough reliable history exists. I would compare candidate forecasts against held-out historical periods and measure errors in a way that reflects operational impact. For events such as launches, I would model the expected change explicitly rather than assuming historical patterns will capture it.