The Load Testing Engineer validates that systems perform under expected and peak loads before traffic arrives. Load tests are most valuable run in production-like environments against real bottlenecks - not in staging against a single-instance setup. The goal is not to run load tests; it is to find and fix the bottleneck before users do.
Test Types
| Type | Pattern | Goal | Duration |
|---|---|---|---|
| Baseline | Realistic average load | Establish performance SLI baselines | 5–15 min |
| Load test | Expected peak traffic | Verify SLOs hold under normal peak | 30–60 min |
| Stress test | Ramp to breaking point | Find saturation point and failure mode | 30 min |
| Spike test | Sudden 10× traffic increase | Verify auto-scaling speed | 10 min |
| Soak test | Sustained moderate load | Detect memory leaks, connection leaks | 8–24 hours |
k6 Test Script
import http from 'k6/http';
import { check, sleep } from 'k6';
import { Rate, Trend } from 'k6/metrics';
const errorRate = new Rate('errors');
const checkoutDuration = new Trend('checkout_duration');
export const options = {
stages: [
{ duration: '2m', target: 50 }, // Ramp up
{ duration: '5m', target: 100 }, // Sustain peak
{ duration: '2m', target: 0 }, // Ramp down
],
thresholds: {
http_req_duration: ['p(95)<500'], // 95% of requests < 500ms
http_req_failed: ['rate<0.01'], // Error rate < 1%
errors: ['rate<0.05'], // Custom error rate < 5%
},
};
const BASE = __ENV.BASE_URL || 'https://api.example.com';
export default function () {
// Login
const loginRes = http.post(`${BASE}/auth/login`, JSON.stringify({
email: 'load-test@example.com',
password: 'password',
}), { headers: { 'Content-Type': 'application/json' } });
check(loginRes, { 'login 200': r => r.status === 200 });
const token = loginRes.json('token');
// Main flow
const start = Date.now();
const orderRes = http.post(`${BASE}/orders`, JSON.stringify({ productId: 'prod_1' }), {
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
});
checkoutDuration.add(Date.now() - start);
check(orderRes, { 'order created': r => r.status === 201 });
errorRate.add(orderRes.status !== 201);
sleep(1); // Think time between requests
}