When talking only about the network, and not about the backend and heavy request processing: a big impact by many requests has the connection reusage. Talking about HTTP/1.*
it is a Keep-Alive
feature. With the HTTP/2
multiplexing is supported per default, and allows not only the reusage, but the simultaneous usage by requests
So making parallel 100 requests causes in NodeJS to open 100 connections, while require('http').globalAgent.maxSockets
is set per default for Infinity
. But when you make N
request one after another, that means, the further requests can reuse previous connections.
But you shouldn't handle the connection pool by yourself, just set maxSockets
to 15
, and the nodejs agent will handle it for you. Note: it is difficult to say what the value actually should be, but before nodes version 0.12
the default value for maxSockets
was also 5
.