ablog

不器用で落着きのない技術者のメモ

nfsiostat で NFS の I/O レイテンシや IOPS を調べる

NFS で iostat の await と svctm のような情報を取れるツールが欲しいと思っていたら nfsiostat という素敵なツールを見つけた。await にあたるのが avg exe (ms)、svctm にあたるのが avg RTT (ms) だと思う。
iostat の await と svctm の意味は Linux の iostat の出力結果を銀行のATMに例えて説明してみる - ablog 参照。

書式

$ nfsstat <interval>

実行例

  • ops/s: 秒間の read または write リクエストの発行回数
  • kB/s: 1秒間に read または write されたサイズ(KB)
  • kB/op: 1回の read または write の秒間の平均サイズ(KB)
  • avg RTT (ms): カーネルが RPC リクエストを発行してから応答までの時間(単位:1/1000秒)。おそらく、iostat の svctm に近い感じかと。
  • avg exe (ms): NFS Client がカーネルに RPC リクエストを発行して完了するまでの時間(単位:1/1000秒)。avg RTT (ms) を含む。おそらく、iostat の await に近い感じかと。
$ nfsiostat 5                                                                                                                                        

******:/backup/ mounted on /backup:

   op/s         rpc bklog
   0.00            0.00
read★:             ops/s            kB/s           kB/op         retrans         avg RTT (ms)★    avg exe (ms)★
                  0.000           0.000           0.000        0 (0.0%)           0.000           0.000
write★:            ops/s            kB/s           kB/op         retrans         avg RTT (ms)    avg exe (ms)
                  0.000           0.000           0.000        0 (0.0%)           0.000           0.000

...

補足

/proc/self/mountstats から情報を取得しているので、nfsiostat がなくても /proc/self/mountstats を定期的に記録しておけば同じことができそう。Python スクリプトを置くだけなので、そんなことをしないといけない環境は少ないと思うが。

  • strace より
$ strace -e open nfsiostat 2>&1|grep /proc                                                                                                          
open("/proc/meminfo", O_RDONLY|O_CLOEXEC) = 3
open("/proc/self/mountstats", O_RDONLY) = 3
#!/usr/bin/python
# -*- python-mode -*-
"""Emulate iostat for NFS mount points using /proc/self/mountstats ★
"""

...

def iostat_command(name):
    """iostat-like command for NFS mount points
    """
    mountstats = parse_stats_file('/proc/self/mountstats') ★

作者

作者は Linux カーネル開発者(元NetApp、現ORACLE)の Chuck Lever で、Linux NFS と FedFS の実装をしているようです。

30 週に渡り多彩な Linux カーネル開発者を紹介していくシリーズ、今週は Oracle の Chuck Lever に話を聞きました。彼は Linux NFS と FedFS の実装の仕事をしていますが、Linux に関わるようになったのはミシガン大学に在学中でした。彼から Linux 初心者へのスペシャル アドバイスがあります。コンピューター史上最大の共同開発プロジェクトの一員の面白い見識を、ぜひどうぞ。

30人のLinuxカーネル開発者:Chuck Lever

参考

NAME

       nfsiostat   -   Emulate   iostat   for   NFS   mount   points   using
       /proc/self/mountstats

..

       <mount_point>
              If one or more <mount point> names are specified, statistics
              for only these mount points will be displayed.  Otherwise, all
              NFS mount points on the client are listed.

       The meaning of each column of nfsiostat's output is the following:
               - op/s
                      This is the number of operations per second.
               - rpc bklog
                      This is the length of the backlog queue.
               - kB/s
                      This is the number of kB written/read per second.
               - kB/op
                      This is the number of kB written/read per each
                      operation.
               - retrans
                      This is the number of retransmissions.
               - avg RTT (ms)
                      This is the duration from the time that client's
                      kernel sends the RPC request until the time it
                      receives the reply.
               - avg exe (ms)
                      This is the duration from the time that NFS client
                      does the RPC request to its kernel until the RPC
                      request is completed, this includes the RTT time
                      above.