Detailed description of VMSTAT commands in Linux memory and performance diagnostics

Source: Internet
Author: User
Tags switches cpu usage high cpu usage

The Vmstat command is the most common Linux/unix monitoring tool that can show the status of a server at a given time interval, including server CPU utilization, memory usage, virtual memory exchange, IO Read and write situations. Compared to top, the Vmstat can see the CPU, memory, and IO usage of the whole machine, instead of just seeing the CPU usage and memory usage of each process.

Run the sample

The use of the general Vmstat tool is done by two numeric parameters, the first parameter is the number of time intervals sampled, the unit is seconds, the second parameter is the number of samples, such as:

[Email protected]-199:~#Vmstat2 1Procs-----------Memory---------- ---Swap-- -----Io---- -System-- ----Cpu----RBSwpd FreeBuffCacheSiSoBiBoInchCS US sy ID WA0  0  97640< Span class= "pun" >  53884 192800 578212    0    Span class= "lit" >0     3     20    1    12  1  2 93  3   

2 indicates that the server state is collected every two seconds, and 1 means that it is collected only once.

In fact, in the application process, we will be monitoring for a period of time, do not want to monitor the direct end of Vmstat, such as:

[Email protected]-199:~#Vmstat2Procs-----------Memory---------- ---Swap-- -----Io---- -System-- ----Cpu----RBSwpdFreeBuffCacheSiSoBiBoInch CS US sy ID WA019764050348 192812 5783520032011212 933009764054636 192812 578360000 1412614724 868039764053908 192816 578356000629611024 869009764054156 192816 5783600001411311835 83 11 0  0  97640  53908  192816 578360    0    0     0     16  107   103  2   3 87  9  

This means that Vmstat collects data every 2 seconds, until I end the program.

Detailed parameters

The Linux memory Monitor vmstat command output is divided into six sections:

(1) processProcs:R: Number of processes waiting in the run queue 。B: In the waitingIoNumber of processes 。(2)Linux Memory Monitoring MemoryMemoy:Swpd: The currently available swap memory (unitKb)。Free: Idle Memory (in unitsKb)。Buff: Buffer to go in the number of memory (in units:Kb)。Cache: The amount of memory that is used as a cache (in units:Kb)。(3) Linux Memory monitoringSwapSwap pageSi: Number of swapped pages exchanged from disk to memory, in units:KbSecondsSo: Number of swap pages from memory swap to disk, in units:KbSeconds(4)Linux Memory monitoringIoBlock device:Bi: The number of blocks sent to the block device, in blocks per second.Bo: The number of blocks received from the block device, in blocks per second.(5)Linux Memory monitoringSystem system:      in:   interrupts per second, including clock interrupts.     cs:  The number of environment (context) conversions per second.  (6) linux   Memory monitoring cpu CPU:      cs: time the user process used      sy: Time used by the system process.      id: CPU idle time   

Common diagnostics:

1, if R is often greater than 4, and the ID is often less than 40, indicating that the CPU load is very heavy.

2, if the Bi,bo is not equal to 0 for a long time, indicates that the physical memory capacity is too small.

The specific meanings of each parameter are as follows:

R means running the queue (that is, how many processes are really allocated to the CPU), the server I am testing is currently idle, there is no program running, when this value exceeds the number of CPUs, there will be a CPU bottleneck. This is also related to top of the load, the general load over 3 is relatively high, more than 5 is high, more than 10 is not normal, the state of the server is very dangerous. The load on top is similar to the run queue per second. If the running queue is too large, it means that your CPU is busy, which generally results in high CPU usage.

b represents the blocking process, which is not much to say, the process is blocked, you understand.

swpd Virtual memory has been used size, if greater than 0, indicates that your machine is out of physical memory, if not the cause of program memory leaks, then you should upgrade the memory or the memory-consuming task to other machines.

Free physical memory size, my machine memory total 8G, the remaining 3415M.

Buff Linux/unix system is used to store, directory inside what content, permissions, etc. of the cache, I machine about more than 300 m

the cache cache is used directly to memorize the files we open, to buffer the files, I have about 300 m of this machine (this is the smart place of Linux/unix, the spare part of the physical memory to do the file and directory cache, is to improve the performance of the program execution, When the program uses memory, buffer/cached is quickly used. )

Si reads the size of the virtual memory from disk every second, if this value is greater than 0, it means that the physical memory is not enough or the memory leaks, to find out the memory process. My machine has plenty of memory and everything is fine.

so per second the virtual memory is written to the size of the disk, if this value is greater than 0, ibid.

The number of blocks received per second by BI block devices, where the block device refers to all the disks and other block devices on the system, the default block size is 1024byte, I have no IO operation on this machine, so it has been 0, but I have been working on copying large amounts of data (2-3T) The machine has seen can reach 140000/s, disk write speed of almost 140M per second

The number of blocks that Bo block devices send per second, such as when we read a file, the Bo will be greater than 0. Bi and Bo are generally close to 0, otherwise the IO is too frequent and needs to be adjusted.

in CPU interrupts per second, including time interrupts

CS per second, such as the number of context switches, such as we call the system function, the context switch, the thread of the switch, but also the process context switch, the smaller the value of the better, too big, to consider the number of threads or processes, such as in Apache and Nginx Web server , we generally do performance testing will carry out thousands of concurrent or even tens of thousands of concurrent testing, the process of selecting a Web server can be the peak of the process or the thread has been down, pressure measurement, until CS to a relatively small value, the process and the number of threads is a more appropriate value. System calls are also, each time the system function is called, our code will enter the kernel space, resulting in context switching, this is very resource-intensive, but also try to avoid frequent calls to system functions. Too many context switches means that most of your CPU is wasted in context switching, resulting in less time for the CPU to do serious work, and the CPU not being fully utilized, is undesirable.

US user CPU time, I used to do encryption and decryption very frequently on the server, you can see us approaching 100,r running queue reached 80 (the machine is doing a stress test, poor performance).

sy System CPU time, if too high, indicates a long system call time, for example, the IO operation is frequent.

ID Idle CPU time, in general, ID + US + sy = 100, generally I think ID is idle CPU usage, US is the user CPU usage, SY is the system CPU utilization.

wt waits for IO CPU time.

Detailed description of VMSTAT commands in Linux memory and performance diagnostics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.