Performance Testing
Critical rules
- Progressive profiles only: Smoke → Load → Stress → Soak → Spike. Never jump to stress first.
- Encode SLOs as k6
thresholdsthat fail the run — eyeballing is not a gate. - Every VU iteration includes
sleep()think time (prevents accidental DDoS). - Send
traceparent(+ load-test id) so slow percentiles map to OpenTelemetry spans. - Prove resilience with chaos (latency/failure injection); pair
resiliencepatterns. - Run load in CI to catch regressions. Diagnose bottlenecks via traces, not guesses.
- Before full profile scripts or chaos helpers, read the matching resource below.
Workflow
- Confirm unit/integration pass. Failing smoke with 1 VU = functional bug, not a perf problem.
- Write smoke (1 VU, ~1m, low error rate). Pass before higher load.
- Add load at expected traffic with p95/p99 and error-rate thresholds.
- Escalate: stress (find break point), soak (hours, watch memory/leak), spike (burst + recovery).
- Correlate: inject W3C
traceparentandx-load-test-id; query traces for pool exhaustion, N+1, rate limits. - Chaos: inject latency/failures (in-process helpers or Toxiproxy). Verify timeouts, retries, circuit breakers fire. Before implementing injectors, read references/chaos.md.
- CI: run load on main/nightly; upload JSON/HTML artifacts; fail on threshold breach.
Resources
- references/load-profiles.md — smoke/load/stress/soak/spike options, thresholds, k6 CLI, tracing headers. Read when authoring scripts.
- references/chaos.md — latency/failure helpers, Toxiproxy, chaos scenarios, CI sketch. Read when proving resilience under fault.
- references/rationalizations.md — excuse→reality, pitfalls, red flags. Read when tempted to skip a gate.
Validation
- [ ] Smoke passed before higher profiles
- [ ] Each profile has SLO
thresholds; VUs usesleep() - [ ] Requests carry
traceparent(+ load-test id) - [ ] Resilience patterns exercised by chaos
- [ ] Load runs in CI; bottlenecks diagnosed via traces
Constraints
- Not for unit/mutation tests (
writing-tests,mutation-testing) or React render micro-opts (react-development). - Pyramid placement of load/chaos:
testing-strategy. Patterns under test:resilience. Trace correlation:observability. Bottleneck follow-up:debugging-methodology.