Vmstat Command detailed--linux performance analysis

Source: Internet
Author: User
Tags switches high cpu usage

Version information:

Procps version 3.2.8

Basic use:

Vmstat [-A] [-n] [-T] [-s unit] [delay [count]]

[-A]: Show active and inactive memory

[-N]: Displays the field name only once at the beginning, and for the case of multiple information collection

[-T]: At the end of each piece of information, the time at which information is collected is displayed

[-S unit]: displayed using the specified units. The parameters are K, K, M, M, respectively, representing 1000, 1024, 1000000, 1048576 bytes (byte). The default unit is K (1024x768 bytes)

[Delay [Count]]:delay is the information collection interval, count is the number of times the information is collected

Vmstat [-S] [-n] [-s unit]

[-S]: show memory-related statistics

Vmstat [-M] [-n] [delay [count]]

[-M]: Displays slabinfo,slabinfo information is recorded in the/proc/slabinfo file. Slab is a memory allocation mechanism for Linux.

Vmstat [-d] [-n] [delay [count]]

[-D]: Displays statistics about the relevant disk

Note: This is different from the downstairs-p difference Statistics, statistics object This is the disk-P is a sub-partition, this cannot specify all the output

Vmstat [-P disk partition] [-n] [delay [count]]

[-P disk partition]: Displays the statistics of the disk sub-partitions, where there is no iostat information so useful

Vmstat [-F]

[-f]: Fork quantity since start up Note: The fork here should be the fork () function of the kernel, in the parent process,fork returns the process ID of the newly created child process

Vmstat [-v]

[-V]: version information

Output Explanation:

According to the actual situation of Vmstat, the following is interpreted for the output of vmstat-a.

R : To run the queue (that is to say how many processes are really allocated to the CPU), I test the server is currently idle CPU, no program is 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: The process of blocking, this is not much to say, the process is blocked, you understand.

SWPD: The size of virtual memory used, 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: The size of the spare physical memory, my machine memory total 8G, the remaining 3415M.

Buff: Linux/unix system is used to store, directory inside what content, permissions and so on cache, I machine probably occupy more than 300 m

Cache:cache directly to memory of our open files, to buffer the file, I am about to occupy more than 300 m (this is the smart place of the 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 will be used very quickly. )

si: The size of the virtual memory read from disk per second, if the value is greater than 0, indicates that the physical memory is not enough or memory leaks, to find the consumption of memory process resolved. My machine has plenty of memory and everything is fine.

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

bi: The number of blocks received per second by the block device, 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

bo: The number of blocks that a block device sends 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: Number of CPU interrupts per second, including time interrupts

CS: The number of context switches per second, for example, we call the system function, the context switch, the thread of the switch, but also the process context switch, the value of the smaller the better, too big, to consider lowering the number of threads or processes, For example, in the Apache and Nginx Web server, we generally do performance testing in 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, This process and the number of threads is the 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 stress testing, 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.

Usage examples:




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.