# Gatling URL: https://gatling.io/ Gatling is another big player in the load testing tool space. Gatling load testing may not be as popular as [[JMeter]] load testing, but it definitely has its own share of avid fans, especially among developers. The most divisive characteristic of Gatling is that it has no UI. Instead, you’ll write your Gatling load testing scripts in a text editor using pure code like this: ![](assets/1621807285_80.png) This may turn off some people, but others may be charmed by Gatling’s easy, simple approach to load testing. Gatling is written in Scala, which is a relatively user-friendly language, and it’s a lot easier to hook up to continuous integration tools rather than other tools that require an interface to edit a script. Gatling does have a smaller community behind it, so while there is still quite a bit of training material and plugins for Gatling, it can’t match the information that’s out there for JMeter. One of the big advantages to Gatling load testing is that it is more efficient than JMeter for large-scale load tests. Unlike JMeter, which starts up a thread for every virtual user that needs to be run, Gatling uses a different structure that allows it to run more than one user per thread, minimising the total number of threads used. If you’re looking at a test that you hope to scale up to more than 100,000 users, you should consider using Gatling. ## Technical details - Written in [[Java]], but scripting is in [[Scala]] - Uses [[Akka framework]] for [[JVM]] and [[Netty framework]] to handle I/O - On an 8-core machine, Gatling will run 40 threads but can generate 100,000 rps and 1,000 VUs ## History - Released in December 2011 - Created by [[Stéphane Landelle]] in [[France]] - In 2017, [Stéphane said]([[Load Testing Done Right using Gatling with Stephane Landelle]]) that Gatling had been downloaded 700,000 times. ## Philosophy - Gatling is "opinionated". It makes decisions at the design level based on best practices in testing: - [[A testing tool should not slow down the feedback cycle.]] - And quick in testing = text. This is something we've had in functional tools, but Gatling brings this speediness to load testing as well. - Gatling is code-only, and thus easy to get started with. - [[The 1 Thread=1 Virtual User Paradigm is flawed]] - A thread needs to be slowed down with `sleep` to accurately simulate a virtual user. This is a waste! - Instead, Gatling reuses threads to make requests from other virtual users. - Gatling uses a [[Message-oriented architecture]] that focuses on measuring throughput using messages, not virtual users. [[User concurrency is an ambiguous measure of throughput]]. - [[Gatling Competitive Advantages]] - [[Gatling Bundle Structure]] ## How to use Gatling - [[Basics of scripting in Gatling]] - [[Number of virtual users in Gatling]] - [[Think time in Gatling]] - [[Test Parameters in Gatling]] - [[Parameterization in Gatling]] - [[Concurrent requests in Gatling]] - [[Scenarios in Gatling]] - [[Network bandwidth throttling in Gatling]] ## Key features of a load testing tool ## Scripting ### Creating a script - [x] [[Recorder]] - Full UI recorder - Accessed via `/bin/recorder.sh` - ![](assets/1621807286_81.png) - Source: https://gatling.io/docs/current/quickstart/[[quickstart]] - [x] [[Exclude third-party or configured domains]] - [x] [[Sample script packaged in]] - Sample simulation `computerdatabase`, basic and advanced versions, come in the bundle. - [ ] [[GUI Test Builder]] - [x] [[Code-based scripting]] - [x] [[Protocol-based load testing]] - [ ] [[Browser-based testing]] ### Making the script robust - Protocols Supported - [x] [[HTTP/1.1] - [x] [[HTTP/2] - [ ] [[WebSockets]] - [ ] [[gRPC] - [ ] [[Citrix ICA] - [ ] [[LDAP] - [x] [[Modify headers]] - [x] [[Response assertions]] - [[Error handling]] - [x] [[Output to log upon error]] - [ ] [[Screenshots]] - [x] [[Continue on error or restart iteration]] - [[Debugging]] - Test metrics at runtime every 5 seconds - ![](assets/1621807286_82.png) - Test summary at the end - ![](assets/1621807287_83.png) - [x] [[See request and response headers and bodies on single iteration]] - [x] [[Change log levels]] - [x] [[Transaction groups]] - [x] [[Custom functions or test fragments]] ### Making the script realistic - [[Correlation of dynamic values]] - [ ] [[JMeter Regular Expression Extractor]] - [ ] [[CSS Selector]] - [ ] [[JSON Extractor]] - [x] [[Dynamic think time and pacing]] - [x] [[Conditional logic]] - [ ] [[Parallel execution of requests]] - [x] [[Download embedded resources]] - [x] [[Follow redirects]] - [x] [[Network bandwidth throttling]] - [[Network bandwidth throttling in Gatling]] - [x] [[Cache management]] - [[Cache management in Gatling]] - [ ] [[Startup and teardown thread groups]] ### Test data - [ ] [[Static test data]] - [ ] [[Unique data generation during runtime]] - [ ] [[Virtual Table Server]] ### Collaborating on a script - [ ] [[Version Control System]] - [ ] [[Test Scaffolding]] ## Execution ### [ ] [[Test Scenarios]] ### [x] [[Configurable Load profile]] - [x] [[Number of virtual users]] - [x] [[Duration]] - [ ] [[Origin or Region]] - [x] [[Ramp-up]] - [ ] [[Ramp down]] - [x] [[Number of iterations]] - [x] [[Fully customizable load profile]] ### SLAs - [ ] [[Set multiple thresholds]] ### [ ] [[Execution Parameters]] ### Memory consumption benchmark 1000 users on [[AWS]] m5.xlarge according to [[flood.io]] ## Analysis ### Dashboard - [x] [[Pre-generated reports]] - Test summary generated in CLI - ![](assets/1621807287_83.png) - Reports are automatically generated after every "simulation" (test run). They are HTML files. - ![](assets/1621807289_85.png) - [ ] [[Custom dashboard creation]] - [ ] [[Reusable dashboards]] - Easy error troubleshooting - [ ] [[Screenshots]] - [x] [[Response bodies]] - [x] [[Assertion success or failure]] - Represented as `OK` and `KO` in output - [x] [[Log for transaction failure]] ### Metrics - [x] [[Response time]] - [x] [[Request throughput]] - [x] [[Number of virtual users]] - [x] [[Error rate]] - [x] [[Network throughput]] - [ ] [[Load generator CPU]] - [ ] [[Load generator memory]] ### Graphs - [x] [[Different Graph Types]] - [ ] [[View by transaction]] - [ ] [[View by load generator or region]] - [ ] [[Custom views]] ### Results - [x] [[Raw data]] - [x] [[At least 1s granularity]] - [x] [[Export as plain text]] ## Continuous Load Testing - [x] [[Jenkins]] - [x] [[Azure Pipelines]] - [x] [[Travis CI]] - [x] [[CircleCI]] ## References - [[Load Testing Done Right using Gatling with Stephane Landelle]]