Gatling, a load testing tool with a difference.
Tags: automation, loadtesting, stresstesting
Published: 2018-07-09 00:23:21

---
title: Gatling, a load testing tool with a difference.
published: true
description: automation, load testing, stress testing
tags: automation, load testing, stress testing
---

*Cross posted from [my blog](https://davidjeddy.com).

<strong>A little background.</strong>

Load testing tools generally send a high number of requests against a target host of your choosing. These tools are used to stress test how many requests a service can handle before it becomes unacceptably slow, unresponsive, or even crash a service. So being able to answer the question of <code>how many users a website/app/service handle before the <a href="https://www.nytimes.com/2012/03/01/technology/impatient-web-users-flee-slow-loading-sites.html">slow down causes users to turn away</a></code> is a very, VERY important one. Load testing tools have a variety of mechanisms to calculate the answer. Herein I evaluated <a href="https://gatling.io/">Gatling.io</a>'s offering.

<strong>What makes Gatling Different?</strong>

Gatling allows the user (developer/operator) to record a series of actions in the browser of choosing. At the tempo of a real user, multiple steps, form input, reloads; all can be done because the test cases are being created by a real user in a real browser. Use cases can be grouped and executed by virtual user assignment or individually. For the more technically inclined among us Gatling also supports a Scala like domain specific language (DSL). This languages allows for near infinite control on how tests are executed. Perfect for testing auto-scaling policies and load balancing in large cloud based systems. Finally, if you have the budget Gatling offers a '<a href="https://gatling.io/gatling-frontline/">Frontline</a>' service. A SaaS offering that <code>helps you manage all aspects of performance testing through its interface</code>.

Bonus: Gatling can also render the output using a handful of different chart systems, I only evaluated the high chart offering so <a href="https://dictionary.cambridge.org/us/dictionary/english/ymmv">YMMV</a> with the visualizations.

<strong>Opinionated 15min Crash course</strong>

For this demo, we will be stepping through the process as I did to get a basic test case created and executed. The <a href="https://gatling.io/docs/current/quickstart/">Quick start guide</a> has more details . This is my quick start steps.

<strong>Prerequisite</strong>: <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">Java 8</a>, a terminal/command prompt, and the current version of <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>.

<span style="text-decoration: underline;">Install</span>

Download the project, at the time of writing <a href="https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/2.3.1/gatling-charts-highcharts-bundle-2.3.1-bundle.zip">2.3.1</a> was the current.

Unzip the file, I did it into `~/Projects/tools/<span class="s1">gatling-charts-highcharts-bundle-2.3.1</span>`

Go into the new directory.

<span style="text-decoration: underline;">Record</span>

Execute ./bin.recorder.sh, wait, after a few moments a Java application window will be displayed. This is Gatling's main UI.

Enter a value for <code>Package</code> (think <code>vendor</code>, then provide a class name value.

<img class="aligncenter size-full wp-image-739" src="https://davidjeddy.com/wp-content/uploads/2018/07/Gatling-Main-UI.png" alt="" width="1884" height="1704" />

I checked <code>Save preferences</code>; finally hit <code>Start!</code>. In a moment the Recorder window appearse. Leave it alone for now.

Next, I started up Firefox and set the proxy settings to use localhost:8000 for all requests.

<img class="aligncenter size-medium wp-image-740" src="https://davidjeddy.com/wp-content/uploads/2018/07/Firefox-Proxy-2400x1296.png" alt="" width="2400" height="1296" />

Visiting a site of my choice (I used <a href="http://davidjeddy.com/">this site</a>). You should see some output in the recorder's <code>Executed Events</code> panel. This is good, very good.

I moving around the site and recorded some other events.

<img class="aligncenter size-full wp-image-741" src="https://davidjeddy.com/wp-content/uploads/2018/07/Gatling-Recording-User-Events.png" alt="" width="2160" height="1526" />

Once completed I pressed the <code>stop &amp; save</code> button and the window closes.

<img class="aligncenter size-full wp-image-742" src="https://davidjeddy.com/wp-content/uploads/2018/07/Gatling-Recorder-Stop.png" alt="" width="758" height="380" />

As I was done w/ the UI I closed the main window as well.

<span style="text-decoration: underline;">Execute Steps</span>

Back in the terminal the process to execute the recorded is surprisingly straight forward. Executing`./bin/gatling.sh` resulting in the expected package/class name options. Think of these in the same relationship as suite/test in many other tools.

<img class="aligncenter size-full wp-image-743" src="https://davidjeddy.com/wp-content/uploads/2018/07/Gatling-execute-1.png" alt="" width="1282" height="526" />

Selecting the correct value and pressing enter a few times I was greeted with the execution steps running.

The test will take as long, if not longer than, than the original recorded process. The waits between steps, the resource loading, the clicks, etc.

<img class="aligncenter size-full wp-image-744" src="https://davidjeddy.com/wp-content/uploads/2018/07/Gatling-execute-2.png" alt="" width="1270" height="1042" />

At the end of it all Gatling provides a local URL to view the results in a browser with pretty graphs.

<img class="aligncenter size-full wp-image-745" src="https://davidjeddy.com/wp-content/uploads/2018/07/Gatling-execute-3.png" alt="" width="1880" height="282" />

This is the really nice part as compared to many other load testing tools.

<img class="aligncenter size-full wp-image-746" src="https://davidjeddy.com/wp-content/uploads/2018/07/Gatling-Graphs.png" alt="" width="2362" height="1178" />

<strong>Conclusion</strong>

As a load testing tool Gatling is as simple as it gets; just make sure you have the Java 8 JDK set as the JAVA_HOME env variable. With the recorder and the highly versatile DSL scripting ability, and the straight forward CI/CD integrations, and even the Frontline SaaS offering makes Gatling a serious contender for the load testing step in your Operations/QA/Testing process.

&nbsp;

<strong>Addendum</strong>

Gatling ONLY works with the Java 8 JDK. You MUST set your systems JAVA_HOME global variable to the JDK 8 java bin directory. Otherwise you get a cryptic message about not being able to find the test classes.

&nbsp;

<strong>Edit</strong>

Paul-Henri from Gatling saw the articled and emailed me. The Frontline offering is an on-Premises offering, not SaaS. Thank you for the correction Paul-Henri!