Gatling Performance Framework

Gatling logo

Repeatable, CI-friendly load testing for APIs and web endpoints using Gatling. Generate actionable reports and integrate with CI for automated regression detection.

Quick start Sample simulation CI snippet

Overview

Design the framework for maintainability and CI: separate simulations, use feeders for variable data, assert SLAs (p95/p99, error rates) and store artifacts for comparison.

Quick start

  1. Install JDK 11+ and Maven (or Gradle).
  2. Create the project layout and add the Gatling plugin to `pom.xml` (example below).
  3. Add simulations under `src/gatling/scala/simulations` and resources under `src/gatling/resources`.
  4. Run `mvn gatling:test` and review `target/gatling/` report.

Recommended project layout

/project-root
├─ pom.xml
├─ src
│  ├─ gatling
│  │  ├─ scala
│  │  │  └─ simulations
│  │  │     └─ BasicSimulation.scala
│  │  └─ resources
│  │     └─ feeders
│  │        └─ users.csv
│  └─ main
│     └─ resources
└─ reports
      

Maven plugin snippet

Add to the `build/plugins` section of `pom.xml`:

<plugin>
  <groupId>io.gatling</groupId>
  <artifactId>gatling-maven-plugin</artifactId>
  <version>3.10.0</version>
</plugin>

Sample simulation

Example placed at `src/gatling/scala/simulations/BasicSimulation.scala` — uses CSV feeder and assertions.

package simulations

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class BasicSimulation extends Simulation {
  val httpProtocol = http.baseUrl("https://api.example.com").acceptHeader("application/json")

  val feeder = csv("feeders/users.csv").circular

  val scn = scenario("API Load Scenario")
    .feed(feeder)
    .exec(http("Get user").get("/users/${userId}").check(status.is(200)))
    .pause(1.second, 4.seconds)

  setUp(
    scn.inject(atOnceUsers(5), rampUsers(50) during (30.seconds))
  ).protocols(httpProtocol)
   .assertions(global.successfulRequests.percent.gte(95), global.responseTime.percentile4.lte(2000))
}

Update `baseUrl` and endpoints to match your environment. Use feeders to avoid cache artifacts and to vary request parameters.

Run locally & reports

Run locally:

mvn gatling:test

Open target/gatling/<simulation-name>-<timestamp>/index.html for the HTML report. Upload sample reports to reports/ and link them from this page for easy sharing.

View sample reports

CI integration (GitHub Actions)

name: perf-test

on: [push]

jobs:
  gatling:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 17
      - name: Run Gatling tests
        run: mvn -B -q gatling:test
      - name: Upload Gatling report
        uses: actions/upload-artifact@v4
        with:
          name: gatling-report
          path: target/gatling

Consider running lightweight smoke tests on each PR and heavier load runs on schedules or dedicated runners.

Tips & best practices

Resources & examples