def TCP/IP():
https://www.ixigua.com/i6805832300513722892/
滑动窗口
慢启动
拥塞算法
RTT
natty
def TCP_IP():
局部文件句柄限制:
vim /etc/security/limits.conf
增加下面
root soft nofile 1000000
root hard nofile 1000000
* soft nofile 1000000
* hard nofile 1000000
* 表示当前用户,修改后要重启
全局文件句柄限制(所有进程最大打开的文件数,不同系统是不一样,可以直接echo临时修改):
cat /proc/sys/fs/file-max
永久修改全局文件句柄, 修改后生效 sysctl -p
vim /etc/sysctl.conf
增加 fs.file-max = 1000000
[连接回收调优]
https://blog.csdn.net/enweitech/article/details/79261439
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
/sbin/sysctl -w net.ipv4.tcp_tw_recycle=0
/sbin/sysctl -w net.ipv4.tcp_fin_timeout=10
/sbin/sysctl -w net.ipv4.tcp_timestamps=0
vi /etc/sysctl.conf
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1 表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭;
net.ipv4.tcp_tw_recycle = 1 表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭。这个开关,需要net.ipv4.tcp_timestamps(默认开启的)这个开关开启才有效果。
当 tcp_tw_recycle 开启时(tcp_timestamps同时开启,快速回收socket的效果达到),对于位于NAT设备后面的Client来说,是一场灾难——会导到NAT设备后面的Client连接Server不稳定(有的Client能连接server,有的Client不能连接server)。
net.core.rmem_default = 256960
net.core.rmem_max = 4194304
net.core.wmem_default = 256960
net.core.wmem_max = 1048576
net.core.somaxconn = 2048
net.core.optmem_max = 81920
net.ipv4.tcp_mem = 759735 1012981 1519470
net.ipv4.tcp_rmem = 8760 256960 4088000
net.ipv4.tcp_wmem = 8760 256960 4088000
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_retries2 = 3
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.ip_local_reserved_ports = 2280,3000,3868,4369,5000,5002,5671-5673,6373-6379,6443,7275-7279,7777,7890-7892,8005,8080,8090,8443,8700,8888,9080,9082,9210-9219,9500,9600,9797,10000-10001,10010-10011,15672,16379,18167,22002,22101-22102,22401,22799,22902,25672,38750-38753
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.netfilter.nf_conntrack_max = 524288
net.nf_conntrack_max = 524288
net.bridge.bridge-nf-call-iptables=1