When it comes to performance testing, which one should you pick between Jmeter and Gatling? And Why?
In our experience, we noticed that performance testing is often overlooked, especially if compared to other testing activities with a different scope (unit, integration, e2e). However, performance testing is critical to meet the performance standards required by business partners as well as dealing with seasonal or event affected traffic. Then, choosing the right tool is a key step.
Performance testing is widely acknowledged as an important part of the Software Development Life Cycle. Having a responsive application that delivers the expected outcome, without irritating its users, independently from the traffic it is receiving, is not any longer a nice to have feature, but it is more of a must. Applications that do not meet performance expectations quickly lose users, and consequently money to the companies that build them.
Lack of performance can yield an increase in infrastructural costs, reputational damage, and, in the end, decreased return on investment.
Performance testing is a way to prevent the latter scenario, by providing information to the stakeholders on the application’s responsiveness, stability, and scalability under different traffic loads, before it is released to the market. It is a way to shed some light on what is going on under the hood. Ignoring the performance dimension can endanger your business. Here is the recap of some lessons we learned during our performance testing activities targeting several services. These lessons were learned during the journey the Skynet Team started more than one year ago when we decided to invest more and more in performance testing as a way to deliver a higher value for our customers. Particularly, here we are focusing on questions that might arise at the beginning of any performance testing activity. Which of the two approaches (let’s call the code-oriented vs tool-oriented) to pick? How to make the right decision to preserve long-run test maintainability?
When we had to select a proper tool for performance testing on our team, among many others, Jmeter caught our attention because of the following reasons:
XML (JMX) file, that can be configured through a GUI. This makes the learning curve, in the first place, relatively less
steep than other code-oriented approaches.For sure not all that glitters is gold and there are some drawbacks. Notoriously, running Jmeter scripts can be demanding in terms of performance. In any case, it is recommended to run the Jmeter script in headless mode, without lack of irony, to prevent performance issues on the performance testing suite side.
We started using a JMX file as a template. In this template, we defined several test steps (that we called
phases) that everyone could modify and even extend.
After working more than one year in designing, implementing and releasing solutions for automating performance testing we concluded that using JMeter falls short in many respects.
Generally speaking, JMeter lacks a proper embedded coding environment. Even if we cannot expect the precision of an IDE, it must be said that JMeter’s coding capabilities do not allow a full-fledged coding experience (the one you can get with the most popular IDEs), but can, at times, fall short when it comes to debugging your code.
We thought that these issues could be addressed by relying on code instead of configuration.
Firstly, we had to decide which code-based library we wanted to give a try. We went for Gatling, as it is written in Scala, and much of our existing codebase was relying on languages run by the JVM, so we can reuse most of it.
With all the challenges that we noticed in the previous section, we started to address them by creating a new base project which included all the common functionalities that were causing troubles with Jmeter. These are:
Which solved:
This is a how a simulation looks like using the base project we created:
class MyHotelSimulation extends GatlingTemplateFromJson {
override def testedApplication = HotelApp
override def createScenario = scenario("Search Hotels")
.feed(getFeeder)
.exec(http("Search hotels by city")
.post("/searchHotelByCity")
.body(StringBody(
"""{
| "city": "${CITY}"
|}""".stripMargin)).asJson.check(bodyString.transform(_.length).gt(10)))
private def getFeeder = {
val createSynthethicSearchApi = new CreateSynthethicSearchApi
createSynthethicSearchApi.get(10000, SearchType.HOTEL).asScala.map(it => it.asScala.toMap[String, String]).toIndexedSeq.circular
}
}The point is that writing a performance test became much easier. You only need to define a Gatling scenario and a list of environments, everything else is managed by the GatlingTemplateFromJson class.
So, in order to configure these elements at runtime, the test is executed, and accepting this JSON as a parameter:
{
"env": "qa",
"tracing": "hotel-stress-test",
"loadProfile": "simple",
"loadProfileContent": {
"duration": 300,
"users": 3
}
}So, without changing any code, we can configure the environment, the HTTP client configuration, and the load profile.
No tool is better than another. A code-based tool like Gatling allows you to simplify many things, and to make it fit your needs, but it requires a deeper knowledge in order to work with it. Jmeter instead is an easier, popular and intuitive alternative, but its low maintainability makes it arduous to work with it for complex scenarios.
Concluding, Gatling is more flexible, so it allows you to work more efficiently on complex scenarios, and to maintain multiple test suites easily. On the other hand, Jmeter is more suited for projects with a narrower scope. Its GUI makes it useful for quick solutions.
iOS localization is a wild ride where device and app locales play by their own rules. But don’t worry, after some chaos, Apple’s settings actually matched our expectations. Of course, only after a few twists and turns [...]