Capacity Planning
Load testing (k6, Locust, JMeter), traffic modeling, burst handling
Capacity planning ensures systems have sufficient compute, storage, and network resources to handle current and projected traffic without performance degradation. The process involves load testing to establish performance baselines, traffic modeling to project growth, and burst planning for peak events. Tools like k6, Locust (Python), and JMeter simulate realistic traffic patterns. Netflix's chaos engineering and load testing teams run regular "game days" simulating 2x expected peak load to validate capacity headroom.
Key Points
- Little's Law: L = λW (average number in system = arrival rate × average time in system) — fundamental to queuing theory capacity calculations.
- Traffic modeling: use historical percentile growth rates to project 6/12/24-month capacity needs; account for P99 bursts, not just averages.
- k6: JavaScript-scripted load testing tool; integrates with CI; outputs p50/p95/p99 latency, throughput, and error rate metrics — used by Grafana Cloud.
- Locust: Python-based, distributed load generation; intuitive Web UI; programmable user behavior with weight-based task selection.
- JMeter: Java-based, GUI and headless modes; rich protocol support (HTTP, JDBC, MQTT); large enterprise adoption due to plugin ecosystem.
- Burst planning: provision for peak + 2x safety factor; use auto-scaling with pre-warming to handle flash sales, viral events, and award show spikes.
- Headroom rule: keep average CPU utilization at or below 60–70% — provides headroom for traffic spikes before auto-scaling triggers.
- Capacity reviews: quarterly review of cost-per-unit metrics (cost per 1M API calls, cost per GB stored) — prevents unnoticed inefficiencies from scaling into cost crises.
Real-World Example
Amazon runs their infrastructure at 50% average utilization globally — the remaining 50% provides burst headroom without provisioning extra capacity. During Prime Day 2023, they handled 3x normal peak traffic using pre-staged Auto Scaling fleets warmed 2 hours before event start.