You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Dave Johnston <Da...@owmobility.com> on 2013/07/10 15:49:37 UTC

Scalable Http Client

Hi,
I've been trying to execute a large volume of transactions to simulate real traffic using the httpclient.  I'm trying to create 1000 concurrent connections, that each perform 10 requests per second.  i.e. 10000 transactions per second.

I've based my code on the multi-threaded example:
http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java

I've increased the number of connections allowed per route to 1000 and have attempted to measure latency by doing this:

long currentTime = System.currentTimeMillis();
HttpResponse response = httpClient.execute(httpget, context);
long executionTime = System.currentTimeMillis();

System.out.printf("ID [%d] Executed in %d milliseconds\n", id, (executionTime-currentTime));

It looks like the latency increases as the number of connections go up, although I would have hoped to see it stay the same (I've used other load test tools to execute 20K transactions with steady latency).

Whats the best approach for writing an application that behaves this way?  Is the standard PoolingClientConnectionManager with multiple threads the way to go?





Re: Scalable Http Client

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2013-07-11 at 09:24 +0000, Dave Johnston wrote:
> 24 logical cores - 1 server.
> I'm trying to simulate real world traffic, where the server I'm testing against handles 30K + TPS.  So I'm creating 1000 connections each doing between 10 or 30 requests each.
> 

In this case you should have a pool of HttpClient instances each
configured to use a small pool of connections (2 to 5). This setup will
be more representative of thousands of concurrent browser connections.
With one large pool of connections you basically have 1000 thousand of
threads constantly contending for one global pool lock.

Hope this helps

Oleg 

> I've been able to create up to 2000 connections each making 10 requests each per second with other load test tools (tsung), but I'm interested to see if I can  do that by using the apache client, as it means I can hook it into other tools we have for automation.
> 
> 
> -----Original Message-----
> From: Ja kub [mailto:jjakub83@gmail.com] 
> Sent: 11 July 2013 10:19
> To: HttpClient User Discussion
> Subject: Re: Scalable Http Client
> 
> Dave,
> 
> Does this mean 1000 concurrent threads ?
> How many processors do you have ? How many servers ?
> I suppose, that with so many threads latency of every operation increases, try to get latency of 1000xSystem.out.println instead of httpClient.execute(httpget, context); and send results comparison here.
> Please send how much latency increases now ?
> So or so, very interesting case.
> 
> BR
> Jakub
> 
> 
> On Wed, Jul 10, 2013 at 3:49 PM, Dave Johnston <Dave.Johnston@owmobility.com
> > wrote:
> 
> > Hi,
> > I've been trying to execute a large volume of transactions to simulate 
> > real traffic using the httpclient.  I'm trying to create 1000 
> > concurrent connections, that each perform 10 requests per second.  
> > i.e. 10000 transactions per second.
> >
> > I've based my code on the multi-threaded example:
> >
> > http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/
> > apache/http/examples/client/ClientMultiThreadedExecution.java
> >
> > I've increased the number of connections allowed per route to 1000 and 
> > have attempted to measure latency by doing this:
> >
> > long currentTime = System.currentTimeMillis(); HttpResponse response = 
> > httpClient.execute(httpget, context); long executionTime = 
> > System.currentTimeMillis();
> >
> > System.out.printf("ID [%d] Executed in %d milliseconds\n", id, 
> > (executionTime-currentTime));
> >
> > It looks like the latency increases as the number of connections go 
> > up, although I would have hoped to see it stay the same (I've used 
> > other load test tools to execute 20K transactions with steady latency).
> >
> > Whats the best approach for writing an application that behaves this way?
> >  Is the standard PoolingClientConnectionManager with multiple threads 
> > the way to go?
> >
> >
> >
> >
> >
> 
> ---------------------------------------------------------------------
> 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: Scalable Http Client

Posted by Dave Johnston <Da...@owmobility.com>.
24 logical cores - 1 server.
I'm trying to simulate real world traffic, where the server I'm testing against handles 30K + TPS.  So I'm creating 1000 connections each doing between 10 or 30 requests each.

I've been able to create up to 2000 connections each making 10 requests each per second with other load test tools (tsung), but I'm interested to see if I can  do that by using the apache client, as it means I can hook it into other tools we have for automation.


-----Original Message-----
From: Ja kub [mailto:jjakub83@gmail.com] 
Sent: 11 July 2013 10:19
To: HttpClient User Discussion
Subject: Re: Scalable Http Client

Dave,

Does this mean 1000 concurrent threads ?
How many processors do you have ? How many servers ?
I suppose, that with so many threads latency of every operation increases, try to get latency of 1000xSystem.out.println instead of httpClient.execute(httpget, context); and send results comparison here.
Please send how much latency increases now ?
So or so, very interesting case.

BR
Jakub


On Wed, Jul 10, 2013 at 3:49 PM, Dave Johnston <Dave.Johnston@owmobility.com
> wrote:

> Hi,
> I've been trying to execute a large volume of transactions to simulate 
> real traffic using the httpclient.  I'm trying to create 1000 
> concurrent connections, that each perform 10 requests per second.  
> i.e. 10000 transactions per second.
>
> I've based my code on the multi-threaded example:
>
> http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/
> apache/http/examples/client/ClientMultiThreadedExecution.java
>
> I've increased the number of connections allowed per route to 1000 and 
> have attempted to measure latency by doing this:
>
> long currentTime = System.currentTimeMillis(); HttpResponse response = 
> httpClient.execute(httpget, context); long executionTime = 
> System.currentTimeMillis();
>
> System.out.printf("ID [%d] Executed in %d milliseconds\n", id, 
> (executionTime-currentTime));
>
> It looks like the latency increases as the number of connections go 
> up, although I would have hoped to see it stay the same (I've used 
> other load test tools to execute 20K transactions with steady latency).
>
> Whats the best approach for writing an application that behaves this way?
>  Is the standard PoolingClientConnectionManager with multiple threads 
> the way to go?
>
>
>
>
>

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


Re: Scalable Http Client

Posted by Ja kub <jj...@gmail.com>.
Dave,

Does this mean 1000 concurrent threads ?
How many processors do you have ? How many servers ?
I suppose, that with so many threads latency of every operation increases,
try to get latency of 1000xSystem.out.println instead of
httpClient.execute(httpget, context); and send results comparison here.
Please send how much latency increases now ?
So or so, very interesting case.

BR
Jakub


On Wed, Jul 10, 2013 at 3:49 PM, Dave Johnston <Dave.Johnston@owmobility.com
> wrote:

> Hi,
> I've been trying to execute a large volume of transactions to simulate
> real traffic using the httpclient.  I'm trying to create 1000 concurrent
> connections, that each perform 10 requests per second.  i.e. 10000
> transactions per second.
>
> I've based my code on the multi-threaded example:
>
> http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
>
> I've increased the number of connections allowed per route to 1000 and
> have attempted to measure latency by doing this:
>
> long currentTime = System.currentTimeMillis();
> HttpResponse response = httpClient.execute(httpget, context);
> long executionTime = System.currentTimeMillis();
>
> System.out.printf("ID [%d] Executed in %d milliseconds\n", id,
> (executionTime-currentTime));
>
> It looks like the latency increases as the number of connections go up,
> although I would have hoped to see it stay the same (I've used other load
> test tools to execute 20K transactions with steady latency).
>
> Whats the best approach for writing an application that behaves this way?
>  Is the standard PoolingClientConnectionManager with multiple threads the
> way to go?
>
>
>
>
>

Re: Scalable Http Client

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2013-07-10 at 13:49 +0000, Dave Johnston wrote:
> Hi,
> I've been trying to execute a large volume of transactions to simulate real traffic using the httpclient.  I'm trying to create 1000 concurrent connections, that each perform 10 requests per second.  i.e. 10000 transactions per second.
> 
> I've based my code on the multi-threaded example:
> http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
> 
> I've increased the number of connections allowed per route to 1000 and have attempted to measure latency by doing this:
> 
> long currentTime = System.currentTimeMillis();
> HttpResponse response = httpClient.execute(httpget, context);
> long executionTime = System.currentTimeMillis();
> 
> System.out.printf("ID [%d] Executed in %d milliseconds\n", id, (executionTime-currentTime));
> 
> It looks like the latency increases as the number of connections go up, although I would have hoped to see it stay the same (I've used other load test tools to execute 20K transactions with steady latency).
> 
> Whats the best approach for writing an application that behaves this way?  Is the standard PoolingClientConnectionManager with multiple threads the way to go?
> 


Dave,

If you are _absolutely_ sure you need to have 1000 concurrent
connections, you might be better served by the async version of Apache
HttpClient

http://hc.apache.org/httpcomponents-asyncclient-dev/index.html

Oleg


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