direktspeed / serve-static-production

Serve static files in a production Environment via Kernel sendfile and other extras
MIT License
0 stars 0 forks source link

handle file limits #4

Open frank-dspeed opened 7 years ago

frank-dspeed commented 7 years ago

Open files

How to know how much open files u consume?

ulimit -n # open files limit per process

lsof | grep nginx | wc -l # count how many open files an app is taking

cat /proc/sys/fs/file-max # get max open files allowed

Number of file descriptors used for Nginx. This is set in the OS with 'ulimit -n 200000'

or using /etc/security/limits.conf

Edit /etc/security/limits.conf in order to increase hard and soft opened files allowed

* hard nproc 200000

* soft nproc 200000

worker_rlimit_nofile 200000;

Caches information about open FDs, freqently accessed files.

Changing this setting, in my environment, brought performance up from 560k req/sec, to 904k req/sec.

I recommend using some varient of these options, though not the specific values listed below.

open_file_cache max=200000 inactive=5s; open_file_cache_valid 15s; open_file_cache_min_uses 1; open_file_cache_errors off;