What a load test is and how it works
Load testing is a kind of performance testing: the system receives a stream of requests from virtual users, and you check how well it copes with a given load — response time, throughput, error rate and resource usage.
You test the behaviour of the system, not the code: does it hold up under the expected flow of visitors, and does it degrade at peak? In ISTQB CT-PT, load testing is one of the performance test types: the system receives increasing levels of realistic load from a specified number of concurrent users or processes. It differs from a stress test, which looks for the limit and for behaviour beyond what the system can handle (see the section “Load test types”).
How a test is built
A test has three parts. The load generator starts virtual users (VUs): each one runs a scenario in a loop, sending requests and waiting. They put pressure on the system under test: the load balancer, the application and the database. Metrics come from two sides: client-side metrics, response time and error rate, which the generator knows, and server-side metrics, CPU, memory and database queries, from system monitoring. The analysis puts the two sides together: a rise in latency coincides with CPU or database saturation.
According to ISTQB, a load generator is a separate group of tools: the load has to be modelled and applied to the system, which takes dedicated tools and often a separate machine. The tool also collects measurements as it goes: for protocol-level scenarios these cover server and network time, so server monitoring is set up separately. Keep an eye on the generator itself too: if it runs short of CPU, response times are overstated (see the section “Checklist”).
The steps of a test
A load test is a series of steps, not a single run. First come the goals: what you are testing and against which threshold, for example 95% of requests faster than 300 ms and fewer than 1% errors. Then the load model: how many virtual users and at what request rate, open or closed model (see the section “Load models”). Then the scenarios: which actions a user repeats. Next, the environment and data: a test environment close to production, with prepared data. The last three steps are the run, the analysis of results and the report (see the section “Analysing results and reporting”).
- Goals and thresholds: the expected load and a pass/fail criterion
- Load model: open or closed, and the profile over time
- Scenarios: realistic user and data flows
- Environment: a test environment and monitoring close to production
- Run: a smoke test first, then the main run
- Analysis and report: comparison with the baseline and the thresholds
The first run is a smoke test: minimal load, to check that the scenario works and returns what is expected. After that comes the main run against the thresholds, followed by a comparison with the baseline run: without a baseline you cannot tell whether you improved the system or broke it.
import http from 'k6/http';import { check } from 'k6'; export const options = { vus: 20, duration: '1m', thresholds: { http_req_failed: ['rate<0.01'], http_req_duration: ['p(95)<300'], },}; export default function () { const res = http.get('https://example.com/api/items'); check(res, { 'status 200': (r) => r.status === 200 });}The thresholds are written right in the test: http_req_failed keeps the error rate below 1%, and p(95) requires 95% of requests to be faster than 300 ms. k6 checks the metrics against the thresholds itself and shows at the end of the run whether the test passed.
How k6 differs from JMeter
The tool is a load generator, and for most tasks either will do. k6 is a command-line tool: the scenario is written in JavaScript, and the load is described with options and executors. JMeter is a Java application: a test is assembled from elements in a graphical interface and stored in a .jmx plan file. Everything else follows from that.
| Feature | k6 | Apache JMeter |
|---|---|---|
| Scenario | JavaScript code, stored in git and code-reviewed | a .jmx plan, built in the graphical interface |
| Protocols | HTTP, WebSocket, gRPC; more through extensions | HTTP, JDBC, FTP, LDAP, JMS; more through plugins |
| Running in CI | a single k6 run command, thresholds in the exit code | non-GUI mode, HTML report |
| Generator resources | low: one process handles thousands of VUs | higher: one thread per virtual user |
| Results | a summary at the end, streams to JSON, CSV or platforms | a CSV or XML file, an HTML report after the run |
| Checks and thresholds | checks and thresholds in the script itself | assertions and listeners in the plan elements |
Choose k6 when tests live alongside the code: scenarios in git, thresholds in CI, an automatic run before each release. Choose JMeter when the protocols are not HTTP, such as a database, LDAP or JMS, or when the team is used to building tests in a graphical interface. For protocol-level scenarios in both tools, response-time metrics cover only the server and the network: what happens inside the browser is not visible (see the sections “k6: scripts and running”, “Apache JMeter”).
What you need to know first
A load test sends real HTTP requests, so you need a reference on HTTP and REST: methods and response codes, headers, cookies. Basic JavaScript is enough, at the level of functions and imports: a k6 scenario is ordinary code. Latency metrics and percentiles are covered in the section “Metrics: latency, percentiles, RPS”.
Section sources
the section is written from these pages- ISTQB Certified Tester Performance Testing Syllabus v1.0istqb.org/wp-content/uploads/2024/11/ISTQB-CT-PT_Syllabus_v1.0_2018.pdf(opens in a new tab)
- ISTQB Certified Tester Performance Testing Syllabus v1.0istqb.org/wp-content/uploads/2024/11/ISTQB-CT-PT_Syllabus_v1.0_2018.pdf(opens in a new tab)
- API load testinggrafana.com/docs/k6/v2.3.x/testing-guides/api-load-testing/(opens in a new tab)
- Apache JMeterjmeter.apache.org/index.html(opens in a new tab)
- Apache JMeter — Getting startedjmeter.apache.org/usermanual/get-started.html(opens in a new tab)