New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maxSockets does not limit the number of socket connections #1249
Comments
Does a new options object get created for every call? If so, your pool might not be shared between requests, causing each 1 request to have a maxSockets of 5 (which in effect, means there is no limit). You can pass in the pool to The documentation around how pool works could probably be improved as well. |
@FredKSchott Good point, it uses a new option for each call. I thought I tried to use request = require 'request'
request.defaults
pool:
maxSockets: 100
exports.send = (req, res, next) ->
options =
url: "https://google.com.au"
strictSSL: true
secureProtocol: true
request options, (err, response, body) ->
res.send 200, body However I can only see around 10 rather than 100 socket connections during the performance test. |
see this comment: #1150 (comment)
|
Great, it works, thanks a lot! |
This has come up several times recently, for example request#1150 and request#1249.
This has come up several times recently, for example request#1150 and request#1249.
Hi folks,
I am trying to use
pool({maxSockets: 100})
to increase the defaultmaxSockets
number. I find that once I setpool
in the option, no matter what value you give tomaxSocket
, it seems always enable maxSockets to beInfinity
.My local test:
so if you
npm start
and go tolocalhost:8080/test
, you would send a get request tohttps://google.com.au
Now I use the performance tool
wrk
to run this test:wrk -t12 -c3000 -d30s http://127.0.0.1:8080/test
, which initiates 12 threads to create 3000 connections and last 30 seconds.Next get the
ip
of google.com.au byhost google.com.au
and I get:Then in the console I do
watch "netstat -an | grep 74.125 | wc -l
From the output I can see there are always hundreds of socket connections opening no matter what value I give
maxSockets
. But If I don't setpool : { maxSockets: xxx}
in theoptions
, I will only see around 10 opening sockets from console.Is my way of using
maxSockets
correct? Do I miss something here?Thanks
The text was updated successfully, but these errors were encountered: