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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • From Load Testing to Performance Engineering: Why the Shift Matters
  • Estimating Software Projects: A Practical Approach for Tech Leads
  • Load Testing Essentials for High-Traffic Applications
  • Queuing Theory for Non-Functional Testing

Trending

  • 5 AI Security Incidents That Broke Things in Production (and What They Have in Common)
  • Every Cache Miss Is a Tiny Tax on Your Performance
  • Observability for Agents and Workflows: Tracing Prompts, Tool Calls, and Business Outcomes End-to-End
  • Why Stable RAG Answers Can Still Hide Unstable Evidence
  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.

By 
Siva Prasad Rao Janapati user avatar
Siva Prasad Rao Janapati
·
Feb. 01, 17 · Opinion
Likes (3)
Comment
Save
Tweet
Share
6.2K 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. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • From Load Testing to Performance Engineering: Why the Shift Matters
  • Estimating Software Projects: A Practical Approach for Tech Leads
  • Load Testing Essentials for High-Traffic Applications
  • Queuing Theory for Non-Functional Testing

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook