JMeter has been the main stage for performance and load testing since its launch in 1998, which is why JMeter is often used as a benchmark to evaluate new performance/load testing space entrants. When compared to JMeter, Gatling is a considerably new load-testing framework. But given the scarcity of new load testing tools, Gatling was well-received by the automated testing community upon launch in 2012.
This blog will compare Gatling vs. JMeter by exploring each testing solution in-depth and comparing them feature by feature.
Table of Contents:
- What is Gatling?
- Gatling Programming Languages
- How to Create Gatling Load Tests
- What is Apache JMeter?
- JMeter Programming Languages
- How to Create JMeter Load Tests
- Gatling vs. JMeter: A Side-by-Side Comparison
What is Gatling?
Gatling is a load-testing tool. Its website describes it as: “Load-Test-As-Code: the best way to load test your applications, designed for DevOps and CI/CD. Discover the Gatling load testing tool.” Gatling load tests are designed entirely with code. The tool runs on JVM, and you must have Java installed to create or run Gatling tests.
With a free, open-source version and commercial version, Gatling runs on multiple 64-bit LTS versions of Java, such as 8, 11, and 17.
Gatling Programming Languages
When Gatling was launched, you could only write Gatling load testing scripts using the Scala language. Gatling later added support for other Java Virtual Machine (JVM)-based languages. It is possible to write Gatling scripts using the following languages:
- Scala
- Java
- Kotlin
How to Create Gatling Load Tests
Beginners can generate Gatling load testing scripts using the Gatling recorder. But once the code is generated, you will need a Java IDE to edit and customize it. It is possible to use IDEs like IntelliJ and Eclipse for authoring Gatling load-testing scripts.
The easiest way to create a new Gatling project is by cloning one of the repositories, such as the Gatling Maven plugin demo for Scala. Creating a Gatling project from scratch is possible, but this might be slightly complicated for new users.
Gatling Load Test Example
Gatling load tests are made up of code and some configurations. Here’s an example:
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class GatlingExample extends Simulation{
// 1 Http Configuration
val httpProtocol = http.baseUrl(url="https://videogamedb.uk/api")
.acceptHeader(value="application/json")
// 2 Scenario Definition
val scn = scenario("Video Game DB - 3 calls")
.exec(http(requestName="Get all video games - 1st call").
get("/videogame"))
.pause(duration = 5)
.exec(http(requestName="Get specific game")
.get("/videogame/1"))
.pause(1, 10)
.exec(http(requestName="Get all video games again")
.get("/videogame")
)
// 3 Load Scenario
setUp(
scn.inject(atOnceUsers(users=3))
).protocols(httpProtocol)
}
For more examples, you can check with the Gatling community here.
What is Apache JMeter?
JMeter is a free and open-source load testing tool. It is widely used for performance, load, and stress testing.
JMeter can be used for many application types, including but not limited to
- Web applications stress and load testing
- Web API stress, load, and functional testing
- FTP stress and load testing
- Database stress and load testing
- LDAP stress and load testing
- Web Service stress, gear, and functional testing
- MongoDB load tests
The latest version of JMeter is 5.5, and it runs on multiple versions of Java, starting from Java 8. All features of JMeter are available since it is open-source and free.
JMeter Programming Languages
Performance and load tests created with JMeter don’t have to contain programming instructions. No coding skills are needed to develop and run performance/load tests with JMeter. But if duty calls, you may include logic written in multiple programming languages in your JMeter scripts. The list of programming languages supported out of the box by the JMeter is given below,
- Java
- Groovy
- JavaScript
JMeter tests are stored in XML format with the file extension .jmx.
How to Create JMeter Load Tests
JMeter comes with a GUI for creating and modifying load tests. The GUI offers a wide variety of lego-like customizable test elements which you can include in your tests. You can customize and rearrange test elements according to your testing needs to get the desired results. It is possible to customize the behavior of JMeter components by customizing their parameters. It is not recommended to run the tests using the JMeter GUI for performance reasons. Instead, we must use the JMeter through the Command-line mode (previously known as a non-GUI mode) to run load tests.
JMeter Load Test Example
A sample JMeter load test is given below.
Please, don’t underestimate the power of JMeter by sheer looks. There’s more than what meets the eye. There is almost no learning curve, and the supportive community is enormous.
Gatling vs. JMeter: A Side-by-Side Comparison
A comparison of JMeter and Gatling is given below in a tabular form to help you decide which tool is better for your load-testing scenarios.
JMeter | Gatling (Open-Source) | |
UI for load testing | JMeter provides a UI for creating load tests. | Gatling doesn’t provide a UI for creating load tests. |
Option for no-code load testing | No-code load testing load and performance testing. Code is optional. | All code load testing. Must have skills in Scala, Kotlin, or Java languages. |
Script changes | JMeter scripts can’t be changed without JMeter UI. | Gatling scripts can be changed using multiple IDEs. |
Distributed testing capabilities | Running master/enslaved person distributed tests is possible. | Running master/enslaved person distributed tests is possible. |
Application types | Can test a large number of application types. | Can test a smaller number of application types. |
CI/CD support | CI/CD support is an afterthought. | It is built with modern CI/CD systems in mind. |
Customized reporting | JMeter load test reports can be customized. | Report customization is not possible. |
Version control compatibility | JMeter doesn’t fit well with source control systems like Git/SVN. | Work well with source control systems such as SVN and Git. |
Live test run monitoring | Live test run monitoring is possible. | Live test run monitoring is NOT possible. |
Plugins | A massive number of JMeter plugins are available. | A smaller number of plugins are available. |
Third-party cloud services | Third-party cloud services are available for running distributed load tests (e.g., BlazeMeter). | Third-party cloud services are available for running distributed load tests (e.g., BlazeMeter). In addition, Gatling OSS supports distributed tests. |
Generate test plans from HAR files | JMeter can’t generate test plans from HAR files natively (third-party support). | The Gatling recorder (link) can generate load-testing scripts from HAR files. |
Reusable components | Creating reusable components is challenging in JMeter. | You can easily use your coding chops, like OOP, to create reusable components. |
Third-party script recorder availability | A third-party script recorder is available as a browser extension. | No third-party script recorder is available. |
Let us take a closer look at these points comparing Gatling vs. JMeter below:
JMeter Provides a UI for Creating Load Tests
JMeter provides tools for visual programming to create load tests. They are like the famous cartoon “Voltron,” quickly assembled with blocks. By clicking, configuring, and arranging test components, you can easily set the parameters to fit the needs of your test scenarios. Test components include controllers, samplers, pre/post processors, and assertions. No coding skills are needed to create load tests using JMeter (though code can make tests more powerful).
Gatling, on the other hand, does not provide a UI for organizing your load tests. “Load testing as code” is the foundation of Gatling. That’s why no visual utility is available to create or customize Gatling load-testing scripts. You must write the code yourself.
Dependency on JMeter UI
JMeter UI is the primary tool for creating new JMeter load/performance testing scripts. Making small changes to JMeter’s .jmx files is possible with any text editor, but it’s a risky business and highly prone to failure. To create and update JMeter scripts, you must use the JMeter UI. In Gatling, you can create and modify Gatling load tests using multiple IDEs like IntelliJ Idea, VS Code, and Eclipse.
JMeter UI also has some limitations. For example, it is only possible to have one test plan opened in a JMeter UI window at any time. Within this window, you can open the properties of only one test element at a time. A multi-window UI would be more helpful, but it is not there.
In addition, updating all references will be very hard if you rename a variable in your JSR223 or BeanShell code.
Gatling load tests, on the other hand, are just Java code (or maybe Scala/Kotlin code, based on your preference). It is possible to open more than one test script in the same window and play around. If you change a variable name in an IDE window, updating all references is a piece of cake.
Running Master/Slave Distributed Tests
JMeter has improved at distributed load/performance test execution. Despite immense possibilities, Gatling’s open-source version won’t let you run your load tests in a distributed form. This one is major if you ask me. Setting up and running distributed tests with JMeter is intuitive and well-documented. You can use various options like containers and virtual machines to run JMeter distributed load tests. For example, running distributed load tests on AWS Elastic Container Service can be a potent tool.
You Can Test Many Application Types Using JMeter
It is possible to load test a wide variety of applications using JMeter, including but not limited to the list of application types given below.
You can use Gatling open source for testing the applications of the following types. A table is shown below for a comparison of application types supported by JMeter and Gatling.
JMeter | Gatling |
|
|
It is possible to Customize Reports Generated by JMeter
Most projects have unique load test result reporting needs. One size does not fit all. It is possible to customize the reports generated by JMeter easily. In the case of Gatling OSS, you can’t customize the reports. A screenshot of a report generated by JMeter is attached below.
JMeter Doesn’t Fit Well With Source Control Systems
As described earlier, JMeter stores test configurations in XML files. Various settings related to testing components are stored in element attributes and within the element body. Identifying the differences between different versions of your load test scripts can be very difficult.
Gatling tests are code, and keeping track of code is easy with tools like Git, SVN, and Helix Core.
CI/CD Support in JMeter and Gatling
Contemporary agile development is about continuous everything. This includes Continuous Integration (CI), Continuous Delivery (CD), and Continuous Testing (CT).
JMeter was around before agile became mainstream. That’s why it does not have great support for CI/CD systems like Jenkins, Bamboo, Azure DevOps, and TeamCity. JMeter tooling was not created with running through automation and reporting via CI/CD systems in mind.
Gatling prides itself on being “Modern load testing as code.” Being modern in the software world means you have to be on top of your CI/CD game. Gatling was built with modern CI/CD systems in mind. For this reason, Gatling has out-of-the-box support for Bamboo, Jenkins, and TeamCity CI/CD systems.
JMeter Live Test Run Monitoring
Observability is crucial in performance and load testing. We can’t just create a bunch of load tests, run them and wait for them to produce the desired results. Some form of feedback is needed while our load tests are running. JMeter allows live test run monitoring. The same is not true for Gatling OSS. It is possible to use tools like BlazeMeter Taurus to run JMeter tests and see which calls have passed/failed in real-time.
The Number of Available Plugins
The number of plugins available for JMeter is significantly higher than the number of “Extensions” available for Gatling.
- JMeter Listener pack: allows writing load test data on the fly to InfluxDB, ElasticSearch, and ClickHouse.
- BlazeMeter Step-by-step Debugger: Enables step-by-step debugging of JMeter scripts.
- Servers Performance Monitoring: Keep track of the server being loaded live.
- BlazeMeter Citrix Plugin: Enable load-testing Citrix XenApp exposed applications
Third-Party Cloud Services for Load and Performance Testing
You can easily leverage the services offered by multiple cloud providers to run your JMeter and Gatling load tests. One such provider is the BlazeMeter which calls itself “The Complete Continuous Testing Platform.” You do not even have to know the tools that well. You can leverage recorders or open-source Taurus.
Creating Load Tests From HTTP Archive (HAR)
HTTP Archive format or HAR is a format for storing a web browser’s interactions with a website. Many types of software, other than browsers, can also generate HAR files. A list of applications that can export HAR files is given below.
In the case of Google Chrome, you can generate the HAR file through the Network tab in Chrome Developer Tools. An example is shown in the screenshot below.
You may let different users or the QA department perform interactions with a website and send you the results as a HAR file, which you could use to generate load tests. JMeter does not provide the functionality to import HAR files as load tests.
Third-party tools let you convert a HAR file into a JMeter performance/load test. The BlazeMeter JMX converter is a good example.
Reusing Load Testing Components
In the case of JMeter, it is harder to create reusable components. We can get stuck in awkward copy/paste situations if we use the same logic in multiple places. Component reuse is easier in the case of Gatling because it is entirely coded. You can use programming principles such as Object Oriented Programming in your test code to make it easily maintainable and robust.
Browser Extension for Recording JMeter Tests
It is possible to generate JMeter load and performance test scripts directly from the browser. You can use the BlazeMeter browser extension to create load tests based on your interactions with a website. No browser extension is available for generating Gatling load test scripts from the browser.
Bottom Line
We have tried to objectively compare JMeter vs. Gatling. Hopefully, it will help you pick the best tool for your load testing needs.