You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Philippe Mouawad <p....@ubik-ingenierie.com> on 2014/05/13 23:59:46 UTC

httpClient.getConnectionManager() performance with HTTP only

Hello,
We have a report of Performance issue when using HttpClient4 with HTTP.

User noticed cacert was read very frequently.

I traced the calls and it is due to :
HttpClient#getConnectionManager()
=>

    public synchronized final ClientConnectionManager
getConnectionManager() {
        if (connManager == null) {
            connManager = createClientConnectionManager();
        }
        return connManager;
    }

==>        final SchemeRegistry registry =
SchemeRegistryFactory.createDefault();

====>         registry.register(
                new Scheme("https", 443,
SSLSocketFactory.getSocketFactory()));


=======>
    public static SSLSocketFactory getSocketFactory() throws
SSLInitializationException {
        SSLContext sslcontext;
        try {
            sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(null, null, null); <======== Reads CACERTS
            return new SSLSocketFactory(
                sslcontext,
                BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
        } catch (NoSuchAlgorithmException ex) {
            throw new SSLInitializationException(ex.getMessage(), ex);
        } catch (KeyManagementException ex) {
            throw new SSLInitializationException(ex.getMessage(), ex);
        }
    }
This reads the cacerts.
In this case user is not using HTTPS at all but gets this performance issue

Issue is not present in HTTPCLient 3.1
-- 
Regards.
Philippe

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg, Users,
I am pinging again on my questions.

As I didn't get any answer I am wondering if my questions here are stupid
or if you didn't have time to answer yet (which I can quite understand :-)
).
If they are stupid :-) , let me know so that I can scratch my head a bit
more.

Thanks a lot for your time and help.
Regards

On Mon, Dec 29, 2014 at 3:15 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi Oleg,
> Thanks for answers.
> Clarifications below inline.
> Regards
>
> On Mon, Dec 29, 2014 at 10:04 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
>
>> On Sun, 2014-12-28 at 22:09 +0100, Philippe Mouawad wrote:
>> > Hi,
>> > Related to this topic, once we switch to 1 instance of HttpClient
>> shared by
>> > all threads, how can we reset SSLContext ?
>> > We need this feature within jmeter to simulate SSL handshake per client
>> ,
>> > we currently do :
>> > httpClient.getConnectionManager().shutdown();
>> > Which by the way is rather very inefficient way to do this.
>> >
>>
>> What do you mean by resetting SSLContext, changing some SSL handshake
>> parameters?
>>
> In JMeter, when we want to simulate Client certicate authentication, we
> currently "reset" SSL Context by calling  httpClient.getConnectionManager().shutdown();
> in order to reproduce the SSL renegociation:
>
> https://github.com/apache/jmeter/blob/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> See lines 630 to 638.
>
>
>> One can force SSL renegotiation by evicting all idle connections from
>> the connection pool.
>>
> Ok, that's good to know, so it means even today it would be better to call
> this instead:
>
> httpClient.getConnectionManager().closeIdleConnections(1, TimeUnit.MICROSECONDS);
>
>
>
>> Please note that if JMeter needs to simulate several physical users
>> having a separate connection pool per distinct user may be the easiest
>> and the most representative strategy.
>>
>
> What is the object to use if it's not 1 HttpClient per user as we do today
> ?
>
> PoolingHttpClientConnectionManager does not seem to be the one, as if it's shared among threads, how could we reset it only for 1 user ?
>
>
>> Cheers
>>
>> Oleg
>>
>> > Thanks
>> > Regards
>> >
>> > On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
>> > wrote:
>> >
>> > > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
>> > > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>> > >
>> > > ...
>> > >
>> > > > >> Issue is not present in HTTPCLient 3.1
>> > > > >
>> > > > > Philippe
>> > > > >
>> > > > > If HttpClient is used correctly, this code should only be
>> executed only
>> > > > > once. Why does JMeter create more than one instance of HttpClient?
>> > > >
>> > > > We currently create an instance for each instance of different proxy
>> > > > settings and each protocol and each authority, because the client is
>> > > > created with these settings.
>> > > >
>> > > > This is also done for each thread.
>> > > >
>> > > > IIRC, this was necessary originally. We have not rewritten the code
>> > > > yet to use all the latest features.
>> > > >
>> > >
>> > > I see. For the time what you can do is to use a custom SSL socket
>> > > factory that lazily initializes SSL context when requested for the
>> first
>> > > time. This is exactly what HC 3.1 does. It will be somewhat slower
>> given
>> > > that one would need to mutex to synchronize access to the
>> initialization
>> > > code.
>> > >
>> > > Oleg
>> > >
>> > > > > Oleg
>> > > > >
>> > > >
>> > > >
>> ---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > > > For additional commands, e-mail:
>> httpclient-users-help@hc.apache.org
>> > > >
>> > >
>> > >
>> > >
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
On Fri, Jan 23, 2015 at 11:48 PM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Fri, 2015-01-23 at 23:10 +0100, Philippe Mouawad wrote:
> > On Fri, Jan 23, 2015 at 10:00 PM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> > > On Fri, 2015-01-23 at 20:42 +0100, Philippe Mouawad wrote:
> > > > On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <olegk@apache.org
> >
> > > wrote:
> > >
> > > ...
> > >
> > > > > >
> > > > > > > Please note that if JMeter needs to simulate several physical
> users
> > > > > > > having a separate connection pool per distinct user may be the
> > > easiest
> > > > > > > and the most representative strategy.
> > > > > > >
> > > > > >
> > > > > > What is the object to use if it's not 1 HttpClient per user as
> we do
> > > > > today
> > > > > > ?
> > > > > >
> > > > > > PoolingHttpClientConnectionManager does not seem to be the one,
> as if
> > > > > > it's shared among threads, how could we reset it only for 1 user
> ?
> > > > > >
> > > > >
> > > > > You should continue using one HttpClient instance per distinct user
> > > > > either with a pooling or basic connection manager. The only thing
> you
> > > > > might want to customize is changing SSL context initialization from
> > > > > eager to lazy.
> > > > >
> > > > >
> > > > Does it means we are stuck with 1 HttpClient instance per distinct
> user ?
> > > >
> > >
> > > What do you mean by that? You do not have to use one HttpClient
> instance
> > > per distinct user, but it makes things easier if you really need to
> > > ensure that one user thread cannot re-use connections created by
> another
> > > user thread.
> > >
> > >
> > The requirement is related to Mutual SSL authentication feature (mainly
> > auth by certificate but also tests that want to put pressure on HTTPS by
> > replaying SSL Handshake).
> > To implement this we need to  Control reuse of cached SSL Context, see:
> > - https.use.cached.ssl.context property
> >
> > Currently in JMeter, as we have 1 HttpClient per user, we are able to
> call
> > without impacting other user:
> >
> >    - httpClient.getConnectionManager().closeIdleConnections(1,
> >    TimeUnit.MICROSECONDS);
> >
> > My understanding of your answer was that if we switch to a shared
> > HttpClient instance doing this would have side effects on other users.
> >
> > So I concluded we needed to stick to 1 HttpClient per Thread/User.
> >
> > Did I misunderstand ?
> >
> > If I did, then I still don't see how we can reset SSL Context for 1 user
> if
> > we have 1 HttpClient per thread/User.
> >
>
> What is your main _design_ objective here? Do you want to generate
> maximum load in terms of requests per second across multiple user
> threads or do you want user threads to represent a single user as
> realistically as possible? If former you should be using one pool of
> connections for all threads / users, if the latter you should be using
> one pool per thread / user.
>
> Oleg
>
>
> IMHO Design objecitve is being realistic while having the best possible
performance.
So now answer is clear :-), seems we willl stick to 1 HttpClient per user.

Thanks a lot for your time and precious help Oleg !!!




-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
On Fri, Jan 23, 2015 at 11:48 PM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Fri, 2015-01-23 at 23:10 +0100, Philippe Mouawad wrote:
> > On Fri, Jan 23, 2015 at 10:00 PM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> > > On Fri, 2015-01-23 at 20:42 +0100, Philippe Mouawad wrote:
> > > > On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <olegk@apache.org
> >
> > > wrote:
> > >
> > > ...
> > >
> > > > > >
> > > > > > > Please note that if JMeter needs to simulate several physical
> users
> > > > > > > having a separate connection pool per distinct user may be the
> > > easiest
> > > > > > > and the most representative strategy.
> > > > > > >
> > > > > >
> > > > > > What is the object to use if it's not 1 HttpClient per user as
> we do
> > > > > today
> > > > > > ?
> > > > > >
> > > > > > PoolingHttpClientConnectionManager does not seem to be the one,
> as if
> > > > > > it's shared among threads, how could we reset it only for 1 user
> ?
> > > > > >
> > > > >
> > > > > You should continue using one HttpClient instance per distinct user
> > > > > either with a pooling or basic connection manager. The only thing
> you
> > > > > might want to customize is changing SSL context initialization from
> > > > > eager to lazy.
> > > > >
> > > > >
> > > > Does it means we are stuck with 1 HttpClient instance per distinct
> user ?
> > > >
> > >
> > > What do you mean by that? You do not have to use one HttpClient
> instance
> > > per distinct user, but it makes things easier if you really need to
> > > ensure that one user thread cannot re-use connections created by
> another
> > > user thread.
> > >
> > >
> > The requirement is related to Mutual SSL authentication feature (mainly
> > auth by certificate but also tests that want to put pressure on HTTPS by
> > replaying SSL Handshake).
> > To implement this we need to  Control reuse of cached SSL Context, see:
> > - https.use.cached.ssl.context property
> >
> > Currently in JMeter, as we have 1 HttpClient per user, we are able to
> call
> > without impacting other user:
> >
> >    - httpClient.getConnectionManager().closeIdleConnections(1,
> >    TimeUnit.MICROSECONDS);
> >
> > My understanding of your answer was that if we switch to a shared
> > HttpClient instance doing this would have side effects on other users.
> >
> > So I concluded we needed to stick to 1 HttpClient per Thread/User.
> >
> > Did I misunderstand ?
> >
> > If I did, then I still don't see how we can reset SSL Context for 1 user
> if
> > we have 1 HttpClient per thread/User.
> >
>
> What is your main _design_ objective here? Do you want to generate
> maximum load in terms of requests per second across multiple user
> threads or do you want user threads to represent a single user as
> realistically as possible? If former you should be using one pool of
> connections for all threads / users, if the latter you should be using
> one pool per thread / user.
>
> Oleg
>
>
> IMHO Design objecitve is being realistic while having the best possible
performance.
So now answer is clear :-), seems we willl stick to 1 HttpClient per user.

Thanks a lot for your time and precious help Oleg !!!




-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2015-01-23 at 23:10 +0100, Philippe Mouawad wrote:
> On Fri, Jan 23, 2015 at 10:00 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> 
> > On Fri, 2015-01-23 at 20:42 +0100, Philippe Mouawad wrote:
> > > On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> > ...
> >
> > > > >
> > > > > > Please note that if JMeter needs to simulate several physical users
> > > > > > having a separate connection pool per distinct user may be the
> > easiest
> > > > > > and the most representative strategy.
> > > > > >
> > > > >
> > > > > What is the object to use if it's not 1 HttpClient per user as we do
> > > > today
> > > > > ?
> > > > >
> > > > > PoolingHttpClientConnectionManager does not seem to be the one, as if
> > > > > it's shared among threads, how could we reset it only for 1 user ?
> > > > >
> > > >
> > > > You should continue using one HttpClient instance per distinct user
> > > > either with a pooling or basic connection manager. The only thing you
> > > > might want to customize is changing SSL context initialization from
> > > > eager to lazy.
> > > >
> > > >
> > > Does it means we are stuck with 1 HttpClient instance per distinct user ?
> > >
> >
> > What do you mean by that? You do not have to use one HttpClient instance
> > per distinct user, but it makes things easier if you really need to
> > ensure that one user thread cannot re-use connections created by another
> > user thread.
> >
> >
> The requirement is related to Mutual SSL authentication feature (mainly
> auth by certificate but also tests that want to put pressure on HTTPS by
> replaying SSL Handshake).
> To implement this we need to  Control reuse of cached SSL Context, see:
> - https.use.cached.ssl.context property
> 
> Currently in JMeter, as we have 1 HttpClient per user, we are able to call
> without impacting other user:
> 
>    - httpClient.getConnectionManager().closeIdleConnections(1,
>    TimeUnit.MICROSECONDS);
> 
> My understanding of your answer was that if we switch to a shared
> HttpClient instance doing this would have side effects on other users.
> 
> So I concluded we needed to stick to 1 HttpClient per Thread/User.
> 
> Did I misunderstand ?
> 
> If I did, then I still don't see how we can reset SSL Context for 1 user if
> we have 1 HttpClient per thread/User.
> 

What is your main _design_ objective here? Do you want to generate
maximum load in terms of requests per second across multiple user
threads or do you want user threads to represent a single user as
realistically as possible? If former you should be using one pool of
connections for all threads / users, if the latter you should be using
one pool per thread / user.

Oleg



Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2015-01-23 at 23:10 +0100, Philippe Mouawad wrote:
> On Fri, Jan 23, 2015 at 10:00 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> 
> > On Fri, 2015-01-23 at 20:42 +0100, Philippe Mouawad wrote:
> > > On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> > ...
> >
> > > > >
> > > > > > Please note that if JMeter needs to simulate several physical users
> > > > > > having a separate connection pool per distinct user may be the
> > easiest
> > > > > > and the most representative strategy.
> > > > > >
> > > > >
> > > > > What is the object to use if it's not 1 HttpClient per user as we do
> > > > today
> > > > > ?
> > > > >
> > > > > PoolingHttpClientConnectionManager does not seem to be the one, as if
> > > > > it's shared among threads, how could we reset it only for 1 user ?
> > > > >
> > > >
> > > > You should continue using one HttpClient instance per distinct user
> > > > either with a pooling or basic connection manager. The only thing you
> > > > might want to customize is changing SSL context initialization from
> > > > eager to lazy.
> > > >
> > > >
> > > Does it means we are stuck with 1 HttpClient instance per distinct user ?
> > >
> >
> > What do you mean by that? You do not have to use one HttpClient instance
> > per distinct user, but it makes things easier if you really need to
> > ensure that one user thread cannot re-use connections created by another
> > user thread.
> >
> >
> The requirement is related to Mutual SSL authentication feature (mainly
> auth by certificate but also tests that want to put pressure on HTTPS by
> replaying SSL Handshake).
> To implement this we need to  Control reuse of cached SSL Context, see:
> - https.use.cached.ssl.context property
> 
> Currently in JMeter, as we have 1 HttpClient per user, we are able to call
> without impacting other user:
> 
>    - httpClient.getConnectionManager().closeIdleConnections(1,
>    TimeUnit.MICROSECONDS);
> 
> My understanding of your answer was that if we switch to a shared
> HttpClient instance doing this would have side effects on other users.
> 
> So I concluded we needed to stick to 1 HttpClient per Thread/User.
> 
> Did I misunderstand ?
> 
> If I did, then I still don't see how we can reset SSL Context for 1 user if
> we have 1 HttpClient per thread/User.
> 

What is your main _design_ objective here? Do you want to generate
maximum load in terms of requests per second across multiple user
threads or do you want user threads to represent a single user as
realistically as possible? If former you should be using one pool of
connections for all threads / users, if the latter you should be using
one pool per thread / user.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
On Fri, Jan 23, 2015 at 10:00 PM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Fri, 2015-01-23 at 20:42 +0100, Philippe Mouawad wrote:
> > On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
>
> ...
>
> > > >
> > > > > Please note that if JMeter needs to simulate several physical users
> > > > > having a separate connection pool per distinct user may be the
> easiest
> > > > > and the most representative strategy.
> > > > >
> > > >
> > > > What is the object to use if it's not 1 HttpClient per user as we do
> > > today
> > > > ?
> > > >
> > > > PoolingHttpClientConnectionManager does not seem to be the one, as if
> > > > it's shared among threads, how could we reset it only for 1 user ?
> > > >
> > >
> > > You should continue using one HttpClient instance per distinct user
> > > either with a pooling or basic connection manager. The only thing you
> > > might want to customize is changing SSL context initialization from
> > > eager to lazy.
> > >
> > >
> > Does it means we are stuck with 1 HttpClient instance per distinct user ?
> >
>
> What do you mean by that? You do not have to use one HttpClient instance
> per distinct user, but it makes things easier if you really need to
> ensure that one user thread cannot re-use connections created by another
> user thread.
>
>
The requirement is related to Mutual SSL authentication feature (mainly
auth by certificate but also tests that want to put pressure on HTTPS by
replaying SSL Handshake).
To implement this we need to  Control reuse of cached SSL Context, see:
- https.use.cached.ssl.context property

Currently in JMeter, as we have 1 HttpClient per user, we are able to call
without impacting other user:

   - httpClient.getConnectionManager().closeIdleConnections(1,
   TimeUnit.MICROSECONDS);

My understanding of your answer was that if we switch to a shared
HttpClient instance doing this would have side effects on other users.

So I concluded we needed to stick to 1 HttpClient per Thread/User.

Did I misunderstand ?

If I did, then I still don't see how we can reset SSL Context for 1 user if
we have 1 HttpClient per thread/User.




> > Regarding eager to lazy, let me be a bit lazy :-), but as you seem to
> know
> > exactly what to do could you point me to the involved classes ?
> > I must reckon I have a lot of work on JMeter so if you can help me
> speedup
> > this It would be great.
> >
>
>
> http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/xref/org/apache/http/conn/socket/LayeredConnectionSocketFactory.html
>
> http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/xref/org/apache/http/conn/ssl/SSLConnectionSocketFactory.html
>

Thanks a lot Oleg.

>
> Oleg
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
On Fri, Jan 23, 2015 at 10:00 PM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Fri, 2015-01-23 at 20:42 +0100, Philippe Mouawad wrote:
> > On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
>
> ...
>
> > > >
> > > > > Please note that if JMeter needs to simulate several physical users
> > > > > having a separate connection pool per distinct user may be the
> easiest
> > > > > and the most representative strategy.
> > > > >
> > > >
> > > > What is the object to use if it's not 1 HttpClient per user as we do
> > > today
> > > > ?
> > > >
> > > > PoolingHttpClientConnectionManager does not seem to be the one, as if
> > > > it's shared among threads, how could we reset it only for 1 user ?
> > > >
> > >
> > > You should continue using one HttpClient instance per distinct user
> > > either with a pooling or basic connection manager. The only thing you
> > > might want to customize is changing SSL context initialization from
> > > eager to lazy.
> > >
> > >
> > Does it means we are stuck with 1 HttpClient instance per distinct user ?
> >
>
> What do you mean by that? You do not have to use one HttpClient instance
> per distinct user, but it makes things easier if you really need to
> ensure that one user thread cannot re-use connections created by another
> user thread.
>
>
The requirement is related to Mutual SSL authentication feature (mainly
auth by certificate but also tests that want to put pressure on HTTPS by
replaying SSL Handshake).
To implement this we need to  Control reuse of cached SSL Context, see:
- https.use.cached.ssl.context property

Currently in JMeter, as we have 1 HttpClient per user, we are able to call
without impacting other user:

   - httpClient.getConnectionManager().closeIdleConnections(1,
   TimeUnit.MICROSECONDS);

My understanding of your answer was that if we switch to a shared
HttpClient instance doing this would have side effects on other users.

So I concluded we needed to stick to 1 HttpClient per Thread/User.

Did I misunderstand ?

If I did, then I still don't see how we can reset SSL Context for 1 user if
we have 1 HttpClient per thread/User.




> > Regarding eager to lazy, let me be a bit lazy :-), but as you seem to
> know
> > exactly what to do could you point me to the involved classes ?
> > I must reckon I have a lot of work on JMeter so if you can help me
> speedup
> > this It would be great.
> >
>
>
> http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/xref/org/apache/http/conn/socket/LayeredConnectionSocketFactory.html
>
> http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/xref/org/apache/http/conn/ssl/SSLConnectionSocketFactory.html
>

Thanks a lot Oleg.

>
> Oleg
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2015-01-23 at 20:42 +0100, Philippe Mouawad wrote:
> On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

...

> > >
> > > > Please note that if JMeter needs to simulate several physical users
> > > > having a separate connection pool per distinct user may be the easiest
> > > > and the most representative strategy.
> > > >
> > >
> > > What is the object to use if it's not 1 HttpClient per user as we do
> > today
> > > ?
> > >
> > > PoolingHttpClientConnectionManager does not seem to be the one, as if
> > > it's shared among threads, how could we reset it only for 1 user ?
> > >
> >
> > You should continue using one HttpClient instance per distinct user
> > either with a pooling or basic connection manager. The only thing you
> > might want to customize is changing SSL context initialization from
> > eager to lazy.
> >
> >
> Does it means we are stuck with 1 HttpClient instance per distinct user ?
> 

What do you mean by that? You do not have to use one HttpClient instance
per distinct user, but it makes things easier if you really need to
ensure that one user thread cannot re-use connections created by another
user thread.

> Regarding eager to lazy, let me be a bit lazy :-), but as you seem to know
> exactly what to do could you point me to the involved classes ?
> I must reckon I have a lot of work on JMeter so if you can help me speedup
> this It would be great.
> 

http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/xref/org/apache/http/conn/socket/LayeredConnectionSocketFactory.html
http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/xref/org/apache/http/conn/ssl/SSLConnectionSocketFactory.html

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2015-01-23 at 20:42 +0100, Philippe Mouawad wrote:
> On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

...

> > >
> > > > Please note that if JMeter needs to simulate several physical users
> > > > having a separate connection pool per distinct user may be the easiest
> > > > and the most representative strategy.
> > > >
> > >
> > > What is the object to use if it's not 1 HttpClient per user as we do
> > today
> > > ?
> > >
> > > PoolingHttpClientConnectionManager does not seem to be the one, as if
> > > it's shared among threads, how could we reset it only for 1 user ?
> > >
> >
> > You should continue using one HttpClient instance per distinct user
> > either with a pooling or basic connection manager. The only thing you
> > might want to customize is changing SSL context initialization from
> > eager to lazy.
> >
> >
> Does it means we are stuck with 1 HttpClient instance per distinct user ?
> 

What do you mean by that? You do not have to use one HttpClient instance
per distinct user, but it makes things easier if you really need to
ensure that one user thread cannot re-use connections created by another
user thread.

> Regarding eager to lazy, let me be a bit lazy :-), but as you seem to know
> exactly what to do could you point me to the involved classes ?
> I must reckon I have a lot of work on JMeter so if you can help me speedup
> this It would be great.
> 

http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/xref/org/apache/http/conn/socket/LayeredConnectionSocketFactory.html
http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/xref/org/apache/http/conn/ssl/SSLConnectionSocketFactory.html

Oleg



Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Mon, 2014-12-29 at 15:15 +0100, Philippe Mouawad wrote:
> > Hi Oleg,
> > Thanks for answers.
> > Clarifications below inline.
> > Regards
> >
>
> Hi Philippe
>
> sorry for such a long delay in answering your message.
>
>
> No problem, I understand you can be busy.


> > > One can force SSL renegotiation by evicting all idle connections from
> > > the connection pool.
> > >
> > Ok, that's good to know, so it means even today it would be better to
> call
> > this instead:
> >
> > httpClient.getConnectionManager().closeIdleConnections(1,
> > TimeUnit.MICROSECONDS);
> >
> >
>
> Yes, it is.
>
Ok will do it.

>
> >
> > > Please note that if JMeter needs to simulate several physical users
> > > having a separate connection pool per distinct user may be the easiest
> > > and the most representative strategy.
> > >
> >
> > What is the object to use if it's not 1 HttpClient per user as we do
> today
> > ?
> >
> > PoolingHttpClientConnectionManager does not seem to be the one, as if
> > it's shared among threads, how could we reset it only for 1 user ?
> >
>
> You should continue using one HttpClient instance per distinct user
> either with a pooling or basic connection manager. The only thing you
> might want to customize is changing SSL context initialization from
> eager to lazy.
>
>
Does it means we are stuck with 1 HttpClient instance per distinct user ?

Regarding eager to lazy, let me be a bit lazy :-), but as you seem to know
exactly what to do could you point me to the involved classes ?
I must reckon I have a lot of work on JMeter so if you can help me speedup
this It would be great.

Thanks in advance
Regards

> Hope this helps
>
> Oleg
>
> >
> > > Cheers
> > >
> > > Oleg
> > >
> > > > Thanks
> > > > Regards
> > > >
> > > > On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <
> olegk@apache.org>
> > > > wrote:
> > > >
> > > > > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > > > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> > > > >
> > > > > ...
> > > > >
> > > > > > >> Issue is not present in HTTPCLient 3.1
> > > > > > >
> > > > > > > Philippe
> > > > > > >
> > > > > > > If HttpClient is used correctly, this code should only be
> executed
> > > only
> > > > > > > once. Why does JMeter create more than one instance of
> HttpClient?
> > > > > >
> > > > > > We currently create an instance for each instance of different
> proxy
> > > > > > settings and each protocol and each authority, because the
> client is
> > > > > > created with these settings.
> > > > > >
> > > > > > This is also done for each thread.
> > > > > >
> > > > > > IIRC, this was necessary originally. We have not rewritten the
> code
> > > > > > yet to use all the latest features.
> > > > > >
> > > > >
> > > > > I see. For the time what you can do is to use a custom SSL socket
> > > > > factory that lazily initializes SSL context when requested for the
> > > first
> > > > > time. This is exactly what HC 3.1 does. It will be somewhat slower
> > > given
> > > > > that one would need to mutex to synchronize access to the
> > > initialization
> > > > > code.
> > > > >
> > > > > Oleg
> > > > >
> > > > > > > Oleg
> > > > > > >
> > > > > >
> > > > > >
> ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail:
> httpclient-users-unsubscribe@hc.apache.org
> > > > > > For additional commands, e-mail:
> httpclient-users-help@hc.apache.org
> > > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
On Fri, Jan 23, 2015 at 6:09 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Mon, 2014-12-29 at 15:15 +0100, Philippe Mouawad wrote:
> > Hi Oleg,
> > Thanks for answers.
> > Clarifications below inline.
> > Regards
> >
>
> Hi Philippe
>
> sorry for such a long delay in answering your message.
>
>
> No problem, I understand you can be busy.


> > > One can force SSL renegotiation by evicting all idle connections from
> > > the connection pool.
> > >
> > Ok, that's good to know, so it means even today it would be better to
> call
> > this instead:
> >
> > httpClient.getConnectionManager().closeIdleConnections(1,
> > TimeUnit.MICROSECONDS);
> >
> >
>
> Yes, it is.
>
Ok will do it.

>
> >
> > > Please note that if JMeter needs to simulate several physical users
> > > having a separate connection pool per distinct user may be the easiest
> > > and the most representative strategy.
> > >
> >
> > What is the object to use if it's not 1 HttpClient per user as we do
> today
> > ?
> >
> > PoolingHttpClientConnectionManager does not seem to be the one, as if
> > it's shared among threads, how could we reset it only for 1 user ?
> >
>
> You should continue using one HttpClient instance per distinct user
> either with a pooling or basic connection manager. The only thing you
> might want to customize is changing SSL context initialization from
> eager to lazy.
>
>
Does it means we are stuck with 1 HttpClient instance per distinct user ?

Regarding eager to lazy, let me be a bit lazy :-), but as you seem to know
exactly what to do could you point me to the involved classes ?
I must reckon I have a lot of work on JMeter so if you can help me speedup
this It would be great.

Thanks in advance
Regards

> Hope this helps
>
> Oleg
>
> >
> > > Cheers
> > >
> > > Oleg
> > >
> > > > Thanks
> > > > Regards
> > > >
> > > > On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <
> olegk@apache.org>
> > > > wrote:
> > > >
> > > > > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > > > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> > > > >
> > > > > ...
> > > > >
> > > > > > >> Issue is not present in HTTPCLient 3.1
> > > > > > >
> > > > > > > Philippe
> > > > > > >
> > > > > > > If HttpClient is used correctly, this code should only be
> executed
> > > only
> > > > > > > once. Why does JMeter create more than one instance of
> HttpClient?
> > > > > >
> > > > > > We currently create an instance for each instance of different
> proxy
> > > > > > settings and each protocol and each authority, because the
> client is
> > > > > > created with these settings.
> > > > > >
> > > > > > This is also done for each thread.
> > > > > >
> > > > > > IIRC, this was necessary originally. We have not rewritten the
> code
> > > > > > yet to use all the latest features.
> > > > > >
> > > > >
> > > > > I see. For the time what you can do is to use a custom SSL socket
> > > > > factory that lazily initializes SSL context when requested for the
> > > first
> > > > > time. This is exactly what HC 3.1 does. It will be somewhat slower
> > > given
> > > > > that one would need to mutex to synchronize access to the
> > > initialization
> > > > > code.
> > > > >
> > > > > Oleg
> > > > >
> > > > > > > Oleg
> > > > > > >
> > > > > >
> > > > > >
> ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail:
> httpclient-users-unsubscribe@hc.apache.org
> > > > > > For additional commands, e-mail:
> httpclient-users-help@hc.apache.org
> > > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2014-12-29 at 15:15 +0100, Philippe Mouawad wrote:
> Hi Oleg,
> Thanks for answers.
> Clarifications below inline.
> Regards
> 

Hi Philippe

sorry for such a long delay in answering your message. 


> > One can force SSL renegotiation by evicting all idle connections from
> > the connection pool.
> >
> Ok, that's good to know, so it means even today it would be better to call
> this instead:
> 
> httpClient.getConnectionManager().closeIdleConnections(1,
> TimeUnit.MICROSECONDS);
> 
> 

Yes, it is.

> 
> > Please note that if JMeter needs to simulate several physical users
> > having a separate connection pool per distinct user may be the easiest
> > and the most representative strategy.
> >
> 
> What is the object to use if it's not 1 HttpClient per user as we do today
> ?
> 
> PoolingHttpClientConnectionManager does not seem to be the one, as if
> it's shared among threads, how could we reset it only for 1 user ?
> 

