> On Jan 14, 2016, at 4:54 AM, virajn <mayuravi...@gmail.com> wrote:
> 
> I have cxf web service and i'm using Asynchronous method calls. I'm using
> Callback approach ( using javax.xml.ws.AsyncHandler -
> http://cxf.apache.org/docs/developing-a-consumer.html ) to get the response
> as follows
> 
>     Future<?> asyncResponse = myWebService.testMethodAsync(param, new
> MyAsyncHandler());
> 
> This method works fine and I get the correct response. 
> 
> My problem is the performance. I measured the time taken just for above line
> and my application showing around 2000ms just for above line ( I did the
> test using jmeter). My application is deployed in tomcat and stated unusual
> delay happens after jmeter start nearly 50 threads. At the beginning of the
> test delay is under 5ms. But after few minutes it suddenly reach to near
> 1000ms then vary between approximately 900ms to 2000ms for 97% of the
> requests. 
> 
> I did the same test using standalone java cxf async client instead web
> application, but in that test above line always return under 5ms. Therefore
> I'm suspecting, in my web application there might be problem with thread
> scheduling ( because my web application do lot of other things while running
> the test and i can not stop these services without making drastic changes)
> OR is there any other problem here ? May be running out of thread pool used
> by cxf async client ?


Likely the thread pool.   By default, we use the HTTPUrlConnection in the JDK 
which is synchronous.   Thus, we dispatch the requests on background threads.  
The default pool is 25 threads so #26 has to wait for one of the other requests 
to finish.   

You have three options:

1) You can reconfigure the thread pool to be larger.   That really would just 
delay the problem further and suck up more resources though.

2) You could use the normal synchronous calls and then configure your web 
server to have a bigger thread pool for dispatches.   Since it’s ending up 
synchronous anyway, this may be easier.

3) Switch to using CXF’s async based transport.  Pretty much just add 
cxf-rt-transports-http-hc and the async client deps and it should work.   This 
uses the Apache HTTP AsyncClient instead of the JDK provide URLCOnnection which 
should allow true async waiting without he problems with blocked threads on the 
thread pool.



-- 
Daniel Kulp
dk...@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to