Gatling – SBT For Load Testing

Gatling is an open source load testing framework based on Scala, Akka and Netty and ready our self for load testing. Load testing is performed to determine a system’s behaviour under both normal and at peak conditions.

The aim includes;

  • High performance
  • Ready-to-present HTML reports
  • Scenario recorder and developer-friendly DSL


1. In project/plugins.sbt, add:

addSbtPlugin("io.gatling" % "gatling-sbt" % "2.1.6")

Also needs to add these two dependencies in  build.sbt:

libraryDependencies += "io.gatling.highcharts" % "gatling-charts-highcharts" % "2.1.6" % "test"
libraryDependencies += "io.gatling"            % "gatling-test-framework"    % "2.1.6" % "test"


A Simulation is a real Scala class containing 4 different parts:
we can define the baseURL, which will be prepended to all the relative paths in the scenario definition. Also we can define some other configurations such as common headers, user agent etc, which will be added on each request.

we define the headers which can be used for each request that will be sent to the server.

This is the main part of your test. It has a sequence of exec commands. Each exec command is used to execute a set of actions(GET, POST, etc.) that will be executed in order to simulate.

This is usually the last part of the test script. This is where we define the load we want to inject to your server

Example Code:

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

  Load test on scalaJobz Rest api for find all jobs
class TestScript extends Simulation {
  val baseurl = ""
  val httpConf = http.baseURL(baseurl)

  val scn = scenario("Finding all jobs")


Running the Scenario

$ sbt test


Screenshot from 2015-07-09 15:45:37

it provides meaningful reports through we can easily understand our result. Report is present in our target folder.

Screenshot from 2015-07-09 15:56:01


This entry was posted in Scala and tagged , , , . Bookmark the permalink.

3 Responses to Gatling – SBT For Load Testing

  1. Pingback: Gatling – SBT For Load Testing – payalblog2

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s