# Exit if User per sec reached certain rate?

**URL:** <https://community.gatling.io/t/exit-if-user-per-sec-reached-certain-rate/9489>\
**Category:** Gatling (Open-Source)\
**Created:** [January 8, 2025, 5:34am UTC](https://community.gatling.io/t/exit-if-user-per-sec-reached-certain-rate/9489 "2025-01-08T05:34:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trinp](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/trinp/32/1593_2.png) [@trinp](https://community.gatling.io/u/trinp)\
**Post date:** [January 8, 2025, 5:34am UTC](https://community.gatling.io/t/exit-if-user-per-sec-reached-certain-rate/9489/1 "2025-01-08T05:34:27Z")

</div>

Hi, wish you all a new year of health and wealth.

During my load test, as some problems may happen such as response time degradation which could lead to user’s connection being longer than usual. For example, usually my load test will need only 12-20 Users active at the same time, but due to response time degradation, this rate may increase to 25-30 Users at the same time. At this point the test should be automatically stopped as it serves no more purposes (at least for my case).  
I knew the existence of `existHereIfFailed`, however I am not sure about the rate property to implement that to my script. If there is a way, please share with me 🙂

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [January 8, 2025, 7:37am UTC](https://community.gatling.io/t/exit-if-user-per-sec-reached-certain-rate/9489/2 "2025-01-08T07:37:36Z")

</div>

Hi,

This feature, named Run Stop Criteria, is only available in Gatling Enterprise, see [Run Stop Criteria | Gatling Features](https://gatling.io/features/run-stop-criteria).

---

<div class="post-metadata">

**Author:** ![sbittla](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@sbittla](https://community.gatling.io/u/sbittla)\
**Post date:** [January 11, 2025, 2:20am UTC](https://community.gatling.io/t/exit-if-user-per-sec-reached-certain-rate/9489/3 "2025-01-11T02:20:04Z")

</div>

Below scenario ramps up the users 0 through 20 users during the first 5minutes  
And it runs with 20 users for 30 minutes. Irrespective of the time taken by the APIs  
setUp(  
ScenarioName.inject(  
rampUsersPerSec(0) to(20) during(5 minutes),  
constantUsersPerSec(20) during(30 minutes)  
)

```
).protocols(httpConfig)

```

existHereIfFailed - will trigger is nothing to do with number of users. If there is any request fails if you want to exit you can use condition when you define a Scenario. Hope this helps.

For more information you can use refer this doc - [Gatling injection scripting reference](https://docs.gatling.io/reference/script/core/injection/)

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [February 10, 2025, 2:20am UTC](https://community.gatling.io/t/exit-if-user-per-sec-reached-certain-rate/9489/4 "2025-02-10T02:20:48Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
