Linux system has a performance problem, generally we can use top, iostat, free, vmstat and other commands to view the initial positioning problems. Iostat can provide us with rich IO status data.
1. Basic use
1 Ten
The parameter-D indicates that the device (disk) usage status is displayed; k Some columns that use block are forced to use kilobytes; 1 10 indicates that the data is refreshed every 1 seconds and is displayed 10 times.
Iostat-d-K1 TenDevice:tps Kb_read/s kb_wrtn/s Kb_read kb_wrtnsda39.29 21.14 1.44 441339807 29990031sda10.00 0.00 0.00 1623 523sda21.32 1.43 4.54 29834273 94827104Sda36.30 0.85 24.95 17816289 520725244Sda50.85 0.46 3.40 9543503 70970116Sda60.00 0.00 0.00 550 236Sda70.00 0.00 0.00 406 0sda80.00 0.00 0.00 406 0sda90.00 0.00 0.00 406 0sda1060.68 18.35 71.43 383002263 1490928140Device:tps Kb_read/s kb_wrtn/s Kb_read kb_wrtnsda327.55 5159.18 102.04 5056 -sda10.00 0.00 0.00 0 0
TPS: The number of transmissions per second of the device (indicate, transfers per second, were issued to the.). "One-time transfer" means "one-time I/O request". Multiple logical requests may be merged 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 number of data written, these units are kilobytes.
In the example above, we can see statistics on the disk SDA and its partitions, when the total disk TPS for statistics is 39.29, and the following is the TPS for each partition. (because it is an instantaneous value, the total TPS is not strictly equal to the sum of each partition TPs)
2.-X parameter
With the-x parameter, we can get more statistical information.
Iostat-d-x-k1 TenDEVICE:RRQM/s wrqm/s r/sW/s rsec/s wsec/s rkb/s wkb/s avgrq-sz avgqu-sz await SVCTM%UTILSDA1.56 28.31 7.80 31.49 42.51 2.92 21.26 1.46 1.16 0.03 0.79 2.62 10.28DEVICE:RRQM/s wrqm/s r/sW/s rsec/s wsec/s rkb/s wkb/s avgrq-sz avgqu-sz await SVCTM%UTILSDA2.00 20.00 381.00 7.00 12320.00 216.00 6160.00 108.00 32.31 1.75 4.50 2.17 84.20
rrqm/s: How much of this device-dependent read request is being merge per second (when the system call needs to read the data, the VFS sends the request to each FS, if FS finds that different read requests read the same block of data, FS merges this request into a merge); wrqm/s: How much of this device-related write request is merged per second.
rsec/s: Number of sectors read per second;wsec/: Number of sectors written per second. r/s: The number of read requests that were issued to the device per second;w/s: The number of write Reques TS that were issued to the device per second;
await: The average time (in milliseconds) for each IO request to be processed. This can be understood as the response time of IO, generally the system IO response time should be less than 5ms, if greater than 10ms is relatively large.
%util: All processing io time, divided by total statistic time, in the statistical time. For example, if the statistic interval is 1 seconds, the device has 0.8 seconds to process Io, and 0.2 seconds is idle, then the device's%util = 0.8/1 = 80%, so this parameter implies the device's busy level. Generally, if this parameter is 100% indicates that the device is already running close to full load (of course if it is a multi-disk, even if%util is 100% because of the concurrency of the disk, disk usage may not be the bottleneck).
3.-C parameter
Iostat can also be used to get CPU partial state values:
1 Ten 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
4. Common usage
1 Ten 1 #查看设备使用率(% 1 #查看cpu状态
5. Example Analysis
Iostat-d-K1|grepSda10device:tps Kb_read/s kb_wrtn/s Kb_read kb_wrtn sda1060.72 18.95 71.53 395637647 1493241908sda10299.02 4266.67 129.41 4352 thesda10483.84 4589.90 4117.17 4544 4076sda10218.00 3360.00 100.00 3360 -sda10546.00 8784.00 124.00 8784 124sda10827.00 13232.00 136.00 13232 136
As seen above, the average number of disk transfers per second is about 400, and the disk reads about 5MB per second and writes about 1MB.
Iostat-d-x-k1DEVICE:RRQM/s wrqm/s r/sW/s rsec/s wsec/s rkb/s wkb/s avgrq-sz avgqu-sz await SVCTM%UTILSDA1.56 28.31 7.84 31.50 43.65 3.16 21.82 1.58 1.19 0.03 0.80 2.61 10.29SDA1.98 24.75 419.80 6.93 13465.35 253.47 6732.67 126.73 32.15 2.00 4.70 2.00 85.25SDA3.06 41.84 444.90 54.08 14204.08 2048.98 7102.04 1024.49 32.57 2.10 4.21 1.85 92.24
You can see the average response time of the disk <5ms, and the disk usage is >80. The disk responds properly, but it is already busy.
Linux iostat Monitoring IO Status