Skip to content

Instantly share code, notes, and snippets.

@mping
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mping/4d8934b4e8171c5c0488 to your computer and use it in GitHub Desktop.
Save mping/4d8934b4e8171c5c0488 to your computer and use it in GitHub Desktop.
changing the maximum num of connections
worker_processes 4;
worker_rlimit_nofile 1024768;
events {
worker_connections 20480;
use epoll;
}

ulimit

cat /proc/sys/fs/file-max
3296746

With 20480 Connections per worker, the nginx master may need 20480 * 12 (256760) file descriptors.

sudo -i bash -c 'echo "* hard nofile 262400" >> /etc/security/limits.conf'
sudo -i bash -c 'echo "* soft nofile 262400" >> /etc/security/limits.conf'
sudo -i bash -c 'echo "fs.file-max = 3296746" >> /etc/sysctl.conf'

sudo -i sysctl -w fs.file-max=262400
sudo -i sysctl -p

cat /proc/sys/fs/file-max
262400

oops...

sudo vi /etc/security/limits.conf

Remove nofile lines inserted above.

sudo -i sysctl -w fs.file-max=3296746

sudo -i sysctl -p

cat /proc/sys/fs/file-max
3296746

All good again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment