# Dynamic number of users for scenario with websocket

**URL:** <https://community.gatling.io/t/dynamic-number-of-users-for-scenario-with-websocket/4317>\
**Category:** Gatling (Open-Source)\
**Created:** [May 15, 2018, 7:54am UTC](https://community.gatling.io/t/dynamic-number-of-users-for-scenario-with-websocket/4317 "2018-05-15T07:54:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![elr1co13013](https://avatars.discourse-cdn.com/v4/letter/e/5f8ce5/32.png) [@elr1co13013](https://community.gatling.io/u/elr1co13013)\
**Post date:** [May 15, 2018, 7:54am UTC](https://community.gatling.io/t/dynamic-number-of-users-for-scenario-with-websocket/4317/1 "2018-05-15T07:54:55Z")

</div>

I have an application with n users connected by websocket, and each time one user send a transaction request, I want to check that I receive n messages : 1 OK as response for the transaction, and n-1 messages as notifications from the other users. I have the following code :

```auto
class MySimulation extends Simulation {

  val numberOfUsers = 70

  val httpConf = http
    .baseURL("http://localhost:8080")
    .wsBaseURL("ws://localhost:8080")

  val scn = scenario("WebSocket")
    .during(30 seconds) {
      exec(ws("Connect WS").open("/websocket"))
        .pause(3 seconds)
        .repeat(480) {
          exec(ws("Transaction Request").sendText(session => """{my transaction request}""")
            .check(wsAwait.within(500 milliseconds).until(numberOfUsers)))
        }
        .pause(3 seconds)
        .exec(ws("Close WS").close)
    }

  setUp(scn.inject(atOnceUsers(numberOfUsers)).protocols(httpConf))
}

```

This is working well.  
Now I would like to have a scenario with a dynamic number of users : for example I start with 1 user (so I should receive 1 message), then 5 seconds later I have 5 users (then I should receive 5 messages for each user), and so on until 150 users. For each ws check, I need to have the right number of users at instant t.

How can I manage this scenario ?
