Module 2. Advanced testing · Lesson 13 of 41 · 13 min
Performance testing: load, percentiles, bottlenecks
Load, stress, spike and soak; why you look at p95 instead of the average; how to plan your first test.
Four questions about performance
- Can the system handle the expected load?
- Where is its limit, and what happens beyond it?
- How does it survive a sudden spike?
- Does it degrade over hours of operation?
Each question has its own load profile.
The average lies
If 95 requests take 100 ms and 5 take 3 seconds, the average is ≈ 245 ms and looks acceptable. But one user in twenty waits three seconds. That's why requirements are written in percentiles:
- p50 (median) — the typical experience;
- p95 — what an "unlucky" user sees;
- p99 — the tail, where timeouts and complaints live.
| Percentile | Value in the example | Meaning |
|---|---|---|
| p50 | ≈ 190 ms | half of the requests are faster |
| p95 | ≈ 600 ms | 5% of the requests are slower |
| p99 | ≈ 1.2 s | 1% of the requests are slower |
How to plan your first test
- Scenario — real user actions (search → product page → cart → checkout), not one endpoint.
- Profile — how many users, how fast the load ramps up, for how long.
- Data — realistic volumes: search on an empty database is always fast.
- Criteria — for example, p95 < 800 ms and errors < 1% with 500 concurrent users.
- Monitoring — CPU, memory, the database connection pool, queues. Without it you see the symptom, not the cause.
Tools
k6 and JMeter are the most popular for HTTP; Gatling and Locust are alternatives. A simple k6 scenario:
import http from "k6/http";
import { check } from "k6";
export const options = { vus: 50, duration: "5m", thresholds: { http_req_duration: ["p(95)<800"] } };
export default function () {
const res = http.get("https://staging.example.com/api/products?q=phone");
check(res, { "status 200": (r) => r.status === 200 });
}
Typical bottlenecks
N+1 database queries, missing indexes, synchronous calls to external services, large responses without pagination, memory leaks (visible only in a soak test).
Performance is part of the non-functional testing covered in the levels and types lesson.
Key takeaways
- Load, stress, spike and soak tests answer different performance questions.
- Requirements use p95/p99 — the average hides the tail of slow requests.
- Without server monitoring a test shows the symptom, not the cause.
Check yourself
1. Which test looks for memory leaks?
2. Why are requirements set at p95 rather than the average?
3. Search is fast on staging but slow in production. The most likely cause?