mainly refers to the system kernel parameter adjustment in the Linux system for the service application, the optimization does not have the standard,optimization According to the actual needs is the most appropriate. 1) Edit the kernel configuration file
Vim/etc/sysctl.con
2) Parameters and brief description
Net.ipv4.tcp_fin_timeout =2#保持在FIN-wait-2 State of the time so that the system can handle more connections. The value of this parameter is an integer in seconds. Net.ipv4.tcp_tw_reuse=1#开启重用, allows the time_wait socket to be used for new TCP connections. The default is 0, which means close. Net.ipv4.tcp_tw_recycle=1#开启TCP连接中TIME_WAIT Fast recovery of sockets. The default value is 0, which means close. Net.ipv4.tcp_syncookies=1#开启SYN cookie, which enables cookie processing when a SYN wait queue overflows, protecting against a small amount of SYN attacks. The default is 0, which means close. Net.ipv4.tcp_keepalive_time= -#keepalived启用时TCP发送keepalived消息的拼度. The default bit is 2 hours. Net.ipv4.tcp_keepalive_probes=5#TCP发送keepalive探测以确定该连接已经断开的次数. This value can also be shortened appropriately, depending on the situation. NET.IPV4.TCP_KEEPALIVE_INTVL= the#探测消息发送的频率, multiply tcp_keepalive_probes to get the time to kill a connection that has not responded since the start of the probe. The default value is 75 seconds, which means that no active connections will be discarded after approximately 11 minutes. For general applications, this value is somewhat larger and can be changed as needed. In particular, the Web Class Server needs to be smaller. Net.ipv4.ip_local_port_range=1024x768 65000#指定外部连接的端口范围. The default value is 3276861000. Net.ipv4.tcp_max_syn_backlog=262144#表示SYN队列的长度, the preset is 1024, where the queue length is set to 262144to accommodate more waiting connections. Net.ipv4.tcp_max_tw_buckets= the#系统同时保持TIME_WAIT套接字的最大数量, if more than this value will be immediately clear and output a warning message. The default value is 180000. For squid, the effect is not very large, but can control the TIME_WAIT socket maximum, to avoid the squid server was dragged dead. Net.ipv4.tcp_syn_retries=1#表示在内核放弃建立连接之前发送SYN包的数量. Net.ipv4.tcp_synack_retries=1#设置内核放弃连接之前发送SYN +the number of ACK packets. Net.core.somaxconn=16384#定义了系统中每一个端口最大的监听队列的长度, for a high-load Web service environment that often handles new connections, the default value is 128, which is small. Net.core.netdev_max_backlog=16384#表示当在每个网络接口接收数据包的速率比内核处理这些包的速率快时, the maximum number of packets that are allowed to be sent to the queue. Net.ipv4.tcp_max_orphans=16384#表示系统中最多有多少TCP套接字不被关联到任何一个用户文件句柄上. If you exceed the number set here, the connection resets and outputs a warning message. This limitation is only for the purpose of preventing simple Dos attacks. This value cannot be too small.
3) Effective configuration
Sysctl-p
From Jane Book: https://www.jianshu.com/p/3096a8e6a36f
Linux kernel optimization