Capacity Planning and Load Testing
Capacity planning explained: forecasting demand, headroom and utilisation targets, load testing methods, finding the bottleneck and planning for peaks.
Capacity planning makes sure a system has enough resources (servers, database throughput, network, storage, third-party quotas) to meet demand with acceptable performance, at a reasonable cost, and before the demand arrives. It combines forecasting how load will grow, measuring how much load each component can actually handle through load testing, and keeping headroom for spikes and failures.
The capacity planning loop
- Measure current demand in the units that drive cost: requests per second per endpoint, messages per second, storage growth per day, concurrent connections.
- Forecast growth from trends and known events: organic growth, launches, marketing campaigns, seasonal peaks such as festival sales.
- Find each component's limit with load tests, and identify the bottleneck that saturates first.
- Plan headroom: target utilisation that leaves room for spikes and for losing a zone.
- Provision and verify, then repeat on a schedule, because both demand and the system change.
Headroom and utilisation targets
Running at 100% utilisation means no room for spikes, and latency rises sharply well before that because queues grow as utilisation approaches its limit. Typical targets are 50-70% at expected peak for latency-sensitive services. Also plan for N+1 or N+2 redundancy: if traffic is spread across three zones and one fails, the other two must absorb its share.
| Scenario | Rule of thumb |
|---|---|
| Normal peak | Stay below the utilisation where latency starts climbing (often 60-70% CPU) |
| Zone failure | With 3 zones, each zone's normal peak share must fit in the remaining 2 (run at ≤ 66% of zone capacity) |
| Known event (sale, launch) | Forecast the multiple over normal peak and pre-scale; don't rely on autoscaling reacting in time |
| Storage | Alert well before full; plan expansion time (resharding a database can take weeks) |
Load testing
| Test | Purpose |
|---|---|
| Load test | Run expected peak traffic and confirm latency and errors meet targets |
| Stress test | Increase load until something breaks, to find the true limit and how it fails |
| Soak test | Hold a high load for hours to find leaks, slow degradation and full disks |
| Spike test | Jump traffic suddenly, to test autoscaling, caches and connection pools |
- Model real traffic: the same mix of endpoints, payload sizes, cache hit rates and user behaviour as production. A test that only hits a cached endpoint proves nothing.
- Test in a production-like environment, or carefully in production with synthetic traffic, since staging rarely has the same data size or dependencies.
- Watch the whole path: database connections, thread pools, queues and downstream services often saturate before CPU does. See connection pooling.
- Measure latency percentiles, not averages. See latency vs throughput.
Finding the bottleneck
Every system has one resource that saturates first, and adding capacity anywhere else does nothing. Use the USE method (utilisation, saturation, errors) per resource and look for the first one to hit its limit: CPU, memory, disk I/O, network, database connections, lock contention, a single-threaded component, or a third-party rate limit. Fix or scale that one, then test again, because the bottleneck moves.
Back-of-the-envelope maths gets you a first estimate before any test. See capacity estimation.
Planning for spiky and unpredictable demand
- Autoscaling handles gradual changes but lags by minutes; pre-warm before known events. See autoscaling.
- Queues absorb bursts for work that can be asynchronous. See message queues.
- Load shedding and rate limits protect the system when demand exceeds any plan. See load shedding.
- Quotas and limits with cloud providers and third parties must be raised ahead of time.
Where it’s used
Forecast a 10x peak, load-test the checkout path, pre-scale and raise payment-provider limits weeks ahead.
Track storage and write growth to schedule resharding or larger instances before limits are hit.
Plan CDN and origin capacity for live events with predictable, huge spikes.
In an interview
- Measure demand in cost-driving units and forecast with known events.
- Keep headroom for spikes and a zone failure.
- Load test with realistic traffic and find the first bottleneck.
- Pre-scale for known peaks instead of relying on autoscaling.
Further reading
- SRE book: Software Engineering in SRE (capacity planning)Google
- The USE MethodBrendan Gregg