Skip to content

Instantly share code, notes, and snippets.

@binhqd
Last active November 1, 2017 08:39
Show Gist options
  • Save binhqd/f35a0cfafe876884466ad5ce2f91fdf5 to your computer and use it in GitHub Desktop.
Save binhqd/f35a0cfafe876884466ad5ce2f91fdf5 to your computer and use it in GitHub Desktop.
Enable OS max connections and ports
# Check number of CPUs
grep ^processor /proc/cpuinfo | wc -l
# set maximum number of open files (current session)
ulimit -u 10000
ulimit -n 10000
# Modify number open files
vi /etc/security/limits.conf
# * soft nofile 64000
# * hard nofile 64000
# root soft nofile 64000
# root hard nofile 64000
# Max file size
vi /etc/sysctl.conf
fs.file-max = 2097152
# Enable session limits
vi /etc/pam.d/common-session
# session required pam_limits.so
vi /etc/pam.d/common-session-noninteractive
# restart
sysctl -p
echo 6400 64000 > /proc/sys/net/ipv4/ip_local_port_range
sudo -u nginx bash -c "ulimit -a"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment