# How to give maximum duration for simulation???

**URL:** <https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674>\
**Category:** Gatling (Open-Source)\
**Created:** [November 12, 2014, 5:54am UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674 "2014-11-12T05:54:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![47saikumar](https://avatars.discourse-cdn.com/v4/letter/4/a9a28c/32.png) [@47saikumar](https://community.gatling.io/u/47saikumar)\
**Post date:** [November 12, 2014, 5:54am UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/1 "2014-11-12T05:54:44Z")

</div>

Hi,

I am new to gatling…can anybody please explain that How can I give maxDuration option for simulation…If I use maxduration simulation will be completed in that specific time…is it correct???  
And what is the effect of performance by using this method…please explain with code example…

Thanks

---

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [November 12, 2014, 9:55pm UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/2 "2014-11-12T21:55:07Z")

</div>

I admit, the documentation does not make it clear where the maxDuration is applied.

`  
val scn = exec( . . . )

setUp(  
scn  
.maxDuration // does it go here?  
.inject( … )  
.maxDuration // or here?  
).maxDuration // or here?

`

I don’t know the answer. But it would be just as easy for you to try it out and see for yourself as it would be for me to do it for you and tell you the answer.

Think of it as “teaching a man to fish.” 🙂

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [November 13, 2014, 10:28am UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/3 "2014-11-13T10:28:46Z")

</div>

[https://github.com/gatling/gatling/issues/2372](https://github.com/gatling/gatling/issues/2372)

…

---

<div class="post-metadata">

**Author:** ![47saikumar](https://avatars.discourse-cdn.com/v4/letter/4/a9a28c/32.png) [@47saikumar](https://community.gatling.io/u/47saikumar)\
**Post date:** [November 13, 2014, 12:02pm UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/4 "2014-11-13T12:02:37Z")

</div>

Thnaks for your info john…I tried with different combinations…But doesn’t work…Can you please tell me your experiments…

---

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [November 13, 2014, 3:29pm UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/5 "2014-11-13T15:29:11Z")

</div>

I don’t typically use maxDuration. I have a ramp up period, a sustain period, and there is a natural ramp down as the users quit. That works fine for me. If you need maxDuration, ask yourself if you have a bug in your scenario that stops it from quitting on its own.

---

<div class="post-metadata">

**Author:** ![47saikumar](https://avatars.discourse-cdn.com/v4/letter/4/a9a28c/32.png) [@47saikumar](https://community.gatling.io/u/47saikumar)\
**Post date:** [November 27, 2014, 6:15pm UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/6 "2014-11-27T18:15:38Z")

</div>

John…My context is can we control the total simulation time in gatling???Meaning suppose If I am doing simulation for 100 users and ramp up time 1user per second…Is it possible to control the total simulation time??I think no…But correct me If I am taking deviation.

---

<div class="post-metadata">

**Author:** ![Abhinav\_Gogna](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Abhinav\_Gogna](https://community.gatling.io/u/Abhinav_Gogna)\
**Post date:** [November 27, 2014, 6:58pm UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/7 "2014-11-27T18:58:48Z")

</div>

Yes you can control total simulation time.

eg: [http://gatling.io/docs/2.0.3/general/scenario.html#during](http://gatling.io/docs/2.0.3/general/scenario.html#during)

---

<div class="post-metadata">

**Author:** ![Jay\_Williams](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@Jay\_Williams](https://community.gatling.io/u/Jay_Williams)\
**Post date:** [February 16, 2016, 5:33pm UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/8 "2016-02-16T17:33:18Z")

</div>

It is used like this:

setUp(scn.inject(rampUsers(10) over(50 seconds))).protocols(httpProtocol).maxDuration(5 minutes)

---

<div class="post-metadata">

**Author:** ![param\_veer\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@param\_veer\_Singh](https://community.gatling.io/u/param_veer_Singh)\
**Post date:** [April 4, 2016, 8:51am UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/9 "2016-04-04T08:51:49Z")

</div>



---

<div class="post-metadata">

**Author:** ![Shravan\_Kumar](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@Shravan\_Kumar](https://community.gatling.io/u/Shravan_Kumar)\
**Post date:** [July 11, 2016, 8:06pm UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/10 "2016-07-11T20:06:08Z")

</div>

Hi Sai,

does maxDuration worked? Please some code?

Thanks in advance.

KR,  
Sravan

---

<div class="post-metadata">

**Author:** ![Pritam\_Banerjee](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@Pritam\_Banerjee](https://community.gatling.io/u/Pritam_Banerjee)\
**Post date:** [September 20, 2016, 5:38pm UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/11 "2016-09-20T17:38:31Z")

</div>

Here you will find it:

[http://gatling.io/docs/2.2.2/general/simulation\_setup.html](http://gatling.io/docs/2.2.2/general/simulation_setup.html)

Like this:

```auto
setUp(scn.inject(rampUsers(1000) over(20 minutes))).maxDuration(10 minutes)

```

---

<div class="post-metadata">

**Author:** ![Yining\_Chen](https://avatars.discourse-cdn.com/v4/letter/y/c0e974/32.png) [@Yining\_Chen](https://community.gatling.io/u/Yining_Chen)\
**Post date:** [September 4, 2019, 12:42pm UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/12 "2019-09-04T12:42:53Z")

</div>

Doesn’t work for me

---

<div class="post-metadata">

**Author:** ![Tedy\_Yu](https://avatars.discourse-cdn.com/v4/letter/t/4491bb/32.png) [@Tedy\_Yu](https://community.gatling.io/u/Tedy_Yu)\
**Post date:** [November 12, 2019, 6:22am UTC](https://community.gatling.io/t/how-to-give-maximum-duration-for-simulation/1674/13 "2019-11-12T06:22:37Z")

</div>

From doc version, it only supports 3.3+.