You should continue using one HttpClient instance per distinct user
either with a pooling or basic connection manager. The only thing you
might want to customize is changing SSL context initialization from
eager to lazy.

Hope this helps

Oleg 

> 
> > Cheers
> >
> > Oleg
> >
> > > Thanks
> > > Regards
> > >
> > > On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> > > wrote:
> > >
> > > > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> > > >
> > > > ...
> > > >
> > > > > >> Issue is not present in HTTPCLient 3.1
> > > > > >
> > > > > > Philippe
> > > > > >
> > > > > > If HttpClient is used correctly, this code should only be executed
> > only
> > > > > > once. Why does JMeter create more than one instance of HttpClient?
> > > > >
> > > > > We currently create an instance for each instance of different proxy
> > > > > settings and each protocol and each authority, because the client is
> > > > > created with these settings.
> > > > >
> > > > > This is also done for each thread.
> > > > >
> > > > > IIRC, this was necessary originally. We have not rewritten the code
> > > > > yet to use all the latest features.
> > > > >
> > > >
> > > > I see. For the time what you can do is to use a custom SSL socket
> > > > factory that lazily initializes SSL context when requested for the
> > first
> > > > time. This is exactly what HC 3.1 does. It will be somewhat slower
> > given
> > > > that one would need to mutex to synchronize access to the
> > initialization
> > > > code.
> > > >
> > > > Oleg
> > > >
> > > > > > Oleg
> > > > > >
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > > > >
> > > >
> > > >
> > > >
> >
> >
> >
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2014-12-29 at 15:15 +0100, Philippe Mouawad wrote:
> Hi Oleg,
> Thanks for answers.
> Clarifications below inline.
> Regards
> 

Hi Philippe

sorry for such a long delay in answering your message. 


> > One can force SSL renegotiation by evicting all idle connections from
> > the connection pool.
> >
> Ok, that's good to know, so it means even today it would be better to call
> this instead:
> 
> httpClient.getConnectionManager().closeIdleConnections(1,
> TimeUnit.MICROSECONDS);
> 
> 

Yes, it is.

> 
> > Please note that if JMeter needs to simulate several physical users
> > having a separate connection pool per distinct user may be the easiest
> > and the most representative strategy.
> >
> 
> What is the object to use if it's not 1 HttpClient per user as we do today
> ?
> 
> PoolingHttpClientConnectionManager does not seem to be the one, as if
> it's shared among threads, how could we reset it only for 1 user ?
> 

You should continue using one HttpClient instance per distinct user
either with a pooling or basic connection manager. The only thing you
might want to customize is changing SSL context initialization from
eager to lazy.

Hope this helps

Oleg 

> 
> > Cheers
> >
> > Oleg
> >
> > > Thanks
> > > Regards
> > >
> > > On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> > > wrote:
> > >
> > > > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> > > >
> > > > ...
> > > >
> > > > > >> Issue is not present in HTTPCLient 3.1
> > > > > >
> > > > > > Philippe
> > > > > >
> > > > > > If HttpClient is used correctly, this code should only be executed
> > only
> > > > > > once. Why does JMeter create more than one instance of HttpClient?
> > > > >
> > > > > We currently create an instance for each instance of different proxy
> > > > > settings and each protocol and each authority, because the client is
> > > > > created with these settings.
> > > > >
> > > > > This is also done for each thread.
> > > > >
> > > > > IIRC, this was necessary originally. We have not rewritten the code
> > > > > yet to use all the latest features.
> > > > >
> > > >
> > > > I see. For the time what you can do is to use a custom SSL socket
> > > > factory that lazily initializes SSL context when requested for the
> > first
> > > > time. This is exactly what HC 3.1 does. It will be somewhat slower
> > given
> > > > that one would need to mutex to synchronize access to the
> > initialization
> > > > code.
> > > >
> > > > Oleg
> > > >
> > > > > > Oleg
> > > > > >
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > > > >
> > > >
> > > >
> > > >
> >
> >
> >
> 
> 



Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg, Users,
I am pinging again on my questions.

As I didn't get any answer I am wondering if my questions here are stupid
or if you didn't have time to answer yet (which I can quite understand :-)
).
If they are stupid :-) , let me know so that I can scratch my head a bit
more.

Thanks a lot for your time and help.
Regards

On Mon, Dec 29, 2014 at 3:15 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi Oleg,
> Thanks for answers.
> Clarifications below inline.
> Regards
>
> On Mon, Dec 29, 2014 at 10:04 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
>
>> On Sun, 2014-12-28 at 22:09 +0100, Philippe Mouawad wrote:
>> > Hi,
>> > Related to this topic, once we switch to 1 instance of HttpClient
>> shared by
>> > all threads, how can we reset SSLContext ?
>> > We need this feature within jmeter to simulate SSL handshake per client
>> ,
>> > we currently do :
>> > httpClient.getConnectionManager().shutdown();
>> > Which by the way is rather very inefficient way to do this.
>> >
>>
>> What do you mean by resetting SSLContext, changing some SSL handshake
>> parameters?
>>
> In JMeter, when we want to simulate Client certicate authentication, we
> currently "reset" SSL Context by calling  httpClient.getConnectionManager().shutdown();
> in order to reproduce the SSL renegociation:
>
> https://github.com/apache/jmeter/blob/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> See lines 630 to 638.
>
>
>> One can force SSL renegotiation by evicting all idle connections from
>> the connection pool.
>>
> Ok, that's good to know, so it means even today it would be better to call
> this instead:
>
> httpClient.getConnectionManager().closeIdleConnections(1, TimeUnit.MICROSECONDS);
>
>
>
>> Please note that if JMeter needs to simulate several physical users
>> having a separate connection pool per distinct user may be the easiest
>> and the most representative strategy.
>>
>
> What is the object to use if it's not 1 HttpClient per user as we do today
> ?
>
> PoolingHttpClientConnectionManager does not seem to be the one, as if it's shared among threads, how could we reset it only for 1 user ?
>
>
>> Cheers
>>
>> Oleg
>>
>> > Thanks
>> > Regards
>> >
>> > On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
>> > wrote:
>> >
>> > > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
>> > > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>> > >
>> > > ...
>> > >
>> > > > >> Issue is not present in HTTPCLient 3.1
>> > > > >
>> > > > > Philippe
>> > > > >
>> > > > > If HttpClient is used correctly, this code should only be
>> executed only
>> > > > > once. Why does JMeter create more than one instance of HttpClient?
>> > > >
>> > > > We currently create an instance for each instance of different proxy
>> > > > settings and each protocol and each authority, because the client is
>> > > > created with these settings.
>> > > >
>> > > > This is also done for each thread.
>> > > >
>> > > > IIRC, this was necessary originally. We have not rewritten the code
>> > > > yet to use all the latest features.
>> > > >
>> > >
>> > > I see. For the time what you can do is to use a custom SSL socket
>> > > factory that lazily initializes SSL context when requested for the
>> first
>> > > time. This is exactly what HC 3.1 does. It will be somewhat slower
>> given
>> > > that one would need to mutex to synchronize access to the
>> initialization
>> > > code.
>> > >
>> > > Oleg
>> > >
>> > > > > Oleg
>> > > > >
>> > > >
>> > > >
>> ---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > > > For additional commands, e-mail:
>> httpclient-users-help@hc.apache.org
>> > > >
>> > >
>> > >
>> > >
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg,
Thanks for answers.
Clarifications below inline.
Regards

On Mon, Dec 29, 2014 at 10:04 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Sun, 2014-12-28 at 22:09 +0100, Philippe Mouawad wrote:
> > Hi,
> > Related to this topic, once we switch to 1 instance of HttpClient shared
> by
> > all threads, how can we reset SSLContext ?
> > We need this feature within jmeter to simulate SSL handshake per client ,
> > we currently do :
> > httpClient.getConnectionManager().shutdown();
> > Which by the way is rather very inefficient way to do this.
> >
>
> What do you mean by resetting SSLContext, changing some SSL handshake
> parameters?
>
In JMeter, when we want to simulate Client certicate authentication, we
currently "reset" SSL Context by calling
httpClient.getConnectionManager().shutdown();
in order to reproduce the SSL renegociation:
https://github.com/apache/jmeter/blob/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
See lines 630 to 638.


> One can force SSL renegotiation by evicting all idle connections from
> the connection pool.
>
Ok, that's good to know, so it means even today it would be better to call
this instead:

httpClient.getConnectionManager().closeIdleConnections(1,
TimeUnit.MICROSECONDS);



> Please note that if JMeter needs to simulate several physical users
> having a separate connection pool per distinct user may be the easiest
> and the most representative strategy.
>

What is the object to use if it's not 1 HttpClient per user as we do today
?

PoolingHttpClientConnectionManager does not seem to be the one, as if
it's shared among threads, how could we reset it only for 1 user ?


> Cheers
>
> Oleg
>
> > Thanks
> > Regards
> >
> > On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> > > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> > >
> > > ...
> > >
> > > > >> Issue is not present in HTTPCLient 3.1
> > > > >
> > > > > Philippe
> > > > >
> > > > > If HttpClient is used correctly, this code should only be executed
> only
> > > > > once. Why does JMeter create more than one instance of HttpClient?
> > > >
> > > > We currently create an instance for each instance of different proxy
> > > > settings and each protocol and each authority, because the client is
> > > > created with these settings.
> > > >
> > > > This is also done for each thread.
> > > >
> > > > IIRC, this was necessary originally. We have not rewritten the code
> > > > yet to use all the latest features.
> > > >
> > >
> > > I see. For the time what you can do is to use a custom SSL socket
> > > factory that lazily initializes SSL context when requested for the
> first
> > > time. This is exactly what HC 3.1 does. It will be somewhat slower
> given
> > > that one would need to mutex to synchronize access to the
> initialization
> > > code.
> > >
> > > Oleg
> > >
> > > > > Oleg
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > > >
> > >
> > >
> > >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg,
Thanks for answers.
Clarifications below inline.
Regards

