Load test simulates expected user traffic to measure the performance of a system under normal conditions. It ensures that the system can handle concurrent users and transactions within acceptable performance thresholds.
Reliability and performance tests
Load test
1 min
Intro
Easy explanation
Checking if a bridge can safely carry the daily traffic of cars over time.
Scheme
Info
To better understand the terms in testing and tool k6 see vocabulary.
Key characteristics
- Focused on expected load: Simulates real-life usage scenarios with many users.
- Sustained execution: Runs over a longer period to gather performance metrics.
- Concurrent users: Measures how the system handles simultaneous user sessions.
- Performance benchmarks: Helps define acceptable response times, throughput, and error rates.
- Detects bottlenecks: Reveals performance limitations under typical usage.
Practical examples
- Can 1000 users browse the shop at the same time?
- How fast does the API respond when 500 concurrent users call it?
Users and time
Number of virtual users:
Depends on the expected traffic. Example: simulate 100–1000 concurrent users.
Execution time:
Usually between 10-60 minutes (or longer), long enough to measure system behavior under sustained load.
Examples with tool k6
Simple example
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
// approx. 10% of duration, ramp-up to 100 users
{ duration: '3m', target: 100 },
// hold 100 users for 30m
{ duration: '30m', target: 100 },
// approx. 10% of duration, ramp-down to 0 users
{ duration: '3m', target: 0 },
],
thresholds: {
http_req_failed: ['rate<0.01'], // <1% errors
http_req_duration: ['p(95)<1000'], // 95% of requests < 1s
},
};
export default function () {
const response = http.get('https://api.example.com/products');
check(response, {
'status is 200': (res) => res.status === 200,
});
sleep(1);
}
Runnable example
Playground
Dive deeper with a live test demonstration.