Debian系统内核 网络性能调优






更新环境

apt update -y && apt full-upgrade -y && apt autoremove -y && apt autoclean -y && apt install -y curl wget sudo socat


调整参数

sudo sysctl -w net.core.somaxconn=65535 net.core.netdev_max_backlog=16384 net.ipv4.tcp_max_syn_backlog=8192 net.ipv4.tcp_fin_timeout=15 net.ipv4.tcp_keepalive_time=300 net.ipv4.tcp_keepalive_probes=5 net.ipv4.tcp_keepalive_intvl=15 net.ipv4.tcp_tw_reuse=1 net.ipv4.ip_local_port_range='1024 65535' net.ipv4.tcp_tw_recycle=1



上面这行命令将系统参数更改为一些经过测试的优化值,包括:


net.core.somaxconn:等待接受连接的队列大小的最大值

net.core.netdev_max_backlog:网络设备驱动程序的输出队列大小

net.ipv4.tcp_max_syn_backlog:接受SYN请求的最大数量

net.ipv4.tcp_fin_timeout:等待连接中的数据传输结束的时间

net.ipv4.tcp_keepalive_time:开始发送TCP keepalive消息的时间

net.ipv4.tcp_keepalive_probes:发送keepalive消息的数量

net.ipv4.tcp_keepalive_intvl:发送TCP keepalive消息之间的时间间隔

net.ipv4.tcp_tw_reuse:允许重新使用处于TIME_WAIT状态的socket

net.ipv4.ip_local_port_range:指定本地端口范围

net.ipv4.tcp_tw_recycle:启用TCP连接快速回收机制

注意:修改系统内核参数可能会导致一些潜在的风险,因此在执行这些命令之前请确保你已经了解了这些风险。


BBR相关

cat > /etc/sysctl.conf << EOF

net.core.default_qdisc=fq_pie

net.ipv4.tcp_congestion_control=bbr

EOF

sudo sysctl -p



重启服务器

reboot



恢复初始参数

sudo sysctl -w net.core.somaxconn=128 net.core.netdev_max_backlog=1000 net.ipv4.tcp_max_syn_backlog=512 net.ipv4.tcp_fin_timeout=60 net.ipv4.tcp_keepalive_time=7200 net.ipv4.tcp_keepalive_probes=9 net.ipv4.tcp_keepalive_intvl=75 net.ipv4.tcp_tw_reuse=0 net.ipv4.ip_local_port_range='32768 60999' net.ipv4.tcp_tw_recycle=0

评论

此博客中的热门博文

科技lion官方一键脚本上线!VPS监控测试建站维护于一身的全能工具箱

2023国外的接码平台分享

CloudCone付费VPS分享 挺便宜的