On Mon, Dec 29, 2014 at 10:04 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Sun, 2014-12-28 at 22:09 +0100, Philippe Mouawad wrote:
> > Hi,
> > Related to this topic, once we switch to 1 instance of HttpClient shared
> by
> > all threads, how can we reset SSLContext ?
> > We need this feature within jmeter to simulate SSL handshake per client ,
> > we currently do :
> > httpClient.getConnectionManager().shutdown();
> > Which by the way is rather very inefficient way to do this.
> >
>
> What do you mean by resetting SSLContext, changing some SSL handshake
> parameters?
>
In JMeter, when we want to simulate Client certicate authentication, we
currently "reset" SSL Context by calling
httpClient.getConnectionManager().shutdown();
in order to reproduce the SSL renegociation:
https://github.com/apache/jmeter/blob/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
See lines 630 to 638.


> One can force SSL renegotiation by evicting all idle connections from
> the connection pool.
>
Ok, that's good to know, so it means even today it would be better to call
this instead:

httpClient.getConnectionManager().closeIdleConnections(1,
TimeUnit.MICROSECONDS);



> Please note that if JMeter needs to simulate several physical users
> having a separate connection pool per distinct user may be the easiest
> and the most representative strategy.
>

What is the object to use if it's not 1 HttpClient per user as we do today
?

PoolingHttpClientConnectionManager does not seem to be the one, as if
it's shared among threads, how could we reset it only for 1 user ?


> Cheers
>
> Oleg
>
> > Thanks
> > Regards
> >
> > On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> > > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> > >
> > > ...
> > >
> > > > >> Issue is not present in HTTPCLient 3.1
> > > > >
> > > > > Philippe
> > > > >
> > > > > If HttpClient is used correctly, this code should only be executed
> only
> > > > > once. Why does JMeter create more than one instance of HttpClient?
> > > >
> > > > We currently create an instance for each instance of different proxy
> > > > settings and each protocol and each authority, because the client is
> > > > created with these settings.
> > > >
> > > > This is also done for each thread.
> > > >
> > > > IIRC, this was necessary originally. We have not rewritten the code
> > > > yet to use all the latest features.
> > > >
> > >
> > > I see. For the time what you can do is to use a custom SSL socket
> > > factory that lazily initializes SSL context when requested for the
> first
> > > time. This is exactly what HC 3.1 does. It will be somewhat slower
> given
> > > that one would need to mutex to synchronize access to the
> initialization
> > > code.
> > >
> > > Oleg
> > >
> > > > > Oleg
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > > >
> > >
> > >
> > >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sun, 2014-12-28 at 22:09 +0100, Philippe Mouawad wrote:
> Hi,
> Related to this topic, once we switch to 1 instance of HttpClient shared by
> all threads, how can we reset SSLContext ?
> We need this feature within jmeter to simulate SSL handshake per client ,
> we currently do :
> httpClient.getConnectionManager().shutdown();
> Which by the way is rather very inefficient way to do this.
> 

What do you mean by resetting SSLContext, changing some SSL handshake
parameters? 

One can force SSL renegotiation by evicting all idle connections from
the connection pool. 

Please note that if JMeter needs to simulate several physical users
having a separate connection pool per distinct user may be the easiest
and the most representative strategy.

Cheers

Oleg 

> Thanks
> Regards
> 
> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> 
> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> >
> > ...
> >
> > > >> Issue is not present in HTTPCLient 3.1
> > > >
> > > > Philippe
> > > >
> > > > If HttpClient is used correctly, this code should only be executed only
> > > > once. Why does JMeter create more than one instance of HttpClient?
> > >
> > > We currently create an instance for each instance of different proxy
> > > settings and each protocol and each authority, because the client is
> > > created with these settings.
> > >
> > > This is also done for each thread.
> > >
> > > IIRC, this was necessary originally. We have not rewritten the code
> > > yet to use all the latest features.
> > >
> >
> > I see. For the time what you can do is to use a custom SSL socket
> > factory that lazily initializes SSL context when requested for the first
> > time. This is exactly what HC 3.1 does. It will be somewhat slower given
> > that one would need to mutex to synchronize access to the initialization
> > code.
> >
> > Oleg
> >
> > > > Oleg
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > >
> >
> >
> >



Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sun, 2014-12-28 at 22:09 +0100, Philippe Mouawad wrote:
> Hi,
> Related to this topic, once we switch to 1 instance of HttpClient shared by
> all threads, how can we reset SSLContext ?
> We need this feature within jmeter to simulate SSL handshake per client ,
> we currently do :
> httpClient.getConnectionManager().shutdown();
> Which by the way is rather very inefficient way to do this.
> 

What do you mean by resetting SSLContext, changing some SSL handshake
parameters? 

One can force SSL renegotiation by evicting all idle connections from
the connection pool. 

Please note that if JMeter needs to simulate several physical users
having a separate connection pool per distinct user may be the easiest
and the most representative strategy.

Cheers

Oleg 

> Thanks
> Regards
> 
> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> 
> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> >
> > ...
> >
> > > >> Issue is not present in HTTPCLient 3.1
> > > >
> > > > Philippe
> > > >
> > > > If HttpClient is used correctly, this code should only be executed only
> > > > once. Why does JMeter create more than one instance of HttpClient?
> > >
> > > We currently create an instance for each instance of different proxy
> > > settings and each protocol and each authority, because the client is
> > > created with these settings.
> > >
> > > This is also done for each thread.
> > >
> > > IIRC, this was necessary originally. We have not rewritten the code
> > > yet to use all the latest features.
> > >
> >
> > I see. For the time what you can do is to use a custom SSL socket
> > factory that lazily initializes SSL context when requested for the first
> > time. This is exactly what HC 3.1 does. It will be somewhat slower given
> > that one would need to mutex to synchronize access to the initialization
> > code.
> >
> > Oleg
> >
> > > > Oleg
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > >
> >
> >
> >



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
Related to this topic, once we switch to 1 instance of HttpClient shared by
all threads, how can we reset SSLContext ?
We need this feature within jmeter to simulate SSL handshake per client ,
we currently do :
httpClient.getConnectionManager().shutdown();
Which by the way is rather very inefficient way to do this.

Thanks
Regards

On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> ...
>
> > >> Issue is not present in HTTPCLient 3.1
> > >
> > > Philippe
> > >
> > > If HttpClient is used correctly, this code should only be executed only
> > > once. Why does JMeter create more than one instance of HttpClient?
> >
> > We currently create an instance for each instance of different proxy
> > settings and each protocol and each authority, because the client is
> > created with these settings.
> >
> > This is also done for each thread.
> >
> > IIRC, this was necessary originally. We have not rewritten the code
> > yet to use all the latest features.
> >
>
> I see. For the time what you can do is to use a custom SSL socket
> factory that lazily initializes SSL context when requested for the first
> time. This is exactly what HC 3.1 does. It will be somewhat slower given
> that one would need to mutex to synchronize access to the initialization
> code.
>
> Oleg
>
> > > Oleg
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
>
>
>

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
Related to this topic, once we switch to 1 instance of HttpClient shared by
all threads, how can we reset SSLContext ?
We need this feature within jmeter to simulate SSL handshake per client ,
we currently do :
httpClient.getConnectionManager().shutdown();
Which by the way is rather very inefficient way to do this.

Thanks
Regards

On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> ...
>
> > >> Issue is not present in HTTPCLient 3.1
> > >
> > > Philippe
> > >
> > > If HttpClient is used correctly, this code should only be executed only
> > > once. Why does JMeter create more than one instance of HttpClient?
> >
> > We currently create an instance for each instance of different proxy
> > settings and each protocol and each authority, because the client is
> > created with these settings.
> >
> > This is also done for each thread.
> >
> > IIRC, this was necessary originally. We have not rewritten the code
> > yet to use all the latest features.
> >
>
> I see. For the time what you can do is to use a custom SSL socket
> factory that lazily initializes SSL context when requested for the first
> time. This is exactly what HC 3.1 does. It will be somewhat slower given
> that one would need to mutex to synchronize access to the initialization
> code.
>
> Oleg
>
> > > Oleg
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
>
>
>

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by UBIK LOAD PACK Support <su...@ubikloadpack.com>.
Hi Oleg,
Is there some sample somewhere showing how to implement this ?

Thanks
Regards
@ubikloadpack
On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> ...
>
> > >> Issue is not present in HTTPCLient 3.1
> > >
> > > Philippe
> > >
> > > If HttpClient is used correctly, this code should only be executed only
> > > once. Why does JMeter create more than one instance of HttpClient?
> >
> > We currently create an instance for each instance of different proxy
> > settings and each protocol and each authority, because the client is
> > created with these settings.
> >
> > This is also done for each thread.
> >
> > IIRC, this was necessary originally. We have not rewritten the code
> > yet to use all the latest features.
> >
>
> I see. For the time what you can do is to use a custom SSL socket
> factory that lazily initializes SSL context when requested for the first
> time. This is exactly what HC 3.1 does. It will be somewhat slower given
> that one would need to mutex to synchronize access to the initialization
> code.
>
> Oleg
>
> > > Oleg
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
>
>
>

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello,
For information on a test plan with following configuration (15 threads, 5
minutes run) we make 138% more samples with 3.0 than with 2.13 thanks to
fixing of https://bz.apache.org/bugzilla/show_bug.cgi?id=58099.
The gain is due to the non init of SSL Context when only HTTP is used.
Maybe including this in HttpClient should be reconsidered.

Regards
Philippe

