My app quits at relatively low stress point when I run load test on it. For testing I use this npm package loadtest.
I run the test at 1000 requests per second with 10 concurrency for 10 seconds.
loadtest http://localhost:3000/my/api -t 10 -c 10 --rps 1000
The application quits after about two seconds and gives the following error which is not very useful.
events.js:163 throw er; // Unhandled 'error' event ^ Error: accept ENFILE at exports._errnoException (util.js:1050:11) at TCP.onconnection (net.js:1462:24)
Apparently, this is related to the number of open files. I tried this command
ulimit -n <number> but it doesn't help. It's limited at 9999 (I can't set it above that).
The application can handle around 400rps at 10 concurrencies.
My local machine is a Mac OS Sierra, CPU: 1.6GHz, RAM: 8GB.
macOS sets rather low kernel limits on the allowed number of open file descriptors (both in total and per process). I had to check on my wife's Mac, and the default per-process limit is 10240, which is basically spot on to what you are being limited to using
ulimit cannot go beyond the kernel-imposed limit).
It's easy to increase these values, though, running the
sudo sysctl kern.maxfiles=122880 kern.maxfilesperproc=102400
(those are the values that I'm using on my Mac, they are rather arbitrary but work okay for me)
If you want them to stick after a reboot, add the following two lines to the file
/etc/sysctl.conf (if it doesn't exist yet, just create it):