Direkt zum Hauptbereich

Creating load tests with Gatling instead of JMeter

I just came around a tool called Gatling (http://gatling-tool.org/) to create load tests for web applications. I used to use JMeter for a long time, but JMeter has weaknesses that Gatling doesn‘t have.

JMeter uses a synchronous request approach. That means for every request JMeter generates, an internal thread is raised and therefore blocked until a response is being received or a timeout happens. This results in resource blocking on the load injector. The maximum number of threads is limited within a JVM - dependent on the underlying infrastructure -  and even if you are able to run a lot of parallel threads this will result in a high CPU and memory utilization. Although performance tweaking and scaling out to distributed testing might help in such a case, it makes testing more complex and error-prone.

This behavior can result in distorted metrics. Think about a typical breakpoint load test. You want to determine, which is the maximum number of requests per second your tested system can serve. This will be limited by JMeter to

max_requests_per_second = (1000 / average_request_time_in milliseconds) * max_jmeter_threads

Even if the system could server more, this is the maximum number JMeter can inject. This is especially important when the tested application has long response cycles, e.g. because of long lasting transactions or long lasting calculations within the requests.

Gatling is a tool built on Scala and Akka which is capable to serve much more parallel requests. It doesn‘t use a „thread per request“ model. Requests are generated using Akka concurrency features. Akka is built on Scala actors, that are internally based on isolated futures which can be created very fast and managed independently in a large number within a system. This makes is easy to create tens of thousands of parallel request on a convenience hardware based load injector.

Like JMeter, Gatling can be configured using scripts, „Scanarios“ in the Gatling terminology. Those are created in a Domain Specific Language that can be build with Scala features. For example a test with a simple clickstream in a web application can be defined as follows:

val stdSearch = scenario("Standard Search")
    .exec( http("Access Google").get("http://www.google.com") )
    .pause(2, 3)
    .exec( http("Search for 'auconsil'").get("http://google.com/#").queryParam("q","auconsil"))
    .pause(2))

setUp(stdSearch.users(4000).ramp(180))

The script is more or less self-explanatory. It creates a scenario with 2 requests and 2 pauses. Afterwards a load test - a so called simulation - is defined with 4000 parallel users and a time of 180 seconds after which all users are active.

This combination of Scala based DSL and scripting together with the actor based concurrency model and an extremely lightweight CPU and memory footprint makes Gatling to me a first choice for future projects.

Kommentare

Beliebte Posts aus diesem Blog

Device-Weiche in PHP

Anforderungen für Device-Weichen Je mehr Anforderungen an die Unterstützung von unterschiedlichen Devices kommen, desto öfter steht man vor der Frage, wie die verschiedenen Ausgabegeräte zwecks unterschiedliche Behandlung auf einer Seite unterschieden werden können, um dann z.B. jeweils eine Weiterleitung auf unterschiedliche Zielseiten vorzunehmen welche das entsprechende Device unterstützen, also eine sogenannte Device-Weiche oder Browser-Weiche. Klassische Use Cases sind hier: Je nach Device die "klassische" Website oder die mobile Site anzeigen Eine Landing Page erstellen, welche unterschiedliche mobile Devices zu unterschiedlichen Zielseiten (z.B. Subdomains) verzweigt Eine Redirect-Verteilerseite, welche mobile Devices in die verschiedenen Stores für einen mobile App Download weiterleitet Das letztgenannte Beispiel möchte ich hier einmal exemplarisch demonstrieren. Man stelle sich folgendes Szenario vor: Demo-Szenario Im Rahmen einer Web-Anwendung ...

Add an existing Grails project to Bitbucket using Git

I just started using Bitbucket as a new service to host masters of my source code repositories using Git. If you develop with Grails (like I also do more often) and ever asked yourself how to create a Git repository out of an existing project, here is the solution. Prerequisits Of course you need to have Git installt locally on your machine. If you haven't here are instructions on how to do it (if your a Mac user, I find this Mac OS X installer very useful). Of course you also need an account for bitbucket.org . It's free and easy to set up. In addition to your account you need to create an empty repository. Follow the guidance on the Bitbucket site, it's quite easy. Prepare your grails project As you do not want to store all your files in the repository, you need to create a so called .gitignore file. To do so, you can use a grails command: > grails integrate-with --git Afterwards, the .gitignore file has been created. If you are using the Grovy & Gr...