hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Cohen <sco...@javactivity.org>
Subject Re: Right way to simulate session connections in loadtesting simulator using HttpClient
Date Mon, 08 Dec 2014 17:37:43 GMT
To be a little more specific about what I am looking for:
The standard way of creating HttpClients seems to be
HttpClientBuilder.build().  If you don't specify an 
HttpClientConnectionManager, the pooled one will be used, which is not 
what I want.  If I specify, instead, a BasicHttpClientConnectionManager, 
and then try to work through the HttpClient, closing it at the end of 
the session, I get all sorts of IllegalStateExceptions due to the 
underlying state of the connection.

It seems as though I can't reliably use the 
BasicHttpClientConnectionManager solely by working through the methods 
of HttpClient, instead I must manually manage the underlying 
HttpConnection.  Are there examples where this is done?

Thanks.

On 12/06/2014 03:14 PM, Steve Cohen wrote:
> I am building a standalone java application to generate load on a
> system, simulating real world conditions.
>
> The application is multithreaded, using the java.util.concurrent
> framework to generate lots of pooled threads, each of which runs
> "sessions". When the session is complete, the runnable ends and the
> thread is returned to the scheduler pool. Each "session" consists of the
> following:
>
> generate HTTP PUT #1 to server
> wait x seconds (randomized within logical limit)
> generate HTTP PUT #2 to server
> generate HTTP PUT #3 to server
> wait y seconds (randomized within logical limit)
> generate HTTP PUT #4 to server
> generate HTTP PUT #5 to server
> approximately 2 minutes are taken up all together per session
>
> Each thread created by the concurrent pool maintains a connection
> (embodied in an HTTPClient) which is reused by subsequent sessions.
> After each request a call to HttpRequest.releaseConnection() is made, as
> is recommended in many online sources.
>
> It all works pretty well. But perhaps it works TOO well.
>
> While keeping the connections open and releasing them gives optimum
> performance, since I am building a simulator,  I really DON'T want
> optimal performance. I want to simulate SUBOPTIMAL performance. I want
> the server to have to go through connection establishment on each
> session as if the sessions were coming from different computers, not
> from the same one.
>
> I want to create the connection (embedded in an HTTP client) at the
> beginning of each session and close it at the end of the session.
>
> It seems that HttpClient, by default, uses connection pooling.  How do I
> defeat this?  I've tried closing the connection at the completion of
> each session, but then it can no longer be used.
>
> What is the correct way to achieve the simulation I am trying to create
> with HttpClient?
>
> Thanks.
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message