Load Testing and Baselines
Load Testing and Baselines
Overview
Microbenchmarks don’t replace load tests. Establish a baseline: throughput, p50/p99 latency, error rate, resource use—then change one variable.
Tools
| Tool | Role |
|---|---|
hey / vegeta / k6 |
HTTP load |
go test -bench |
Function-level |
pprof under load |
See real hotspots |
hey -z 30s -c 50 http://127.0.0.1:8080/api/booksBaseline template
Scenario: GET /api/books (cached / uncached)
Concurrency: 50
Duration: 60s
Result: QPS=… p50=… p99=… errors=…
CPU=… RSS=… (from metrics or `ps`)
Commit: abc123
SLO-oriented load
Drive load until error budget or latency SLO breaks—know the capacity ceiling.
Avoiding test lies
- Warm up before measuring
- Separate client machine when possible
- Watch coordinated omission (load tools that delay sending)
- Fix payloads and auth
Rules of thumb
| Do | Don’t |
|---|---|
| Record env + commit with results | Compare laptop vs prod blindly |
| Increase load gradually | Jump to 10k connections first |
| Pair with profiles | Optimize without a number |
Try next
- Baseline one endpoint; save numbers in a markdown table.
- Add artificial
time.Sleepand remeasure.
- Capture CPU pprof during
hey.