Performance and load testing
Types of performance tests, the metrics that matter, how to design a realistic load test and how to read the results.
A feature that works for one user can collapse under a thousand. Performance testing answers three questions: how fast is the system now, how much load can it take, and what breaks first when it's overloaded.
Types of performance tests
| Type | Question | Example |
|---|---|---|
| Load | Does it meet targets at expected traffic? | 500 concurrent users browsing and buying for 30 minutes |
| Stress | Where is the breaking point and how does it fail? | Increase users until errors appear |
| Spike | Can it survive a sudden jump? | Traffic ×10 in one minute after a newsletter or game launch |
| Endurance (soak) | Does it degrade over time? | Steady load for 8–24 hours to find memory leaks |
| Scalability | Does adding servers help? | Repeat the load test with 2 and 4 instances |
| Front-end performance | How fast does a page feel to a user? | Core Web Vitals on a mid-range phone over 4G |
Metrics that matter
- Response time percentiles: the average hides problems; look at p95 and p99 (95% / 99% of requests were faster than this)
- Throughput: requests or transactions per second
- Error rate: share of failed requests under load
- Resource usage: CPU, memory, database connections, queue length
- Front-end metrics: Largest Contentful Paint (main content visible), Interaction to Next Paint (responsiveness), Cumulative Layout Shift (visual stability)
Designing a realistic test
- Define goals with the business: for example, “p95 under 800 ms for search and checkout at 300 concurrent users, error rate below 1%”.
- Model real behaviour: use analytics to choose scenarios and their proportions — most users browse, fewer search, even fewer pay.
- Prepare data: enough products, users and orders; avoid every virtual user hitting the same record.
- Use a production-like environment: a test on a laptop-sized server says little about production.
- Ramp up gradually and keep the peak long enough to see trends.
- Monitor the servers during the test, not just the load tool's report.
A small k6 script
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '2m', target: 100 }, // ramp up
{ duration: '10m', target: 100 }, // hold
{ duration: '1m', target: 0 }, // ramp down
],
thresholds: {
http_req_duration: ['p(95)<800'],
http_req_failed: ['rate<0.01'],
},
};
export default function () {
const res = http.get('https://staging.example.com/api/products?q=hoodie');
check(res, { 'status is 200': (r) => r.status === 200 });
sleep(Math.random() * 3 + 1); // think time
}
Reading the results
Look for the point where response times start climbing steeply or errors appear, then match it with server metrics. Typical culprits are slow database queries without indexes, too few database connections, synchronous calls to slow external services, missing caching, and memory leaks that only show up after hours.
Tools
| Tool | Strength |
|---|---|
| k6 | Scripts in JavaScript, great for CI and developers |
| Apache JMeter | Mature, GUI, many protocols |
| Gatling | High performance, readable reports |
| Locust | Scenarios in Python |
| Lighthouse / PageSpeed Insights | Front-end performance and Core Web Vitals |


