As an aid for EMFILE errors I once came up with this -> 
 https://github.com/medikoo/fs2/#descriptorshandler
It works like a charm, and prevents EMFILE errors whichever affecting 
function you use, (even fs.watch if you use fs2 watch functionalities)
I wouldn't just advertise to load it within generic modules, it should be 
loaded *once*, at very beginning of node shell script, that's it (as e.g. 
here: https://github.com/medikoo/xlint/blob/master/bin/xlint#L8 )

On Sunday, May 12, 2013 3:24:49 PM UTC+2, Alex Kocharin wrote:
>
> Hi everyone,
>
> I wonder if it would make sense to recommend everyone to set "ulimit -n" 
> to unlimited when using node... I seem to run into issues with it every now 
> and then.
>
> Anyway, it seems that node.js core itself has serious trouble with it. I 
> used "ab -n 10000 -c 5000" to bombard a simple http server with thousands 
> of requests, and after that node.js starts to eat up 100% CPU and never 
> returns control to javascript. HTTP port remains open, but connection is 
> closed as soon as anybody connects to it.
>
> Can you recheck it? Maybe I have some silly settings on my computer that 
> cause this.
>
> Tested several versions. 0.8.23 fails with EMFILE (this is to be 
> expected), 0.8.7 and 0.9.1 handles anything successfully (surprising, but 
> ok), but all versions starting I believe from 0.9.2 including current 
> version have this issue.
>
> I wonder if it's a security issue, and everybody can freeze node.js server 
> by just opening 2k connections to it.
>
>
> I'm using this for testing:
> ```
> setInterval(function() {
>    console.log('I\'m alive, ', Date.now());
> }, 1000);
>
> require('http').createServer(function(req, res) {
>    res.end('xxx');
> }).listen(12345);
> ```
>
> In another console (under root because ordinary user can't up ulimit by 
> himself):
> # ulimit -n 10000
>
> # ab -n 10000 -c 5000 http://127.0.0.1:12345/
> This is ApacheBench, Version 2.3 <$Revision: 655654 $>
> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
> Licensed to The Apache Software Foundation, http://www.apache.org/
>
> Benchmarking 127.0.0.1 (be patient)
> apr_socket_recv: Connection reset by peer (104)
> Total of 59 requests completed
>
> # ps aux | grep node
> alex      4582 91.7  0.2 592480 11192 pts/11   Rl+  12:58   0:31 node 
> /tmp/test.js
> root      4596  0.0  0.0   8976   876 pts/4    S+   12:59   0:00 grep node
>
> # time telnet 127.0.0.1 12345
> Trying 127.0.0.1...
> Connected to 127.0.0.1.
> Escape character is '^]'.
> Connection closed by foreign host.
>
> real    0m0.004s
> user    0m0.004s
> sys     0m0.000s
>

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to