# Polling kills my machine

**URL:** <https://community.gatling.io/t/polling-kills-my-machine/7545>\
**Category:** Gatling (Open-Source)\
**Created:** [January 19, 2023, 12:43pm UTC](https://community.gatling.io/t/polling-kills-my-machine/7545 "2023-01-19T12:43:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianolc79](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@marianolc79](https://community.gatling.io/u/marianolc79)\
**Post date:** [January 19, 2023, 12:43pm UTC](https://community.gatling.io/t/polling-kills-my-machine/7545/1 "2023-01-19T12:43:31Z")

</div>

Hello

I’m in the 3.9 version of Gatling. I don’t know if I’m doing well but with this scenario:

```java
ScenarioBuilder scenarioBuild() {
        return
                scenario(SCENARIO_NAME)
                        .exec(
                                poll()
                                        .every(5)
                                        .exec(httpFilterRequest("Commodore"))
                        );

    }

    {
        setUp(
                scenarioBuild()
                        .injectClosed(
                                constantConcurrentUsers(1).during(Duration.ofMinutes(1))
                        )
        )
                .maxDuration(Duration.ofMinutes(1))
                .protocols(httpBuilder().disableFollowRedirect());
    }

```

My laptop finish to block. It creates many many requests. My goal was to exec a request every 5 secs during 1 minute. What I’m doing wrong?

Here a copy of the console report:

```auto
---- Requests ------------------------------------------------------------------
> Global (OK=12 KO=40929 )
> Computer filter Commodore (OK=12 KO=40929 )
---- Errors --------------------------------------------------------------------
> j.n.SocketException: No buffer space available (maximum connec 40929 (100.0%)
tions reached?): connect

```

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![GeMi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gemi/32/939_2.png) [@GeMi](https://community.gatling.io/u/GeMi)\
**Post date:** [January 19, 2023, 1:55pm UTC](https://community.gatling.io/t/polling-kills-my-machine/7545/2 "2023-01-19T13:55:20Z")

</div>

Hi,  
check this solution:

> <https://github.com/gemiusz/gatling-examples-maven-java/blob/master/src/test/java/pl/gemiusz/Case0014Loop5times1RPSand3sPauseSimulation.java>

---

<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 19, 2023, 2:19pm UTC](https://community.gatling.io/t/polling-kills-my-machine/7545/3 "2023-01-19T14:19:17Z")

</div>

`poll` is a non blocking background task so your scenario terminates immediately as it doesn’t contain anything else.

Your injection profile is `constantConcurrentUsers(1)` meaning a new virtual user starts as soon as the current single one terminates.

As a result, you’re indeed spawning virtual users like crazy.

Note that your scenario must call `.exec(poll().stop())`.

---

<div class="post-metadata">

**Author:** ![marianolc79](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@marianolc79](https://community.gatling.io/u/marianolc79)\
**Post date:** [January 19, 2023, 3:00pm UTC](https://community.gatling.io/t/polling-kills-my-machine/7545/4 "2023-01-19T15:00:53Z")

</div>

> [@slandelle](#):
>
> constantConcurrentUsers

Ok. Thanks slandelle. I didn’t fully understand poll action.

---

<div class="post-metadata">

**Author:** ![GeMi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gemi/32/939_2.png) [@GeMi](https://community.gatling.io/u/GeMi)\
**Post date:** [January 19, 2023, 3:32pm UTC](https://community.gatling.io/t/polling-kills-my-machine/7545/5 "2023-01-19T15:32:31Z")

</div>

I don’t get why:

> [@slandelle](#):
>
> `poll` is a non blocking background task so your scenario terminates immediately as it doesn’t contain anything else.
> 
> Your injection profile is `constantConcurrentUsers(1)` meaning a new virtual user starts as soon as the current single one terminates.
> 
> As a result, you’re indeed spawning virtual users like crazy.
> 
> Note that your scenario must call `.exec(poll().stop())`.

is solution if you write:

> [@marianolc79](#):
>
> My goal was to exec a request every 5 secs during 1 minute. What I’m doing wrong?

I’m little confused 😕

Of corse you are missing things that @slandelle mention but you try to archive some goal.

---

<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 19, 2023, 3:36pm UTC](https://community.gatling.io/t/polling-kills-my-machine/7545/6 "2023-01-19T15:36:03Z")

</div>

@GeMi Both our answers are partial solutions: you explained how to implement the user case properly, I explained why the current code doesn’t work and why it crashes (and that it’s not a Gatling bug).

---

<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 18, 2023, 3:36pm UTC](https://community.gatling.io/t/polling-kills-my-machine/7545/7 "2023-02-18T15:36:38Z")

</div>

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