On Thu, 2012-06-21 at 13:20 -0700, Rossen Stoyanchev wrote: > I've been experimenting with the "Concurrent asynchronous HTTP exchanges" > sample here: > http://hc.apache.org/httpcomponents-asyncclient-dev/examples.html > > I submit 20 requests to a test server that takes 1 second to respond. I see > two requests complete every second and it takes 10 seconds in total to > complete all 20 requests. So it looks like there is a bottleneck. > > I happen to have the current thread name included in log messages and I can > see requests completing in one of two threads ("I/O dispatcher 1" and "I/O > dispatcher 2"). Could it be that some thread count needs to increase? I > expected with NIO the number of threads could be kept lower than with > blocking I/O. > > My question is what settings on DefaultHttpAsyncClient would you recommend to > configure for processing a larger number of concurrent requests? > > I tried this but it didn't make a difference: > > IOReactorConfig ioReactorConfig = new IOReactorConfig(); > ioReactorConfig.setIoThreadCount(20); > HttpAsyncClient httpclient = new DefaultHttpAsyncClient(ioReactorConfig); > > > thanks, > Rossen >
Hi Rossen Per default HttpAsyncClient allows only two concurrent connections to the same host (same route to be exact) as required by the HTTP specification. This is a spec compliant behavior. You might want to increase this number using connection manager settings if you need higher concurrency. The number of dispatcher threads should be equal to the number of physical CPU cores of your system. This is done automatically by default using Runtime.getRuntime().availableProcessors() call. If you set the max connections per route number to ten, the total execution time of 20 requests in your example should drop to approximately 2 seconds. Hope this helps Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
