Sysctl optimization updates for Redis, MongoDB, etc.

Sysctl Performance tips for Redis, MongoDB, etc.

# backup:
$ sysctl -a > /home/sysctl_$(date +%Y%m%d).bak
#check:
$ sysctl -a
 
# make changes to sysctl.conf:
$ vi/nano /etc/sysctl.conf
 
# web - nginx, redis, mongo, etc:
vm.swappiness = 10
vm.dirty_ratio = 40
vm.dirty_background_ratio = 10
# for larger servers:
net.ipv4.tcp_rmem = 4096 12582912 33554432
net.ipv4.tcp_wmem = 4096 12582912 33554432
net.core.rmem_max = 33554432
net.core.wmem_max = 33554432
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
#
net.ipv4.tcp_max_syn_backlog = 65536
kernel.keys.root_maxkeys = 1000000
#Raise somaxconn (above 511)
net.core.somaxconn = 4096
 
# vm.overcommit_memory (optional):
# vm.overcommit_memory = 1
####
 
# set in /etc/rc.local (test reboot stickiness)
# ensure changes to sysctl configuration persist across reboots:
$ sysctl -p
 
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi

more info:

  • https://wiki.mikejung.biz/Sysctl_tweaks
  • https://www.techandme.se/performance-tips-for-redis-cache-server/
  • https://unix.stackexchange.com/questions/99154/disable-transparent-hugepages
  • Leave a Reply