Simple Gatling load test example in Scala

gating logo

Gatling is a library which allows you to test the performance of your API’s/websites by mimicking real world load scenarios. In this article ill be showing you a Gatling load test example so that you can run some load tests.

Gatling gives a nice summary of how you performed which includes errors that are present in your website under high load. Gatling also allows you to customise and configure the load when testing & also the duration of the test.

Gatling is written in Scala so what language best to use for the simplest Gatling load test example. In this article ill be showing you how to edit and run the most simple Gatling load test locally on your machine.

I will be assuming you already have Scala installed (view prerequisites). This Gatling load test example should only be used to test your own API’s to website, please do not abuse other services unless you have permission.


  1. Scala installed – Follow this guide
  2. Java 1.8 installed – Follow this guide
  3. A GitHub account – Create one here
  4. An IDE setup for Scala or any way to edit code (I use IntelliJ) – Get it here

Editing the load test

  1. Clone my repository from here: github icon simple-gatling-load-test
  2. Open the project and navigate to the file called Website.scala
  3. Edit val website = "" to include your website instead
  4. Edit val page = "/gatling-load-test-example" to the page you want to load test, or leave as / to test the homepage
  5. Navigate to BaselineSimulations.scala and go to line 46
  6. Edit the maxRPS (requests per second), to your desired amount
  7. Edit line 55 & change the minutes figures to how long you want the load test to run for

Running the load test

  1. Be sure to have Scala & Java 8 & sbt installed – follow this guide if you have not installed it yet
  2. Open up your operating systems command line (Windows – Command prompt, Macos – Terminal)
  3. Navigate to the \simple-gatling-load-test directory
  4. Type in sbt, you should enter into sbt
  5. Type in gatling:test, this should run the load test you configured previously
  6. You should see the output below, while the test is running
Gatling being run on macOS terminal

Once the test finishes running, you should be presented with a full report of the load test. It will look something like this:

Load test report on terminal window

Viewing load test results

Gatling also generates a index.html. This file contains the full report of the load test but displayed in a nice GUI. It has a lot more metrics and information then the report on the terminal windows. Once the load test finishes, it should give you a directory associated with the load test you just ran. Navigate to this directory and open the index.html file in Chrome/Firefox etc.

Some of the metrics in the GUI look like this:

Having these metrics stored is very useful as you can use them to compare different runs. Once you make a significant change to your website or API you can rerun the load test and compare it to the previous load tests.


Additionally, you may experience slow down on your machine when the Gatling load test is running. This is because Gatling is using a high percentage of the CPU power to make the necessary requests for the load test. I tend to leave the load test running and go do something else while so that it does not affect the results. Having a more powerful CPU will allow you to make more RPS, which is a very good thing as if you want to test with 3000+ RPS then you will need a very well performing CPU.

I have a Windows machine which I use more often but it is not as powerful as my Mac, so whenever I run any load tests I use my mac. My Macs specs are:

My Mac Book Pro specs

Leave a Reply

Your email address will not be published. Required fields are marked *