Traffic spikes from launches, campaigns and seasonal peaks find your system's limits for you, usually at the worst moment. A load test finds them first, on your schedule.
Types of tests
| Test | Shape | Answers |
|---|---|---|
| Smoke | Very low load, short | Does the script and environment work? |
| Load | Expected peak, sustained | Do we meet our targets at peak? |
| Stress | Increasing until failure | Where is the breaking point, and how do we fail? |
| Spike | Sudden jump | Do we survive a burst while autoscaling catches up? |
| Soak | Normal load for hours | Leaks and slow degradation over time |
Make it realistic
- Use real journeys: browse, search, add to cart, check out, in realistic proportions taken from analytics.
- Include think time between steps, or you test an unrealistic number of requests per user.
- Use realistic data: many products and users, not one product requested a million times (which only tests the cache).
- Test from outside, through the CDN and load balancer, not just against one pod.
- Use a production-like environment, or carefully scheduled tests against production with safeguards.
A k6 example
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '5m', target: 200 }, // ramp up
{ duration: '20m', target: 200 }, // hold at expected peak
{ duration: '5m', target: 0 },
],
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<800'],
},
};
export default function () {
const res = http.get(`${__ENV.BASE}/api/products?page=${Math.ceil(Math.random() * 50)}`);
check(res, { 'status 200': (r) => r.status === 200 });
sleep(Math.random() * 3 + 1);
}
What to measure
From the load tool: request rate, error rate and latency percentiles. From your systems at the same time:
- Per-endpoint p95 and errors from traces.
- Saturation: CPU against limits, memory, database connections, pool waits, queue depth.
- Database: slow queries, locks, CPU.
- Autoscaling: replicas over time against load.
The USE method is a good checklist: for each resource, utilisation, saturation and errors.
Finding the bottleneck
When latency rises, open traces of slow requests during the test. Is the time in a database query, waiting for a connection, in an external API, or in your own code? The first resource to saturate is your bottleneck; fix it and test again, because the next bottleneck will appear.
Worked example
A shop expected 5× normal traffic for a sale. A load test at 3× showed p95 rising from 300 ms to 2.4 s. Traces showed most of the time before the first database span: requests were waiting for a database connection. The pool was 10 per pod and 12 pods were running, while the database could handle more. They raised the pool to 20 per pod (still under max_connections), fixed an N+1 query on the product page, and set the HPA target to 60%. The next test held p95 under 500 ms at 5×, and the sale passed without incident.
Safety when testing production
Coordinate with the team, avoid peak times, exclude test traffic from analytics and billing, use test accounts and test payment modes, and keep a stop switch. Watch error rates and abort if real users are affected.
Checklist
- Clear goal and pass criteria (for example p95 under 800 ms, errors under 1% at 2× peak).
- Realistic journeys, data and think time.
- Monitoring of every layer during the test.
- Traces to find the bottleneck.
- Fix, re-test, record results.
VitalRix APM and infrastructure monitoring show latency per endpoint and saturation per pod during the test, so the bottleneck is visible while the load is still running. Related: capacity planning and the launch day checklist.
Common mistakes
- Testing one URL repeatedly, which mostly tests the cache.
- Load generators that are the bottleneck: check their CPU and network, and spread load across several machines if needed.
- Ignoring warm-up: the first minutes after a deploy behave differently from steady state.
- Looking only at averages: p95 and p99, and error rates, tell the story.
- No monitoring of dependencies, so the test shows "slow" without showing why.
Reporting the result
Write down the load you tested, the pass criteria, what passed, the first bottleneck you hit, what you changed and the result of the re-test. Keep these reports; the next test can then be compared with the last one, and capacity decisions rest on data rather than memory.
How often should I load test?
Before launches and expected peaks, after major architectural changes, and periodically (for example quarterly) to catch regressions.
Can I load test production?
Yes, carefully: at quiet times, with test data and accounts, coordinated with the team, and with a stop switch.
Which load testing tool should I use?
k6, Gatling, Locust and JMeter are all capable. Choose one your team can script and run in CI.
Try VitalRix free
Uptime monitoring, APM, logs, real user monitoring and status pages in one place. No credit card needed.