On Wed, Feb 17, 2016 at 7:47 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hello,
> I think I have fixed the issue in JMeter, I attached patch to:
> - https://bz.apache.org/bugzilla/show_bug.cgi?id=58099
>
> Reviews and feedback very welcome.
> Regards
>
> On Tue, Jan 5, 2016 at 3:05 PM, sebb <se...@gmail.com> wrote:
>
>> On 22 December 2015 at 08:36, Oleg Kalnichevski <ol...@apache.org> wrote:
>> > On Sun, 2015-12-20 at 22:44 +0100, Philippe Mouawad wrote:
>> >> Hi Oleg,
>> >> Back to this old subject and knowing that we must stick to 1
>> HttpClient per
>> >> thread (as per all the discussion that followed this).
>> >> Is there a plan to implement this lazy init of SSLContext in
>> HttpClient as
>> >> it used to be the case in HC3 ?
>> >>
>> >> For our project, it's a killer in terms of performance, and for other
>> use
>> >> cases, it appears kind of weird that an SSLContext is initialized even
>> for
>> >> a pure HTTP traffic.
>> >>
>> >
>> > Given that HttpClient instance should be initialized only once, eager
>> > initialization of the SSLContext looks reasonable to me.
>>
>> AFAICT there are lots of ways to configure the HttpClient instance by
>> using HttpClientBuilder or HttpClients.
>> So I don't understand why you say that the HttpClient instance should
>> only be initialised once.
>>
>> > One, of course, can make SSL initialization lazy by using a custom
>> > connection socket factory with SSLContext initialized on demand.
>> >
>> > Hope this helps
>> >
>> > Oleg
>> >
>> >> Thanks
>> >> Regards
>> >>
>> >>
>> >>
>> >> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
>> >> wrote:
>> >>
>> >> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
>> >> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>> >> >
>> >> > ...
>> >> >
>> >> > > >> Issue is not present in HTTPCLient 3.1
>> >> > > >
>> >> > > > Philippe
>> >> > > >
>> >> > > > If HttpClient is used correctly, this code should only be
>> executed only
>> >> > > > once. Why does JMeter create more than one instance of
>> HttpClient?
>> >> > >
>> >> > > We currently create an instance for each instance of different
>> proxy
>> >> > > settings and each protocol and each authority, because the client
>> is
>> >> > > created with these settings.
>> >> > >
>> >> > > This is also done for each thread.
>> >> > >
>> >> > > IIRC, this was necessary originally. We have not rewritten the code
>> >> > > yet to use all the latest features.
>> >> > >
>> >> >
>> >> > I see. For the time what you can do is to use a custom SSL socket
>> >> > factory that lazily initializes SSL context when requested for the
>> first
>> >> > time. This is exactly what HC 3.1 does. It will be somewhat slower
>> given
>> >> > that one would need to mutex to synchronize access to the
>> initialization
>> >> > code.
>> >> >
>> >> > Oleg
>> >> >
>> >> > > > Oleg
>> >> > > >
>> >> > >
>> >> > >
>> ---------------------------------------------------------------------
>> >> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> >> > > For additional commands, e-mail:
>> httpclient-users-help@hc.apache.org
>> >> > >
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello,
For information on a test plan with following configuration (15 threads, 5
minutes run) we make 138% more samples with 3.0 than with 2.13 thanks to
fixing of https://bz.apache.org/bugzilla/show_bug.cgi?id=58099.
The gain is due to the non init of SSL Context when only HTTP is used.
Maybe including this in HttpClient should be reconsidered.

Regards
Philippe

On Wed, Feb 17, 2016 at 7:47 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hello,
> I think I have fixed the issue in JMeter, I attached patch to:
> - https://bz.apache.org/bugzilla/show_bug.cgi?id=58099
>
> Reviews and feedback very welcome.
> Regards
>
> On Tue, Jan 5, 2016 at 3:05 PM, sebb <se...@gmail.com> wrote:
>
>> On 22 December 2015 at 08:36, Oleg Kalnichevski <ol...@apache.org> wrote:
>> > On Sun, 2015-12-20 at 22:44 +0100, Philippe Mouawad wrote:
>> >> Hi Oleg,
>> >> Back to this old subject and knowing that we must stick to 1
>> HttpClient per
>> >> thread (as per all the discussion that followed this).
>> >> Is there a plan to implement this lazy init of SSLContext in
>> HttpClient as
>> >> it used to be the case in HC3 ?
>> >>
>> >> For our project, it's a killer in terms of performance, and for other
>> use
>> >> cases, it appears kind of weird that an SSLContext is initialized even
>> for
>> >> a pure HTTP traffic.
>> >>
>> >
>> > Given that HttpClient instance should be initialized only once, eager
>> > initialization of the SSLContext looks reasonable to me.
>>
>> AFAICT there are lots of ways to configure the HttpClient instance by
>> using HttpClientBuilder or HttpClients.
>> So I don't understand why you say that the HttpClient instance should
>> only be initialised once.
>>
>> > One, of course, can make SSL initialization lazy by using a custom
>> > connection socket factory with SSLContext initialized on demand.
>> >
>> > Hope this helps
>> >
>> > Oleg
>> >
>> >> Thanks
>> >> Regards
>> >>
>> >>
>> >>
>> >> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
>> >> wrote:
>> >>
>> >> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
>> >> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>> >> >
>> >> > ...
>> >> >
>> >> > > >> Issue is not present in HTTPCLient 3.1
>> >> > > >
>> >> > > > Philippe
>> >> > > >
>> >> > > > If HttpClient is used correctly, this code should only be
>> executed only
>> >> > > > once. Why does JMeter create more than one instance of
>> HttpClient?
>> >> > >
>> >> > > We currently create an instance for each instance of different
>> proxy
>> >> > > settings and each protocol and each authority, because the client
>> is
>> >> > > created with these settings.
>> >> > >
>> >> > > This is also done for each thread.
>> >> > >
>> >> > > IIRC, this was necessary originally. We have not rewritten the code
>> >> > > yet to use all the latest features.
>> >> > >
>> >> >
>> >> > I see. For the time what you can do is to use a custom SSL socket
>> >> > factory that lazily initializes SSL context when requested for the
>> first
>> >> > time. This is exactly what HC 3.1 does. It will be somewhat slower
>> given
>> >> > that one would need to mutex to synchronize access to the
>> initialization
>> >> > code.
>> >> >
>> >> > Oleg
>> >> >
>> >> > > > Oleg
>> >> > > >
>> >> > >
>> >> > >
>> ---------------------------------------------------------------------
>> >> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> >> > > For additional commands, e-mail:
>> httpclient-users-help@hc.apache.org
>> >> > >
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello,
I think I have fixed the issue in JMeter, I attached patch to:
- https://bz.apache.org/bugzilla/show_bug.cgi?id=58099

Reviews and feedback very welcome.
Regards

On Tue, Jan 5, 2016 at 3:05 PM, sebb <se...@gmail.com> wrote:

> On 22 December 2015 at 08:36, Oleg Kalnichevski <ol...@apache.org> wrote:
> > On Sun, 2015-12-20 at 22:44 +0100, Philippe Mouawad wrote:
> >> Hi Oleg,
> >> Back to this old subject and knowing that we must stick to 1 HttpClient
> per
> >> thread (as per all the discussion that followed this).
> >> Is there a plan to implement this lazy init of SSLContext in HttpClient
> as
> >> it used to be the case in HC3 ?
> >>
> >> For our project, it's a killer in terms of performance, and for other
> use
> >> cases, it appears kind of weird that an SSLContext is initialized even
> for
> >> a pure HTTP traffic.
> >>
> >
> > Given that HttpClient instance should be initialized only once, eager
> > initialization of the SSLContext looks reasonable to me.
>
> AFAICT there are lots of ways to configure the HttpClient instance by
> using HttpClientBuilder or HttpClients.
> So I don't understand why you say that the HttpClient instance should
> only be initialised once.
>
> > One, of course, can make SSL initialization lazy by using a custom
> > connection socket factory with SSLContext initialized on demand.
> >
> > Hope this helps
> >
> > Oleg
> >
> >> Thanks
> >> Regards
> >>
> >>
> >>
> >> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> >> wrote:
> >>
> >> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> >> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> >> >
> >> > ...
> >> >
> >> > > >> Issue is not present in HTTPCLient 3.1
> >> > > >
> >> > > > Philippe
> >> > > >
> >> > > > If HttpClient is used correctly, this code should only be
> executed only
> >> > > > once. Why does JMeter create more than one instance of HttpClient?
> >> > >
> >> > > We currently create an instance for each instance of different proxy
> >> > > settings and each protocol and each authority, because the client is
> >> > > created with these settings.
> >> > >
> >> > > This is also done for each thread.
> >> > >
> >> > > IIRC, this was necessary originally. We have not rewritten the code
> >> > > yet to use all the latest features.
> >> > >
> >> >
> >> > I see. For the time what you can do is to use a custom SSL socket
> >> > factory that lazily initializes SSL context when requested for the
> first
> >> > time. This is exactly what HC 3.1 does. It will be somewhat slower
> given
> >> > that one would need to mutex to synchronize access to the
> initialization
> >> > code.
> >> >
> >> > Oleg
> >> >
> >> > > > Oleg
> >> > > >
> >> > >
> >> > >
> ---------------------------------------------------------------------
> >> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >> > > For additional commands, e-mail:
> httpclient-users-help@hc.apache.org
> >> > >
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
>



-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello,
I think I have fixed the issue in JMeter, I attached patch to:
- https://bz.apache.org/bugzilla/show_bug.cgi?id=58099

Reviews and feedback very welcome.
Regards

On Tue, Jan 5, 2016 at 3:05 PM, sebb <se...@gmail.com> wrote:

> On 22 December 2015 at 08:36, Oleg Kalnichevski <ol...@apache.org> wrote:
> > On Sun, 2015-12-20 at 22:44 +0100, Philippe Mouawad wrote:
> >> Hi Oleg,
> >> Back to this old subject and knowing that we must stick to 1 HttpClient
> per
> >> thread (as per all the discussion that followed this).
> >> Is there a plan to implement this lazy init of SSLContext in HttpClient
> as
> >> it used to be the case in HC3 ?
> >>
> >> For our project, it's a killer in terms of performance, and for other
> use
> >> cases, it appears kind of weird that an SSLContext is initialized even
> for
> >> a pure HTTP traffic.
> >>
> >
> > Given that HttpClient instance should be initialized only once, eager
> > initialization of the SSLContext looks reasonable to me.
>
> AFAICT there are lots of ways to configure the HttpClient instance by
> using HttpClientBuilder or HttpClients.
> So I don't understand why you say that the HttpClient instance should
> only be initialised once.
>
> > One, of course, can make SSL initialization lazy by using a custom
> > connection socket factory with SSLContext initialized on demand.
> >
> > Hope this helps
> >
> > Oleg
> >
> >> Thanks
> >> Regards
> >>
> >>
> >>
> >> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> >> wrote:
> >>
> >> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> >> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> >> >
> >> > ...
> >> >
> >> > > >> Issue is not present in HTTPCLient 3.1
> >> > > >
> >> > > > Philippe
> >> > > >
> >> > > > If HttpClient is used correctly, this code should only be
> executed only
> >> > > > once. Why does JMeter create more than one instance of HttpClient?
> >> > >
> >> > > We currently create an instance for each instance of different proxy
> >> > > settings and each protocol and each authority, because the client is
> >> > > created with these settings.
> >> > >
> >> > > This is also done for each thread.
> >> > >
> >> > > IIRC, this was necessary originally. We have not rewritten the code
> >> > > yet to use all the latest features.
> >> > >
> >> >
> >> > I see. For the time what you can do is to use a custom SSL socket
> >> > factory that lazily initializes SSL context when requested for the
> first
> >> > time. This is exactly what HC 3.1 does. It will be somewhat slower
> given
> >> > that one would need to mutex to synchronize access to the
> initialization
> >> > code.
> >> >
> >> > Oleg
> >> >
> >> > > > Oleg
> >> > > >
> >> > >
> >> > >
> ---------------------------------------------------------------------
> >> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >> > > For additional commands, e-mail:
> httpclient-users-help@hc.apache.org
> >> > >
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
>



