Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance of Axios http calls is bad, calls are taking longer time resulting in lower transactions per second

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");

});
like image 682
user2745257 Avatar asked Mar 31 '20 13:03

user2745257


1 Answers

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.

like image 61
mmomtchev Avatar answered Oct 24 '22 14:10

mmomtchev