Gatling – Light weight load testing tool

gatling-logo

                                   Gatling is a lightweight stress testing tool backed by Scala, Akka, and Netty. It works asynchronously if the underlying HTTP request is non-blocking. It uses messages for virtual user simulation than thread per virtual user. Because of this, it consumes lesser system resources to run the load test. In this article let us see a REST endpoint load testing by following the below steps.

Step 1: Download the Gatling bundle from http://gatling.io/#/resources/download . The folder structure of GATLING_HOME is explained below.

gatling_folder_structure

Step 2: Set GATLING_HOME and JAVA_HOME environment variables and write a sample simulation using Scala. As a java developer you no need to have strong Scala knowledge to write Gatling simulations with Scala. We need to have very basic knowledge. A simulation is given below to test a REST endpoint.


package org.smarttechie
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class SampleRESTEndPointPrefSimulation extends Simulation {
val httpProtocol = http
.baseURL("<base url of your end point>") //the base url of your end point
val restEndPoint = "/posts" //provide the URI of your end point
val restEndpointScenario = scenario("Posts_Pref_Simulation")
.exec(http("request_1")
.get(restEndPoint))
setUp(restEndpointScenario.inject(rampUsers(1000) over (10 seconds))).protocols(httpProtocol)
}

                     In the above simulation, we are ramping up the 1000 users in 10 seconds. Once the simulation script is ready, go to the bin folder and launch the gatling.bat/gatling.sh. The script will run the simulation available under “simulations” folder and generates the reports under the results folder.

The sample report is given below.

gatling_performance_stats

In the coming article, we will see how to use Gatling maven integration and additional features like feeders, externalizing the properties, etc. Till then, Stay Tune!!!

Siva Janapati is an Architect with experience in building Cloud Native Microservices architectures, Reactive Systems, Large scale distributed systems, and Serverless Systems. Siva has hands-on in architecture, design, and implementation of scalable systems using Cloud, Java, Go lang, Apache Kafka, Apache Solr, Spring, Spring Boot, Lightbend reactive tech stack, APIGEE edge & on-premise and other open-source, proprietary technologies. Expertise working with and building RESTful, GraphQL APIs. He has successfully delivered multiple applications in retail, telco, and financial services domains. He manages the GitHub(https://github.com/2013techsmarts) where he put the source code of his work related to his blog posts.

Tagged with: , ,
Posted in Testing
One comment on “Gatling – Light weight load testing tool
  1. Yesu Raj says:

    Good article. I will try this testing tool. Please keep posting. Thanks.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Dzone.com
DZone

DZone MVB

Java Code Geeks
Java Code Geeks
OpenSourceForYou