I have written a small web server that I wrote in node.js that uses node-java to invoke a commercial product API. I originally used (mostly all) Async (non-Sync) calls to invoke that API, as shown here:
Critique for node.js+node-java application that interfaces with a COTs product?
but I noticed some kind of puzzling problems last week with the API (the Jmeter test would hang for awhile at the end of the test and the commercial product would take awhile to process the last several requests) while testing, and I've been trying to figure those out.
So, then, today, I decided to try to modify the node.js+node-java code to use only Sync calls to invoke the API.
I changed this part of the code:
// The following also now works, and this invokes the PDP in Asynch mode!!
var x = java.callStaticMethod("OesPdp", "DoAtzRequest", "xxx", function (err, data) {
if (err) {
console.log("In handleRequest: err = [" + err + "}");
return;
}
console.log("In handleRequest: In callback-good-path, data=[" + data + "]");
// NOTE that the 'data' is what is being returned from the DoAtzRequest method of the OesPdp Object!!
response.end("THE DATA IS: [" + data + "]");
return "AAAAAAAAAAAAAAAA";
} // end CALLBACK function
);
by replacing it with this (i.e., I'd call the API method using Sync call):
// The following WORKS, but it invokes/runs the PDP in Sync mode...
var x = java.callStaticMethodSync("OesPdp", "DoAtzRequest", "xxx");
console.log("x=[" + x + "]");
console.log("THE DATA that was returned from the OES PDP, 'x', IS: [" + x + "]");
response.end("THE DATA that was returned from the OES PDP, 'x', IS: [" + x + "]");
I'm using Jmeter to do the load testing, and my base test runs 10 simultaneous threads continuously, and previously when I was using the Async calls, I was assuming that the app was processing 10 requests "simultaneously", so I thought that when I switched all the method calls to Sync calls, that the web server app would be processing all requests sequentially and that I'd get really worse/bad results.
But, to my surprise, after I switched the method calls to Sync calls, my Jmeter test results were way, way better, and I went from processing ~9000 requests in 60 seconds test run to ~35K requests in 60 seconds :(!!
Additionally, the problems that I kind of alluded to earlier, don't occur when I used the new code with the Sync calls!
I'm glad that it is working better using the Sync method call, but I am really puzzled/confused now about why the load test results would be BETTER and also, SO MUCH BETTER, when I use the Sync method call, than when I was using the Async method calls??
Can anyone explain why this is the case?
Thanks, Jim
P.S. One thing I should mention is that in both the old code and the new code, the call to instantiate the API Java object was a Sync one (i.e., using "java.newInstanceSync"):
var MyOesPdpClass = java.newInstanceSync('OesPdp');