DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Performance
  4. Gatling: A Lightweight Load Testing Tool

Gatling: A Lightweight Load Testing Tool

Gatling consumes fewer system resources to run a load test than other options. It works asynchronously if the underlying HTTP request is nonblocking.

Siva Prasad Rao Janapati user avatar by
Siva Prasad Rao Janapati
·
Feb. 01, 17 · Opinion
Like (3)
Save
Tweet
Share
5.14K Views

Join the DZone community and get the full member experience.

Join For Free

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

1. Download the Gatling Bundle

You can download this from Gatling. The folder structure of GATLING_HOME is explained below.

gatling_folder_structure

2. Set Environment Variables

Set GATLING_HOME and JAVA_HOME environment variables and write a sample simulation using Scala. As a Java developer, you don't 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 1,000 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 the simulations folder and generates the reports under 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, how to externalize the properties, etc. Until then, stay tuned!

Gatling (software) Load testing

Published at DZone with permission of Siva Prasad Rao Janapati, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Why Does DevOps Recommend Shift-Left Testing Principles?
  • Visual Network Mapping Your K8s Clusters To Assess Performance
  • Promises, Thenables, and Lazy-Evaluation: What, Why, How
  • A Real-Time Supply Chain Control Tower Powered by Kafka

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: