Linux system Performance Bottleneck (IO/CPU/MEM) when it is a big expense of software tuning, but rather from the hardware to solve more reasonable, software tuning performance increase is negligible. Because the parameters have been set reasonably at the beginning of the system deployment.
Linux system software tuning is to make the parameter settings more reasonable, so as to achieve performance improvement.
I. Linux System Foundation Optimization
When the Linux server completes the installation, we need to make some reasonable settings
- Not use root user login system, add ordinary user, through sudo authorization management, reduce root user risk for human operation
- Configuration Yum source for domestic sources, such as Ali, 163 netease Source
- Configure timing to update system time to prevent business failures due to system errors
- Change the default port of the SSHD service to prevent the root user from logging on to the system
- Shut down the Iptable,selinux service, if the server has a public IP, you need to configure the Iptables service
- Disable unnecessary boot-up, auto-start service: Network,rsyslog,sshd,crond
- Change the system character set support Chinese, suggest or use English to prevent garbled
- Adjust System file descriptors
- Locking system Key files using the chart command:/etc/passwd,/etc/shadow,/etc/group,/etc/gshadow
- Remove the display of the system and kernel login page, i.e. empty/etc/issue
- Adjust the common kernel parameters of the system, mainly with the TCP-related parameters
Two. Common Kernel parameter optimization
Before looking at these parameters need to understand the TCP/IP three-time handshake and four wave principle and process, so as to help understand these parameters
#对于本端断开的socket连接, the time that TCP remains in the fin-wait-2 state net.ipv4.tcp_fin_timeout = * Indicates whether the socket in the time-wait state is allowed to be re-used for new TCP connections, ( This is very helpful for quickly restarting some services, and prompting the ports to be used after startup Net.ipv4.tcp_tw_reuse = # Open Fast time-wait sockets recovery net.ipv4.tcp_tw_recycle = # When the SYN wait queue appears overflow, the syncookies is sent like the other. The aim is to prevent SYN flood attacks. Net.ipv4.tcp_syncookies = 1#tcp The time interval (in seconds) for sending KeepAlive probe messages to confirm that the TCP connection is valid. An attack that prevents connections but does not send data on both sides. Net.ipv4.tcp_keepalive_time = 600# indicates the port range used for outward connection Net.ipv4.ip_local_port_range = 4000 65000# for those (sync) connection requests that still do not have a client acknowledgement , the maximum number that needs to be saved in the queue. For systems that exceed 128Mb of memory, the default value is 1024net.ipv4.tcp_max_syn_backlog = 16384# The maximum number of timewait sockets the system handles at the same time Net.ipv4.tcp_max_tw_ Buckets = 36000# route cache refresh frequency, how long after a route fails to jump to another, the default is 300net.ipv4.route.gc_timeout = #对于一个新建连接, the kernel to send the number of SYN connection requests before deciding to discard. Net.ipv4.tcp_syn_retries = # for a remote connection request SYN, the kernel sends a SYN +ack datagram to confirm receipt of the last SYN connection request package. This is the second step of the so-called three-time handshake (threeway handshake) mechanism. This determines the number of syn+ack that are sent by the inner kernel before it abandons the connection. Net.ipv4.tcp_synack_retries = # is used to limit the number of maximum packets in the Listening (LISTEN) queue, which causes the link to time out or trigger a retransmission mechanism. Net.core.somaxconn = 16384# the rate at which each network interface receives packets is faster than the rate at which the kernel processes these packets, allowing delivery toMaximum number of packets in a queue Net.core.netdev_max_backlog = 16384# System can handle the maximum number of TCP sockets that are not part of any process. If this amount is exceeded, then the connection that is not part of any process is immediately reset and a warning message is displayed. Net.ipv4.tcp_max_orphans = 16384
For parameter related English explanation can see Help document man TCP
Linux Basic optimization