Skip to main content

Gatling vs Locust: The Same Test Run in Both Tools

Gatling vs Locust, tested: at 2,000 users Gatling sent 5,440 requests a second from one JVM; one Locust process reached 3,003 and its own median rose to 270 ms.

Gatling vs Locust: The Same Test Run in Both Tools

Gatling vs Locust is a choice between the Java virtual machine and Python. Gatling runs simulations written in Java, Kotlin, Scala, JavaScript or TypeScript, compiled and run on the JVM, which spreads the load over every CPU core. Locust runs plain Python classes, and each Locust process uses one core, so heavy tests need several processes. Both are open source and built for tests written as code.

To compare them on more than feature lists, we ran the same tests in Gatling 3.16.1 and Locust 2.47.0 against one local API. At 200 users they reported the same throughput. At 2,000 users, Gatling kept up from one JVM while one Locust process fell behind and reported its own backlog as response time. In a server slowdown, Gatling kept sending 100 requests a second and Locust halved.

Key Takeaways

  • Pick by language and build tooling first. JVM teams get Gatling inside Maven or Gradle; Python teams get Locust, with every PyPI library their services already use.
  • On a 200-user test both tools sent about 542 requests a second with no errors. Gatling reports whole milliseconds, so its median for sub-millisecond responses read 0 ms; Locust’s default client added a few milliseconds to each response time.
  • At 2,000 users (about 5,400 requests a second needed), Gatling delivered 5,440 using about 0.08 CPU seconds per 1,000 requests. One Locust process reached 3,003, warned that its CPU was above 90%, and reported a 270 ms median for a server that answers in 25 ms or less. Four processes closed the gap at about four times Gatling’s CPU per request.
  • Gatling has an open workload model; Locust users wait for each response. When the server slowed from 25 ms to 2 seconds, Gatling held 100 arrivals a second and Locust dropped to 50.
  • CI defaults are opposite: Locust exits with code 1 on any failed request, Gatling with code 0 unless an assertion fails.
  • LoadFocus runs JMeter and k6 scripts in the cloud; it does not run Gatling simulations or locustfiles.

Gatling vs Locust at a glance

Gatling 3.16.1Locust 2.47.0
LicenceApache 2.0 Community Edition (gRPC, GraphQL, JDBC, MQTT and Kafka under Gatling’s Enterprise Component License); paid Enterprise plansMIT, free
Tests written inJava, Kotlin, Scala, JavaScript or TypeScriptPython (a locustfile)
RuntimeJava virtual machine, run through Maven, Gradle, sbt or the JavaScript CLIgevent greenlets; one process uses one CPU core; Python 3.11 or later
Built-in protocolsHTTP, WebSocket, server-sent events, JMS; gRPC, GraphQL, JDBC, MQTT and Kafka limited to 5 users and 5 minutes in the free editionHTTP; contrib users for MQTT, Socket.IO, MongoDB, PostgreSQL, DNS, OpenAI, Milvus and Qdrant; anything else through your own Python client
Load modelsOpen (injectOpen) and closed (injectClosed) profilesUsers and spawn rate (closed); per-user pacing; custom shapes in Python
Pass or fail in CIAssertions, exit code 1 on failureExit code 1 on any failed request, or your own rule in Python
ReportHTML report after every runLive web UI on port 8089; CSV and HTML reports on request
Distributed loadGatling Enterprise (paid); the Community Edition runs locallyFree master and workers; --processes on one machine

Versions, licences and limits are from each project’s release pages, documentation and installed packages as of November 2026.

What is the main difference between Gatling and Locust?

The runtime around the test. A Gatling simulation is a compiled class on the Java virtual machine: it describes each scenario once as a chain of steps, and Gatling’s engine runs thousands of virtual users on a few dozen threads across all CPU cores. A Locust test is a Python class: each user is a greenlet, a lightweight coroutine, and every user in a process shares one Python interpreter and one core.

That shapes everything else. Gatling needs a build tool, a JDK and a few seconds to start the JVM, and in return one process produces a lot of load. Locust needs pip install locust and starts in well under a second, and a locustfile can import anything on PyPI: a database driver, a message queue client or a signing library your service already uses. The cost is that you start more Locust processes when one core is not enough.

How do the scripts compare?

Both describe the same journey in about the same number of lines; they differ in where per-user state lives. Our test logs in once per user, keeps the token, then loops three requests: the product list, one product (which 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 (condensed from the class we ran; imports omitted):

public class Shop extends Simulation {
  ScenarioBuilder shop = scenario("shop")
      .exec(http("login").post("/api/login")
          .body(StringBody(session -> "{\"user\":\"u" + session.userId() + "\",\"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));
  }
}

In Locust, the same test is a class. Logging in goes in on_start, which runs once per user, the token is an attribute of the user object, and the think time is the class’s wait_time:

import random
from locust import HttpUser, task, constant

class Shopper(HttpUser):
    host = "http://127.0.0.1:8099"
    wait_time = constant(1)

    def on_start(self):
        res = self.client.post("/api/login", json={"user": f"u{id(self)}", "password": "secret"})
        self.token = res.json()["token"]

    @task
    def shop(self):
        self.client.get("/api/items")
        item_id = random.randint(1, 50)
        self.client.get(f"/api/items/{item_id}", name="/api/items/[id]")
        self.client.post("/api/cart", json={"id": item_id},
                         headers={"Authorization": f"Bearer {self.token}"})

Gatling keeps the load profile and pass or fail rules in the simulation; Locust takes users, spawn rate and duration on the command line (locust -f shop.py --headless -u 200 -r 20 -t 60s). Gatling keeps per-user data in a session and reads it with #{token}; Locust uses ordinary attributes. One Gatling detail cost us a run: our first version wrote #{userId} in the login body, which is not a session attribute. The expression failed, so the login and add-to-cart requests were never sent, and the run still passed its assertions (more on that in the CI section).

Our Gatling tutorial covers the project setup and the HTML report, and the Locust tutorial covers the rest of the locustfile.

Do Gatling and Locust report the same results?

For throughput, yes. For response times, they differ in resolution and in overhead. Gatling records whole milliseconds, so responses faster than 1 ms read as 0 ms. Locust’s default HttpUser is built on the Python requests library, and that library’s processing time lands in the measured response time. With 200 users running the test above for 60 seconds:

200 users, 60 sGatling 3.16.1Locust 2.47.0 (HttpUser)
Requests32,62732,089
Requests per second (as each tool reported it)544542
Median, all requests0 ms7 ms
95th percentile27 ms33 ms
99th percentile27 ms37 ms
Errors00
Load generator memory599 MB (Maven plus the Gatling JVM)70 MB

The server answers the product list and the add-to-cart call in well under a millisecond and the single product in 25 ms, so two of every three requests are sub-millisecond. Gatling’s 0 ms median is those requests rounded down; Locust’s 7 ms median is mostly the client’s own work.

Both round their percentiles, in different ways. Against an endpoint that waits a random 100 to 400 ms (true median 250 ms, 95th percentile 385 ms, 99th 397 ms), with Locust’s faster FastHttpUser client:

100 users, uniform 100 to 400 msGatlingLocust
Median250 ms250 ms
95th percentile386 ms380 ms
99th percentile398 ms400 ms

Gatling’s figures sit within a millisecond of the true values. Locust stores each response time in a bucket so that workers send less data to the master; its source code gives the examples “147 becomes 150, 3432 becomes 3400”. Between 100 ms and 1 second that means 10 ms steps, which is why its 95th percentile read 380 ms. For a pass or fail limit set in round numbers this rarely matters; when comparing two runs a few milliseconds apart, it does.

How much load can one machine generate?

On a 10-core laptop, one Gatling JVM sent about 130,000 requests a second; one Locust process sent 4,000 to 15,000 depending on its HTTP client, and four Locust processes about 53,000. Python runs one process on one core, so a single Locust process stops getting faster once that core is busy, while the JVM spreads Gatling’s virtual users across all cores. Locust’s documentation recommends one worker process per core, and Locust’s --processes flag starts them on one machine.

With 50 users sending requests with no think time to an endpoint that answers instantly, for 30 seconds, on a laptop also running the test server:

50 users, no think timeRequests per secondCPU seconds per 1,000 requests
Gatling129,9890.034
Locust HttpUser, one process4,2900.241
Locust FastHttpUser, one process14,9150.069
Locust FastHttpUser, --processes 453,2130.074

FastHttpUser, Locust’s client built on geventhttpclient, did about 3.5 times the work of the default client on the same core. Even so, Gatling used about half the CPU per request of four FastHttpUser processes and produced 2.4 times their rate.

The more important finding came from the shopping test at 2,000 users, which needs about 5,400 requests a second:

2,000 users, 60 sGatlingLocust, one processLocust, --processes 4
Requests per second5,4403,0035,410
Median0 ms270 ms4 ms
95th percentile26 ms400 ms32 ms
CPU seconds per 1,000 requests0.0760.3250.326
Peak memory893 MB (Maven plus the Gatling JVM)253 MB295 MB (master plus four workers)
Peak threads103 (Maven plus the Gatling JVM)1155

The server’s slowest endpoint waits 25 ms, and Gatling’s 95th percentile on the same test was 26 ms. The 270 ms median from one Locust process was time the requests spent queued inside the load generator. Locust warned during that run that its CPU usage was above 90%, and again at the end, and a reader who skips the log blames the server for the tool’s queue. With four processes the warning did not appear and the numbers matched Gatling’s within a few milliseconds.

Memory runs the other way. Run through Maven, a Gatling test is two Java processes, Maven itself and the forked JVM that runs the simulation, and in this run they used 893 MB at 2,000 users against 295 MB for the Locust master and four workers that kept up. If the machine has little memory and the test is many mostly idle users, Locust is the lighter of the two.

How do Gatling and Locust model load?

Gatling offers both models; Locust offers one. Gatling’s injectClosed profiles hold a number of concurrent users, each waiting for its response, and its injectOpen profiles start new users at a rate whether or not earlier ones have finished. Locust users always wait for each response; Locust’s constant_throughput wait time only caps how often each user sends.

The difference shows when the server slows down, which is the moment a load test exists to catch. We aimed both tools at 100 requests a second and made the server’s response time jump from 25 ms to 2 seconds for 20 seconds, counting arrivals on the server:

Target 100 requests a secondBeforeDuring the slowdownAfter
Gatling, constantUsersPerSec(100)100/s100/s100/s
Locust, 100 users with constant_throughput(1)100/s50/s100/s within 2 s

Gatling started 100 new users every second through the slowdown, so by simple arithmetic about 200 requests were in flight at once, and the 2-second responses showed up in its 95th percentile (2,001 ms). Locust’s 100 users each needed 2 seconds per request, so they sent half as much, in bursts: 100 arrivals one second, none the next. Real traffic does not halve itself when a server slows down, so the closed model understates the overload, and response times look better than users would experience. That effect has a name, coordinated omission, and it is the main reason to prefer an open model for public endpoints.

To get closer to an arrival rate in Locust, run many more users than you need with constant_throughput; its documentation suggests 5,000 users at constant_throughput(0.1) for 500 iterations a second. That holds the rate only while enough users are idle.

How do Gatling and Locust fit in a CI/CD pipeline?

Both can fail a build, with opposite defaults. Locust exits with code 1 if any request failed, whatever the rate. Gatling exits with code 0 however many requests fail, unless the simulation has assertions; when one fails, it exits with code 1 and Maven reports “Gatling simulation assertions failed”. We sent 20 users at an endpoint that returns a 500 error for 5% of requests:

5% of requests failExit code
Gatling, no assertions0 (5.07% failed)
Gatling, assertion failedRequests().percent().lt(1.0)1
Locust, default1 (4.68% failed)
Locust, own rule allowing up to 10% failures0 (4.70% failed)

Gatling’s assertions are one line each on the global stats or on a named request, for failure rates, percentiles and counts. Locust has no assertion syntax; you write the rule in Python and set the exit code when the test ends:

from locust import events

@events.quitting.add_listener
def apply_rules(environment, **kwargs):
    stats = environment.stats.total
    failed = stats.fail_ratio > 0.10 or stats.get_response_time_percentile(0.95) > 500
    environment.process_exit_code = 1 if failed else 0

Two details catch people. Without an explicit status check, Gatling fails any response that is not a 2xx or a 304. And a failed expression in Gatling is not a failed request: in our first run, the broken #{userId} stopped 10,805 add-to-cart requests and 200 logins before they were sent. The console listed them under “Errors”, but the run recorded 21,610 requests and 0 failures, the assertion read “percentage of failed events is less than 1.0 : true (actual : 0.0)”, and Maven exited with code 0. Read the Errors block on a new simulation before trusting a green build.

How do you scale Gatling and Locust beyond one machine?

Locust has distribution built in and free: a master process runs the web UI and coordinates any number of worker processes, on one machine or many, which run the users and send their statistics back. Gatling’s Community Edition runs on one machine; the pricing page describes it as “for local use only”. Distributed, managed load generators are part of Gatling Enterprise.

Gatling Enterprise starts at €89 a month billed annually for the Basic plan, with one load generator and up to 60,000 virtual users; the Team plan is €356 a month billed annually with three load generators (gatling.io/pricing, 26 November 2026). Locust’s hosted route is Azure Load Testing, which Locust’s documentation lists as its hosted option; otherwise you run masters and workers in each region yourself. The protocol limit matters here too: Gatling’s gRPC, GraphQL, JDBC, MQTT and Kafka components stop at 5 users and 5-minute tests in the free edition (docs.gatling.io, setup page of each component, 26 November 2026). Locust has no such limit, but outside HTTP you write or install the client yourself.

When to choose Gatling and when to choose Locust

Choose by language and by how much load one machine has to make. Both tools produce trustworthy numbers when the load generator is not the bottleneck, so the decision rests on who writes the tests, which build tools they already run, and whether arrival-rate load matters to what you are testing.

Choose Gatling when:

  • the team works in Java, Kotlin or Scala and wants tests inside the existing Maven or Gradle build;
  • one machine must produce thousands of requests a second without extra processes;
  • you need an open workload model that keeps sending when the server slows down;
  • you want pass or fail assertions and a full HTML report from every run.

Choose Locust when:

  • the team writes Python, or the test needs Python libraries your services already use;
  • you want free distributed load across your own machines;
  • you want a web UI to start, watch and change a test while it runs;
  • you need gRPC, Kafka or another non-HTTP protocol at scale without a paid licence, and can write the client.

The other pairings are in k6 vs Gatling and k6 vs Locust, which repeat these tests with k6, and our k6 vs JMeter vs Gatling vs Locust comparison puts four tools side by side.

Running load tests in the cloud with LoadFocus

One machine has a ceiling for both tools, and Gatling’s Community Edition runs only locally, so tests that need more load or several regions move to a managed service. LoadFocus runs uploaded JMeter and k6 scripts on its own cloud infrastructure from 25 regions, with up to 20,000 virtual users on the Enterprise plan. It does not run Gatling simulations or locustfiles, so moving there means rewriting the test as a k6 script or a JMeter test plan.

The Gatling alternatives and Locust alternatives pages compare the options for each team, including when staying on your current tool is the better answer.

Frequently Asked Questions

Is Gatling better than Locust?

Neither is better overall. Gatling is better when one machine must produce a high request rate, when you need an open workload model, or when the team works on the JVM. Locust is better for Python teams, for tests that need Python libraries, and for free distributed load. Run side by side on a 200-user test against one local API in November 2026, both sent about 542 requests a second with no errors.

Is Gatling faster than Locust?

Yes, per process. In LoadFocus tests in November 2026 on a 10-core laptop, with 50 users and no think time, one Gatling JVM sent 129,989 requests a second to a fast endpoint, against 4,290 for one Locust process with its default client and 14,915 with FastHttpUser. Four Locust processes reached 53,213 and used about twice Gatling’s CPU per request.

Can Gatling run Locust scripts?

No. Gatling runs simulations written with its Java, Kotlin, Scala, JavaScript or TypeScript SDKs, and Locust runs Python classes, so moving a test between them means rewriting it. The request flow, think times and pass or fail limits carry over as a design; the code does not.

Does Gatling support Python?

No. Gatling’s SDKs cover Java, Kotlin, Scala, JavaScript and TypeScript. A team that wants to keep its load tests in Python should use Locust or another Python-based tool.

Is Gatling free?

The Gatling Community Edition is free and open source under the Apache 2.0 licence, for local use. Its gRPC, GraphQL, JDBC, MQTT and Kafka components are limited to 5 users and 5-minute tests unless you run them on the paid Gatling Enterprise, which also adds distributed load generators. Locust is free under the MIT licence, distributed mode included.

Sources

  • Gatling 3.16.1 and gatling-maven-plugin 4.22.3: github.com/gatling/gatling, release v3.16.1 (16 November 2026), and the Maven Central artifacts, November 2026.
  • Gatling SDK languages and editions: gatling.io/community-vs-enterprise and docs.gatling.io, read 26 November 2026. Implicit 2xx-or-304 status check: docs.gatling.io/reference/script/http/checks, read 26 November 2026.
  • Gatling gRPC, GraphQL, JDBC, MQTT and Kafka limits in the Community Edition (5 users, 5-minute tests): docs.gatling.io, the setup page of each component, read 26 November 2026.
  • Gatling plans and prices: gatling.io/pricing, read 26 November 2026.
  • Locust 2.47.0 package metadata (MIT licence, Python 3.11 or later), contrib users, --exit-code-on-error default and response-time bucketing (locust/stats.py): the installed 2.47.0 package and pypi.org/project/locust, November 2026.
  • Locust distributed runs, one process per core, --processes: docs.locust.io, “Distributed load generation”, read 26 November 2026. Wait times and the 5,000-user constant_throughput example: docs.locust.io, “Writing a locustfile”, November 2026. Azure Load Testing as the hosted option: docs.locust.io, “Hosted load testing”, read 26 November 2026.
  • LoadFocus cloud runs, regions and virtual user limits: loadfocus.com/jmeter-load-testing, loadfocus.com/k6-load-testing and loadfocus.com/pricing; LoadFocus on Gatling and Locust: loadfocus.com/alternatives/gatling-alternative and loadfocus.com/alternatives/locust-alternative, read 26 November 2026.
  • Test runs: Gatling 3.16.1 (Java DSL, Maven 3, Java 17.0.20) and Locust 2.47.0 on Python 3.12.13, against a local Node.js 23.11.1 test API (four worker processes; one process for the slowdown test, which logged every arrival) on an Apple M1 Max, 26 November 2026. CPU seconds are user plus system time of each tool’s whole process tree, memory and threads the peak of that tree sampled every half second; the one-minute load average stayed between 2.6 and 9.1. Timings show patterns, not benchmarks.

Bogdan

Founder at LoadFocus

Bogdan builds and runs the tools this blog is about. He writes from what the products actually do in production, including the parts that break.

Weekly tips right in your inbox.

Don’t miss out on the latest testing tips and tricks, tools and news related to software testing.

Already +20,000 members in the list.

The Load Testing Platform with AI That Explains Your Results

Load test websites and APIs from 25 cloud regions, monitor page speed and uptime, and get AI analysis that explains your results in plain English.

Cloud load testing, website speed and API monitoring in one place.

Hi there! Can I share a cool thing I'm working on with you?

A software testing newsletter that sparks joy.

Our goal is to create helpful content for software developers and testers.

If you're not into it, you can unsubscribe instantly.