12. Performance: Performance QA¶
Most load-testing tools give you numbers. A release needs an answer: did this change make the API slower, or break it under load? k11 Performance QA gives evidence: per-endpoint latency against your SLOs, and regressions against a baseline that are statistically significant. A noisy run doesn't block a release, and a real slowdown doesn't slip through.
Your API tests are the load scenarios¶
Scenarios reuse the flows you already wrote for API Functional QA (tests/api/*.yaml): chained calls, saved IDs, fixtures and auth.
There's no second set of load scripts to maintain.
Each virtual user runs a flow's fixtures once, then repeats: pick a flow by weight, run its HTTP steps in order, run its cleanup, think, repeat. Database checks are skipped under load: they check correctness, not speed, and still run in your functional tests.
Configure: .qa-mcp/perf.yaml¶
environment: staging
engine: auto # k6 if installed, else builtin
profile: { vus: 10, duration: 2m, ramp_up: 20s, think_time_ms: 200 }
scenarios:
browse:
flows:
- { flow: tests/api/view_order.yaml, weight: 3 } # 3x more often
- tests/api/cancel_order.yaml
slos:
"GET /orders/{id}": { p95_ms: 250, error_rate: 0.01 }
"POST /orders": { p95_ms: 600, error_rate: 0.01 }
regression: { metric: p95, tolerance_pct: 10, min_delta_ms: 10, min_samples: 30, p_value: 0.01 }
guardrails: { max_vus: 50, max_duration: 10m, max_rps: 200, abort_error_rate: 0.5 }
plan: # where the numbers come from (read by review_perf_plan, not by the run)
peak: "180 concurrent users at the 2025 sale peak, from production analytics"
duration: "15 min at peak after a 2 min ramp"
test_data: "20k orders, 500 distinct customers from fixtures/customers.csv"
environment_size: "staging: 2 app nodes, db.r6.large; production: 8 nodes, db.r6.2xlarge"
SLOs apply per endpoint or pattern: p95_ms, p99_ms, error_rate, min_rps and others.
The plan: section, and asking first¶
A load test is only as meaningful as its numbers. Why 10 users? Is staging anything like production? review_perf_plan asks before
the first run of a new or changed plan (Chapter 4): missing SLOs, an endpoint no SLO covers, the default profile with no plan.peak
explaining it, default duration, no test-data volume (caches flatter small data), no comparison of the environment with production.
The plan: section records the answers. The run ignores it; people and the review read it. init writes a starter with empty slos
and plan marked # OPEN QUESTION:: an SLO is never invented. An SLO nobody agreed to makes a release look checked when it wasn't.
How a regression is decided¶
For each endpoint, the run is compared with the saved baseline on the configured metric (p95 by default). It is a regression only when all of these hold:
- it's slower by more than
tolerance_pct(default 10%); - it's slower by more than
min_delta_ms(default 10 ms), so 2 ms → 3 ms isn't "50% slower"; - both runs have at least
min_samplesrequests for that endpoint; - a one-sided Mann-Whitney U test says the new latencies are higher with p <
p_value(default 0.01).
A rise in the error rate of more than one percentage point is reported separately. Improvements are reported too.
Baselines¶
k11-performance-qa-mcp baseline # on main: run and save the baseline
k11-performance-qa-mcp baseline --from-last-run
k11-performance-qa-mcp run # on a branch: run, compare, report
Baselines are saved in .qa-mcp/perf-baseline/<scenario>-<environment>.json. Record them from main and commit them, so pull
requests compare against what's actually released. The repository's docs/perf-tests.yml workflow saves the baseline on main and
compares every pull request with it.
Engines and JMeter¶
- Grafana k6, when installed, for heavy load.
- Builtin (Python, nothing to install) for quick checks and CI.
Already on JMeter? Keep your test plans and import the results file. You get the same SLOs, regressions and gate evidence:
jmeter -n -t checkout.jmx -l results.jtl
k11-performance-qa-mcp import results.jtl --env staging --save-baseline # on main
k11-performance-qa-mcp import results.jtl --env staging # on a branch
Name samplers like GET /orders/{id} so they match your SLO patterns.
Command line¶
k11-performance-qa-mcp run [--scenario S] [--env E] [--vus N] [--duration 2m] [--ramp-up 20s] [--max-rps N]
[--engine auto|k6|builtin] [--no-compare] [--report-dir P] [--fail-on any|slo|regression|never]
k11-performance-qa-mcp baseline [same options] | baseline --from-last-run
k11-performance-qa-mcp import FILE.jtl [--scenario S] [--env E] [--save-baseline] [--no-compare] [--fail-on ...]
k11-performance-qa-mcp init
The commands in Claude Code: /perf-check (starts with the review) and /perf-baseline.
Safety¶
- No production load: environments named like production are refused unless they set both
allow_load: trueandproduction_load_acknowledged: true. Other environments need a local host, a test-like name, orallow_load: true. - Data-changing flows run only where writes are allowed.
- Caps on virtual users, duration and request rate, and an automatic stop when too many requests fail.
Evidence for the gate¶
perf-report.json is the perf kind.
| Finding | Rule | Outcome |
|---|---|---|
| 5xx responses under load | perf.server_errors |
block |
| An SLO missed | perf.slo_breached |
block |
| Run aborted (too many failures) | perf.aborted |
block |
| Significant regression | perf.regression |
needs a person |
| Refused by guardrails, or didn't start | perf.not_run |
needs a person |
| No baseline, or too few samples | perf.no_baseline, perf.insufficient_samples |
note |
Changes to migrations, SQL, repositories, caches, database code and performance configuration require performance evidence.