Vmstat command details-linux Performance Analysis

Source: Internet
Author: User
Tags high cpu usage

Version:

Procps version 3.2.8

Basic usage:

Vmstat [-a] [-n] [-t] [-S unit] [delay [count]

[-A]: displays active and inactive memory.

[-N]: The field name is displayed only once at the beginning, and the user-friendly information is displayed when information is collected multiple times.

[-T]: displays the time when information is collected at the end of each message.

[-S unit]: displays data in a specified unit. Parameters include k, K, m, and M, representing 1000, 1024, 1000000, and 1048576 bytes respectively ). The default unit is K (1024 bytes)

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

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

[-S]: displays memory-related statistics.

Vmstat [-m] [-n] [delay [count]

[-M]: displays slabinfo, which is recorded in the/proc/slabinfo file. Slab is a memory allocation mechanism in linux.

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

[-D]: displays statistics of related disks.

Note: The difference between this and-p is different. The statistical information is different. The statistical object is disk-p, which is a subpartition. This cannot specify all outputs.

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

[-P disk partition]: displays the statistics of the disk sub-partitions, which is not as useful as iostat.

Vmstat [-f]

[-F]: Number of forks since startup. Note: fork should be the fork () function of the kernel. In the parent process,ForkReturns the ID of the newly created sub-process.

Vmstat [-V]

[-V]: Version Information

Output explanation:

Based on the actual situation of vmstat, the output of vmstat-a is explained below.

R: Indicates the running Queue (that is, how many processes are actually allocated to the CPU). Currently, the CPU of the server I tested is relatively idle and no program is running. When this value exceeds the number of CPUs, the CPU bottleneck may occur. This is also related to the top load. Generally, when the load exceeds 3, it is relatively high. If the load exceeds 5, it is high. If the load exceeds 10, it is abnormal and the server status is very dangerous. The top load is similar to the running queue per second. If the running queue is too large, it indicates that your CPU is very busy, which may cause high CPU usage.

B: Indicates the blocked process. This is not to mention that the process is blocked. You can understand it.

Swpd: The size of the virtual memory used. If it is greater than 0, the physical memory of your machine is insufficient. If it is not the cause of program memory leakage, you should upgrade the memory or migrate the memory-consuming tasks to other machines.

Free: The size of idle physical memory. The total memory of my machine is 8 GB, and the remaining memory is 3415 MB.

Buff: Linux/Unix systems are used for storage. What content and permissions are contained in the directory are cached. My local machine occupies more than 300 MB.

Cache: cache is used directly to remember the files we open and buffer the files. My local machine occupies more than 300 MB (here is the cleverness of Linux/Unix, cache part of the idle physical memory for files and directories to Improve the Performance of program execution. When the program uses the memory, buffer/cached will be quickly used .)

Si: The size of the virtual memory read from the disk per second. If the value is greater than 0, it indicates that the physical memory is insufficient or the memory is leaked. Find out the memory-consuming process to solve the problem. My machine has plenty of memory and everything is normal.

So: The size of the virtual memory written to the disk per second. If the value is greater than 0, the same as above.

Bi: The number of blocks received by Block devices per second. The Block devices here refer to all disks and other Block devices in the system. The default block size is 1024 bytes. I have no IO operations on this machine, so it has always been 0, but I have seen it on a machine that processes a large amount of data (2-3 TB) that can reach 140000/s, and the disk write speed is almost MB per second.

Bo: Number of blocks sent by Block devices per second. For example, if we read files, the number of bo messages must be greater than 0. Bi and bo are generally close to 0. Otherwise, IO is too frequent and needs to be adjusted.

In: The number of CPU interruptions per second, including time interruptions

Cs: The number of context switches per second. For example, if we call a system function, we need to perform context switching, thread switching, and process context switching. The smaller the value, the better, the larger the value, we need to reduce the number of threads or processes. For example, on a web server such as apache and nginx, we generally perform thousands or even tens of thousands of concurrent tests during performance tests, the process of selecting the web server can be lowered from the process or thread peak until cs reaches a relatively small value. This process and the number of threads are a suitable value. The same is true for system calls. Every time we call a system function, our Code will enter the kernel space, resulting in context switching. This is resource-consuming and we should try to avoid frequent calls to system functions. Too many context switches indicate that most of your CPU is wasted on context switches, resulting in less time for proper CPU operations and insufficient CPU utilization.

Us: The CPU time of the user. I used to perform encryption and decryption on a server that frequently performed encryption and decryption. We can see that the number of us running queues is close to 100, and the number of r running queues reaches 80. (The Machine is performing a stress test, poor performance ).

Sy: System CPU time. If it is too high, it indicates that the system call time is long, for example, frequent IO operations.

Id: Idle CPU time. Generally, id + us + sy = 100. Generally, id indicates idle CPU usage, us indicates user CPU usage, and sy indicates system CPU usage.

Wt: Wait for the io cpu time.

Instance used:




Related Article

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.