I am using the ning async http client to achieve the non-blocking goodness. Doing an apples vs apples test (non blocking vs blocking), I am seeing that the non blocking version is serving more request samples, however the async http client is creating more threads comparing to its blocking counterpart. Is this expected or something that I am missing?
Here are the numbers from the stress test
Async Http Client
jMeter - 2 threads, 120 seconds, 1 sec ramp up
Peak threads : 270
Heap usage: 600mb
Peak cpu usage: 30%
Total samples: 18228
Blocking version
jMeter - 2 threads, 120 seconds, 1 sec ramp up
Peak threads: 118
heap usage: 260mb
cpu usage: 18%
total samples: 1472
I am creating a thread pool of connections (reusing them)
AsyncHttpClientConfig.Builder builder = new AsyncHttpClientConfig.Builder();
builder.setRequestTimeoutInMs(2000);
builder.setMaximumConnectionsPerHost(10);
builder.setMaximumConnectionsTotal(100);
client = new AsyncHttpClient(builder.build());
Is there something I am missing here? I tried looking at the thread dump to see what is creating threads, but did not find anything useful. My bet is that there is a thread for each http connection being spawned to fire the callback on I/O completion in the async http client.