Load Test
Design, run, and analyze load tests. Find your system's breaking point before users do.
Quick Start
/load-test scaffold — generate k6 script from OpenAPI spec or cURL examples
/load-test run <script> — execute + stream metrics
/load-test analyze <results> — interpret results, flag SLO violations
/load-test soak 30m — run soak test (low VU, long duration)
/load-test spike — spike test (sudden burst, check recovery)
Test Scenarios
| Scenario |
Goal |
Duration |
| Smoke |
Verify script works at 1 VU |
1 min |
| Load |
Simulate expected peak traffic |
30 min |
| Stress |
Find breaking point |
Ramp to failure |
| Soak |
Detect memory leaks, slow drift |
2–8 hours |
| Spike |
Instant 10× traffic burst |
1 min burst |
| Breakpoint |
Binary search for max TPS |
Auto |
Workflow
Claude will:
- Infer endpoints from OpenAPI spec / cURL samples / route files
- Generate parameterized k6 or Artillery script
- Define realistic VU ramp (warm up → peak → cool down)
- Add SLO thresholds (p95 < 500ms, error rate < 1%)
- Run test (or provide
docker run command)
- Parse JSON results → surface p50/p95/p99/max + error breakdown
- Recommend: cache headers, DB indexes, connection pool size, rate limits
k6 Script Template
import http from 'k6/http'
import { check, sleep } from 'k6'
import { Rate } from 'k6/metrics'
const errorRate = new Rate('errors')
export const options = {
stages: [
{ duration: '2m', target: 50 }, // ramp up
{ duration: '5m', target: 50 }, // sustain peak
{ duration: '2m', target: 0 }, // ramp down
],
thresholds: {
http_req_duration: ['p(95)<500', 'p(99)<1000'],
errors: ['rate<0.01'],
},
}
export default function () {
const res = http.get('https://api.example.com/products')
check(res, { 'status 200': (r) => r.status === 200 })
errorRate.add(res.status !== 200)
sleep(1)
}
Artillery Script Template
config:
target: "https://api.example.com"
phases:
- duration: 60
arrivalRate: 10
name: Warm up
- duration: 300
arrivalRate: 50
name: Peak load
scenarios:
- name: "Browse products"
flow:
- get:
url: "/products"
expect:
- statusCode: 200
- maxResponseTime: 500
Results Interpretation
/load-test analyze results.json
LOAD TEST RESULTS — 2026-06-14
================================
Duration: 9m | VUs peak: 50 | Total requests: 12,430
LATENCY
p50: 42ms ✅
p95: 380ms ✅ (threshold: <500ms)
p99: 1,240ms ❌ (threshold: <1000ms)
max: 4,800ms ❌
ERROR RATE: 2.3% ❌ (threshold: <1%)
404 Not Found: 0.1%
502 Bad Gateway: 1.8% ← upstream timeout
503 Unavailable: 0.4%
BOTTLENECKS IDENTIFIED
→ DB query P99 800ms on /products?filter=... — add composite index
→ Upstream timeout at 2.2× peak — increase ALB timeout or add circuit breaker
→ Memory grows 15MB/min during soak — suspect connection leak in pool
RECOMMENDATIONS
1. Add index: CREATE INDEX ON products(category_id, created_at DESC)
2. Set keepAlive timeout > ALB idle timeout (current: 60s, ALB: 120s)
3. Limit connection pool max to CPUs × 2 (not unlimited)
SLO Thresholds Reference
| Tier |
p95 |
p99 |
Error Rate |
| Real-time (chat, trading) |
<100ms |
<250ms |
<0.01% |
| Interactive (API, web) |
<300ms |
<800ms |
<0.1% |
| Batch (reports, exports) |
<2s |
<5s |
<1% |
1---2name: load-test3description: Load testing setup, execution, and analysis with k6, Artillery, or Locust. Generates test scripts, defines VU ramp-up scenarios, interprets p99 latency and error rate results, and suggests infrastructure fixes. Use when user wants to load test an API, check throughput limits, validate SLO headroom, or diagnose performance under traffic.4---56# Load Test78Design, run, and analyze load tests. Find your system's breaking point before users do.910## Quick Start1112```13/load-test scaffold — generate k6 script from OpenAPI spec or cURL examples14/load-test run <script> — execute + stream metrics15/load-test analyze <results> — interpret results, flag SLO violations16/load-test soak 30m — run soak test (low VU, long duration)17/load-test spike — spike test (sudden burst, check recovery)18```1920## Test Scenarios2122| Scenario | Goal | Duration |23|----------|------|----------|24| **Smoke** | Verify script works at 1 VU | 1 min |25| **Load** | Simulate expected peak traffic | 30 min |26| **Stress** | Find breaking point | Ramp to failure |27| **Soak** | Detect memory leaks, slow drift | 2–8 hours |28| **Spike** | Instant 10× traffic burst | 1 min burst |29| **Breakpoint** | Binary search for max TPS | Auto |3031## Workflow3233Claude will:341. Infer endpoints from OpenAPI spec / cURL samples / route files352. Generate parameterized k6 or Artillery script363. Define realistic VU ramp (warm up → peak → cool down)374. Add SLO thresholds (p95 < 500ms, error rate < 1%)385. Run test (or provide `docker run` command)396. Parse JSON results → surface p50/p95/p99/max + error breakdown407. Recommend: cache headers, DB indexes, connection pool size, rate limits4142## k6 Script Template4344```javascript45import http from 'k6/http'46import { check, sleep } from 'k6'47import { Rate } from 'k6/metrics'4849const errorRate = new Rate('errors')5051export const options = {52 stages: [53 { duration: '2m', target: 50 }, // ramp up54 { duration: '5m', target: 50 }, // sustain peak55 { duration: '2m', target: 0 }, // ramp down56 ],57 thresholds: {58 http_req_duration: ['p(95)<500', 'p(99)<1000'],59 errors: ['rate<0.01'],60 },61}6263export default function () {64 const res = http.get('https://api.example.com/products')65 check(res, { 'status 200': (r) => r.status === 200 })66 errorRate.add(res.status !== 200)67 sleep(1)68}69```7071## Artillery Script Template7273```yaml74config:75 target: "https://api.example.com"76 phases:77 - duration: 6078 arrivalRate: 1079 name: Warm up80 - duration: 30081 arrivalRate: 5082 name: Peak load8384scenarios:85 - name: "Browse products"86 flow:87 - get:88 url: "/products"89 expect:90 - statusCode: 20091 - maxResponseTime: 50092```9394## Results Interpretation9596```97/load-test analyze results.json9899LOAD TEST RESULTS — 2026-06-14100================================101Duration: 9m | VUs peak: 50 | Total requests: 12,430102103LATENCY104 p50: 42ms ✅105 p95: 380ms ✅ (threshold: <500ms)106 p99: 1,240ms ❌ (threshold: <1000ms)107 max: 4,800ms ❌108109ERROR RATE: 2.3% ❌ (threshold: <1%)110 404 Not Found: 0.1%111 502 Bad Gateway: 1.8% ← upstream timeout112 503 Unavailable: 0.4%113114BOTTLENECKS IDENTIFIED115 → DB query P99 800ms on /products?filter=... — add composite index116 → Upstream timeout at 2.2× peak — increase ALB timeout or add circuit breaker117 → Memory grows 15MB/min during soak — suspect connection leak in pool118119RECOMMENDATIONS120 1. Add index: CREATE INDEX ON products(category_id, created_at DESC)121 2. Set keepAlive timeout > ALB idle timeout (current: 60s, ALB: 120s)122 3. Limit connection pool max to CPUs × 2 (not unlimited)123```124125## SLO Thresholds Reference126127| Tier | p95 | p99 | Error Rate |128|------|-----|-----|-----------|129| Real-time (chat, trading) | <100ms | <250ms | <0.01% |130| Interactive (API, web) | <300ms | <800ms | <0.1% |131| Batch (reports, exports) | <2s | <5s | <1% |