/ VPS / 40浏览

Linux 服务器 sysctl 参数调整实例

net.ipv4.tcp_congestion_control = bbr
net.core.default_qdisc = fq
net.core.optmem_max = 20480
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.ipv4.tcp_rmem = 8192 1048576 33554432
net.ipv4.tcp_wmem = 8192 1048576 33554432
net.ipv4.tcp_collapse_max_bytes = 6291456
net.ipv4.tcp_notsent_lowat = 131072
net.ipv4.udp_rmem_min = 4096
net.ipv4.udp_wmem_min = 4096
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_adv_win_scale = -2
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_moderate_rcvbuf = 1
net.ipv4.tcp_mtu_probing = 0

net.ipv4.ip_local_port_range = 10000 60000
net.ipv4.ip_forward = 1
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_ecn = 0
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_rfc1337 = 0
net.ipv4.tcp_sack = 1
net.ipv4.tcp_frto = 0
net.ipv4.tcp_fack = 1
net.ipv4.tcp_slow_start_after_idle = 0

net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_retries2 = 8
net.ipv4.tcp_syn_retries = 6
net.ipv4.tcp_synack_retries = 3
net.ipv4.tcp_max_orphans = 16384

net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_tw_reuse = 1
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384

net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.tcp_fin_timeout = 30

net.netfilter.nf_conntrack_max = 1000000

kernel.panic = -1
kernel.pid_max = 4194304
kernel.core_uses_pid = 1
fs.file-max = 2097152
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
vm.swappiness = 30
vm.min_free_kbytes = 2048
vm.dirty_ratio = 10
vm.dirty_background_ratio = 5
vm.compaction_proactiveness = 0
vm.extfrag_threshold = 1000

其中net.ipv4.tcp_collapse_max_bytes需要自行编译Cloudflare提供的补丁到内核中才能启用

参考:

Linux 网络调优:内核网络栈参数篇

Optimizing TCP for high WAN throughput while preserving low latency

0

  1. This post has no comment yet

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注