ibm-messaging / mq-mqi-nodejs

Calling IBM MQ from Node.js - a JavaScript MQI wrapper
Apache License 2.0
79 stars 42 forks source link

Performance is not good in async implementation in Node js #141

Closed amitdhingra closed 2 years ago

amitdhingra commented 2 years ago

We have a scenario where we get 300,000 messages in MQ but the rate of processing of messages is very less. About 80 messages are processed per second which is very less. we are looking at around 200 messages per second. We have followed the async implementation. we also tried a lot by tunning getLoopPollTimeMs,getLoopDelayTimeMs and maxConsecutiveGets parameters but nothing works for us :(

So kindly help. what we can do in order to improve the performance of our application?

For more info, we are using the following version of IBMMQ and Node js "ibmmq": "^0.9.18", Node js version : v14.18.2

ibmmqmet commented 2 years ago

The implementation for getting messages has a number of yield points and timing restrictions in an attempt to be fair both to multiple objects that might want to get messages and also to other parts of the application.

The fastest way to get lots of messages will be to use GetSync. with any yielding being done by your code as it actually processes each message. But even a loop with no real message processing is always going to be slower than the same loop in a C program as the cross-language interfaces have to be involved each time.

I've not measured the cost of an MQGET in Node compared to C, but it's not going to be the same.

freerider7777 commented 2 years ago

We use cluster - N threads start in parallel - works much faster https://nodejs.org/api/cluster.html

amitdhingra commented 2 years ago

It worked for me. Cluster implementation works much faster. Thanks a lot :)