Home > System Tutorial > LINUX > Understand Linux disk performance using iostat command

Understand Linux disk performance using iostat command

WBOY
Release: 2023-12-29 09:11:58
forward
1191 people have browsed it

Introduction

iostat is mainly used to monitor the IO load of system devices. When iostat is run for the first time, it displays various statistical information since the system startup. Running iostat thereafter will display statistical information since the last time the command was run. Users can obtain the required statistical information by specifying the number and time of statistics.

grammar

iostat [ -c ] [ -d ] [ -h ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ] [ device [...] | ALL ] [ -p [ device [,...] | ALL ] ] [ interval [ count ] ]

Getting started

iostat -d -k 1 10
Device:tpskB_read/skB_wrtn/skB_readkB_wrtn
sda39.2921.14 1.44441339807 29990031
sda10.00 0.00 0.00 1623523
sda21.32 1.43 4.54 29834273 94827104
sda36.30 0.8524.95 17816289520725244
sda50.85 0.46 3.409543503 70970116
sda60.00 0.00 0.00550236
sda70.00 0.00 0.004060
sda80.00 0.00 0.004060
sda90.00 0.00 0.004060
sda1060.6818.3571.43383002263 1490928140
 
Device:tpskB_read/skB_wrtn/skB_readkB_wrtn
sda 327.555159.18 102.04 5056100
sda10.00 0.00 0.0000
Copy after login

Parameters -d indicates that the device (disk) usage status is displayed; -k some columns that use blocks as units are forced to use Kilobytes as units; 2 indicates that the data display is refreshed every 2 seconds.

The meaning of output information

tps: The number of transfers per second of the device (Indicate the number of transfers per second that were issued to the device.). "One transfer" means "one I/O request". Multiple logical requests may be combined into "one I/O request". The size of the "one transfer" request is unknown.

kB_read/s: The amount of data read from the device (drive expressed) per second;
kB_wrtn/s: The amount of data written to the device (drive expressed) per second;
kB_read: The total amount of data read;
kB_wrtn: The total amount of data written; these units are Kilobytes.

In the above example, we can see the statistics of disk sda and its various partitions. The total disk TPS calculated at that time was 39.29. The following is the TPS of each partition. (Because it is an instantaneous value, the total TPS is not strictly equal to the sum of the TPS of each partition)

Specify the name of the monitored device as sda. The output of this command is exactly the same as the above command.

iostat -d sda 2

Monitor all hard disk devices by default, now specify to monitor only sda.

-x parameters
iostat also has a more commonly used option -x, which will be used to display extended data related to io.

iostat -d -x -k 1 10
Device:rrqm/s wrqm/s r/s w/srsec/swsec/srkB/swkB/s avgrq-sz avgqu-sz awaitsvctm%util
sda1.5628.317.80 31.49 42.512.9221.26 1.46 1.16 0.030.79 2.6210.28
Device:rrqm/s wrqm/s r/s w/srsec/swsec/srkB/swkB/s avgrq-sz avgqu-sz awaitsvctm%util
sda2.0020.00 381.007.00 12320.00216.006160.00 108.0032.31 1.754.50 2.1784.20
Copy after login

The meaning of output information

rrqm/s: How many read requests related to this device are merged per second (when the system call needs to read data, VFS will send the request to each FS. If the FS finds different read requests, If the data is the same block, FS will merge this request into Merge); wrqm/s: How many write requests related to this device are merged per second.

rsec/s: Number of sectors read per second;
wsec/: Number of sectors written per second.
rKB/s: The number of read requests that were issued to the device per second;
wKB/s: The number of write requests that were issued to the device per second;
avgrq-sz average requested sector size
avgqu-sz is the average request queue length. There is no doubt that the shorter the queue length, the better.
await: The average processing time of each IO request (unit is microseconds and milliseconds). This can be understood as the IO response time. Generally, the system IO response time should be less than 5ms. If it is greater than 10ms, it will be larger.
This time includes queue time and service time. That is to say, under normal circumstances, await is greater than svctm. The smaller the difference between them, the shorter the queue time. On the contrary, the larger the difference, the longer the queue time, indicating that the system has failed. problem.
svctm represents the average service time (in milliseconds) of each device I/O operation. If the value of svctm is very close to await, it means that there is almost no I/O waiting and the disk performance is very good. If the value of await is much higher than the value of svctm, it means that the I/O queue wait is too long and the applications running on the system will Slow down.
%util: All processing IO time within the statistical time, divided by the total statistical time. For example, if the statistics interval is 1 second, the device is processing IO for 0.8 seconds, and idle for 0.2 seconds, then the %util of the device = 0.8/1 = 80%, so this parameter implies how busy the device is
. Generally, if this parameter is 100%, it means that the device is running close to full capacity (of course, if there are multiple disks, even if %util is 100%, disk usage may not reach a bottleneck due to the concurrency capability of the disk).

-c parameter
iostat can also be used to obtain part of the CPU status value:

iostat -c 1 10
avg-cpu: %user %nice %sys %iowait %idle
1.98 0.00 0.35 11.45 86.22
avg-cpu: %user %nice %sys %iowait %idle
1.62 0.00 0.25 34.46 63.67

Common usage

iostat -d -k 1 10 #View TPS and throughput information (disk read and write speed unit is KB)
iostat -d -m 2 #View TPS and throughput information (disk read and write speed unit is MB)
iostat -d -x -k 1 10 #View device usage (%util), response time (await) iostat -c 1 10 #View cpu status

Case Analysis

ostat -d -k 1 |grep sda10
Device:tpskB_read/skB_wrtn/skB_readkB_wrtn
sda1060.7218.9571.53395637647 1493241908
sda10 299.024266.67 129.41 4352132
sda10 483.844589.904117.17 4544 4076
sda10 218.003360.00 100.00 3360100
sda10 546.008784.00 124.00 8784124
sda10 827.00 13232.00 136.0013232136
Copy after login

As seen above, the average number of disk transfers per second is about 400; the disk reads about 5MB per second and writes about 1MB.

iostat -d -x -k 1
Device:rrqm/s wrqm/s r/s w/srsec/swsec/srkB/swkB/s avgrq-sz avgqu-sz awaitsvctm%util
sda1.5628.317.84 31.50 43.653.1621.82 1.58 1.19 0.030.80 2.6110.29
sda1.9824.75 419.806.93 13465.35253.476732.67 126.7332.15 2.004.70 2.0085.25
sda3.0641.84 444.90 54.08 14204.08 2048.987102.041024.4932.57 2.104.21 1.8592.24
Copy after login

You can see that the average response time of the disk is <5ms, and the disk usage is >80. The disk responds normally, but is already very busy.

The above is the detailed content of Understand Linux disk performance using iostat command. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template