On Mon, 2017-09-25 at 17:38 +0200, Stefan Sobernig wrote:
> Hi everybody,
> 
> I want to collect (execution) timing probes from various processing
> stages of a request/response inside an AsyncHttpClient (running HC 5
> alpha 2 & friends).
> 
> So far, I rougly implemented sth. sketched out my Oleg in this
> posting I
> found when crawling the archive:
> 
> > 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. 
> 
> http://httpcomponents.10934.n7.nabble.com/Scalable-Http-Client-td2071
> 2.html
> 

As of 5.0-alpha3 HttpClient also supports so called lax (or concurrent)
connection pooling which does not involve a global lock. 


> I have some follow-up questions:
> 
> 1) How to best emit timing probes (start, end time) for a
> request/response pair: Setup a pair of correlated request/response
> interceptors? 

By using an execution interceptor:

https://github.com/apache/httpcomponents-client/blob/master/httpclient5
/src/main/java/org/apache/hc/client5/http/async/AsyncExecChainHandler.j
ava

See these examples

https://github.com/apache/httpcomponents-client/blob/master/httpclient5
/src/examples/org/apache/hc/client5/http/examples/ClientInterceptors.ja
va

https://github.com/apache/httpcomponents-client/blob/master/httpclient5
/src/examples/org/apache/hc/client5/http/examples/AsyncClientMessageTra
ilers.java

> Instrument the FutureCallback callback methods? Right now,
> I collect at every of those, but the start times (FutureCallback
> construction, request interceptor) do not match my intention, as they
> are processed before the request is eventually executed. There is
> clearly sth. more appropriate that I am missing ...
> 
> 2) How can I best collect timing probes from establishing the
> underlying
> connections? (connection established times).
> 

By using a custom AsyncClientConnectionOperator, I think

https://github.com/apache/httpcomponents-client/blob/master/httpclient5
/src/main/java/org/apache/hc/client5/http/nio/AsyncClientConnectionOper
ator.java


> 3) "a small pool of connections (2 to 5)" Am I reading this
> correctly,
> that each AsyncHttpClient instance should be equipped with its own
> connection manager (setConnectionManager),

Yes.


>  with setMaxConnTotal(5) and
> setMaxConnPerRoute(5), assuming that each pool has a min of 2? Can I
> influence the minimum number of connections?
> 

I am not sure I understand.


> 4) If I want to force my AsyncHttpClients/async HttpRequests setup
> into
> a blocking, sequential variant (as implemented using a loop over a
> BasicHttpClient), can I use a semaphore as hinted at here:
> 

A Semaphore can help limit the total number of concurrent connections.
If you want to sequentially execute requests you just need to wait on
the response future before proceeding to the next request.

Hope this helps

Oleg  

> > final Semaphore semaphore = new Semaphore(1);
> 
> https://stackoverflow.com/questions/30101865/how-to-configure-the-num
> ber-of-allowed-pending-requests-in-apache-async-client
> 
> Any hints would be greatly appreciated!
> 
> Thx,
> Stefan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to