-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by sebb <se...@gmail.com>.
On 22 December 2015 at 08:36, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Sun, 2015-12-20 at 22:44 +0100, Philippe Mouawad wrote:
>> Hi Oleg,
>> Back to this old subject and knowing that we must stick to 1 HttpClient per
>> thread (as per all the discussion that followed this).
>> Is there a plan to implement this lazy init of SSLContext in HttpClient as
>> it used to be the case in HC3 ?
>>
>> For our project, it's a killer in terms of performance, and for other use
>> cases, it appears kind of weird that an SSLContext is initialized even for
>> a pure HTTP traffic.
>>
>
> Given that HttpClient instance should be initialized only once, eager
> initialization of the SSLContext looks reasonable to me.

AFAICT there are lots of ways to configure the HttpClient instance by
using HttpClientBuilder or HttpClients.
So I don't understand why you say that the HttpClient instance should
only be initialised once.

> One, of course, can make SSL initialization lazy by using a custom
> connection socket factory with SSLContext initialized on demand.
>
> Hope this helps
>
> Oleg
>
>> Thanks
>> Regards
>>
>>
>>
>> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>>
>> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
>> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>> >
>> > ...
>> >
>> > > >> Issue is not present in HTTPCLient 3.1
>> > > >
>> > > > Philippe
>> > > >
>> > > > If HttpClient is used correctly, this code should only be executed only
>> > > > once. Why does JMeter create more than one instance of HttpClient?
>> > >
>> > > We currently create an instance for each instance of different proxy
>> > > settings and each protocol and each authority, because the client is
>> > > created with these settings.
>> > >
>> > > This is also done for each thread.
>> > >
>> > > IIRC, this was necessary originally. We have not rewritten the code
>> > > yet to use all the latest features.
>> > >
>> >
>> > I see. For the time what you can do is to use a custom SSL socket
>> > factory that lazily initializes SSL context when requested for the first
>> > time. This is exactly what HC 3.1 does. It will be somewhat slower given
>> > that one would need to mutex to synchronize access to the initialization
>> > code.
>> >
>> > Oleg
>> >
>> > > > Oleg
>> > > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> > >
>> >
>> >
>> >
>>
>>
>
>

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by sebb <se...@gmail.com>.
On 22 December 2015 at 08:36, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Sun, 2015-12-20 at 22:44 +0100, Philippe Mouawad wrote:
>> Hi Oleg,
>> Back to this old subject and knowing that we must stick to 1 HttpClient per
>> thread (as per all the discussion that followed this).
>> Is there a plan to implement this lazy init of SSLContext in HttpClient as
>> it used to be the case in HC3 ?
>>
>> For our project, it's a killer in terms of performance, and for other use
>> cases, it appears kind of weird that an SSLContext is initialized even for
>> a pure HTTP traffic.
>>
>
> Given that HttpClient instance should be initialized only once, eager
> initialization of the SSLContext looks reasonable to me.

AFAICT there are lots of ways to configure the HttpClient instance by
using HttpClientBuilder or HttpClients.
So I don't understand why you say that the HttpClient instance should
only be initialised once.

> One, of course, can make SSL initialization lazy by using a custom
> connection socket factory with SSLContext initialized on demand.
>
> Hope this helps
>
> Oleg
>
>> Thanks
>> Regards
>>
>>
>>
>> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>>
>> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
>> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>> >
>> > ...
>> >
>> > > >> Issue is not present in HTTPCLient 3.1
>> > > >
>> > > > Philippe
>> > > >
>> > > > If HttpClient is used correctly, this code should only be executed only
>> > > > once. Why does JMeter create more than one instance of HttpClient?
>> > >
>> > > We currently create an instance for each instance of different proxy
>> > > settings and each protocol and each authority, because the client is
>> > > created with these settings.
>> > >
>> > > This is also done for each thread.
>> > >
>> > > IIRC, this was necessary originally. We have not rewritten the code
>> > > yet to use all the latest features.
>> > >
>> >
>> > I see. For the time what you can do is to use a custom SSL socket
>> > factory that lazily initializes SSL context when requested for the first
>> > time. This is exactly what HC 3.1 does. It will be somewhat slower given
>> > that one would need to mutex to synchronize access to the initialization
>> > code.
>> >
>> > Oleg
>> >
>> > > > Oleg
>> > > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> > >
>> >
>> >
>> >
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sun, 2015-12-20 at 22:44 +0100, Philippe Mouawad wrote:
> Hi Oleg,
> Back to this old subject and knowing that we must stick to 1 HttpClient per
> thread (as per all the discussion that followed this).
> Is there a plan to implement this lazy init of SSLContext in HttpClient as
> it used to be the case in HC3 ?
> 
> For our project, it's a killer in terms of performance, and for other use
> cases, it appears kind of weird that an SSLContext is initialized even for
> a pure HTTP traffic.
> 

Given that HttpClient instance should be initialized only once, eager
initialization of the SSLContext looks reasonable to me.

One, of course, can make SSL initialization lazy by using a custom
connection socket factory with SSLContext initialized on demand.

Hope this helps

Oleg

> Thanks
> Regards
> 
> 
> 
> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> 
> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> >
> > ...
> >
> > > >> Issue is not present in HTTPCLient 3.1
> > > >
> > > > Philippe
> > > >
> > > > If HttpClient is used correctly, this code should only be executed only
> > > > once. Why does JMeter create more than one instance of HttpClient?
> > >
> > > We currently create an instance for each instance of different proxy
> > > settings and each protocol and each authority, because the client is
> > > created with these settings.
> > >
> > > This is also done for each thread.
> > >
> > > IIRC, this was necessary originally. We have not rewritten the code
> > > yet to use all the latest features.
> > >
> >
> > I see. For the time what you can do is to use a custom SSL socket
> > factory that lazily initializes SSL context when requested for the first
> > time. This is exactly what HC 3.1 does. It will be somewhat slower given
> > that one would need to mutex to synchronize access to the initialization
> > code.
> >
> > Oleg
> >
> > > > Oleg
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > >
> >
> >
> >
> 
> 



Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sun, 2015-12-20 at 22:44 +0100, Philippe Mouawad wrote:
> Hi Oleg,
> Back to this old subject and knowing that we must stick to 1 HttpClient per
> thread (as per all the discussion that followed this).
> Is there a plan to implement this lazy init of SSLContext in HttpClient as
> it used to be the case in HC3 ?
> 
> For our project, it's a killer in terms of performance, and for other use
> cases, it appears kind of weird that an SSLContext is initialized even for
> a pure HTTP traffic.
> 

Given that HttpClient instance should be initialized only once, eager
initialization of the SSLContext looks reasonable to me.

One, of course, can make SSL initialization lazy by using a custom
connection socket factory with SSLContext initialized on demand.

Hope this helps

Oleg

> Thanks
> Regards
> 
> 
> 
> On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> 
> > On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> >
> > ...
> >
> > > >> Issue is not present in HTTPCLient 3.1
> > > >
> > > > Philippe
> > > >
> > > > If HttpClient is used correctly, this code should only be executed only
> > > > once. Why does JMeter create more than one instance of HttpClient?
> > >
> > > We currently create an instance for each instance of different proxy
> > > settings and each protocol and each authority, because the client is
> > > created with these settings.
> > >
> > > This is also done for each thread.
> > >
> > > IIRC, this was necessary originally. We have not rewritten the code
> > > yet to use all the latest features.
> > >
> >
> > I see. For the time what you can do is to use a custom SSL socket
> > factory that lazily initializes SSL context when requested for the first
> > time. This is exactly what HC 3.1 does. It will be somewhat slower given
> > that one would need to mutex to synchronize access to the initialization
> > code.
> >
> > Oleg
> >
> > > > Oleg
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > >
> >
> >
> >
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg,
Back to this old subject and knowing that we must stick to 1 HttpClient per
thread (as per all the discussion that followed this).
Is there a plan to implement this lazy init of SSLContext in HttpClient as
it used to be the case in HC3 ?

For our project, it's a killer in terms of performance, and for other use
cases, it appears kind of weird that an SSLContext is initialized even for
a pure HTTP traffic.

Thanks
Regards



On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> ...
>
> > >> Issue is not present in HTTPCLient 3.1
> > >
> > > Philippe
> > >
> > > If HttpClient is used correctly, this code should only be executed only
> > > once. Why does JMeter create more than one instance of HttpClient?
> >
> > We currently create an instance for each instance of different proxy
> > settings and each protocol and each authority, because the client is
> > created with these settings.
> >
> > This is also done for each thread.
> >
> > IIRC, this was necessary originally. We have not rewritten the code
> > yet to use all the latest features.
> >
>
> I see. For the time what you can do is to use a custom SSL socket
> factory that lazily initializes SSL context when requested for the first
> time. This is exactly what HC 3.1 does. It will be somewhat slower given
> that one would need to mutex to synchronize access to the initialization
> code.
>
> Oleg
>
> > > Oleg
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg,
Back to this old subject and knowing that we must stick to 1 HttpClient per
thread (as per all the discussion that followed this).
Is there a plan to implement this lazy init of SSLContext in HttpClient as
it used to be the case in HC3 ?

