Measuring Performance With Gatling
Learn the basics of using Gatling, an open-source tool for load testing.
Join the DZone community and get the full member experience.
Join For FreeThere are many open-source tools and paid solutions to perform load tests efficiently. At Loadium, we have supported Apache JMeter and Selenium-based tests for load testing. Gatling, a load test tool, has been on the market for a few years and it’s a mature performance testing tool to use. In the near future, we are going to support Gatling tests.
First, it is an open-source load testing framework for your web application and web service tests. It’s very easy to install Gatling onyour local machine. Scenarios are implemented with a simple domain specific language (DSL). If you are familiar with DSL-type testing frameworks, it will be very easy to adopt Gatling for your performance tests. You can generate readable and easy to maintain performance test code.
Pros & Cons of Gatling
Pros of Gatling:
- High performance: You can inject more virtual users on a local machine compared to JMeter
- The scenario recorder is very user-friendly and creates easy to read DSL scenarios
- Great visual HTML reports
Cons of Gatling:
- Limited Protocol Support: As you know, JMeter has over 20+ protocol support with the plugins, etc.
- IDE: You only have a recorder as a UI. You should do some coding for JSON, XML, or CSS operations.
Actually, we cannot say those are some cons; there is some missing stuff compared to JMeter. Gatling is more of a developer/QA tool by nature.
Tech Stack Behind Gatling
- HTTP
- JMS
- WebSockets
- Server-sent events
Gatling’s installation process is simple and doesn’t require machine-by-machine basis installation.
Gatling projects can be started like any other Maven project. It has its own archetype and gives you a good starting point.
Gatling is built on Scala, Akka, and Netty. Scenarios should be developed in Scala, so that’s another language to learn for some of us.
Gatling also provides a visually rich report full of data to tell us what’s going on with the application under test.
You can easily integrate Gatling tests with Jenkins even if you don’t use Loadium or similar cloud-based products.
You can execute your Gatling tests with the help of a maven plugin and Gradle plugin.
Scenario Architecture of Gatling
Basically, load testing scenarios can be structured in four different parts:
HTTP Protocol Configuration
This is the base URL that runs against your tests. You can also do some global configuration like user agent, language header, connection, and so on.
Headers Definition
As with all HTTP requests, you need to define headers with a request that will be sent to the server. Sometimes you might need them, but for realistic load testing, the headers add a bit of a load on servers that are testing.
Scenario Definition
The core of your test! A scenario includes a group of actions (like GET, POST, etc.) that are executed to simulate a user’s interaction with the application. You can find information about HTTP requests in our previous article.
Simulation Definition
This is where you define the behavior of your real users. You define the load (number of users), ramp-up, and execution time that concurrently executes your scenario. Then, all you need to do is to execute your test from the command line client. You have the HTML report to analyze the response times of your request.
Those are the basics of Gatling. We’ll discover more in our next blog posts.
Stay tuned!
Published at DZone with permission of Canberk Akduygu. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments