Skip to content

Instantly share code, notes, and snippets.

@dragolabs
Last active October 15, 2015 13:33
Show Gist options
  • Save dragolabs/25159ab5145de20b8437 to your computer and use it in GitHub Desktop.
Save dragolabs/25159ab5145de20b8437 to your computer and use it in GitHub Desktop.
Optimazed sysctl.conf and limits.d
# /etc/security/limits.d/10tuning.conf
# max number of open files
* soft nofile 999999
* hard nofile 999999
root soft nofile 999999
root hard nofile 999999
# max stack size (KB)
* soft stack unlimited
* hard stack unlimited
root soft stack unlimited
root hard stack unlimited
# /etc/sysctl.conf
# Apply: sysctl -p
net.ipv4.conf.all.rp_filter=1
net.ipv4.icmp_echo_ignore_broadcasts=1
fs.nr_open = 1048576
fs.file-max = 3276800
fs.aio-max-nr = 1048576
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_orphan_retries = 1
vm.swappiness = 1
net.core.netdev_max_backlog = 3000
net.core.somaxconn = 262144
net.ipv4.tcp_max_syn_backlog = 8096
net.ipv4.tcp_max_tw_buckets = 720000
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1800
### IPV4 specific settings
# turns TCP timestamp support off, default 1, reduces CPU use
net.ipv4.tcp_timestamps = 0
# turn SACK support on -- you probably want this off for 10GigE
net.ipv4.tcp_sack = 1
# scalling support
net.ipv4.tcp_window_scaling=1
# on systems with a VERY fast bus to memory interface this is the big plus
# sets min/default/max TCP read buffer, default 4096 87380 174760
# setting to 100M - 10M is too small for cross country (chsmall)
net.ipv4.tcp_rmem = 1000000 1000000 1000000
# sets min/pressure/max TCP write buffer, default 4096 16384 131072
net.ipv4.tcp_wmem = 1000000 1000000 1000000
# sets min/pressure/max TCP buffer space, default 31744 32256 32768
net.ipv4.tcp_mem = 150000000 150000000 150000000
### CORE settings (for socket and UDP effect)
# maximum receive socket buffer size, default 131071
net.core.rmem_max = 1000000
# maximum send socket buffer size, default 131071
net.core.wmem_max = 1000000
# default receive socket buffer size, default 65535
net.core.rmem_default = 2524287
# default send socket buffer size, default 65535
net.core.wmem_default = 2524287
# maximum amount of option memory buffers, default 10240
net.core.optmem_max = 2524287
# number of unprocessed input packets before kernel starts dropping them, default 300
net.core.netdev_max_backlog = 300000
# enable window scaling RFC1323 TCP window scaling
net.ipv4.tcp_window_scaling=1
kernel.shmmax = 1147483648
# Probably it will help to reduce the number of TIME_WAIT connections.
# You can also make these changes permanent in /etc/sysctl.conf:
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=1
# recomendation redis
vm.overcommit_memory = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment