Load Testing
In one line
Load testing simulates real user traffic to check if the system handles expected load — response times, throughput, error rates.
In simple words
Load testing answers: "Can our system handle the traffic we expect?" It simulates realistic user load and measures performance metrics.
What load testing measures:
- Response time — how fast the system responds under load
- Throughput — requests per second the system can handle
- Error rate — percentage of failed requests under load
- Resource usage — CPU, memory, database connections, etc.
Types of load tests:
- Baseline — normal expected traffic
- Peak — highest expected traffic (Black Friday, product launch)
- Volume — large amounts of data, not necessarily high concurrency
- Endurance — sustained load over a long period (see Soak Testing)
Process:
- Define test scenarios (user journeys, not just API calls)
- Gradually increase load to target level
- Monitor system metrics during the test
- Identify bottlenecks (database, CPU, memory, network)
- Optimize and re-test
Tools: k6, JMeter, Locust, Artillery, Gatling.
Example
// k6 load test script
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '2m', target: 100 }, // ramp up to 100 users
{ duration: '5m', target: 100 }, // stay at 100 users
{ duration: '2m', target: 200 }, // ramp up to 200 users
{ duration: '5m', target: 200 }, // stay at 200 users
{ duration: '2m', target: 0 }, // ramp down to 0
],
thresholds: {
http_req_duration: ['p(95)<500'], // 95% of requests < 500ms
http_req_failed: ['rate<0.01'], // < 1% errors
},
};
export default function () {
const res = http.get('https://api.example.com/products');
check(res, {
'status is 200': (r) => r.status === 200,
'has products': (r) => r.json().length > 0,
});
sleep(1); // think time between requests
}k6 gradually ramps up users, sends requests, and checks thresholds. If 95th percentile response time exceeds 500ms or error rate exceeds 1%, the test fails.
Common confusions
Confused with: stress testing
The difference: Load testing simulates expected traffic to verify the system handles it — it tests normal/peak conditions. Stress testing pushes beyond expected limits to find the breaking point — it tests failure conditions. Load testing asks 'can we handle our traffic?'; stress testing asks '@when do we break?'
Related terms
Related Resources
Related Lessons
- Performance Testing
Load testing.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.