Increase maxSockets

suggest change

Basics

require('http').globalAgent.maxSockets = 25

// You can change 25 to Infinity or to a different value by experimenting

Node.js by default is using maxSockets = Infinity at the same time (since v0.12.0). Until Node v0.12.0, the default was maxSockets = 5 (see v0.11.0). So, after more than 5 requests they will be queued. If you want concurrency, increase this number.

Setting your own agent

http API is using a Global Agent. You can supply your own agent. Like this:

const http = require('http')
const myGloriousAgent = new http.Agent({ keepAlive: true })
myGloriousAgent.maxSockets = Infinity

http.request({ ..., agent: myGloriousAgent }, ...)

Turning off Socket Pooling entirely

const http = require('http')
const options = {.....}

options.agent = false

const request = http.request(options)

Pitfalls

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents