All HowTo's Linux Ubuntu, Mint & Debian Linux

Basic Website Stress-Test with Gatling2

This article demonstrates how to run a basic website stress-test using Gatling2. See the previous article on how to install Galting2. In this example, i’m running Gatling2 from “/root/gatling2/”.

Create a file in the “/root/gatling2/user-files/simulation/” directory called “MyTest1.scala” (/root/gatling2/user-files/simulation/MyTest1.scala). Add the following content to it:

import io.gatling.core.Predef._
import io.gatling.core.session.Expression
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import io.gatling.http.Headers.Names._
import io.gatling.http.Headers.Values._
import scala.concurrent.duration._
import bootstrap._
import assertions._

class MyTest2 extends Simulation {

        val httpProtocol = http
                .acceptEncodingHeader("gzip, deflate")
                .userAgentHeader("Mozilla/5.0 (X11; Linux x86_64; rv:10.0.8) Gecko/20121010 Firefox/10.0.8")

        val headers_1 = Map("""Accept""" -> """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""")

        val headers_4 = Map("""Accept""" -> """*/*""")

        val scn = scenario("Scenario Name")

        setUp(scn.inject(atOnce(30 user))).protocols(httpProtocol)

In the above, change the URL’s in bold with the URL’s that you want to include in your stress-test.

Now you can run Gatling like this:

cd ~

Output form the above:

GATLING_HOME is set to /root/gatling2
Choose a simulation number:
[0] MyTest1
[1] MyTest2
[2] MyTest3

At this point you can choose the number (relating to the test you want to run) and start the stress-test. When done, you can copy the results (which is a website complete with styles) to your website root directory so you can view the results. For example, i want to copy my results to my webserver at “”:

scp -r /root/gatling2/results/0-20131125095458 /var/www/html/results/MyTest1