For our project, it's a killer in terms of performance, and for other use
cases, it appears kind of weird that an SSLContext is initialized even for
a pure HTTP traffic.

Thanks
Regards



On Thu, May 15, 2014 at 10:39 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> > On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> ...
>
> > >> Issue is not present in HTTPCLient 3.1
> > >
> > > Philippe
> > >
> > > If HttpClient is used correctly, this code should only be executed only
> > > once. Why does JMeter create more than one instance of HttpClient?
> >
> > We currently create an instance for each instance of different proxy
> > settings and each protocol and each authority, because the client is
> > created with these settings.
> >
> > This is also done for each thread.
> >
> > IIRC, this was necessary originally. We have not rewritten the code
> > yet to use all the latest features.
> >
>
> I see. For the time what you can do is to use a custom SSL socket
> factory that lazily initializes SSL context when requested for the first
> time. This is exactly what HC 3.1 does. It will be somewhat slower given
> that one would need to mutex to synchronize access to the initialization
> code.
>
> Oleg
>
> > > Oleg
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:

...

> >> Issue is not present in HTTPCLient 3.1
> >
> > Philippe
> >
> > If HttpClient is used correctly, this code should only be executed only
> > once. Why does JMeter create more than one instance of HttpClient?
> 
> We currently create an instance for each instance of different proxy
> settings and each protocol and each authority, because the client is
> created with these settings.
> 
> This is also done for each thread.
> 
> IIRC, this was necessary originally. We have not rewritten the code
> yet to use all the latest features.
> 

I see. For the time what you can do is to use a custom SSL socket
factory that lazily initializes SSL context when requested for the first
time. This is exactly what HC 3.1 does. It will be somewhat slower given
that one would need to mutex to synchronize access to the initialization
code.

Oleg

> > Oleg
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 



Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2014-05-14 at 19:46 +0100, sebb wrote:
> On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:

...

> >> Issue is not present in HTTPCLient 3.1
> >
> > Philippe
> >
> > If HttpClient is used correctly, this code should only be executed only
> > once. Why does JMeter create more than one instance of HttpClient?
> 
> We currently create an instance for each instance of different proxy
> settings and each protocol and each authority, because the client is
> created with these settings.
> 
> This is also done for each thread.
> 
> IIRC, this was necessary originally. We have not rewritten the code
> yet to use all the latest features.
> 

I see. For the time what you can do is to use a custom SSL socket
factory that lazily initializes SSL context when requested for the first
time. This is exactly what HC 3.1 does. It will be somewhat slower given
that one would need to mutex to synchronize access to the initialization
code.

Oleg

> > Oleg
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: httpClient.getConnectionManager() performance with HTTP only

Posted by sebb <se...@gmail.com>.
On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Tue, 2014-05-13 at 23:59 +0200, Philippe Mouawad wrote:
>> Hello,
>> We have a report of Performance issue when using HttpClient4 with HTTP.
>>
>> User noticed cacert was read very frequently.
>>
>> I traced the calls and it is due to :
>> HttpClient#getConnectionManager()
>> =>
>>
>>     public synchronized final ClientConnectionManager
>> getConnectionManager() {
>>         if (connManager == null) {
>>             connManager = createClientConnectionManager();
>>         }
>>         return connManager;
>>     }
>>
>> ==>        final SchemeRegistry registry =
>> SchemeRegistryFactory.createDefault();
>>
>> ====>         registry.register(
>>                 new Scheme("https", 443,
>> SSLSocketFactory.getSocketFactory()));
>>
>>
>> =======>
>>     public static SSLSocketFactory getSocketFactory() throws
>> SSLInitializationException {
>>         SSLContext sslcontext;
>>         try {
>>             sslcontext = SSLContext.getInstance("TLS");
>>             sslcontext.init(null, null, null); <======== Reads CACERTS
>>             return new SSLSocketFactory(
>>                 sslcontext,
>>                 BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
>>         } catch (NoSuchAlgorithmException ex) {
>>             throw new SSLInitializationException(ex.getMessage(), ex);
>>         } catch (KeyManagementException ex) {
>>             throw new SSLInitializationException(ex.getMessage(), ex);
>>         }
>>     }
>> This reads the cacerts.
>> In this case user is not using HTTPS at all but gets this performance issue
>>
>> Issue is not present in HTTPCLient 3.1
>
> Philippe
>
> If HttpClient is used correctly, this code should only be executed only
> once. Why does JMeter create more than one instance of HttpClient?

We currently create an instance for each instance of different proxy
settings and each protocol and each authority, because the client is
created with these settings.

This is also done for each thread.

IIRC, this was necessary originally. We have not rewritten the code
yet to use all the latest features.

> Oleg
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: httpClient.getConnectionManager() performance with HTTP only

Posted by sebb <se...@gmail.com>.
On 14 May 2014 12:28, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Tue, 2014-05-13 at 23:59 +0200, Philippe Mouawad wrote:
>> Hello,
>> We have a report of Performance issue when using HttpClient4 with HTTP.
>>
>> User noticed cacert was read very frequently.
>>
>> I traced the calls and it is due to :
>> HttpClient#getConnectionManager()
>> =>
>>
>>     public synchronized final ClientConnectionManager
>> getConnectionManager() {
>>         if (connManager == null) {
>>             connManager = createClientConnectionManager();
>>         }
>>         return connManager;
>>     }
>>
>> ==>        final SchemeRegistry registry =
>> SchemeRegistryFactory.createDefault();
>>
>> ====>         registry.register(
>>                 new Scheme("https", 443,
>> SSLSocketFactory.getSocketFactory()));
>>
>>
>> =======>
>>     public static SSLSocketFactory getSocketFactory() throws
>> SSLInitializationException {
>>         SSLContext sslcontext;
>>         try {
>>             sslcontext = SSLContext.getInstance("TLS");
>>             sslcontext.init(null, null, null); <======== Reads CACERTS
>>             return new SSLSocketFactory(
>>                 sslcontext,
>>                 BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
>>         } catch (NoSuchAlgorithmException ex) {
>>             throw new SSLInitializationException(ex.getMessage(), ex);
>>         } catch (KeyManagementException ex) {
>>             throw new SSLInitializationException(ex.getMessage(), ex);
>>         }
>>     }
>> This reads the cacerts.
>> In this case user is not using HTTPS at all but gets this performance issue
>>
>> Issue is not present in HTTPCLient 3.1
>
> Philippe
>
> If HttpClient is used correctly, this code should only be executed only
> once. Why does JMeter create more than one instance of HttpClient?

We currently create an instance for each instance of different proxy
settings and each protocol and each authority, because the client is
created with these settings.

This is also done for each thread.

IIRC, this was necessary originally. We have not rewritten the code
yet to use all the latest features.

> Oleg
>

Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2014-05-13 at 23:59 +0200, Philippe Mouawad wrote:
> Hello,
> We have a report of Performance issue when using HttpClient4 with HTTP.
> 
> User noticed cacert was read very frequently.
> 
> I traced the calls and it is due to :
> HttpClient#getConnectionManager()
> =>
> 
>     public synchronized final ClientConnectionManager
> getConnectionManager() {
>         if (connManager == null) {
>             connManager = createClientConnectionManager();
>         }
>         return connManager;
>     }
> 
> ==>        final SchemeRegistry registry =
> SchemeRegistryFactory.createDefault();
> 
> ====>         registry.register(
>                 new Scheme("https", 443,
> SSLSocketFactory.getSocketFactory()));
> 
> 
> =======>
>     public static SSLSocketFactory getSocketFactory() throws
> SSLInitializationException {
>         SSLContext sslcontext;
>         try {
>             sslcontext = SSLContext.getInstance("TLS");
>             sslcontext.init(null, null, null); <======== Reads CACERTS
>             return new SSLSocketFactory(
>                 sslcontext,
>                 BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
>         } catch (NoSuchAlgorithmException ex) {
>             throw new SSLInitializationException(ex.getMessage(), ex);
>         } catch (KeyManagementException ex) {
>             throw new SSLInitializationException(ex.getMessage(), ex);
>         }
>     }
> This reads the cacerts.
> In this case user is not using HTTPS at all but gets this performance issue
> 
> Issue is not present in HTTPCLient 3.1

Philippe

If HttpClient is used correctly, this code should only be executed only
once. Why does JMeter create more than one instance of HttpClient?

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: httpClient.getConnectionManager() performance with HTTP only

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2014-05-13 at 23:59 +0200, Philippe Mouawad wrote:
> Hello,
> We have a report of Performance issue when using HttpClient4 with HTTP.
> 
> User noticed cacert was read very frequently.
> 
> I traced the calls and it is due to :
> HttpClient#getConnectionManager()
> =>
> 
>     public synchronized final ClientConnectionManager
> getConnectionManager() {
>         if (connManager == null) {
>             connManager = createClientConnectionManager();
>         }
>         return connManager;
>     }
> 
> ==>        final SchemeRegistry registry =
> SchemeRegistryFactory.createDefault();
> 
> ====>         registry.register(
>                 new Scheme("https", 443,
> SSLSocketFactory.getSocketFactory()));
> 
> 
> =======>
>     public static SSLSocketFactory getSocketFactory() throws
> SSLInitializationException {
>         SSLContext sslcontext;
>         try {
>             sslcontext = SSLContext.getInstance("TLS");
>             sslcontext.init(null, null, null); <======== Reads CACERTS
>             return new SSLSocketFactory(
>                 sslcontext,
>                 BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
>         } catch (NoSuchAlgorithmException ex) {
>             throw new SSLInitializationException(ex.getMessage(), ex);
>         } catch (KeyManagementException ex) {
>             throw new SSLInitializationException(ex.getMessage(), ex);
>         }
>     }
> This reads the cacerts.
> In this case user is not using HTTPS at all but gets this performance issue
> 
> Issue is not present in HTTPCLient 3.1

Philippe

If HttpClient is used correctly, this code should only be executed only
once. Why does JMeter create more than one instance of HttpClient?

Oleg