Gatling is an open-source performance testing tool used to evaluate the web applications and APIs under concurrent request mode. In this post, we are going to see, how to utilise Gatling tool to evaluate the performance of the REST APIs with the help of Karate framework integration.
One of the key advantages of Gatling is thread management in which a single thread will be created to trigger concurrent request from the client machine but other tools including JMeter used to create multiple threads which will squeeze the client environment resources.
Gatling supports various protocols such as HTTP/HTTPS, web socket, JDBC, MQTT etc.
How to setup client environment?
- Install JDK 8 in your PC and setup the environment variable
- Download Maven 3.8.6 and setup the environment variable
- Install IntelliJ IDEA community edition IDE
- Map the JDK 8 in the IDE
- Install Scala from the market place available in the IDE
- Install and map the Scala SDK 2.13.10 in the IDE for the target project
- Import the sample project using the below GitHub repo and start using after modifying the scripts in accordance with your needs.
https://github.com/gopekanna/performance/
How to work with Karate Framework?
Test runner associated with the IDE will be utilized to test the API request/response working as expected including various types of assertion. I’ve used mocky.io to create a mock response from the cloud server and used the same mocky endpoint throughout the project.
Using BDD approach, scripts has been prepared to trigger the REST API payload available in the client which is nothing but the IDE. Please refer the below screenshot which includes sample payload.


Run the script using the Test Runner based on the below screenshot.

Karate Framework implementation is ready and now, we are going to move towards the Gatling integration with Karate Framework.
perform.scala script file associated with the IDE is going to play the role of single or multiple users request in which the required feature file should be called in the scala script file as mentioned below.

Please note, injection specific request count can be mentioned in the same scala script file to trigger the concurrent request from the client environment. Multiple option available in the Gatling based on the below URL.
- atOnceUsers
- rampUsers
https://gatling.io/docs/gatling/tutorials/advanced/
Use the below command in the console window or maven window in the IDE to start executing your prepared test script for the performance evaluation of APIs.
mvn test-compile gatling:test
After simulation started based on the concurrent user count including the duration part, you could see the results in the console window of IDE.
Index html report will be generated to proceed your analysis after the completion of Gatling simulation in the IDE. Please refer the below sample report for your quick reference.


Thank you!