k6 vs Gatling is a choice between two code-first load testing tools that work alike and differ in language and runtime. k6 runs JavaScript or TypeScript scripts in one Go binary. Gatling runs simulations written in Java, Kotlin, Scala, JavaScript or TypeScript, on the Java virtual machine, built with Maven, Gradle, sbt or npm. Both model open and closed workloads, and both can fail a CI build.
To compare them on more than feature lists, we ran the same tests in k6 v2.4.0 and Gatling 3.16.1 against one local API. On everyday tests they agreed to within 2 ms. The differences were in start-up cost, in how each tool reports fast responses, and in what happened when the server slowed down mid-test.
Key Takeaways
- Pick by language and build tooling. JVM teams get Gatling inside their existing Maven or Gradle build; teams that want a single binary and no build tool get k6; JavaScript teams can use either, since Gatling also has a JavaScript SDK.
- On the same 200-user and 2,000-user tests, k6 and Gatling reported the same throughput and 95th percentiles within 2 ms of each other.
- Gatling reports whole milliseconds, so sub-millisecond responses show as 0 ms. k6 reports microseconds.
- Both have open workload models. In a 20-second server slowdown, Gatling kept 100 arrivals a second; k6 averaged 92 and dropped 153 iterations while it started new virtual users.
- Neither fails CI on errors by default: both exited with code 0 at a 5% error rate until we added a threshold (k6, exit 99) or an assertion (Gatling, exit 1). LoadFocus runs k6 scripts in the cloud, not Gatling simulations.
k6 vs Gatling at a glance
| k6 v2.4.0 | Gatling 3.16.1 | |
|---|---|---|
| Licence | AGPL-3.0, free | Apache 2.0 Community Edition (gRPC, GraphQL, JDBC, MQTT and Kafka under an Enterprise Component License); paid Enterprise plans |
| Tests written in | JavaScript or TypeScript | Java, Kotlin, Scala, JavaScript or TypeScript |
| Runtime | One Go binary | Java virtual machine (64-bit OpenJDK LTS 11 to 25); JavaScript SDK via npm and Node.js 24 or later |
| Built-in protocols | HTTP/1.1, HTTP/2, WebSocket, gRPC, real browser | HTTP, WebSocket, server-sent events, JMS; gRPC, GraphQL, JDBC, MQTT and Kafka limited to 5 users and 5 minutes in the free edition |
| Load models | Closed (VUs) and open (arrival-rate) executors | injectClosed and injectOpen profiles |
| Pass or fail in CI | Thresholds, exit code 99 on failure | Assertions, exit code 1 on failure |
| Report | Terminal summary; HTML web dashboard on request | HTML report after every run |
| Distributed load | k6 Operator on Kubernetes, or Grafana Cloud k6 (free tier, then usage-based) | Gatling Enterprise (paid); Community Edition runs locally |
Versions, licences and limits are from each project’s release pages and documentation as of November 2026.
What is the main difference between k6 and Gatling?
The runtime around the script. k6 is one executable: download it, write a .js or .ts file, run k6 run. Gatling is a library on the Java virtual machine: a simulation is a class in a Maven, Gradle or sbt project (or an npm project for the JavaScript SDK), compiled and run through the build tool’s plugin. Both are code-first; neither has a GUI test editor.
That makes Gatling the natural fit for teams whose services are already Java or Kotlin: the load test lives in the same build, uses the same IDE and can share code with the application’s own tests. k6 suits teams that do not want a JVM or a build tool in their test pipeline. The scripting models are closer than the runtimes: both describe a user’s journey as a sequence of requests with checks and pauses.
How do the scripts compare?
Both scripts describe the same journey as a sequence of requests with checks and pauses; Gatling builds it once as an immutable chain, while k6 runs ordinary JavaScript on every iteration. Our test logs in once per user, keeps the token, then loops three requests (the product list, one product that takes 25 ms on the server, and an add-to-cart call that sends the token) with one second of think time. In Gatling’s Java DSL:
public class ShopSimulation extends Simulation {
ScenarioBuilder shop = scenario("shop")
.exec(session -> session.set("uid", session.userId()))
.exec(http("login").post("/api/login")
.body(StringBody("{\"user\":\"u#{uid}\",\"password\":\"secret\"}"))
.check(status().is(200), jsonPath("$.token").saveAs("token")))
.forever().on(
exec(http("list").get("/api/items").check(status().is(200)))
.exec(session -> session.set("id", ThreadLocalRandom.current().nextInt(1, 51)))
.exec(http("item").get("/api/items/#{id}"))
.exec(http("cart").post("/api/cart")
.header("Authorization", "Bearer #{token}")
.body(StringBody("{\"id\":#{id}}"))
.check(status().is(201)))
.pause(Duration.ofSeconds(1)));
{
setUp(shop.injectClosed(rampConcurrentUsers(0).to(200).during(10),
constantConcurrentUsers(200).during(50)))
.protocols(http.baseUrl("http://127.0.0.1:8099").contentTypeHeader("application/json"))
.maxDuration(Duration.ofSeconds(60))
.assertions(global().failedRequests().percent().lt(1.0),
global().responseTime().percentile(95.0).lt(500));
}
}
The k6 version is plain JavaScript: a default function that runs per iteration, with the login guarded by a variable at module scope, which each virtual user gets its own copy of:
import http from 'k6/http';
import { check, sleep } from 'k6';
const BASE = 'http://127.0.0.1:8099';
let token;
export const options = {
stages: [{ duration: '10s', target: 200 }, { duration: '50s', target: 200 }],
thresholds: { http_req_failed: ['rate<0.01'], http_req_duration: ['p(95)<500'] },
};
export default function () {
if (!token) {
const res = http.post(`${BASE}/api/login`, JSON.stringify({ user: `u${__VU}`, password: 'secret' }),
{ headers: { 'Content-Type': 'application/json' } });
token = res.json('token');
}
check(http.get(`${BASE}/api/items`), { 'list 200': (r) => r.status === 200 });
const id = Math.floor(Math.random() * 50) + 1;
http.get(`${BASE}/api/items/${id}`);
http.post(`${BASE}/api/cart`, JSON.stringify({ id }), {
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
});
sleep(1);
}
The structures map one to one: stages to injection steps, thresholds to assertions, check() to .check(). The style differs. Gatling builds the scenario once as an immutable chain and keeps per-user data in a session (#{token}); k6 runs ordinary imperative code per iteration. Gatling’s checks also do the extraction (saveAs), where in k6 you read the response body yourself. Our Gatling tutorial walks through a full simulation, and the k6 checks guide covers k6’s side.
Do k6 and Gatling report the same results?
Yes, apart from rounding. Both time a request from sending it to receiving the response, and both use non-blocking networking, so neither adds much of its own time. On the shopping test above, at 200 and at 2,000 users, throughput matched within 2% and 95th percentiles within 2 ms:
| k6, 200 users | Gatling, 200 users | k6, 2,000 users | Gatling, 2,000 users | |
|---|---|---|---|---|
| Requests | 32,522 | 32,501 | 326,036 | 326,307 |
| Requests per second | 533 | 542 | 5,344 | 5,438 |
| Median | 0.86 ms | 0 ms | 1.03 ms | 0 ms |
| 95th percentile | 28.05 ms | 27 ms | 27.91 ms | 26 ms |
| Errors | 0 | 0 | 0 | 0 |
Gatling’s median of 0 ms is not an error. Gatling records response times in whole milliseconds, and two of the three requests in this test answer in under one, so its median rounds down to zero. k6 keeps microseconds. Against an endpoint that waits a random 100 to 400 ms (true 95th percentile 385 ms, 99th 397 ms), the two agreed almost exactly: k6 reported 384.9 and 397.48 ms, Gatling 384 and 397 ms. The rounding only matters when you compare fast endpoints, or set limits below a few milliseconds.
Which uses fewer resources, k6 or Gatling?
Gatling used less CPU per request once the test was big enough to hide the JVM’s start-up; k6 finished small tests about 4 seconds sooner and needed no build step. Run through Maven, a Gatling test is two Java processes: Maven itself and the forked JVM that runs the simulation.
| k6 v2.4.0 | Gatling 3.16.1 (via Maven) | |
|---|---|---|
| A 1-second test, start to finish | 1.4 s | 5.2 s |
| 2,000 users, 60 s: CPU time per 1,000 requests | 0.108 s | 0.083 s |
| 2,000 users: peak memory | 684 MB | 521 MB (Maven 192 MB, Gatling 329 MB) |
| 2,000 users: peak threads | 47 | 101 (Maven 37, Gatling 64) |
| 50 users, no think time, 30 s: requests per second | 101,345 | 124,826 |
A 1-second test took 5.2 seconds from start to finish through Maven, with the simulation already compiled, so about 4 seconds went on starting two JVMs; k6 needed about 0.4 seconds of its own. A first run also compiles. In a pipeline that runs a short smoke test on every commit, that adds up. On large tests it disappears: at 2,000 users Gatling used about 23% less CPU per request than k6, and in an all-out run with no think time it pushed 23% more requests a second on a similar number of cores. Each k6 virtual user carries its own JavaScript runtime, which is why k6’s memory grows with users (684 MB at 2,000) while Gatling’s stayed near its JVM baseline. Both ran 2,000 users on a laptop without errors, so at this size either tool is fine.
How do k6 and Gatling model load when the server slows down?
Both tools offer open and closed models, but they size the open model differently. k6’s arrival-rate executors start iterations at a set rate from a pool of virtual users you size with preAllocatedVUs and maxVUs; when the pool runs dry, k6 skips iterations and counts them in dropped_iterations. Gatling’s injectOpen creates a new virtual user for every arrival, with no pool to run out of.
We aimed both at 100 requests a second, made the server’s response time jump from 25 ms to 2 seconds for 20 seconds, and counted arrivals on the server:
| Target 100 requests a second | Before | During the slowdown | After | Total |
|---|---|---|---|---|
Gatling constantUsersPerSec(100) | 100/s | 100/s | 100/s | 6,000 |
k6 constant-arrival-rate, maxVUs: 1000 | 100/s | 92/s (153 dropped) | 100/s | 5,847 |
k6 constant-arrival-rate, maxVUs: 100 | 100/s | 50/s (1,010 dropped) | 100/s | 4,991 |
Gatling’s arrivals never moved. k6 with room for 1,000 virtual users still fell to 50 to 75 arrivals a second for the first few seconds of the slowdown, while it initialised new VUs (it peaked at 201), then caught up. With the pool capped at 100, k6 printed “Insufficient VUs, reached 100 active VUs and cannot initialize more” and sent half the load for 20 seconds. k6 is explicit about the shortfall, and pre-allocating enough VUs fixes it. Gatling’s model avoids it by letting the number of active users grow for as long as responses stay slow. Our k6 scenarios guide has the executor options.
The slowdown also shows why the model matters for the numbers. Gatling, which kept sending, reported a mean response time of 685 ms for the run. k6 with its pool capped at 100, which behaved like a closed model once the pool ran out, sent about 1,000 fewer requests and reported a mean of 422 ms. The server was equally slow in both runs; the run that sent less traffic during the slow window measured fewer slow responses.
How do k6 and Gatling fit in a CI/CD pipeline?
The same way: neither fails a run on errors unless you say what failure is. k6 checks thresholds at the end of the test and exits with code 99 when one fails. Gatling checks assertions and exits with code 1, which fails the Maven or Gradle build. Without either, both exit with code 0 however many requests failed.
We sent 20 users at an endpoint that returns a 500 error for 5% of requests:
| 5% of requests fail | Exit code |
|---|---|
| k6, no thresholds | 0 (5.08% failed) |
k6, threshold http_req_failed: ['rate<0.01'] | 99 |
| Gatling, no assertions | 0 (4.97% failed) |
Gatling, assertion failedRequests().percent().lt(1.0) | 1 |
Maven reported “Failed to execute goal … Gatling simulation assertions failed !” and exited with code 1. Two details differ. Unless you add your own status check, Gatling fails any response that is not a 2xx status or 304; k6’s http_req_failed treats any status from 200 to 399 as expected. And Gatling writes its HTML report after every run, while k6 writes an HTML file only when you set K6_WEB_DASHBOARD=true and K6_WEB_DASHBOARD_EXPORT, or write a handleSummary function; our k6 reports guide compares the options.
Which supports more protocols?
Gatling, by count; k6, for free use at scale. Gatling covers HTTP, WebSocket, server-sent events and JMS, plus gRPC, GraphQL, JDBC, MQTT and Kafka. k6 covers HTTP/1.1 and HTTP/2, WebSocket and gRPC, and its browser module drives a real Chromium browser for front-end tests. More protocols come to k6 through extensions.
The catch is in Gatling’s licence. Its gRPC component is distributed under the Gatling Enterprise Component License, and its documentation says that with the free Community Edition usage is limited to 5 users and 5-minute tests. The GraphQL, JDBC, MQTT and Kafka components carry the same licence and the same limits. k6’s gRPC support has no such limit. And Gatling does not drive real browsers: its Playwright integration records a browser journey and replays it as HTTP traffic.
How do you scale k6 and Gatling beyond one machine?
With money or with Kubernetes. Gatling’s pricing page describes the Community Edition as “for local use only”. Gatling Enterprise plans start at €89 a month billed annually (Basic, one load generator), and distributed testing is listed from the Team plan, €356 a month billed annually (gatling.io/pricing, 17 November 2026). k6 also runs on one machine, but the free k6 Operator spreads one test over many pods in a Kubernetes cluster.
Grafana Cloud k6 is the hosted route on the k6 side, with a free tier of 500 virtual user hours a month and usage-based pricing beyond it. Our k6 Operator guide shows what changes when one test is split across runners, including thresholds that are checked per runner. On the Gatling side, you can run the same simulation on several machines by hand and combine the results yourself, with no coordinator in the free edition.
When to choose k6 and when to choose Gatling
Choose by your team’s language and build tooling. On the same HTTP tests, both produced matching numbers and handled 2,000 users on one laptop, so the k6 vs Gatling decision rests on the runtime you want in your pipeline, the protocols you test and how you plan to scale past one machine.
Choose k6 when:
- the team wants to write JavaScript or TypeScript without a build tool, or does not want a JVM in the test pipeline;
- short tests run often, so starting in under a second beats 4 seconds of JVM start-up;
- you need gRPC at scale or real-browser tests without a paid plan;
- you want free distributed runs on your own Kubernetes cluster.
Choose Gatling when:
- the services are Java, Kotlin or Scala, and the tests should live in the same build;
- you want an open workload model that never runs out of virtual users;
- you want a complete HTML report after every run without extra flags;
- one machine must get more load per CPU core than k6 gave in these tests.
For Python teams, k6 vs Locust repeats these tests against Locust, and for YAML scenarios on Node.js, k6 vs Artillery does the same with Artillery. JMeter vs Gatling compares Gatling with JMeter on similar tests, and our k6 vs JMeter vs Gatling vs Locust comparison puts four tools side by side.
Running k6 tests in the cloud with LoadFocus
When one machine is not enough and Kubernetes is more than the team wants to run, a managed service takes over the load generators. LoadFocus runs uploaded k6 scripts on its own cloud infrastructure from 25 regions, with up to 20,000 concurrent virtual users depending on the plan, and a percentage of the load per region if you want it. It runs k6 and JMeter scripts but not Gatling simulations.
The Gatling alternative page sets out when staying on Gatling is the better answer. For k6, see k6 load testing in the cloud.
Frequently Asked Questions
Is k6 better than Gatling?
Neither is better overall. k6 is better for JavaScript teams that want a single binary, for short and frequent CI tests, and for gRPC or browser testing without a paid plan. Gatling is better for JVM teams, for open-model tests that must never run out of virtual users, and for more load per CPU core. Run side by side on the same HTTP tests at 200 and 2,000 users in November 2026, both reported matching throughput and response times.
Is Gatling faster than k6?
Yes, on large tests. In LoadFocus tests in November 2026 on one Apple M1 Max laptop, Gatling used about 23% less CPU per request than k6 at 2,000 users, and with 50 users and no think time it sent 124,826 requests a second against k6’s 101,345. On small tests k6 finishes sooner: run through Maven, Gatling spent about 4 seconds starting two Java processes before a 1-second test.
Can Gatling run k6 scripts?
No. Gatling runs its own simulations, and although it has a JavaScript SDK, a k6 script uses k6’s APIs and must be rewritten as a Gatling simulation. The request flow, think times and pass or fail limits carry over as a design; the code does not. k6 cannot run Gatling simulations either.
Does Gatling support JavaScript?
Yes. Besides Java, Kotlin and Scala, Gatling has a JavaScript and TypeScript SDK, installed with npm and run with Gatling’s own command-line tool, which needs Node.js 24 or later. Gatling JavaScript simulations use Gatling’s API, not k6’s, so they cannot run in k6, and k6 scripts cannot run in Gatling.
Is Gatling free?
The Gatling Community Edition is free and open source under the Apache 2.0 licence, for local use. Unlimited use of the gRPC, GraphQL, JDBC, MQTT and Kafka components is part of the paid Gatling Enterprise plans, and distributed testing is listed from the Team plan up. k6 is free under the AGPL-3.0 licence, including the k6 Operator for distributed runs on Kubernetes.
Sources
- k6 v2.4.0 release notes and licence: github.com/grafana/k6, release v2.4.0 (12 November 2026) and repository licence, November 2026.
- k6 executors, arrival-rate options and
dropped_iterations: grafana.com/docs/k6, “Executors” and “Constant arrival rate”, November 2026. k6 browser module and protocols: grafana.com/docs/k6, November 2026. - Grafana Cloud k6 free tier (500 virtual user hours a month) and usage-based Pro pricing: grafana.com/pricing, read 17 November 2026.
- Gatling 3.16.1 and gatling-maven-plugin 4.22.3: github.com/gatling/gatling release v3.16.1 (16 November 2026) and repo1.maven.org maven-metadata.xml, November 2026.
- Gatling Java requirements, SDK languages and the JavaScript SDK’s Node.js requirement: docs.gatling.io, “Install Gatling locally”, November 2026. Injection profiles: docs.gatling.io/concepts/injection, November 2026. Assertions: docs.gatling.io/concepts/assertions, November 2026.
- Gatling gRPC, GraphQL, JDBC, MQTT and Kafka licence and Community Edition limits (5 users, 5-minute tests): docs.gatling.io, the setup page of each component, read 17 November 2026; implicit 2xx-or-304 status check: docs.gatling.io/reference/script/http/checks, November 2026; protocol list: docs.gatling.io/reference/script, November 2026.
- Gatling editions and plans: gatling.io/pricing, read 17 November 2026. Playwright used as a capture tool only: gatling.io/blog/load-testing-playwright-gatling, November 2026.
- LoadFocus k6 cloud runs, regions and virtual user limits: loadfocus.com/k6-load-testing and loadfocus.com/pricing; LoadFocus on Gatling: loadfocus.com/alternatives/gatling-alternative, read 17 November 2026.
- Test runs: k6 v2.4.0 (macOS arm64 binary) and Gatling 3.16.1 (Java DSL, Maven 3, gatling-maven-plugin 4.22.3, Java 17.0.20), against a local Node.js test API on an Apple M1 Max, 17 November 2026. Memory and threads were sampled per process every second, CPU totals from
/usr/bin/time -l; the slowdown test counted arrivals on the server. The laptop carried other work during the runs (load average 7 to 30), so compare the tools within a test, not between tests. Timings show patterns, not benchmarks.