Cloud capacity planning
Start with a workload, not a machine
Capacity planning asks how much usable work a system can deliver while meeting latency, error and cost objectives. For a fictional bookstore search service, define a request as one search, target 240 completed searches/s at peak, p95 end-to-end latency at most 180 ms, and errors below 1% over a five-minute window. These are invented design targets, not measured provider performance. Record request mix (search, checkout, background work), payload sizes, cache hit ratio, geographic distribution, diurnal variation, burst duration, and expected growth. Distinguish offered arrivals, admitted work, completed work and rejected requests. Throughput is completions per unit time; concurrency is simultaneous in-flight work; latency is elapsed time per request. A throughput increase is not a success if errors or tail latency violate the objective.
For steady workloads in a stable system, Little's Law gives average in-flight work L = arrival rate λ × average residence time W, for the same population and boundary, with long-run flow balance and finite averages. At 240 requests/s and mean residence time 0.125 s, L = 30 requests. Do not substitute p95 for the mean, use offered arrivals that were rejected, or apply the formula as an equilibrium prediction while the backlog grows. A queue-only boundary uses queue arrival rate and mean waiting time; the whole-service boundary includes service time.
Size the constraining resource
Use an independently measured sustainable throughput at the target latency/error objective rather than maximum observed throughput. Suppose an illustrative replica reaches 80 requests/s at saturation and testing supports a 60 requests/s operating target. At 240 requests/s, ceil(240/60) = 4 ready replicas. To survive loss of one replica, provision 5 ready replicas; a six-replica quota leaves one additional slot. These assumptions require balanced traffic, equivalent replicas and no shared bottleneck. If a database safely handles only 180 queries/s and each request issues one query, adding application replicas cannot reach 240 requests/s. Either reduce queries per request, improve database capacity, or revise the objective.
| Resource | Model or signal | Common limitation |
|---|---|---|
| CPU | CPU-seconds/request × requests/s | 240 × 0.01 = 2.4 CPU cores busy on average; 60% target implies 4 usable cores |
| RAM | base working set + per-inflight memory | 512 MiB + 30 × 4 MiB = 632 MiB before overhead |
| Disk | operations/request × requests/s | 3 × 240 = 720 IOPS; throughput and latency limits also apply |
| Network | bytes/request × requests/s | 25,000 × 240 = 6 MB/s or 48 Mbit/s, excluding protocol overhead |
| Dependency | connection pool, quota, query throughput | Shared limits may dominate local capacity |
Use consistent units: 1 MB = 1,000,000 bytes; 1 MiB = 1,048,576 bytes. CPU cores in this model are equivalent usable cores, not interchangeable cloud vCPUs. Memory headroom includes runtime, buffers and peaks. Disk IOPS and bytes/s are distinct; a 16 KiB operation at 720 IOPS is 11.25 MiB/s. Monitor throttling, credits and device or instance ceilings as well as mean utilization.
Plan for bursts and elasticity
For a fluid queue model with constant offered demand 300 requests/s and available service 240 requests/s, backlog grows by 60/s while capacity is insufficient. During a 20 s startup delay, 1,200 requests accumulate if every request is admitted and no timeout occurs. Once 360 requests/s is ready, demand remains 300 and the excess service rate is 60/s; draining takes 20 s. A bounded queue of 600 requests cannot absorb the entire startup interval: reject or defer overflow and honor deadlines. A queue that is empty at the start is not proof of sustainable capacity.
Vertical scaling increases resources per instance and may help memory-bound or single-node workloads but has size ceilings and restart risks. Horizontal scaling adds instances, requiring partitionable work, traffic balancing and shared-state design. Set minimum ready capacity, maximum capacity, scale-out signal, stabilization and safe scale-in draining. For example, scale from a measured operating target of 60 requests/s per replica, with queue age or saturation as corroboration; never treat 60 as a universal threshold. Use scheduled capacity for predictable peaks, include startup and readiness delays, and check quotas before a rollout. Quota permission is not a guarantee of available physical capacity. Capacity reservations are distinct from discount commitments and may incur charges even when idle.
Compare cloud planning controls
| Provider | Example scope | Planning action |
|---|---|---|
| AWS | EC2 Auto Scaling for supported instance groups, EC2 On-Demand Capacity Reservations for matching capacity in a zone | Check instance type, zone, quota, readiness, billing for unused reservations and downstream limits |
| Azure | VM Scale Sets and Azure Load Testing for supported workloads | Check VM family/regional quotas, scale rules, storage and network limits; use an approved isolated environment |
| Google Cloud | Managed instance groups and quota-aware resource allocation guidance | Check regional/zonal resource availability, quota, startup behavior and backend capacity |
Official evidence: AWS scaling guidance, EC2 capacity reservation scope, reservation billing, Azure capacity planning, and Google resource allocation. Search excerpts reviewed; confirm service configuration and availability before a real deployment. No cloud resources or pricing quotes were requested.
Cache and cost as capacity decisions
With 240 searches/s, one database lookup per miss, and a 75% cache hit ratio, mean database demand is 60 queries/s. A cold cache with 0% hits produces 240 queries/s, exceeding the illustrative 180 queries/s database target. Plan warm-up, expiry jitter, coalescing of identical concurrent misses, bounded admission and freshness rules. Avoid caching private results across users; keys must include the relevant authorization scope. A cache reduces some work but adds memory, network and invalidation overhead.
If five ready replicas cost a fictional $0.08 each per hour, a 24-hour day costs $9.60 for compute alone. Four cost $7.68 but fail the one-replica-loss requirement. A spare capacity slot, reservation, egress, storage operations and cache costs need separate accounting. Optimize cost per successful request while satisfying service objectives, not cost per instance in isolation.
Check your understanding
At 360 requests/s and a tested operating target of 60 requests/s per replica, six ready replicas are required; seven tolerate one loss under balanced traffic. A quota of six means the design is blocked until capacity is reworked or the quota and availability are confirmed. If mean residence time is 150 ms in steady state, average in-flight work is 54. If a shared store is limited to 200 queries/s, a 50% cache hit ratio reduces mean queries to 180, but a cold cache needs 360. Identify the shared limit and a safe cold-start policy before increasing application replicas.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Cloud capacity planning — knowledge check
Choose the best answer for each offline scenario.
Which inputs belong in Little’s Law for a stable service?
At 360 requests/s and 60 per replica, how many ready replicas tolerate one loss?
A store handles 180 queries/s and every request needs one query. What happens at 240 requests/s?
What does a 75% cache hit ratio imply for 240 searches/s, one lookup per miss?
What is the difference between quota and capacity reservation?