五 性能调试---I/O性能分析

1:衡量I/O闲忙程度的指标
2:I/O资源成为系统性能的瓶颈的征兆
3:哪些活动是占用I/O资源的大户?
4:利用iostat分析I/O的利用率
5:利用SAR命令分析磁盘活动
6:利用SAR命令分析缓冲区的活动
7:利用SAR命令分析交换区的活动
8:利用GlancePlus分析系统的I/O活动情况
9:对I/O需求密集型系统的性能调试


衡量I/O闲忙程度的指标


下面是一些衡量I/O闲忙程度的经用指标:

磁盘利用率(disk utilization)
磁盘队列长度(disk queue length)
磁头/逻辑卷的读/写速率(read/write rates per spindle/logical volume)
原始I/O(raw I/O):主要用于数据库应用
交换队列的长度(swap queue length)
缓存命中率(buffer cache hit ratio)
网络文件系统和无盘工作站速率(NFS and diskless rates(server))

I/O资源成为系统性能的瓶颈的征兆


当I/O成为瓶颈时,会出现下面这些典型的症状:

过高的磁盘利用率(high disk utilization)
太长的磁盘等待队列(large disk queue length)
等待磁盘I/O的时间所占的百分率太高(large percentage of time waiting for disk I/O)
太高的物理I/O速率:large physical I/O rate(not sufficIEnt in itself)
过低的缓存命中率(low buffer cache hit ratio(not sufficient in itself))
太长的运行进程队列,但CPU却空闲(large run queue with idle CPU)

哪些活动是占用I/O资源的大户?


下面是一些占用大量I/O资源的活动:

换页(paging):paging不仅会引起内存问题,还可能引起磁盘问题;
open,creat,and stat system calls:系统调用会引起大量的磁盘I/O;
multiuser I/O and random I/O
relational database
core dumps


利用iostat分析I/O的利用率


iostat - report I/O statistics

iostat iteratively reports I/O statistics for each active disk on the system.

If two or more disks are present, data is presented on successive lines for each disk.

With the advent of new disk technologies, such as data striping, where a single data transfer is spread across several disks, the number of milliseconds per average seek becomes impossible to compute accurately. At best it is only an approximation, varying greatly, based on several dynamic system conditions. For this reason and to maintain backward compatibility, the milliseconds per average seek ( msps ) field is set to the value 1.0.

它的语法为:

iostat [-t] [interval [count]]

其选项的含义为:

-t:Report terminal statistics as well as disk statistics.
interval: Display successive lines which are summaries of the last interval seconds. The first line reported is for the time since a reboot and each subsequent line is for the last interval only.
count: Repeat the statistics count times.
对结果的分析:

通过查看bps列和sps列的值我们可以知道哪些磁盘比较忙,哪些磁盘比较闲 。


利用SAR命令分析磁盘活动


通过命令sar -d,我们可以分析系统中的每个磁盘和磁带的活动情况 。

Report activity for each block device, e.g., disk or tape drive. One line is printed for each device that had activity during the last interval. If no devices were active, a blank line is printed.Each line contains the following data:

device:设备名;
%busy: Portion of time device was busy servicing a request; statistics.
avque: Average number of requests outstanding for the device;
r w/s: Number of data transfers per second (read and writes) from and to the device;
blks/s: Number of bytes transferred (in 512-byte units) from and to the device;
avwait: Average time (in milliseconds) that transfer requests waited idly on queue for the device;
avserv: Average time (in milliseconds) to service each transfer request (includes seek, rotational latency, and data transfer times) for the device.

推荐阅读