Post summary: Tutorial how to use Gatling and do successful performance testing with it.
This is first of series of posts designed to give complete overview of Gatling performance testing tool. Other post in the series are:
- Performance testing with Gatling – record and playback
- Performance testing with Gatling – Scala fundamentals
- Performance testing with Gatling – recorded simulation explanation
- Performance testing with Gatling – integration with Maven
- Performance testing with Gatling – advanced usage
- Performance testing with Gatling – reports
Performance testing is a way to identify how application behaves in case of high user load. In this post “performance testing” is used as a collective term but it actually has different aspects which are described in Performance, Load, Stress and Soak testing post. The essence and best practices of performance testing are described into How to do proper performance testing post. Current post is about how to do it with Gatling
Gatling is very powerful tool. Build on top of Akka it enables thousands of virtual users on a single machine. Akka has message driven architecture and this overrides the JVM limitation of handling many threads. Virtual users are not threads but messages. Tests are written in Scala, which makes scenarios creation and maintenance more complex.
For easy scenario creation Gatling provide very good recorder. It works as a proxy capturing all traffic and converting it into Gatling scenario. Detailed explanation how to record scenario can be found in Performance testing with Gatling – record and playback post.
Once simulation is recorded it can be changed with proper values, user count, etc and run. How to run a simulation can be found in the end of Performance testing with Gatling – record and playback post.
“Simulation” is the actual test. It is a Scala class that extends Gatling’s io.gatling.core.scenario.Simulation class. Simulation has a HTTP Protocol object instantiated and configured with proper values as URL, request header parameters, authentication, caching, etc. Simulation has one or more “Scenario”. Scenario is a series of HTTP Requests with different action (POST/GET) and request parameters. Scenario is the actual user execution path. It is configured with load users count and ramp up pattern. This is done in the Simulation’s “setUp” method. Several scenarios can form one simulation. There are other elements like Feeders that create input data and Checks that are used to validate responses. Those will be discussed in separate post.
REST and SOAP
REST and SOAP are also easily supported by Gatling since in they are very nature they are just a HTTP requests. SOAP is HTTP POST request with XML data put into request body. It is possible to have some special HTTP Headers in the request but in general case this is it. REST is either HTTP GET request with key/value params in the URI or HTTP POST request with JSON or XML data into request body. There are also HTTP Header parameters in the request to indicate the data type being sent, etc.
Scala is object oriented language and functional programming language, providing best of both worlds. Everything in Scala is object, there are no primitive data types like int, long, char, etc in Java. More simple Scala tutorial can be found in Performance testing with Gatling – Scala fundamentals post.
In order to properly edit simulation it should be included in a project and imported in some IDE. Gatling provide a Gatling Maven plugin. There are more plugins to be used they can be found on Gatling extensions page. Simulation can be recorded with recorder and further processed as a Maven project. Information with examples how this can be done is shown in Performance testing with Gatling – integration with Maven and Performance testing with Gatling – advanced usage posts.
Gatling is very good performance testing tool. It is capable of creating immense amount of traffic from a single node. It requires basic knowledge in Scala which is his main disadvantage. Java code can be directly used in Scala classes. Advance usage is from a Maven project which makes it more easy to use and maintain scenarios.