Why does high server load start?
Excessive use of the following items can directly lead to high load problems:
How do I check these items?
It depends on whether you want to review current resource usage or historical resource usage. Of course, we will discuss these two aspects in this article.
A brief description of the SAR
Historical resource usage can be viewed through the SAR tool, which, by default, should be installed on all cpanel servers by means of the Sysstat package. The server's running state data is collected as long as the sysstat is periodically executed (/ETC/CRON.D/SYSSTAT) through cron commands. If Cron is not running, Sysstat will not be able to collect historical statistical results.
To view historical resource usage in SAR, we must provide the file with a path that matches the statistics.
For example, if you're going to look at the average server load situation since number 23rd this month, you can run the following command:
Code:
[Email protected] ~]$ sar-q-f/var/log/sa/sa23
The-Q in the above command is used to obtain the average payload information, and-F is used to specify which file the SAR obtains information from. Note that the SAR may not be able to use running information for a week or earlier.
If you intend to view statistics for the current date, you do not have to specify a time for it. Enter the following command to display the average load situation today:
Code:
[Email protected] ~]$ sar-q
We strongly recommend that you read the SAR documentation:
Code:
[email protected] ~]$ man SAR
It provides statistics that help us to know exactly what the server is running.
Current CPU Usage
Run top and check the percentage of idle CPUs shown in the%id section in the CPU (s) row. The higher the number, the better the result, indicating that the CPU workload is not strong. The CPU in the 99% idle state has little to do with any actual tasks, while the CPU in 1% idle means close to full load.
Code:
[email protected] ~]$ top C
Tip: Writable P classifies the process according to how much CPU resources are consumed.
History of CPU Usage
To view the "%idle" column:
Code:
[Email protected] ~]$ sar-p
Current Memory usage
Code:
[Email protected] ~]$ free-m
Tip: Run top C and write m to see which process consumes the most memory.
Historical Memory usage
The command content differs depending on the SAR version. Earlier versions showed percent memory usage versus virtual memory usage by adding the "-r" parameter, but the new version used the "-S" parameter to display the percentage of virtual memory usage.
Check%memused and%swpused:
Code:
[Email protected] ~]$ Sar-r
Or:
Code:
[Email protected] ~]$ Sar-r
Code:
[Email protected] ~]$ sar-s
Memory usage Tip: High server memory consumption is actually very normal. This is because memory reads and writes faster and more efficiently than the server disk, so the operating system tends to preload the memory as a buffer mechanism to increase data read speed.
Similarly, the percentage of memory usage is not a big problem (unless you have set up a virtual memory partition, but this is not related to memory itself). What you really need to focus on is the percentage of virtual memory usage, because virtual memory will only take over if the server's physical memory is fully occupied. The lower the number, the better the server's running state. If virtual memory usage is 0%, it means that our servers are able to take full advantage of physical memory to perform tasks.
So how much virtual memory usage is too high? It depends on how you feel about yourself. In general, if the virtual memory usage has not been high, then our server running state is still relatively ideal. If you find that virtual memory usage is increasing over time (for example, from 1% to 7% to 32%), which means that some processes on the server are gobbling up memory, we need to investigate the situation in a timely manner (instead of installing more memory directly). Once the server runs out of all physical and virtual memory, the entire system will become extremely slow to run, requiring a reboot to temporarily return to normal.
Current disk I/O usage
Note: This item does not work for Openvz/virtuozzo containers.
The following command will continuously display 10 disk usage statistics at a frequency of once per second. Please pay attention to the%util column in the display result:
Code:
[Email protected] ~]$ Iostat-x 1 10
History of disk I/O usage
Code:
[Email protected] ~]$ sar-d
An excellent system administrator is able to accurately grasp the baseline of server load and immediately make judgments when the current load exceeds the benchmark. The main purpose of doing this (in addition to preventing the server from becoming semi-paralyzed and having to restart) is to keep abreast of what projects the server is running when the load is high. Quick response can help you troubleshoot the problem the first time you find it.
If the server is under high load and it is between two o'clock in the morning and four, we will not be able to start the investigation immediately. Although the SAR will always be around the server, help us to collect the time in the end of which the use of resources, but can not reveal the actual cause of the problem. There are many reasons why the load is too high, including Dos attacks, spam attacks, improper PHP script design, web spiders being too aggressive in drawing the network map, hardware failures, and a burst of disk writes against the user's MySQL database.
The good news is that you can use tools to collect this information and send it automatically when the load is too high. How is it implemented? Start with the list of processes:
Code:
[[Email protected] ~]$ PS AUXWWWF
I created a shell script based on a set of Perl scripts on the server that I used to manage. The combination of this script with other server monitoring tools (such as Nagios) has brought me a lot of convenience in my work. It can check six different items (described in detail below) and send me an email notification when an entry in the process list exceeds the threshold value.
Note: Cpanel Company is not responsible for the development, maintenance or technical support of the script. Please do not submit a service request for this script. If you encounter any problems in your use, please post on the relevant forums or consult an experienced system administrator. Cpanel does not provide any support related to this script.
The specific resource objects it examines are as follows:
One minute average load
Virtual memory usage amount in kilobytes (KB)
Amount of memory used (in kilobytes)
Number of packets received per second
Number of packets emitted per second
Total number of processes
How to use Scripts
To run this script automatically, you need to set up a cron task and set the frequency of the operation according to the actual situation. I find it a good choice to run every five minutes. The script does not need to run as root, so we do not have to assign high permissions to it.
If an item in the monitoring resource object above exceeds a user-defined threshold, the script automatically sends an e-mail message that contains the current list of processes.
The subject line of the e-mail message is as follows:
Code:
server.example.com [l:35] [p:237] [Swap use:1%] [pps in:54 PPS out:289]
Here we explain the entries:
L represents a minute average load
P represents the number of processes in the current process list
Swap usage represents the percentage of virtual memory usage
PPS in represents the number of packets received per second
PPS out represents the number of packets sent per second
This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1792584
Linux Server performance monitoring tool SAR II