automation · gatling · performance

Gatling For Performance Testing

Since a year, I have been using Gatling for our performance testing and thought I should write something about it.Recently I have given talk on it with my colleague, you can look the slides here:

What is Gatling:

Gatling is open source performance tool written in Scala, Akka and Netty. It’s high performance tool which based on Actor, Non blocking I/O and asynchronous concept.You can explore more about in these places:


Google Group:!forum/gatling


Some of the advantage which I found during our use of gatling are:

  1. Easy to write and maintain the test script using Scala DSL
  2. High performance tool which take less memory and cpu on high load.
  3. Detail and configurable reporting support.

Setup Gatling: (I have used the mac to setup gatling)

Check Your Installation:

Test your components. You should see output similar to the following:

$ java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

$ mvn --version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T09:29:23-08:00)
Maven home: /usr/local/Cellar/maven/3.2.5/libexec
Java version: 1.7.0_75, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.5", arch: "x86_64", family: "mac"

$ scala -version
Scala code runner version 2.11.4 -- Copyright 2002-2013, LAMP/EPFL

Let’s Start the test:

Generate Project Using Maven:

Open you command line and run following command:

You can either use your IDE’s facilities for creating a new project using a Maven archetype or, from the command line, type:

mvn archetype:generate

Then, when prompted:

Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains):

Type gatling. You should then see:

Choose archetype:
1: remote -> io.gatling.highcharts:gatling-highcharts-maven-archetype (gatling-highcharts-maven-archetype)

Type 1 to select the archetype, then select the version to use 
(I would recommend to always use the latest version.)

Select the groupId, artifactId and package name for your classes before confirming the archetype creation.

Finish by importing the archetype into your preferred IDE.

You should see following structure:.
├── pom.xml
└── src
└── test
├── resources
│   ├── data
│   ├── gatling.conf
│   ├── logback.xml
│   ├── recorder.conf
│   └── request-bodies
└── scala
├── Engine.scala
├── IDEPathHelper.scala
└── Recorder.scala

Even if above instruction doesn't work, it's ok as I just wanted to show, 
how to create the performance project quickly.

Sample POM File structure:

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">





                        <!-- Configuration for the test results-->



 Here is the code for Simulation:

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

class SearchGoogleLoad extends Simulation {
       val httpProtocol = http
           .acceptEncodingHeader("""gzip, deflate""")
           .userAgentHeader("""Mozilla/5.0 (Macintosh; 
                               Intel Mac OS X 10.9; rv:35.0) 
                               Gecko/20100101 Firfox/35.0""")

       val header_tbs = Map("""Accept""" ->      
       val url = """"""
       val scn = scenario("Gatling_Search")
                  .get(url + """/search?q=gatling"""))
                  .pause(5) //Real time pause

it’s easy to understand, what’s being tested:
We are going to and search for gatling keyword.
This test run for 100 users.

Here is the command to run the test:
mvn clean test -Pexperimentload

Here the result of tests:

 ---- Global Information --------------------------------------------------------
 > request count 1100 (OK=1100 KO=0 )
 > min response time 167 (OK=167 KO=- )
 > max response time 45219 (OK=45219 KO=- )
 > mean response time 9548 (OK=9548 KO=- )
 > std deviation 8501 (OK=8501 KO=- )
 > response time 50th percentile 7675 (OK=7675 KO=- )
 > response time 75th percentile 14493 (OK=14493 KO=- )
 > mean requests/sec 19.105 (OK=19.105 KO=- )
 ---- Response Time Distribution ------------------------------------------------
 > t < 800 ms 122 ( 11%)
 > 800 ms < t < 1200 ms 36 ( 3%)
 > t > 1200 ms 942 ( 86%)
 > failed 0 ( 0%)

it will also generate a gatling report in html format, which you can access by opening the file. You will see something like this on report:

Setup Jenkins:

Install this plugin on Jenkins:

Jenkins Report:

Screenshot 2015-11-23 21.05.38

Here is the sample github project, which I created to give the example:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s