• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

368
Views
Node + Express: loadtest causing the application to quit with Error: accept ENFILE

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.

about 3 years ago · Santiago Trujillo
1 answers
Answer question

0

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 ( ulimit cannot go beyond the kernel-imposed limit).

It's easy to increase these values, though, running the sysctl command:

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

kern.maxfiles=122880
kern.maxfilesperproc=102400
about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error