joyent/node — Issue #2529: fs.writeFile hangs on high load (no error on v.0.6.6)
Author: mrutid
Created: 2012-01-13 11:59:58+00:00
State: open

We are trying to serve as much requests as possible, and write one file per request. With small payload works fine, but on high payload scenarios while the synchronous version still working fine, the asynchronous version (fs.writeFile) hangs. Node stops serving requests and leave most of the files with 0-size (most of them neither get created).

There is no error in v0.6.6

In v.0.4.7 we got:

```{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'EMFILE, Too many open files \'aw_1031\'',
errno: 24,
code: 'EMFILE',
path: 'aw_1031' }```

Same behaviour in Ubuntu(VM) and Mac Osx.

This is the example script we are currently running with:

```ab -n 30000 -c 500 http://HOST:8000/```

var http = require('http');
var fs = require('fs');
var util = require ('util');
var i=0;

function writeALot(req, res){
fs.writeFile("filetest"+i, "Just a try: "+i,
function(err){
if(err) console.log(util.inspect(err));
});
i++;
res.writeHead(200);
res.end();
}
http.createServer(writeALot).listen(8000);

How can we manage the max number of concurrent fd? Any advice?

Thanks in advance.