Getting started: Load testing with Gatling and Redline13 (Part 1)

Doing load testing is often a painful experience. Maybe you have already experienced the pain or you have read my previous blog post on the subject. I am here to make some of the pain go away with Gatling and Redline13.

Load testing with Gatling and Redline13

 


THE AWESOME GATLING

Gatling is a fairly new load testing framework written in Scala…. Yes, Scala…. Yes, you will be writing your tests in Scala…. Yes, it is a functional language. Please, do not panic – it is awesome. I have been setting up load tests in JMeter for some years, and as a developer I often run into some special requirement that the UI and XML definition of JMeter lacks. This is where I really start feeling the pain, and have to come up with all kinds of workarounds. In Gatling, you have the full programming language at your disposal, and it is just like writing a unit test. You can do anything. The vast majority of your test will be written with the Domain Specific Language of Gatling, and you will not even notice you are writing Scala code. For those special requirements, Scala is not much different than some of the functional elements of languages like JavaScript and C#. Once you have your test as code, you start benefiting from improved readability, maintainability, and tools like version control that you know from unit testing.

Another great benefit of Gatling is the way virtual users are handled. In JMeter, each virtual user will require a thread. In Gatling, virtual users are just messages handled with Akka, which scales much better. At Queue-it, we need to perform load tests with hundreds of thousands of concurrent users, which is close to impossible with JMeter. When I started with Gatling, I could not believe how painless it was. These days, I provision 25,000+ concurrent virtual users on a single test server, where I would have a maximum of 2,000 on JMeter.

There are lots of good resources on how to get started with Gatling here, so for now, I will just show you this script which we will use with Redline13.

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class RealValueTalks extends Simulation {
val httpProtocol = http
.baseURL("http://realvaluetalks.com")
val scn = scenario("RealValueTalks")
.exec(http("IndexPage")
.get("/index.html")

.check(status.is(200)))

.pause(2 seconds)

.exec(http("LoadBackgoundImage")

.get("/img/bg.jpg")

.check(status.is(200)))

setUp(scn.inject(rampUsers(1.000) over (30 seconds)))

.protocols(httpProtocol)

}

 


Notice how readable the script is. I think we can agree that it is:

-does a get request to the index page

-verifies the OK response code

-waits 2 seconds

-does a get request to get the background image

-verifies the OK response code

-the test is run with 1,000 virtual users over 30 seconds

Running the test will produce a report like this.

Now that we have our test, let us run it at scale with Redline13, Part 2

Written by: Martin Larsen, Queue-it Senior Developer