Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js process ignores the max open files soft limit #51072

Closed
ocodista opened this issue Dec 6, 2023 · 3 comments
Closed

Node.js process ignores the max open files soft limit #51072

ocodista opened this issue Dec 6, 2023 · 3 comments

Comments

@ocodista
Copy link
Contributor

ocodista commented Dec 6, 2023

Version

v21.4.0

Platform

Linux ip-10-0-1-185 6.2.0-1012-aws #12~22.04.1-Ubuntu SMP Thu Sep 7 14:01:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

node -e "console.log('Current PID:', process.pid); require('child_process').exec('cat /proc/' + process.pid + '/limits', (err, stdout) => { if (err) throw err; console.log(stdout); });"

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior? Why is that the expected behavior?

It should respect the Soft Limit of Max Open files, but it is not, it is ignoring it.

What do you see instead?

ubuntu@ip-10-0-1-185:~/node-api$ ulimit -n
1024
ubuntu@ip-10-0-1-185:~/node-api$ node -e "console.log('Current PID:', process.pid); require('child_process').exec('cat /proc/' + process.pid + '/limits', (err, stdout) => { if (err) throw err; console.log(stdout); });"
Current PID: 3133
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             3738                 3738                 processes
Max open files            1048576              1048576              files
Max locked memory         124477440            124477440            bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       3738                 3738                 signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us
image

Additional information

No response

@ocodista ocodista changed the title Node.js http server ignores the max open files limit Node.js http server ignores the max open files soft limit Dec 6, 2023
@ocodista ocodista changed the title Node.js http server ignores the max open files soft limit Node.js process ignores the max open files soft limit Dec 6, 2023
@H4ad
Copy link
Member

H4ad commented Dec 7, 2023

Initially, I thought it was something related to libuv, but libuv/libuv#3181 points to 6820054d2d.

@bnoordhuis Why node raises the softLimit?

@targos
Copy link
Member

targos commented Dec 7, 2023

The commit message of 6820054d2d explains it.
The soft limit on macOS is 256 by default.

@bnoordhuis
Copy link
Member

It's higher nowadays but still too low for many practical purposes. Intentional behavior, not a bug. Closing.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants