2020-01-06 03:30:04 -05:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2020-01-17 16:31:47 -05:00
|
|
|
|
cat > sysctl.conf <<EOF
|
2020-01-06 03:30:04 -05:00
|
|
|
|
# maximum number of open files/file descriptors
|
|
|
|
|
fs.file-max = 4194303
|
|
|
|
|
|
|
|
|
|
# use as little swap space as possible
|
|
|
|
|
vm.swappiness = 1
|
|
|
|
|
|
|
|
|
|
# prioritize application RAM against disk/swap cache
|
2020-08-28 15:07:55 -04:00
|
|
|
|
vm.vfs_cache_pressure = 50
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
|
|
|
|
# minimum free memory
|
|
|
|
|
vm.min_free_kbytes = 1000000
|
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# follow mellanox best practices https://community.mellanox.com/s/article/linux-sysctl-tuning
|
|
|
|
|
# the following changes are recommended for improving IPv4 traffic performance by Mellanox
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# disable the TCP timestamps option for better CPU utilization
|
|
|
|
|
net.ipv4.tcp_timestamps = 0
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# enable the TCP selective acks option for better throughput
|
|
|
|
|
net.ipv4.tcp_sack = 1
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# increase the maximum length of processor input queues
|
2020-01-06 03:30:04 -05:00
|
|
|
|
net.core.netdev_max_backlog = 250000
|
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# increase the TCP maximum and default buffer sizes using setsockopt()
|
|
|
|
|
net.core.rmem_max = 4194304
|
|
|
|
|
net.core.wmem_max = 4194304
|
|
|
|
|
net.core.rmem_default = 4194304
|
|
|
|
|
net.core.wmem_default = 4194304
|
|
|
|
|
net.core.optmem_max = 4194304
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# increase memory thresholds to prevent packet dropping:
|
|
|
|
|
net.ipv4.tcp_rmem = "4096 87380 4194304"
|
|
|
|
|
net.ipv4.tcp_wmem = "4096 65536 4194304"
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# enable low latency mode for TCP:
|
2020-01-06 03:30:04 -05:00
|
|
|
|
net.ipv4.tcp_low_latency = 1
|
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# the following variable is used to tell the kernel how much of the socket buffer
|
|
|
|
|
# space should be used for TCP window size, and how much to save for an application
|
|
|
|
|
# buffer. A value of 1 means the socket buffer will be divided evenly between.
|
|
|
|
|
# TCP windows size and application.
|
2020-01-06 03:30:04 -05:00
|
|
|
|
net.ipv4.tcp_adv_win_scale = 1
|
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# maximum number of incoming connections
|
|
|
|
|
net.core.somaxconn = 65535
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# maximum number of packets queued
|
|
|
|
|
net.core.netdev_max_backlog = 10000
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
2020-08-28 15:07:55 -04:00
|
|
|
|
# queue length of completely established sockets waiting for accept
|
|
|
|
|
net.ipv4.tcp_max_syn_backlog = 4096
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
|
|
|
|
# time to wait (seconds) for FIN packet
|
2020-08-28 15:07:55 -04:00
|
|
|
|
net.ipv4.tcp_fin_timeout = 15
|
2020-01-06 03:30:04 -05:00
|
|
|
|
|
|
|
|
|
# disable icmp send redirects
|
|
|
|
|
net.ipv4.conf.all.send_redirects = 0
|
|
|
|
|
|
|
|
|
|
# disable icmp accept redirect
|
|
|
|
|
net.ipv4.conf.all.accept_redirects = 0
|
|
|
|
|
|
|
|
|
|
# drop packets with LSR or SSR
|
|
|
|
|
net.ipv4.conf.all.accept_source_route = 0
|
|
|
|
|
|
|
|
|
|
# MTU discovery, only enable when ICMP blackhole detected
|
|
|
|
|
net.ipv4.tcp_mtu_probing = 1
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
echo "Enabling system level tuning params"
|
|
|
|
|
sysctl --quiet --load sysctl.conf && rm -f sysctl.conf
|
|
|
|
|
|
|
|
|
|
# `Transparent Hugepage Support`*: This is a Linux kernel feature intended to improve
|
|
|
|
|
# performance by making more efficient use of processor’s memory-mapping hardware.
|
|
|
|
|
# But this may cause https://blogs.oracle.com/linux/performance-issues-with-transparent-huge-pages-thp
|
|
|
|
|
# for non-optimized applications. As most Linux distributions set it to `enabled=always` by default,
|
|
|
|
|
# we recommend changing this to `enabled=madvise`. This will allow applications optimized
|
|
|
|
|
# for transparent hugepages to obtain the performance benefits, while preventing the
|
|
|
|
|
# associated problems otherwise. Also, set `transparent_hugepage=madvise` on your kernel
|
|
|
|
|
# command line (e.g. in /etc/default/grub) to persistently set this value.
|
|
|
|
|
|
|
|
|
|
echo "Enabling THP madvise"
|
|
|
|
|
echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
|