Skip to content

Instantly share code, notes, and snippets.

@asasmoyo
Last active January 14, 2022 02:14
Show Gist options
  • Save asasmoyo/8af371b751b948c0b5ff552ccd3a9300 to your computer and use it in GitHub Desktop.
Save asasmoyo/8af371b751b948c0b5ff552ccd3a9300 to your computer and use it in GitHub Desktop.
linux sysctl.conf tuning
# /etc/security/limits.conf
* soft nofile 524288
* hard nofile 524288
root soft nofile 524288
root hard nofile 524288
* soft nproc 524288
* hard nproc 524288
root soft nproc 524288
root hard nproc 524288
# /etc/pam.d/su
session required pam_limits.so
# the minimum number of entries to keep in the ARP cache
net.ipv4.neigh.default.gc_thresh1=8096
# the soft maximum number of entries to keep in the ARP cache
net.ipv4.neigh.default.gc_thresh2=12288
# the hard maximum number of entries to keep in the ARP cache
net.ipv4.neigh.default.gc_thresh3=16384
# Have a larger connection range available
net.ipv4.ip_local_port_range=1024 65000
# Reuse closed sockets faster
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_fin_timeout=15
net.ipv4.tcp_tw_recycle=0
# The maximum number of "backlogged sockets". Default is 128.
net.core.somaxconn=40000
net.core.netdev_max_backlog=10000
# 16MB per socket - which sounds like a lot,
# but will virtually never consume that much.
net.core.rmem_max=16777216
net.core.wmem_max=16777216
# Various network tunables
net.ipv4.tcp_max_syn_backlog=20480
net.ipv4.tcp_max_tw_buckets=400000
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_syn_retries=2
net.ipv4.tcp_synack_retries=2
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.tcp_mem=50576 64768 98152
#vm.min_free_kbytes=65536
# Connection tracking to prevent dropped connections (usually issue on LBs)
net.netfilter.nf_conntrack_max=3921300
net.ipv4.netfilter.ip_conntrack_generic_timeout=120
net.netfilter.nf_conntrack_tcp_timeout_established=86400
net.netfilter.nf_conntrack_tcp_timeout_time_wait=1
net.ipv4.ip_nonlocal_bind=1
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_sack=1
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_keepalive_intvl=30
net.ipv4.tcp_moderate_rcvbuf=1
fs.file-max=520000
vm.swappiness=10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment