Convert Figma logo to code with AI

gatling logogatling

Modern Load Testing as Code

6,584
1,205
6,584
38

Top Related Projects

26,066

Write scalable load tests in plain Python 🚗💨

8,653

Apache JMeter open-source load testing tool for analyzing and measuring the performance of a variety of services

24,194

HTTP load testing tool and library. It's over 9000!

38,871

Modern HTTP benchmarking tool

27,122

A modern load testing tool, using Go and JavaScript - https://k6.io

The complete load testing platform. Everything you need for production-grade load tests. Serverless & distributed. Load test with Playwright. Load test HTTP APIs, GraphQL, WebSocket, and more. Use any Node.js module.

Quick Overview

Gatling is an open-source load and performance testing tool designed for web applications. It provides a simple yet powerful way to simulate user behavior and measure system performance under various load conditions. Gatling is written in Scala and leverages Akka for handling high concurrency.

Pros

  • High performance and scalability due to its asynchronous, non-blocking architecture
  • Expressive DSL for writing test scenarios, making it easy to create complex user simulations
  • Detailed and visually appealing HTML reports for analyzing test results
  • Supports various protocols including HTTP, WebSocket, and JMS

Cons

  • Steeper learning curve for users unfamiliar with Scala or functional programming concepts
  • Limited IDE support compared to some other testing tools
  • Fewer plugins and integrations available compared to more established tools like JMeter
  • Can be challenging to debug complex scenarios due to its asynchronous nature

Code Examples

  1. Basic HTTP request:
import io.gatling.core.Predef._
import io.gatling.http.Predef._

class BasicSimulation extends Simulation {
  val httpProtocol = http.baseUrl("http://example.com")
  val scn = scenario("Basic Scenario")
    .exec(http("request_1").get("/"))
  setUp(scn.inject(atOnceUsers(1)).protocols(httpProtocol))
}
  1. Adding think time and assertions:
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._

class AdvancedSimulation extends Simulation {
  val httpProtocol = http.baseUrl("http://example.com")
  val scn = scenario("Advanced Scenario")
    .exec(http("request_1").get("/"))
    .pause(5)
    .exec(http("request_2").get("/api/users"))
    .pause(1, 2)
  setUp(
    scn.inject(rampUsers(10).during(10.seconds))
  ).protocols(httpProtocol)
   .assertions(
     global.responseTime.max.lt(1000),
     global.successfulRequests.percent.gt(95)
   )
}
  1. Using checks and variables:
import io.gatling.core.Predef._
import io.gatling.http.Predef._

class ChecksAndVariables extends Simulation {
  val httpProtocol = http.baseUrl("http://example.com")
  val scn = scenario("Checks and Variables")
    .exec(http("Get User ID")
      .get("/api/users")
      .check(jsonPath("$[0].id").saveAs("userId")))
    .exec(http("Get User Details")
      .get("/api/users/${userId}")
      .check(status.is(200)))
  setUp(scn.inject(atOnceUsers(1)).protocols(httpProtocol))
}

Getting Started

  1. Install Gatling:

    • Download the latest version from the official website
    • Extract the archive to a directory of your choice
  2. Create a new Scala file in the user-files/simulations directory

  3. Write your simulation using the Gatling DSL (see examples above)

  4. Run the simulation:

    ./bin/gatling.sh
    
  5. View the generated HTML report in the results directory

Competitor Comparisons

26,066

Write scalable load tests in plain Python 🚗💨

Pros of Locust

  • Written in Python, making it more accessible for many developers
  • Supports distributed load testing out of the box
  • Highly customizable with a simple, intuitive API

Cons of Locust

  • Generally slower performance compared to Gatling
  • Limited reporting capabilities without additional plugins
  • Lacks built-in support for some protocols (e.g., WebSocket)

Code Comparison

Locust:

from locust import HttpUser, task, between

class MyUser(HttpUser):
    wait_time = between(1, 3)

    @task
    def my_task(self):
        self.client.get("/")

Gatling:

class MySimulation extends Simulation {
  val httpProtocol = http.baseUrl("http://example.com")
  val scn = scenario("My Scenario")
    .exec(http("request_1").get("/"))
  setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

Both Locust and Gatling are popular load testing tools, each with its own strengths. Locust offers simplicity and flexibility with Python, while Gatling provides better performance and more comprehensive reporting. The choice between them often depends on the specific project requirements and the team's expertise.

8,653

Apache JMeter open-source load testing tool for analyzing and measuring the performance of a variety of services

Pros of JMeter

  • More extensive GUI for test creation and management
  • Wider range of supported protocols and integrations
  • Larger community and ecosystem of plugins

Cons of JMeter

  • Heavier resource consumption, especially for large-scale tests
  • Steeper learning curve for complex scenarios
  • Less efficient for high-concurrency testing

Code Comparison

JMeter (XML-based test plan):

<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request">
  <stringProp name="HTTPSampler.domain">example.com</stringProp>
  <stringProp name="HTTPSampler.port">80</stringProp>
  <stringProp name="HTTPSampler.protocol">http</stringProp>
  <stringProp name="HTTPSampler.path">/api/users</stringProp>
</HTTPSamplerProxy>

Gatling (Scala-based DSL):

http("Get Users")
  .get("http://example.com/api/users")
  .check(status.is(200))

Gatling offers a more concise and programmatic approach to defining test scenarios, while JMeter relies on XML configuration. This makes Gatling tests easier to version control and maintain for developers familiar with code-based configurations. However, JMeter's XML approach may be more accessible for non-developers or those who prefer visual test creation.

24,194

HTTP load testing tool and library. It's over 9000!

Pros of Vegeta

  • Lightweight and easy to use, with a simple CLI interface
  • Written in Go, offering good performance and cross-platform compatibility
  • Supports HTTP/2 out of the box

Cons of Vegeta

  • Limited scripting capabilities compared to Gatling's DSL
  • Fewer built-in reports and visualizations
  • Less extensive documentation and community support

Code Comparison

Vegeta (CLI usage):

echo "GET http://example.com" | vegeta attack -duration=5s | vegeta report

Gatling (Scala DSL):

scenario("My Scenario")
  .exec(http("Request")
    .get("http://example.com"))
  .inject(constantUsersPerSec(100) during(5 seconds))

Key Differences

  • Vegeta focuses on simplicity and raw HTTP benchmarking
  • Gatling offers more complex scenarios and detailed reporting
  • Vegeta is better suited for quick, ad-hoc tests
  • Gatling excels in comprehensive load testing and performance analysis

Both tools are valuable for load testing, with Vegeta being more straightforward and Gatling offering more advanced features. The choice depends on the specific requirements of your testing scenario and the level of complexity needed.

38,871

Modern HTTP benchmarking tool

Pros of wrk

  • Lightweight and minimal resource usage
  • Simple command-line interface for quick benchmarking
  • Written in C, offering high performance

Cons of wrk

  • Limited scripting capabilities compared to Gatling
  • Fewer built-in features for complex scenarios
  • Less detailed reporting and analysis tools

Code Comparison

wrk:

wrk.method = "POST"
wrk.body   = '{"key": "value"}'
wrk.headers["Content-Type"] = "application/json"

Gatling:

http("request_name")
  .post("/path")
  .body(StringBody("""{"key":"value"}"""))
  .asJson

Key Differences

  • Gatling offers a more comprehensive testing framework with advanced features for complex scenarios
  • wrk focuses on simplicity and raw performance for quick benchmarking
  • Gatling provides detailed reports and graphs, while wrk offers basic statistics
  • Gatling uses Scala for scripting, allowing for more sophisticated test designs
  • wrk is more suitable for simple load testing, while Gatling excels in full-scale performance testing

Both tools have their strengths, and the choice depends on the specific testing requirements and complexity of the scenarios to be simulated.

27,122

A modern load testing tool, using Go and JavaScript - https://k6.io

Pros of k6

  • Written in Go, offering better performance and lower resource usage
  • Supports JavaScript for test scripting, making it more accessible to web developers
  • Integrates well with Grafana for visualization and analysis

Cons of k6

  • Smaller ecosystem and community compared to Gatling
  • Limited support for protocols beyond HTTP/HTTPS

Code Comparison

k6:

import http from 'k6/http';
import { check } from 'k6';

export default function() {
  let res = http.get('https://test.k6.io');
  check(res, { 'status is 200': (r) => r.status === 200 });
}

Gatling:

import io.gatling.core.Predef._
import io.gatling.http.Predef._

class BasicSimulation extends Simulation {
  val httpProtocol = http.baseUrl("https://test.gatling.io")
  val scn = scenario("BasicSimulation").exec(http("request_1").get("/"))
  setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

Both k6 and Gatling are powerful load testing tools, but they cater to different user preferences. k6 is more developer-friendly with its JavaScript support, while Gatling offers a more comprehensive feature set and larger community. The choice between them often depends on specific project requirements and team expertise.

The complete load testing platform. Everything you need for production-grade load tests. Serverless & distributed. Load test with Playwright. Load test HTTP APIs, GraphQL, WebSocket, and more. Use any Node.js module.

Pros of Artillery

  • Written in JavaScript, making it more accessible for web developers
  • Supports multiple protocols (HTTP, WebSocket, Socket.io) out of the box
  • Easier to set up and configure, with a simpler YAML-based scenario definition

Cons of Artillery

  • Less mature and feature-rich compared to Gatling
  • Limited reporting capabilities and visualization options
  • Smaller community and ecosystem

Code Comparison

Artillery scenario (YAML):

config:
  target: "http://example.com"
  phases:
    - duration: 60
      arrivalRate: 20
scenarios:
  - flow:
    - get:
        url: "/"

Gatling scenario (Scala):

scenario("Simple scenario")
  .exec(http("request")
    .get("/"))
  .inject(constantUsersPerSec(20) during(60 seconds))

Both Artillery and Gatling are powerful load testing tools, but they cater to different audiences. Artillery is more approachable for JavaScript developers and offers quick setup, while Gatling provides more advanced features and better performance for large-scale tests. The choice between them depends on your specific requirements and team expertise.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Gatling Build Status Maven Central

What is Gatling ?

Gatling is a load test tool. It officially supports HTTP, WebSocket, Server-Sent-Events, JMS, gRPC and MQTT.

Motivation

  • Finding fancy GUIs not that convenient for describing load tests, what you want is a friendly expressive DSL in Java, Scala, Kotlin, JavaScript or TypeScript?
  • Wanting something more convenient than huge XML dumps to store in your source version control system?
  • Fed up with having to host a farm of injecting servers because your tool uses blocking IO and one-thread-per-user architecture?

Gatling is for you!

Questions, help?

Read the documentation.

Join the Gatling Community Forum.

Found a real bug? Raise an issue.

Partners

Highsoft AS