Personal tools
You are here: Home Web Reverse Proxy And Cache Increase Nginx file limits on CentOS v7.x
 

Increase Nginx file limits on CentOS v7.x

This is part of tuning Nginx to scale to reasonable workloads.

 

 Change the nginx process limits with a systemd 'drop-in snippet' configuration file:

# mkdir -p /lib/systemd/system/nginx.service.d
# cat > /lib/systemd/system/nginx.service.d/worker_files_limit.conf <<EOF
[Service]
LimitNOFILE=100000
EOF

# systemctl daemon-reload
# systemctl restart nginx.service
 

Add/change the '/etc/nginx/nginx.conf' file:

worker_rlimit_nofile 33000;
events {
  worker_connections  16384;
}

Links

Appendices

Limits

# cat /proc/$(cat /run/nginx.pid)/limits
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             1803                 1803                 processes
Max open files            100000               100000               files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       1803                 1803                 signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

 Systemd 198 release notes (snippets)

In detail:

        * Configuration of unit files may now be extended via drop-in
          files without having to edit/override the unit files
          themselves. More specifically, if the administrator wants to
          change one value for a service file foobar.service he can
          now do so by dropping in a configuration snippet into
          /etc/systemd/systemd/foobar.service.d/*.conf. The unit logic
          will load all these snippets and apply them on top of the
          main unit configuration file, possibly extending or
          overriding its settings. Using these drop-in snippets is
          generally nicer than the two earlier options for changing
          unit files locally: copying the files from
          /usr/lib/systemd/system/ to /etc/systemd/system/ and editing
          them there; or creating a new file in /etc/systemd/system/
          that incorporates the original one via ".include". Drop-in
          snippets into these .d/ directories can be placed in any
          directory systemd looks for units in, and the usual
          overriding semantics between /usr/lib, /etc and /run apply
          for them too.

        * Most unit file settings which take lists of items can now be
          reset by assigning the empty string to them. For example,
          normally, settings such as Environment=FOO=BAR append a new
          environment variable assignment to the environment block,
          each time they are used. By assigning Environment= the empty
          string the environment block can be reset to empty. This is
          particularly useful with the .d/*.conf drop-in snippets
          mentioned above, since this adds the ability to reset list
          settings from vendor unit files via these drop-ins.
Document Actions