Short answer
Choose k6 when the team writes JavaScript, you mainly test HTTP and APIs, and tests should be code in the repository, run in CI with thresholds that stop the pipeline on their own. Choose JMeter when you need many protocols (JDBC, JMS, FTP, SOAP), prefer building tests in a graphical interface rather than in code, or already have tests in it. Both are free and both handle a typical load test of a shop or an API. A well-calculated traffic model matters more than the tool.
Comparison
| JMeter | k6 | |
|---|---|---|
| test language | XML plan built in the GUI, scripts in Groovy | JavaScript |
| engine | Java, a thread per virtual user | Go, a lightweight virtual user |
| protocols | HTTP, JDBC, JMS, FTP, SOAP, LDAP and more, plus plugins | HTTP, WebSocket, gRPC, browser, others via extensions |
| tests in the repository | possible, but the XML file is hard to review in a pull request | naturally, plain code |
| thresholds that stop the pipeline | via plugins or scripts | built in (thresholds) |
| load model | number of threads, throughput controlled with timers | ready-made modes, including a constant number of requests per second |
| reports | HTML report from the command line | summary in the console, export to Grafana and others |
| entry barrier | low for people who don’t code | low for people who know JavaScript |
The same test in both tools
k6, 50 users for 5 minutes, with thresholds:
import http from "k6/http";
import { check, sleep } from "k6";
export const options = {
vus: 50,
duration: "5m",
thresholds: {
http_req_duration: ["p(95)<800"],
http_req_failed: ["rate<0.01"],
},
};
export default function () {
const res = http.get(`${__ENV.BASE_URL}/api/products`);
check(res, { "status 200": (r) => r.status === 200 });
sleep(3);
}
Run it with k6 run -e BASE_URL=https://staging.example.com test.js. If p95 goes over 800 ms or more than 1% of requests fail, k6 exits with an error code and the pipeline stops.
In JMeter the same test is a Thread Group with 50 threads and a duration of 300 seconds, an HTTP Request to /api/products, a Response Assertion on status 200 and a Constant Timer with 3 seconds. Run it without the GUI: jmeter -n -t test.jmx -l results.jtl -e -o report/. I cover the details in a first performance test in JMeter.
When JMeter wins
- you test more than HTTP: databases, queues, FTP, legacy SOAP services;
- the tests are built by people who don’t code;
- you already have a set of JMeter plans and they work;
- you need a specific plugin from JMeter’s large ecosystem.
When k6 wins
- the team writes JavaScript or TypeScript and wants to review tests in pull requests;
- performance tests should run in CI with thresholds on every release;
- you mainly test APIs and HTTP;
- you want to easily hold a constant number of requests per second, regardless of response times.
What to watch out for in both
- the load generator must not run on the same machine as the system under test;
- the average hides problems, look at p95 and p99;
- without think time (pauses between steps) the load is inflated;
- the number of virtual users must come from a traffic model, not from the number of registered users. I explain how to calculate it in how many users to simulate in a load test.
How I can help
As part of performance testing I prepare a traffic model, 3-5 JMeter scenarios and a report with response times, error thresholds and bottlenecks. It usually costs PLN 10,000-15,000 net and takes 2-3 weeks. Before a campaign, the Black Friday performance test checklist will also help. Describe your system and expected traffic in the contact form.