Linux uses Iostat to analyze IO performance

Source: Internet
Author: User


For i/o-bond types of processes, we often use the Iostat tool to view the number of process IO requests, the time it takes for the system to process IO requests, and then to analyze whether there are bottlenecks in IO aspect of the process and operating system interactions.

The following example is used with the Iostat command, which shows how to use Iostat to view the status of IO request, the System IO processing capability, and the meaning of the fields in the command execution results.

1. do not add the option to execute iostat

Let's take a look at the output of the direct execution Iostat:

Iostat Linux (Linux)     06/12/12avg-cpu:  %user   %nice%system%iowait  %steal   %idle           0.07    0.00    0.05    0.06    0.00   99.81Device:            TPs   blk_read/s   blk_wrtn/s   Blk_read   BLK_WRTNSDA               0.58         9.95        37.47    6737006   25377400sdb               0.00         0.00         0.00        824          0

The iostat is executed separately, displaying the statistics from the system boot to the current execution time. The above output, in addition to the top indicates the system version, host name and date of a row, there are two parts:

AVG-CPU: Overall CPU usage statistics, for multi-core CPUs, here is the average of all CPUs

device: IO statistics for each disk device

For a row of CPU statistics, we mainly look at the value of iowait, which indicates when the CPU waits for the IO request to complete. The columns in the device have the following meanings:

    • Device: unit name shown in SDX form
    • TPS: Number of IO read and write requests per second process
    • blk_read/s: Number of Read sectors per second (512bytes for one sector)
    • blk_wrtn/s: Number of write sectors per second
    • blk_read: Total number of read sectors during sampling interval
    • BLK_WRTN: Total number of write sectors during sampling interval

We can use the-C option to display the results of the AVG-CPU section separately, using the-D option to display the information in the device section separately.

2. Specify the sampling time interval and the number of samples

As with the SAR command, we can specify the sampling interval and number of samples for the Iostat command in the form of "iostat interval [count] ":

iostat-d 1 2 Linux (Linux)     06/13/12device:            TPs   blk_read/s   blk_wrtn/s   blk_read   blk_ WRTNSDA               0.55         8.93        36.27    6737086   27367728sdb               0.00         0.00         0.00        928          0Device:            TPs   blk_read/s   blk_wrtn/s   blk_read   blk_wrtnsda               2.00         0.00        72.00          0         72sdb               0.00         0.00         0.00          0          0

The above command output device information, sampling time is 1 seconds, sampling 2 times, if not specify the number of samples, then Iostat will always output the sampling information, until press "CTRL + C" Exit command. Note that the 1th sampling information is the same as the effect of performing iostat alone, which is the statistics from the system to the current execution time.

3. Display read and write information in kilobytes (-k option )

We can use the-k option to specify that part of the output of Iostat is in kilobytes instead of sector number:

iostat-d- k Linux (Linux)     06/13/12device:            TPs    kb_read/s    kb_wrtn/s    kb_read    kb_ WRTNSDA               0.55         4.46        18.12    3368543   13686096sdb               0.00         0.00         0.00        464          0

In the output above, the values for kb_read/s, KB_WRTN/S, Kb_read, and Kb_wrtn are all in kilobytes, compared with the number of sectors, where the value is half of the original value (1KB=512BYTES*2)

4. more detailed io statistics (-x option )

To show more detailed IO device statistics, we can use the-X option, which typically turns on the-X option when analyzing an IO bottleneck:

iostat-x-k-d 1 Linux (Linux)     06/13/12 ... Device:         rrqm/s   wrqm/s     r/s     w/s    rkb/s    wkb/s avgrq-sz avgqu-sz   await  SVCTM  % UTILSDA               0.00  9915.00    1.00   90.00     4.00 34360.00   755.25    11.79   120.57 6.33  57.60

The above columns have the following meanings:

    • rrqm/s: The number of times per second read requests to the device are merged, and the file system merges requests to read the same block
    • wrqm/s: Number of times per second write requests to the device are merged
    • r/s: Number of reads completed per second
    • w/s: Number of writes completed per second
    • rkb/s: Amount of Read data per second (KB)
    • wkb/s: Amount of Write data per second (in kilobytes)
    • Avgrq-sz: The average amount of data per IO operation (units of sectors)
    • Avgqu-sz: Average queue Length of IO requests waiting to be processed
    • await: Average per IO request wait time (including wait time and processing time, in milliseconds)
    • SVCTM: Average processing time per IO request (in milliseconds)
    • %util: The time ratio used for IO operations in cycles, that is, the time ratio of IO queue non-empty

For the example output above, we can obtain the following information:

    1. Write about 30M data (wkb/s value) to disk per second
    2. 91 IO operations per second (R/S+W/S), with write as the principal
    3. Average per IO request waits 120.57 milliseconds, processing time is 6.33 milliseconds
    4. In the queue of IO requests waiting to be processed, there are an average of 11.79 requests residing

There is also a connection between the above values, and we can calculate other values by some value, for example:

Util = (r/s+w/s) * (svctm/1000)

For the above examples are: Util = (1+90) * (6.33/1000) = 0.57603

Linux uses Iostat to analyze IO performance

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: 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.