I think the primary benefit of working with the async transport is that
it supports an asynchronous style of client programming, where Future,
Invocation callbacks are used.
Though it is interesting indeed how it can be optimized, given that it
can be used to do the sync invocations
Cheers, Sergey
On 03/12/14 09:28, user239 wrote:
I was trying to see if there are any advantages of using the async transport
over the regular sync http transport. So I wrote a small test program that
makes 2000 concurrent requests. The server simply waits in a non-blocking
fashion for 1-2 seconds and returns the response.
I profiled it in Netbeans and the results were a bit surprising. Both
transports completed all the requests in the same time (30-35 seconds) and
used the same number of threads (around 30). But the async transport used
200 MB of memory, while the sync one didn't exceed 50 MB according to the VM
Telemetry Overview.
So I have a couple of questions:
1. Does this look like a memory issue with the async transport? Or is this
by design?
2. In what scenario does the async transport clearly outperform the sync
one? Looks like in the program I wrote it was the same and even consumed
much more memory. Or maybe I need to tweak some server/client settings?
I was thinking about using the async transport in a new project for better
scalability, but after running these tests I'm not sure there are any
benefits.
My client code basically looks like this (I'm using CXF 3.0.2 and JDK 6):
MyService service = new MyService();
final int N = 2000;
final Date startTime = new Date();
final AtomicInteger runningRequestCount = new AtomicInteger(N);
final IMyService client = service.getBasicHttpBindingIMyService();
for (long i = 0; i < N; i++) {
client.TestMethodAsync(i, new AsyncHandler<TestMethodResponse>() {
@Override
public void handleResponse(Response<TestMethodResponse>
response) {
try {
Result result = response.get().getTestMethodResult();
// print some information from the "result"
if (runningRequestCount.decrementAndGet() == 0) {
Date endTime = new Date();
Long elapsedTime = endTime.getTime() -
startTime.getTime();
System.out.println("All completed! Took " +
elapsedTime + " milliseconds");
System.exit(0);
}
} catch (InterruptedException ex) {
Logger.getLogger(MyProgram.class.getName()).log(Level.SEVERE, null, ex);
} catch (ExecutionException ex) {
Logger.getLogger(MyProgram.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
--
View this message in context:
http://cxf.547215.n5.nabble.com/Async-transport-performance-using-cxf-rt-transports-http-hc-tp5751832.html
Sent from the cxf-user mailing list archive at Nabble.com.