How does Nodejs performance scale when using http.request?

I am writing an application that heavily uses the http.request method.

In particular, I found that sending requests from 16+ ~ 30 kB at the same time really drives a Nodejs instance on a computer with 512 MB of RAM.

I am wondering if this should be expected, or if Nodejs is the wrong platform for outgoing requests.

+4
source share
2 answers

Yes, this behavior seems quite reasonable.

I would be more concerned that he was doing the work you described without any noticeable load on the system (in this case, it will take a very long time). Remember that node is just I / O execution time, so you can believe that it schedules your I / O requests (approximately) as fast as the underlying system can be used, therefore it uses the system for it (almost) maximum potential, therefore, the system is "really bogged down."

+1
source

One thing you should be aware of is the fact that http.request does not create a new socket for every call. Each request is executed on an object called an "agent", which contains a pool of 5 sockets. If you use the v0.6 branch, you can use this restriction using.

http.globalAgent.maxSockets = Infinity 

Try and see if it helps

+1
source

Source: https://habr.com/ru/post/1396689/


All Articles