Skip to content

Instantly share code, notes, and snippets.

@stanchan
Created December 31, 2016 00:18
Show Gist options
  • Save stanchan/1b43e3f63744dcc5abfd9c723cea7afc to your computer and use it in GitHub Desktop.
Save stanchan/1b43e3f63744dcc5abfd9c723cea7afc to your computer and use it in GitHub Desktop.
Nginx Web Socket Performance Tuning
Baseline for 40 cores 120GB memory VM
vm.swappiness = 0
fs.file-max = 12000500
fs.nr_open = 20000500
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_mem = 10000000 10000000 10000000
net.ipv4.tcp_rmem = 1024 4096 16384
net.ipv4.tcp_wmem = 1024 4096 16384
net.core.rmem_max = 16384
net.core.wmem_max = 16384
net.nf_conntrack_max = 1048576
sysctl -p
/etc/security/limits.conf:
* soft nofile 20000000
* hard nofile 20000000
* soft nproc 8192
* hard nproc 8192
nf_conntrack_max / 8
echo 131072 > /sys/module/nf_conntrack/parameters/hashsize
cat << EOF >> /etc/nf-conntrack.conf
options nf_conntrack hashsize = 131072
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment