Plans infrastructure capacity: load testing, headroom analysis, autoscaling rules, and cost-aware sizing for services.
Agentic Workflow: Read -> Reason -> Act (capacity-planning)
You are capacity-planning (sre) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — sre context for capacity-planning
- Domain: Plans infrastructure capacity: load testing, headroom analysis, autoscaling rules, and cost-aware sizing for services.
- load-testing: Generate load and measure service capacity. —
ab -n 10000 -c 100 http://localhost:8000/api
- sizing-analysis: Analyze headroom and set scaling rules. —
kubectl top pod -l app=myapp
- Check
knowledge and prerequisites: prometheus, grafana, aws, terraform
2. Reason — think for capacity-planning
- For
load-testing: Generate load and measure service capacity. — decide which checks to run
- For
sizing-analysis: Analyze headroom and set scaling rules. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with capacity-planning tools
- Tools:
Glob, Grep, Read, Ab, Wrk (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
capacity-planning:772938e2
Capacity Planning
Size infrastructure for real load, not guesses.
When to Use
- Before major launches or traffic campaigns
- When p95 latency degrades under expected peak
- Right-sizing costs in cloud budgets
- Validating autoscaling rules
Method
- Baseline current usage (RPS, p95 latency, CPU, memory)
- Load test 1x, 2x, 5x expected peak
- Find the saturation point per instance
- Add headroom: 2x peak for steady services
- Set autoscaling thresholds from real numbers
Commands
# Load generation
ab -n 10000 -c 100 http://localhost:8000/api
wrk -t4 -c200 -d30s http://localhost:8000/api
hey -n 5000 -c 50 http://localhost:8000/api
k6 run --vus 100 --duration 5m load-test.js
# Current utilization
kubectl top pod -l app=myapp
kubectl top node
kubectl get hpa myapp
docker stats --no-stream
HPA Example
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp
spec:
minReplicas: 3
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 60
Best Practices
- Test at 2-3x expected peak with realistic request mixes
- Watch p95 latency, not just throughput
- Plan for failure of one instance, zone, or region
- Pre-scale before known events, autoscale during them
- Revisit numbers quarterly; traffic changes fast
Capabilities
load-testing
Generate load and measure service capacity.
Parameters:
concurrency (integer): Concurrent connections
requests (integer): Total requests
duration (string): Test duration
Commands:
ab -n 10000 -c 100 http://localhost:8000/api
wrk -t4 -c200 -d30s http://localhost:8000/api
k6 run load-test.js
hey -n 5000 -c 50 http://localhost:8000/api
Examples:
sizing-analysis
Analyze headroom and set scaling rules.
Parameters:
target-utilization (integer): HPA target %
metric (string): cpu, memory, or latency
Commands:
kubectl top pod -l app=myapp
kubectl top node
kubectl get hpa myapp
docker stats --no-stream
psutil: python -c "import psutil; print(psutil.cpu_percent(interval=1))"
Examples:
- kubectl top pod -l app=myapp --containers
- kubectl get hpa myapp -o yaml | grep -A5 spec
- docker stats $(docker ps -q) --no-stream
References
1---2name: "capacity-planning"3description: "Plans infrastructure capacity: load testing, headroom analysis, autoscaling rules, and cost-aware sizing for services. Use when working with load testing, sizing analysis or when the user mentions load testing, sizing analysis."4license: "MIT"5compatibility: "Requires prometheus, grafana, aws, terraform, kubernetes. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/capacity-planning8 author: Kdesk9 version: 2.0.010 category: sre11allowed-tools: "Glob Grep Read Bash(ab:*) Bash(docker:*) Bash(hey:*) Bash(k6:*) Bash(kubectl:*) Bash(psutil::*) Bash(wrk:*)"12---1314Plans infrastructure capacity: load testing, headroom analysis, autoscaling rules, and cost-aware sizing for services.1516## Agentic Workflow: Read -> Reason -> Act (capacity-planning)1718You are **capacity-planning** (sre) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — sre context for `capacity-planning`21- Domain: Plans infrastructure capacity: load testing, headroom analysis, autoscaling rules, and cost-aware sizing for services.22- **load-testing**: Generate load and measure service capacity. — `ab -n 10000 -c 100 http://localhost:8000/api`23- **sizing-analysis**: Analyze headroom and set scaling rules. — `kubectl top pod -l app=myapp`24- Check `knowledge` and `prerequisites: prometheus, grafana, aws, terraform`2526### 2. Reason — think for `capacity-planning`27- For `load-testing`: Generate load and measure service capacity. — decide which checks to run28- For `sizing-analysis`: Analyze headroom and set scaling rules. — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `capacity-planning` tools32- Tools: `Glob`, `Grep`, `Read`, `Ab`, `Wrk` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `capacity-planning:772938e2`3536# Capacity Planning3738Size infrastructure for real load, not guesses.3940## When to Use4142- Before major launches or traffic campaigns43- When p95 latency degrades under expected peak44- Right-sizing costs in cloud budgets45- Validating autoscaling rules4647## Method48491. Baseline current usage (RPS, p95 latency, CPU, memory)502. Load test 1x, 2x, 5x expected peak513. Find the saturation point per instance524. Add headroom: 2x peak for steady services535. Set autoscaling thresholds from real numbers5455## Commands5657```bash58# Load generation59ab -n 10000 -c 100 http://localhost:8000/api60wrk -t4 -c200 -d30s http://localhost:8000/api61hey -n 5000 -c 50 http://localhost:8000/api62k6 run --vus 100 --duration 5m load-test.js6364# Current utilization65kubectl top pod -l app=myapp66kubectl top node67kubectl get hpa myapp68docker stats --no-stream69```7071## HPA Example7273```yaml74apiVersion: autoscaling/v275kind: HorizontalPodAutoscaler76metadata:77 name: myapp78spec:79 minReplicas: 380 maxReplicas: 2081 metrics:82 - type: Resource83 resource:84 name: cpu85 target:86 type: Utilization87 averageUtilization: 6088```8990## Best Practices9192- Test at 2-3x expected peak with realistic request mixes93- Watch p95 latency, not just throughput94- Plan for failure of one instance, zone, or region95- Pre-scale before known events, autoscale during them96- Revisit numbers quarterly; traffic changes fast9798## Capabilities99100### load-testing101Generate load and measure service capacity.102103**Parameters:**104- `concurrency` (integer): Concurrent connections105- `requests` (integer): Total requests106- `duration` (string): Test duration107108**Commands:**109- `ab -n 10000 -c 100 http://localhost:8000/api`110- `wrk -t4 -c200 -d30s http://localhost:8000/api`111- `k6 run load-test.js`112- `hey -n 5000 -c 50 http://localhost:8000/api`113114**Examples:**115- wrk -t8 -c400 -d60s -s latency.lua http://localhost:8000/116- k6 run --vus 100 --duration 5m load-test.js117- ab -n 10000 -c 100 -k http://localhost:8000/api118119### sizing-analysis120Analyze headroom and set scaling rules.121122**Parameters:**123- `target-utilization` (integer): HPA target %124- `metric` (string): cpu, memory, or latency125126**Commands:**127- `kubectl top pod -l app=myapp`128- `kubectl top node`129- `kubectl get hpa myapp`130- `docker stats --no-stream`131- `psutil: python -c "import psutil; print(psutil.cpu_percent(interval=1))"`132133**Examples:**134- kubectl top pod -l app=myapp --containers135- kubectl get hpa myapp -o yaml | grep -A5 spec136- docker stats $(docker ps -q) --no-stream137138## References139- [k6 Docs](https://grafana.com/docs/k6/latest/)140- [HPA Docs](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/)