Load Testing Using Gatling Installation & Hello World Example

Alpy
3 min readOct 21, 2020

--

Gatling is a load testing tool based on Scala. It comes with support for HTTP servers and is excellent tool to load test the Rest APIs.I will explain step by step how to install and run a simple API test program with Gatling. Make sure you have Java installed on your system.

  1. Go to https://gatling.io and download the open source version.
  2. Once the zipped folder is downloaded , unzip the folder(keep the folder in some meaningful directory)
  3. Open the command prompt and Go to the installed directory path\bin
  4. Run gatling.bat (for Windows OS) or ./gatling.sh(on Mac) and wait for some time

5. You will see simulation example provided by Gatling , you can select any of the option and enter the description and then press enter

6. If you get below metrics without any error , Congratulation .. You are through first level :).

Now let’s write a Simple Gatling Scala program to test API Post request with JSON body. WaitWhat …..Scalaaaaaa ??????? I don’t know Scala….

Don’t Worry…It’s okay if you don’t know Scala , I am not expert either. Lets do some tweaks.

  1. Go to the Folder -> gatling-charts-highcharts-bundle-3.4.1⁩\user-files⁩ \⁨simulations⁩ \⁨computerdatabase

2. Copy paste any existing Scala file and rename it ( I will rename it as PostRequestAPITest.scala). I am using a public API http://dummy.restapiexample.com/api/v1/create to show you the example. Post request has JSON request body with three attribute name, salary, age.

3. Save the file and let’s run gatling again. You should see your file in the Simulation list as shown below (see option 6 )

Simulation Steps

4. Select your file option and optional description and press enter. Gatling will run and collect metrics like given below

Yay…Congratulations !! You have successfully run your first test.

You can see the metrics provide calculated response time and request count. It also generates the UI report that can be viewed under results directory. Here is snapshot of the generated report-

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Alpy
Alpy

Written by Alpy

0 Followers

A Developer, A Technology Enthusiast & A Believer

No responses yet

Write a response