We\'re benchmarking node performance using a simple Hello World node server on AWS (EC2).
No matter what size instance we use Node always appears to max out at 1000
Use the posix
module to raise the limit on the number of file descriptors your process can use.
Install posix
npm install posix
Then in your code that runs when you launch your app...
var posix = require('posix');
// raise maximum number of open file descriptors to 10k,
// hard limit is left unchanged
posix.setrlimit('nofile', { soft: 10000 });
You've reached the default limit of file descriptors a process can use (1024). You can check the limit on the command line by running "ulimit -n". To change the limit, you need to edit /etc/security/limits.conf. Add the follow block:
* soft nofile 65535
* hard nofile 65535
root soft nofile 65535
root hard nofile 65535
"*" applies to all users except root. Limits for root must be added separately. There are soft and hard limit. Users are allowed to change their own limits up to the soft limit but not exceeding the hard limit.
Once the file has been edited, log out and back in again. Verify the change by running ulimit -n. Restart your Node process and you should be good to go.
There's also a system-wide file descriptor limit that can be increased with the following command:
sysctl -w fs.file-max=65535