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?
When you set up connection pooling, instead of closing the client HTTP connection after use, CICS keeps the connection open and stores it in a pool in a dormant state. The dormant connection can be reused by the same application or by another application that connects to the same host and port.
Go to Monitoring and Tuning > Performance Viewer > Current activity , select server, then in PMI viewer select Settings > Log to define logging period and format. And in Modules > Thread pools > WebContainer you can view current counter values. This is rather for short term monitoring, than for constant logging.
Connection pooling means that connections are reused rather than created each time a connection is requested. To facilitate connection reuse, a memory cache of database connections, called a connection pool, is maintained by a connection pooling module as a layer on top of any standard JDBC driver product.
In a nutshell, the class initializes a connection pool based on an ArrayList that stores 10 connections, which can be easily reused. It's also possible to create JDBC connections with the DriverManager class and Datasource implementations.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With