# What are the concurrency semantics for running scenarios?

**URL:** <https://community.gatling.io/t/what-are-the-concurrency-semantics-for-running-scenarios/5134>\
**Category:** Gatling (Open-Source)\
**Created:** [July 16, 2019, 6:44pm UTC](https://community.gatling.io/t/what-are-the-concurrency-semantics-for-running-scenarios/5134 "2019-07-16T18:44:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Harkness](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jon\_Harkness](https://community.gatling.io/u/Jon_Harkness)\
**Post date:** [July 16, 2019, 6:44pm UTC](https://community.gatling.io/t/what-are-the-concurrency-semantics-for-running-scenarios/5134/1 "2019-07-16T18:44:54Z")

</div>

I had to build my own extension to support testing of one of our internal components.  
The extension supports stateful, coordinated consumers pulling data from a proprietary system.

My implementation is essentially an implementation of an `ExitableAction`, where `execute(..)` creates a future on a dedicated ExecutionContext (with an arbitrarily high number of threads).  
The future completion has some very basic throttle logic and calls `next ! session`.

```auto
if (throttled) {
  coreComponents.throttler.throttle(session.scenario, () => next ! session)
} else {
  next ! session
}

```

One of the coordination actions needs to take place on all the consumers, and cannot complete until confirmation is received from all the consumers.  
When I increase the number of consumers (past 32), I see 32 consumers respond to this request correctly, and consumers in excess of 32 do nothing… until the previous 32 complete.  
This breaks our test, as I cannot increase the number of coordinated consumers beyond 32.

The behaviour that I’m seeing only manifests when there are more than 32 users running a scenario that use this action…  
My server has 32 cores, which may/may-not be a coincidence; I have not tested it on a machine with fewer cores.

Its also interesting to note that multiple (different) scenarios with a total of more than 32 users’ do not have this problem; it seems to be limited when I have \> 32 users for the same scenario.

**Is there any limit in gatling that would prevent more than some number of scenario-users’ being active, or waiting on a action-response simultaneously?**  
**If so… how do I tweak it?**

Thank you in advance.

- Jon

---

<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:** [July 16, 2019, 7:00pm UTC](https://community.gatling.io/t/what-are-the-concurrency-semantics-for-running-scenarios/5134/2 "2019-07-16T19:00:26Z")

</div>

Sorry, no idea what you do.  
What I can say for sure is that:

- there isn’t such limitation in Gatling itself, the issue is with your code
- throttling is not a correct mechanism. This is something we ended up implementing because people kept on asking for something similar to JMeter Plugin’s Ultimate ThreadGroup. You should be controlling throughput with the injection profile.

---

<div class="post-metadata">

**Author:** ![Jon\_Harkness](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jon\_Harkness](https://community.gatling.io/u/Jon_Harkness)\
**Post date:** [July 17, 2019, 12:45am UTC](https://community.gatling.io/t/what-are-the-concurrency-semantics-for-running-scenarios/5134/3 "2019-07-17T00:45:08Z")

</div>

> Sorry, no idea what you do.  
> I’m trying to run an arbitrarily high number users, running the same scenario, but am only ever seeing 32 Actions running concurrently.  
> I was hoping there was a secret semaphore hiding somewhere that would limit the number of concurrent, incomplete Actions.

> throttling is not a correct mechanism  
> Should I ignore the `ScenarioContext.throttled` value entirely? (I have never seen the value “true”, in any case.)

I guess I’ll keep digging.  
Thanks.
