Skip to content

Commit 312e846

Browse files
Add section in user guide for http timeouts
1 parent 98c094e commit 312e846

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/guide/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ public class PerformanceTest {
109109
When working with multiple samplers in a test plan, specify their names (eg: `httpSampler("home", "http://my.service")`) to easily check their respective statistics.
110110
:::
111111

112+
::: tip
113+
Set connection and response timeouts to avoid potential execution differences when running test plan in different machines. [Here](#timeouts) are more details.
114+
:::
115+
112116
::: tip
113117
Since JMeter uses [log4j2](https://logging.apache.org/log4j/2.x/), if you want to control the logging level or output, you can use something similar to this [log4j2.xml](../../jmeter-java-dsl/src/test/resources/log4j2.xml).
114118
:::
@@ -2354,6 +2358,25 @@ testPlan(
23542358
)
23552359
```
23562360

2361+
#### Timeouts
2362+
2363+
By default, JMeter uses system default configurations for connection and response timeouts (maximum time for a connection to be established or a server response after a request, before it fails). This is might make the test behave different depending on the machine where it runs. To avoid this, it is recommended to always set these values. Here is an example:
2364+
2365+
```
2366+
testPlan(
2367+
httpDefaults()
2368+
.connectionTimeout(Duration.ofSeconds(10))
2369+
.responseTimeout(Duration.ofMinutes(1)),
2370+
threadGroup(2, 10,
2371+
httpSampler("http://my.service")
2372+
)
2373+
)
2374+
```
2375+
2376+
::: warning
2377+
Currently we are using same defaults as JMeter to avoid breaking existing test plans executions, but in a future major version we plan to change default setting to avoid the common pitfall previously mentioned.
2378+
:::
2379+
23572380
#### Connections
23582381

23592382
jmeter-java-dsl, as JMeter (and also K6), by default **reuses HTTP connections between thread iterations** to avoid common issues with port and file descriptors exhaustion which require manual OS tuning and may manifest in many ways.
@@ -2378,7 +2401,7 @@ httpDefaults()
23782401
```
23792402

23802403
* This and `resetConnectionsBetweenIterations` apply at the JVM level (due to JMeter limitation), so they affect all requests in the test plan and other ones potentially running in the same JVM instance.
2381-
:::
2404+
:::
23822405

23832406
::: warning
23842407
Using `clientImpl(HttpClientImpl.JAVA)` will ignore any of the previous settings and will reuse connections depending on JVM implementation.

0 commit comments

Comments
 (0)