How does one set worker_rlimit_nofile
to a higher number and what's the maxium it can be or is recommended to be?
I'm trying to follow the following advice:
The second biggest limitation that most people run into is also related to your OS. Open up a shell, su to the user nginx runs as and then run the command
ulimit -a
. Those values are all limitations nginx cannot exceed. In many default systems the open files value is rather limited, on a system I just checked it was set to 1024. If nginx runs into a situation where it hits this limit it will log the error (24: Too many open files) and return an error to the client. Naturally nginx can handle a lot more than 1024 files and chances are your OS can as well. You can safely increase this value.To do this you can either set the limit with ulimit or you can use worker_rlimit_nofile to define your desired open file descriptor limit.
From: https://blog.martinfjordvald.com/2011/04/optimizing-nginx-for-high-traffic-loads/
The worker_rlimit_nofile parameter is used to define the maximum number of open files per worker process. The reason this parameter is now specified is because, when adjusting the number of connections per worker, you must also adjust the open file limitations.
What are worker_processes in Nginx. The worker_processes are used to specify the total number of worker processes to spawn simultaneously. The number of worker_processes in Nginx is set to one by default. Executing one worker process per CPU core works perfectly, and we also recommend you configure it in this way.
NGINX can handle a maximum of 512 concurrent connections. In newer versions, NGINX supports up to 1024 concurrent connections, by default.
Through a simple command you can verify the status of the Nginx configuration file: $ sudo systemctl config nginx The output will show if the configuration file is correct or, if it is not, it will show the file and the line where the problem is.
worker_rlimit_nofile
= worker_connections
* 2 file descriptors
Each worker connection open 2 file descriptors (1 for upstream, 1 for downstream)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With