Reputation: 8815
Playing and trying to see how fast node.js can serve a static file from disk using apache bench
ab -r -n 10000 -c 1000 http://server:8080/loadtestfile.txt
I've got ulimit problem on Ubuntu 11.04 x64 VirtualBox VM on OSX Lion
(node) Hit max file limit. Increase "ulimit - n"
I can't increase the limit anymore.
$ ulimit -n 1000000
$ limit -n 1100000
-su: ulimit: open files: cannot modify limit: Operation not permitted
Is this the right way to force node.js to reload the file from disk to serve each HTTP request? How do I increase the limit beyond 1000000?
Normal curl request works:
curl http://server:8080/loadtestfile.txt
Code
var sys = require('sys'),
http = require('http'),
fs = require('fs'),
index;
http.createServer(function(request, response) {
fs.readFile('./loadtestfile.txt', function (err, data) {
response.writeHeader(200, {"Content-Type": "text/plain"});
response.write(data);
response.end();
});
}).listen(8080);
Upvotes: 2
Views: 3693
Reputation: 104090
Ideally, your application would run within the limits given to it; it should cleanly handle accept(2)
returning an error condition with errno(3)
set to EMFILE
or ENFILE
by not trying to accept another connection until an existing connection dies.
However, fixing the application to handle this case gracefully can be difficult; if you just want to raise your limits further to do more testing, there are two possibilities.
Edit /etc/security/limits.conf
to raise the hard limit for your user account for the nofile
limit to something much higher and then log in your user account again.
Do your testing in a root shell; you could either log in as root
directly or use sudo -s
or su
to start the shell, then run the ulimit -n
command from there.
The difficulty is because raising limits requires administrative access. (When you've got a few hundred users on the system simultaneously, you want to keep them playing nice...)
However, I'm going to guess that your application will also run into the system-wide maximum number of open files limit; that is configured via /proc/sys/fs/file-max
. Raise that limit too, if the application complains.
Upvotes: 1