Load Testing Basics: Finding Your Limits
A load test finds the point where a system degrades. Learn the metrics, the test types, and how to run one without breaking production.
By Velloreth
What a load test finds
A load test finds the point where the system degrades.
The number that matters is not the maximum throughput; it is the load at which the latency becomes unacceptable.
A system that handles 1000 requests a second at 50ms and 2000 at 5 seconds has a limit near 1000, not 2000.
The metrics
Latency — how long one request takes. Report the percentiles, not the average.
Throughput — how many requests per second.
Error rate — the percentage of failed requests.
Saturation — how close a resource is to its limit: CPU, memory, connections, disk.
The percentiles matter. An average of 100ms can hide a p99 of 5 seconds, and the slow requests are the ones a user notices.
| Metric | Meaning |
|---|---|
| p50 | The median |
| p95 | 95% of requests are faster |
| p99 | 99% of requests are faster |
Report p95 and p99. A p99 of 5 seconds means one request in a hundred is slow, which on a busy site is a lot of users.
The test types
A smoke test — a small load, to confirm the script works.
A load test — the expected peak load, to confirm the system handles it.
A stress test — increase the load until it fails, to find the breaking point.
A soak test — a moderate load for hours, to find a leak.
A spike test — a sudden increase, to see how the system recovers.
Each answers a different question. A load test answers “does it handle the peak”; a stress test answers “where does it break”.
The environment
Test against a production-like environment.
A small environment gives a misleading number: a system that handles 100 requests a second on a small instance may handle 10,000 on the production hardware, or the reverse if the bottleneck is a shared database.
The data volume matters. A query that is fast on a thousand rows may be slow on a million. Seed a realistic volume.
The network matters. A test from the same machine as the server does not measure the network latency.
The honest caveat: a test environment is never identical. Report the environment with the number, so the result is not over-interpreted.
Writing a test
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '1m', target: 50 }, // ramp up
{ duration: '3m', target: 50 }, // steady
{ duration: '1m', target: 0 }, // ramp down
],
thresholds: {
http_req_duration: ['p(95)<500'],
http_req_failed: ['rate<0.01'],
},
};
export default function () {
const res = http.get('https://example.com/api/products');
check(res, { 'status is 200': (r) => r.status === 200 });
sleep(1);
}
The ramp-up matters. Starting at the target load measures a cold start, which is not the steady state.
The thresholds make the test pass or fail, which is what makes it useful in CI.
A realistic scenario includes a think time, so the load resembles a real user rather than a tight loop.
Reading the result
Find the knee. The point where the latency starts to rise sharply as the load increases. That is the practical limit.
Check the error rate. A rising error rate means the system is shedding load, which is a failure even if the latency looks acceptable.
Check the saturation. A CPU at 100% is the bottleneck; a CPU at 30% with a high latency means the bottleneck is elsewhere, such as a database or a lock.
Correlate with the server metrics. A load test without the server metrics shows the symptom, not the cause.
Common mistakes
Testing against production without a plan. A load test can take the site down for real users.
A test that is too short. A leak appears over hours, not minutes.
A test with no think time. A tight loop is not a realistic user.
Reporting only the average. The average hides the slow requests.
A small test environment. The number is misleading.
No server metrics. The symptom is visible, the cause is not.
A test that is not repeatable. A result that cannot be reproduced is not a result.
Load testing in CI
A small load test in CI catches a performance regression before it reaches production.
Set a threshold, so the test fails when the p95 exceeds a budget.
Keep it short, so the pipeline is not slowed.
Run the full test before a release, not on every commit.
Load testing as a practice
A load test is most useful as a regular practice rather than a one-off exercise before a launch. A baseline measured once becomes stale as the application changes, and a regression that halves the throughput is invisible without a comparison. The practice that works is to run a small load test in the pipeline on every release, with a threshold that fails the build when the latency exceeds a budget, and to run a full test with a soak phase before a major change. The second practice is to record the environment with the number, because a result without the hardware, the data volume, and the network conditions is not comparable to anything. The third is to correlate the load test with the server metrics, because the test shows the symptom and the metrics show the cause, and a number without a cause is not actionable.
Practical guidance
- Find the knee, not the maximum.
- Report p95 and p99, not the average.
- Use a production-like environment.
- Seed a realistic data volume.
- Ramp up rather than starting at the target.
- Include a think time.
- Collect the server metrics alongside.
- Run a soak test for a leak.
- Never test production without a plan.
For the related guides, see caching-strategies-explained and database-indexing-explained. For the broader context, http-caching-headers and how-cdns-actually-work.
Quotable summary
A load test finds the point where the system degrades, and the number that matters is not the maximum throughput but the load at which the latency becomes unacceptable. Latency and throughput are different metrics, and a system can have a low latency at a low throughput and a high latency at a high one, so report p95 and p99 rather than an average that hides the slow requests. A stress test finds the breaking point and a soak test finds a leak that appears over hours, and each answers a different question. Test against a production-like environment with a realistic data volume, because a small environment gives a misleading number, and never run a load test against production without a plan to stop it.