We have microservices built using node js. One service(say service A) need to make http api call to other service(say service B) to complete its functionality. Load test of service A is giving lower TPS (transactions per second) and the reason for this is the api call is taking time. However when load test is done directly on service B gives very good TPS.
During load test TPS start coming down gradually.
So I think node js or the axios library is causing the performance issue.
Could you please let me know how we could get better performance in the api calls.
I have simple express route method as below , I am using soap ui to do simple load test, where I get TPS of less than 50% when compared to TPS of load test done directly to the ping url used below
router.post("/", async function(req, res) {
await axios.get("http://localhost:3501/ping");
res.status(201).json("completed");
});
There is a problem in Node.js where processing every incoming 64Kb of data requires one full rotation of the event loop. If you are doing lots of parallel requests or doing any other work that increases the event loop latency, the performance will suffer greatly. axios
is very impacted by this.
I have a stalled PR to fix this: https://github.com/nodejs/node/pull/39097
One workaround is to increase the highWaterMark
- see the linked issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With