Thank you for the warning :) 2012/7/18 Ben Noordhuis <[email protected]>
> On Tue, Jul 17, 2012 at 6:07 PM, Romain <[email protected]> wrote: > > Hi, > > > > I have a script in node-js that do a lot of http requests. > > > > After 30s, I did 30 000 requests, and I start having errors : `connect > > EHOSTUNREACH` and `getaddrinfo ENOENT` > > > > The command `netstat -putone` tell me that there are a lot of sockets in > > TIME_WAIT state: > > > > ... > > tcp 0 0 10.26.164.13:50180 10.26.165.15:9023 > > TIME_WAIT 0 0 - timewait (0.00/0/0) > > tcp 0 0 10.26.164.13:57571 10.26.165.14:9023 > > TIME_WAIT 0 0 - timewait (0.00/0/0) > > tcp 0 0 10.26.164.13:59341 10.26.165.14:9023 > > TIME_WAIT 0 0 - timewait (0.14/0/0) > > tcp 0 0 10.26.164.13:50219 10.26.165.15:9023 > > TIME_WAIT 0 0 - timewait (0.00/0/0) > > tcp 0 0 10.26.164.13:41825 10.26.165.16:9023 > > TIME_WAIT 0 0 - timewait (0.00/0/0) > > tcp 0 0 10.26.164.13:57264 10.26.165.14:9023 > > TIME_WAIT 0 0 - timewait (0.00/0/0) > > tcp 0 0 10.26.164.13:41151 10.26.165.16:9023 > > TIME_WAIT 0 0 - timewait (0.00/0/0) > > ... > > > > > > $ netstat -putone |grep TIME_WAIT |wc -l > > 31413 > > > > > > Is there a way to tell the OS to reuse the sockets in TIME_WAIT state ? > > I read docs about SO_REUSE_ADDR : > > http://www.unixguide.net/network/socketfaq/4.5.shtml, and it's looks > what I > > need. > > > > Now I am wondering how to pass this option to the tcp socket. > > > > But a grep told me that SO_REUSE_ADDR is used in lib_uv. > > https://github.com/joyent/node/blob/master/deps/uv/src/unix/stream.c#L90 > > libuv sets it but it's called SO_REUSEADDR, that's why you didn't find it. > > The TIME_WAIT timeout is configurable on most operating systems, see > `man 7 tcp` (on Linux) for details. > > I would generally advise against changing the defaults, though. > There's a 50/50 chance that your tweaks will have an adverse impact > and that may not be evident until much, much later - at a time when > you've forgotten all about this gentle warning. :-) > > > I don't understand how lib_uv works. > > > > Is anybody could help me ? > > > > Cheers > > Romain > > > > PS: for information the script is this one: > > > > require('async').forEachLimit(_.range(100000), 5, function(data, > next){ > > > > var request = require('request'); > > > > var hosts = ['tpsmdu11s', 'tpsmdu12s', 'tpsmdu13s']; > > var host = _(hosts).shuffle()[0]; > > var reqOpts = { > > url: 'http://' + host + ':9023/_search', > > method: 'post', > > timeout: options.timeout || 10000, > > body: '{ "a json document": { ... } }' > > }; > > request(reqOpts, next); > > }); > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
