I'm just porting some code over from .net to Java. I've been using the AsyncHttpClient (https://github.com/sonatype/async-http-client) library with the Netty provider.
Doing a little bit of testing I was surprised to see that during the execute call e.g:
httpClient.prepareGet("http://bbc.co.uk").execute(
new AsyncCompletionHandler<Response>() { ... });
The NettyAsyncHttpProvider performs a bootstrap connect to the site i.e.:
bootstrap.connect(new InetSocketAddress(
AsyncHttpProviderUtils.getHost(uri),
AsyncHttpProviderUtils.getPort(uri)));
EDIT: to clarify the NettyAsyncHttpProvider class is part of the AsyncHttpClient Library. It has nothing to do with Netty itself.
Which means on something like the bbc website (on my lowly connection) it takes about 300ms for the execute to complete (then the async receive/complete happens almost immediately). This really kills the performance of my dispatcher which is trying to start multiple async calls. When each call is to the same domain it works well. In my situation I have hundreds of different domains so each call incurs the initial delay while the connection is established which kills the throughput of the dispatcher.
Can anyone offer any advice on how to use this library so it truly works in an async fashion or an alternative library?
Thanks, Paul