Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the production server slows down?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "what to do when the production server slows down". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Top

If you look at the overall usage of the server, it is usually done by top command.

Img

I know you must be a little confused when you see this picture, especially the numbers. What is this?

A fan will show you a line.

Line 1: system time, run time, number of login terminals, system load (the three values are the average values within 1 minute, 5 minutes, and 15 minutes, respectively. A smaller value means a lower load)

Line 2: total number of processes, number of running processes, number of processes in sleep, number of stopped processes, number of dead processes. In general, as long as there is no rigid process, there is no big problem.

Line 3: percentage of resources occupied by users, percentage of resources occupied by the system kernel, percentage of process resources that have changed priority, percentage of idle resources, and so on.

Line 4: total physical memory, memory free, memory usage, amount of memory used as kernel cache

Line 5: total virtual memory, virtual memory free, virtual memory usage, amount of memory that has been preloaded

Line 6 mainly looks at the two parameters PID and COMMAND, where PID is the process ID and COMMAND is the command executed. You can see that the first two processes are both java processes.

In the current interface, press numeric keypad 1 to see the detailed utilization of each CPU

Vmstat

If you want to know how CPU is used, the common command is vmstat.

Generally, the use of the vmstat tool is accomplished through two numerical parameters, the first parameter is the sampling interval, in seconds, and the second parameter is the number of samples. This time, the command of A Fan is: vmstat-n 32 means to take samples every 3 seconds, a total of 2 samples.

The two parameters procs and cpu are mainly concerned with.

Procs:

R: the number of processes running and waiting for CPU time slices. Generally speaking, the running queue of the whole system should not exceed 2 times the total number of cores, otherwise the system will be under too much pressure.

B: number of processes waiting for resources, such as disk IO, network IO, etc.

Cpu:

Us: the percentage of CPU time consumed by the user process. If the us value is high, it means that the CPU time consumed by the user process is relatively long. If it is more than 50% for a long time, it means that the program still needs to be optimized.

Sy: percentage of CPU time consumed by kernel processes

The reference value of us + sy is 80%. If it is greater than 80%, it indicates that there may be insufficient CPU.

Free

Free is used to check the memory. It mainly has three commands: free free-g free-m. Why is free-m recommended by A Fan? let's take a look at their respective running results.

Img

Among them: free command running results show very unfriendly, see 3880324 can you quickly tell me how big it is? free-g this command is rounded, obviously given memory is 4G, as a result, using free-g to check, it turns out to be 3G? excuse me? If there is something wrong with the online environment, you say that because there is not enough memory, the operation and maintenance staff said, "I can't carry this pot."

Relatively speaking, free-m is relatively easy to read, and the results are relatively accurate.

If the available memory of the application / the physical memory of the system is more than 70%, the memory is sufficient and there is no problem, but if it is less than 20%, you should consider increasing the memory.

Df

If you troubleshoot disk problems, the first thing to look at is whether there is enough disk space. I still remember that when A Fan was in the last company, there was a magical problem with svn, that is, no errors were reported anywhere, that is, the code could not be submitted, and in the end, there was not enough disk space.

So don't ask A Fan why when troubleshooting disk problems, the first thing is to see if there is enough disk space!

Checking disk space is either df or df-h.

Iostat

Speaking of disk IO, I'm sure you can imagine that when operating on the database, the first thing to consider is the disk IO operation, because relatively speaking, if a large number of writes to the disk in a certain period of time will result in a long waiting time for the program, resulting in no response from the client side for a long time, will the user experience be reduced?

The command to check disk IO is iostat. If you find a prompt when you use it:-bash: iostat: command not found, that's because sysstat is not installed, just install it: yum install-y sysstat

Then run the command: iostat-xdk 32, which is very similar to the vmstat command.

We don't need to pay attention to so many indicators, we just need to look at these:

RkB/s: read data per second kB

WkB/s: kB of data written per second

Svctm: the aPCge service time (in milliseconds) of the Icano request

Util: a few percent of the time in a second is spent on Imax O operations. If it is close to 100%, it means that the disk bandwidth is full, so it is time to optimize the program or increase the disk.

Sar

For network IO, you can look at it through the command sar-n DEV 32, which is similar to the above, meaning to take samples every 3 seconds, a total of 2 samples.

Where:

IFACE: LAN interface

Rxpck/s: packets received per second

Txpck/s: packets sent per second

RxKB/s: the amount of data received per second, in KByte

TxKB/s: the amount of data sent per second (in KByte)

Rxcmp/s: compressed packets received per second

Txcmp/s: compressed packets sent per second

Rxmcst/s: multicast packets received per second

This way is very simple and intuitive, and it is easier for beginners to see.

This is the end of the content of "what to do if the production server slows down". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report