I’m working on a project that involves Nginx working as a reverse proxy server and traffic distribution balancer for 3 virtual machines at EC2. But I hear I need to update sockets and open file limits so that it will not cause any issues. Sometimes traffic will be like 1000 connections per second but the average is 200-300 connections per second. How to see the current nginx open file limits?
- First find out path to Nginx pid file using the grep command:
grep pid /etc/nginx/nginx.conf
- Then using the prlimit command as follows (assuming that /var/run/nginx.pid is the nginx pid file path)
sudo prlimit -p $(</var/run/nginx.pid) | grep 'open'
- You can see all details as follows including
NOFILE
:
sudo prlimit -p $(</var/run/nginx.pid)
Here is outputs:
RESOURCE DESCRIPTION SOFT HARD UNITS AS address space limit unlimited unlimited bytes CORE max core file size 0 unlimited bytes CPU CPU time unlimited unlimited seconds DATA max data size unlimited unlimited bytes FSIZE max file size unlimited unlimited bytes LOCKS max number of file locks held unlimited unlimited locks MEMLOCK max locked-in-memory address space 8388608 8388608 bytes MSGQUEUE max bytes in POSIX mqueues 819200 819200 bytes NICE max nice prio allowed to raise 0 0 NOFILE max number of open files 524288 524288 files NPROC max number of processes 256564 256564 processes RSS max resident set size unlimited unlimited bytes RTPRIO max real-time priority 0 0 RTTIME timeout for real-time tasks unlimited unlimited microsecs SIGPENDING max number of pending signals 256564 256564 signals STACK max stack size 8388608 unlimited bytes
- See Nginx 24: Too Many Open Files Error And Solution - nixCraft for more info.
1 Like