In the previous lesson, we learned about the different ways to handle errors in Gatling. In this lesson, we will learn about throttling.

What is throttling?

Throttling means limiting or slowing down the number of requests made by the client.

We can throttle the number of requests to reach the given target number of load/users by distributing it over various throttling configurations.

  • If the target load lasts longer than the throttle, the simulation will stop at the end of the throttle.

  • If your target load lasts less than the throttle, the simulation will stop when all the requests are made.

Throttling can be configured either at the scenario level or at the setUp level.

A sample simulation demonstrating throttling at setUp level

This simulation will reach 5 requests per second with a ramp up of 2 seconds. It then holds this throughput for 2 seconds, jumps to 10 requests per second, and finally holds this throughput for 20 seconds. The entire duration of the simulation is 15 seconds, and the target number of users is 50, as given in line 16.

The building blocks for the throttling are:

  • reachRps(target) in (duration): target a throughput with a ramp over a given duration.
  • jumpToRps(target): jump immediately to a given targeted throughput.
  • holdFor(duration): hold the current throughput for a given duration

Get hands-on with 1200+ tech skills courses.