iostatの使用方法

iostatの出力例

$ iostat -x 20
avg-cpu: %user %nice %system %iowait %steal %idle
0.35 0.00 0.48 0.04 0.00 99.13
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 1.37 0.13 4.70 2.13 62.13 13.30 0.01 1.69 0.66 0.32
dm-0 0.00 0.00 0.13 5.87 2.13 62.13 10.71 0.01 1.63 0.53 0.32
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
  • rrqm/s - read requests merged per second:マージされた読込IO要求。大きければ効率よくまとめて読み込んでいる。
  • wrqm/s - write requests merged per second:マージされた書き込みIO要求。大きければ効率よくまとめて書き込んでいる。
  • r/s - reads per second:一秒間に読み込んだ量
  • w/s - writes per second:一秒間に書き込んだ量
  • r/s + w/s = IOPS(Input Output per Second):秒間I/O。
  • rsec/s - The number of sectors read from the device per second:読み込まれたセクタ数(秒間)
  • wsec/s - The number of sectors written to the device per second:書き込まれたセクタ数(秒間)
  • avgrq-sz - The average size (in sectors) of the requests that were issued to the device:平均リクエストサイズ。 セクタの数なので、仮にセクタが512byteだった場合、上記のサンプルでは13.30*512で6.8KB
  • avgqu-sz - The average queue length of the requests that were issued to the device.:待ち行列の長さの平均
  • await - The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them:レスポンスタイム。待ち行列に並んでいる時間+サービスの時間。逆に言えばawait - svctmで列で待機していた平均時間になる。
  • svctm - The average service time (in milliseconds) for I/O requests that were issued to the device:平均処理時間。当然IOが少なければ速くなる。
  • %util - Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%:使用率(ビジー率)

メモ

  • I/O性能が劣化すると平均IOサイズ(avgrq-sz)が変わらないのにサービスタイム(svctm)が大きくなる。
  • I/Oが増えて待ちが発生するとIOPSが増えて、avgqu-szとレスポンスタイム(await)が大きくなる。