Jim Hurne
Jim Hurne

Reputation: 7369

Does JMeter pool HTTP connections?

I know when using the built-in Java HTTP client in a JMeter HTTP Request sampler connections may or may not be pooled, depending on the JVM implementation and configuration.

However, does JMeter pool connections when using HttpClient3.1 or HttpClient4?

There are some hints in the JMeter documentation that it may, but nothing in the documentation definitively states it.

If it does, is there a way to control the connection pool? For example, can you set the size of the pool?

Upvotes: 9

Views: 10070

Answers (2)

Erich Eichinger
Erich Eichinger

Reputation: 1958

Update for JMeter 3: in your HTTPSampler configuration you can use the entries

 <boolProp name="HTTPSampler.concurrentDwn">true</boolProp>
 <stringProp name="HTTPSampler.concurrentPool">10</stringProp>

to specify connection pool size according to this Code-Snippet (from http://svn.apache.org/viewvc/jmeter/tags/v3_0/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?view=markup line 785ff)

      if(this.testElement.isConcurrentDwn()) {
            try {
                int maxConcurrentDownloads = Integer.parseInt(this.testElement.getConcurrentPool());
                    connManager.setDefaultMaxPerRoute(Math.max(maxConcurrentDownloads, connManager.getDefaultMaxPerRoute()));                
                } catch (NumberFormatException nfe) {
                   // no need to log -> will be done by the sampler
                }
            }
       }

The configuration via JMeter UI is a bit quirky:

switch the HTTP Sampler Configuration View to "Advanced", tick "Retrieve all embedded resources", then "Parallel Downloads" and enter a number. You may untick "Retrieve all embedded resources" after that if you don't want JMeter to parse your responses for images

Upvotes: 3

Jim Hurne
Jim Hurne

Reputation: 7369

JMeter does some pooling of HTTP connections when using HttpClient3.1 or HttpClient4.

In both cases, connections are pooled per-thread. Connections are NOT shared across threads.

When using HttpClient3.1, JMeter uses an instance of SimpleHttpConnectionManager on each thread.

When using HttpClient4, JMeter uses an instance of a subclass of PoolingClientConnectionManager on each thread, and it uses PoolingClientConnectonManager's default settings (2 connections per route, and 20 maximum connections).

JMeter does not provide a mechanism for controlling the parameters of the connection pools.

I had to go to JMeter's source code to find this answer. See the following links for reference (the 2.13 tagged code):

Note: this answer is accurate for JMeter 2.13. The answer may be different for other versions of JMeter.

Upvotes: 12

Related Questions