1. Adjust the number of system file descriptors, the default is 1024x768 #ulimit-N to view
[[email protected] core]# ulimit-n1024 adjustment method: [[email protected] core]# echo ' *-nofile 65535 ' >>/etc/securi TY/LIMITS.CONF Note: After the configuration is complete, you need to log back in to take effect [email protected] core]# ulimit-n65535
In a 2.Linux system, after a TCP connection is disconnected, a certain amount of time is retained in the TIME_WAIT state before the port is released. When there are too many concurrent requests, a large number of time_wait state connections are generated, which can be used in a large number of ports if they are not broken in time. At this point, the kernel parameters of TCP can be optimized to clean up the port of Time_wait state in time.
Configuration:/etc/sysctl.conf, empty the original content, copy the following content
[[email protected] core]# cat/etc/sysctl.confnet.ipv4.tcp_syncookies = 1 Net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_ Recycle = 1 Net.ipv4.tcp_fin_timeout = 30net.ipv4.tcp_max_tw_buckets = 6000net.ipv4.ip_local_port_range = 1024 65536net.ipv4.tcp_keepalive_time = 30net.core.rmem_max=16777216net.core.wmem_max=16777216net.ipv4.tcp_rmem=4096 87380 16777216net.ipv4.tcp_wmem=4096 65536 16777216net.ipv4.tcp_timestamps = 1net.core.netdev_max_backlog = 30000net.core.somaxconn = 262144net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_syn_retries = 2net.ipv4.tcp_synack _retries = 2
Parameter explanation:
Net.ipv4.tcp_syncookies = 1: This parameter is not performance-independent, used to resolve SYN attacks on TCP, which has been configured by default
Net.ipv4.tcp_tw_reuse = 1: Indicates enable reuse, allowing time-wait sockets to be reused for new TCP connections, default to 0
Net.ipv4.tcp_tw_recycle = 1: A quick recycle of time-wait sockets in a TCP connection is turned on, default is 0
Net.ipv4.tcp_fin_timeout =: #缩短默认的TIMEOUT时间
Net.ipv4.tcp_max_tw_buckets = 6000: number of #控制最大TIME-wait
Net.ipv4.ip_local_port_range = 1024x768 65536: #向外开放的端口范围
Net.ipv4.tcp_keepalive_time = #长连接超时时间
net.core.rmem_max=16777216: #最大接收套接字缓冲区大小
net.core.wmem_max=16777216: #最大发送套接字缓冲区大小
net.ipv4.tcp_rmem=4096 87380 16777216#TCP接收缓冲大小, corresponding to the minimum, default, maximum
net.ipv4.tcp_wmem=4096 65536 16777216#TCP发送缓冲大小, corresponding to the minimum, default, maximum
Net.ipv4.tcp_timestamps = 1 #不带时间戳节省内存空间
Net.core.netdev_max_backlog = 30000#当网络接口接收速率比内核处理快时允许发到队列的数据包数目
Net.core.somaxconn = 262144#系统同时发起的TCP连接数, exceeding causes connection timeout or retransmission
Net.ipv4.tcp_syn_retries = 2#SYN重试次数
Net.ipv4.tcp_synack_retries = 2#控制内核向已建立连接的远程主机重新发送数据的次数, lower this value to detect connection failure early
Net.ipv4.tcp_max_syn_backlog = 262144#此参数暂不知有何用途
This article is from the "burning Years of Passion" blog, please be sure to keep this source http://liuzhengwei521.blog.51cto.com/4855442/1884098
Optimization of Linux parameters (continuously updated as experience increases)