Windows常用性能计数器总结 Windows常用性能计数器总结

Windows常用性能计数器总结

基础监控:

Processor:
% Processor Time CPU当前利用率,百分比

Memory:
Available MBytes 当前可用内存,兆字节(虚拟内存不需要监控,只有当物理内存不够时才会使用虚拟内存,物理内存已有监控)

LogicalDisk:
% Free Space 逻辑分区可用空间,百分比(物理磁盘IO由于RAID级别不同,或者有的机器没有RAID,无法定义统一的监控阈值)

Network Interface:
Bytes Total/sec 网卡流量:发送+接收,字节

TCPv4:
Connections Established 当前连接数(Established + Close-Wait)


==================================================

CPU:

%Processor Time

%Priviliaged Time
CPU在特权模式下处理线程所花的时间百分比。一般的系统服务,进城管理,内存管理等一些由操作系统自行启动的进程属于这类

%User Time
%Privileged Time计数器正好相反,指的是在用户状态模式下(即非特权模式)的操作所花的时间百分比。如果该值较大,可以考虑是否通过算法优化等方法降低这个值。如果该服务器是数据库服务器,导致此值较大的原因很可能是数据库的排序或是函数操作消耗了过多的CPU时间,此时可以考虑对数据库系统进行优化。

%DPC Time
处理器在网络处理上消耗的时间,该值越低越好。在多处理器系统中,如果这个值大于50%并且%Processor Time非常高,加入一个网卡可能会提高性能。

Memory:

Available Bytes

Pages/sec

该计数器显示由于页面不在物理内存中而需要从磁盘读取的页面数。Pages/sec 的值很大不一定表明内存有问题,而可能是运行使用内存映射文件的程序所致,操作系统经常会利用磁盘交换的方式提高系统可用的内存量或是提高内存的使用效率。(注意该计数器与 Page Faults/sec 的区别,后者只表明数据不能在内存的指定工作集中立即使用,包括硬错误和软错误)

Page Faults/sec计数器可以确保磁盘活动不是由分页导致的。在 Windows 中,换页的原因包括:配置进程占用了过多内存 或者 文件系统活动。

如果在同一硬盘上有多个逻辑分区,需要使用 Logical Disk计数器而非 Physical Disk计数器。查看逻辑磁盘计数器有助于确定哪些文件被频繁访问。当发现磁盘有大量读/写活动时,请查看读写专用计数器以确定导致每个逻辑卷负荷增加的磁盘活动类型,例如,Logical Disk: Disk Write Bytes/sec

Page Input/sec
表示为了解决硬错误而写入硬盘的页数(参考值:>=Page Reads/sec)


Page Reads/sec
表示为了解决硬错误而从硬盘上读取的页数。(参考值: <=5)

  如果怀疑有内存泄露,请监视 Memory/Available Bytes 和 Memory/ Committed Bytes,以观察内存行为,并监视你认为可能在泄露内存的进程的 Process/ Private Bytes、Process/ Working Set 和Process/ Handle Count。如果怀疑是内核模式进程导致了泄露,则还应该监视 Memory/ Pool Nonpaged Bytes、Memory/ Pool Nonpaged Allocs 和 Process(process_name)/ Pool Nonpaged Bytes

  如果发生了内存泄漏,process\private bytes计数器和process\working set 计数器的值往往会升高,同时avaiable bytes的值会降低

private Bytes
是指进程所分配的无法与其他进程共享的当前字节数量。该计数器主要用来判断进程在性能测试过程中有无内存泄漏。

例如:对于一个IIS之上的web应用,我们可以重点监控inetinfo进程的Private Bytes,如果在性能测试过程中,该进程的Private Bytes计数器值不断增加,或是性能测试停止后一段时间,该进程的Private Bytes仍然持续在高水平,则说明应用存在内存泄漏。

Disk:

PhysicalDisk\Avg. Disk sec/Read

以秒计算的在此盘上读取数据的所需平均时间。

Physical Disk\ Disk Reads/sec

在读取操作时从磁盘上传送的字节平均数。


PhysicalDisk\ Avg. Disk sec/Write

以秒计算的在此盘上写入数据的所需平均时间。

Physical Disk\ DiskWrites/sec

在写入操作时从磁盘上传送的字节平均数。

Physical Disk\ Avg.Disk sec/Transfer

反映磁盘完成请求所用的时间。较高的值表明磁盘控制器由于失败而不断重试该磁盘。这些故障会增加平均磁盘传送时间。

%Disk Time和Avg.Disk Queue Length

RAID 磁盘中的 % Disk Time 计数器会指示大于 100% 的值。如果出现这种情况,则使用 PhysicalDisk: Avg.Disk Queue Length计数器来确定等待进行磁盘访问的平均系统请求数量。

如果不是RAID,则使用 % Disk Time 和 Current Disk Queue Length计数器确定是否磁盘存在瓶颈,如果这两个计数器的值一直很高,则可能是磁盘存在瓶颈

Physical Disk:
DiskTransfers/sec 磁盘IOPS
% Disk Time 当前物理磁盘利用率,如果是RAID,该值会大于100%
Current Disk Queue Length 等待进行磁盘访问的当前系统请求数量
Avg.Disk Queue Length 等待进行磁盘访问的平均系统请求数量,用于RAID

Disk counters to monitor

 

Monitor the following counters to ensure the health of disks. Note that the following values represent values measured over time — not values that occur during a sudden spike and not values that are based on a single measurement.

  • Physical Disk: % Disk Time: DataDrive   This counter shows the percentage of elapsed time that the selected disk drive is busy servicing read or write requests. Monitor this counter to ensure that it remains less than two times the number of disks.

  • Logical Disk: Disk Transfers/sec   This counter shows the rate at which read and write operations are performed on the disk. Use this counter to monitor growth trends and forecast appropriately.

  • Logical Disk: Disk Read Bytes/sec and Logical Disk: Disk Write Bytes/sec   These counters show the rate at which bytes are transferred from the disk during read or write operations.

  • Logical Disk: Avg. Disk Bytes/Read   This counter shows the average number of bytes transferred from the disk during read operations. This value can reflect disk latency — larger read operations can result in slightly increased latency.

  • Logical Disk: Avg. Disk Bytes/Write   This counter shows the average number of bytes transferred to the disk during write operations. This value can reflect disk latency — larger write operations can result in slightly increased latency.

  • Logical Disk: Current Disk Queue Length   This counter shows the number of requests outstanding on the disk at the time that the performance data is collected. For this counter, lower values are better. Values above 2 per disk may indicate a bottleneck and should be investigated. This means that a value of up to 8 may be acceptable for a LUN comprised of 4 disks. Bottlenecks can create a backlog that can spread beyond the current server that is accessing the disk, and result in long wait times for users. Possible solutions to a bottleneck are to add more disks to the RAID array, replace existing disks with faster disks, or move some data to other disks.

  • Logical Disk: Avg. Disk Queue Length   This counter shows the average number of both read and write requests that were queued for the selected disk during the sample interval. The rule is that there should be two or fewer outstanding read and write requests per spindle, but this can be difficult to measure because of storage virtualization and differences in RAID levels between configurations. Look for larger than average disk queue lengths in combination with larger than average disk latencies. This combination can indicate that the storage array cache is being overused or that spindle sharing with other applications is affecting performance.

  • Logical Disk: Avg. Disk sec/Read and Logical Disk: Avg. Disk sec/Write   These counters show the average time, in seconds, of a read or write operation to the disk. Monitor these counters to ensure that they remain below 85 percent of the disk capacity. Disk access time increases exponentially if read or write operations are more than 85 percent of disk capacity. To determine the specific capacity for your hardware, refer to the vendor documentation, or use the SQLIO Disk Subsystem Benchmark Tool to calculate it. For more information, see SQLIO Disk Subsystem Benchmark Tool(http://go.microsoft.com/fwlink/?LinkID=105586).

    • Logical Disk: Avg. Disk sec/Read   This counter shows the average time, in seconds, of a read operation from the disk. On a well-tuned system, ideal values are from 1-5 milliseconds (ms) for logs (ideally 1 ms on a cached array), and 4-20 ms for data (ideally less than 10 ms). Higher latencies can occur during peak times, but if high values occur regularly, you should investigate the cause.

    • Logical Disk: Avg. Disk sec/Write   This counter shows the average time, in seconds, of a write operation to the disk. On a well-tuned system, ideal values are from 1-5 ms for logs (ideally 1 ms on a cached array), and 4-20 ms for data (ideally less than 10 ms). Higher latencies can occur during peak times, but if high values occur regularly, you should investigate the cause.

    When you are using RAID configurations with the Avg. Disk sec/Read or Avg. Disk sec/Write, use the formulas listed in the following table to determine the rate of input and output on the disk.

     

    RAID level Formula

    RAID 0

    I/Os per disk = (reads + writes) / number of disks

    RAID 1

    I/Os per disk = [reads + (2 * writes)] / 2

    RAID 5

    I/Os per disk = [reads + (4 * writes)] / number of disks

    RAID 10

    I/Os per disk = [reads + (2 * writes)] / number of disks

    For example, if you have a RAID 1 system that has two physical disks, and your counters are at the values that are shown in the following table:

     

    Counter Value

    Avg. Disk sec/Read

    80

    Logical Disk: Avg. Disk sec/Write

    70

    Avg. Disk Queue Length

    5

    The I/O value per disk can be calculated as follows: (80 + (2 * 70))/2 = 110

    The disk queue length can be calculated as follows: 5/2 = 2.5

    In this situation, you have a borderline I/O bottleneck.

  • From:http://technet.microsoft.com/en-us/library/dd723635(v=office.12).aspx
 
分类:  Windows
------------------------------------

性能计数器(counter)是描述服务器或操作系统性能的一些数据指标。计数器在性能测试中发挥着“监控和分析”的关键作用,尤其是在分析系统的可扩展性、进行性能瓶颈的定位时,对计数器的取值的分析非常关键。但必须说明的是,单一的性能计数器只能体现系统性能的某一个方面,对性能测试结果的分析必须基于多个不同的计数器。

与性能计数器相关的另一个术语是“资源利用率”。该术语指的是系统各种资源的使用状况。为了方便比较,一般用“资源的实际使用/总的资源可用量”形成资源利用率的数据,用以进行各种资源使用的比较。

性能测试之内存篇(windows)

要监视内存不足的状况,请从以下的对象计数器开始:

· Memory\ Available Bytes

· Memory\ Pages/sec

Available Bytes剩余的可用物理内存,单位是兆字节(参考值:>=10%)。表明进程当前可使用的内存字节数。Pages/sec 表明由于硬件页面错误而从磁盘取出的页面数,或由于页面错误而写入磁盘以释放[url=]工作[/url]集空间的页面数。

如果 Available Bytes 的值很小(4 MB 或更小),则说明计算机上总的内存可能不足,或某程序没有释放内存。如果 Pages/sec 的值为 20 或更大,那么您应该进一步研究页交换活动。Pages/sec 的值很大不一定表明内存有问题,而可能是运行使用内存映射文件的程序所致。

操作系统经常会利用磁盘交换的方式提高系统可用的内存量或是提高内存的使用效率。下列四个
指标直接反映了操作系统进行磁盘交换的频度。
Page Faults/sec
当处理器在内存中读取某一页出现错误时,就会产生缺页中断,也就是 page Fault。如果这个页
位于内存的其他位置,这种错误称为软错误,用Transition Fault/sec 来衡量;如果这个页位于硬盘上,必须从硬盘重新读取,这个错误成为硬错误。硬错误会使系统的运行效率很快将下来。Page Faults/sec这个计数器就表示每秒钟处理的错误页数,包括硬错误和软错误。
Page Input/sec
表示为了解决硬错误而写入硬盘的页数(参考值:>=Page Reads/sec)
Page Reads/sec
表示为了解决硬错误而从硬盘上读取的页数。(参考值: <=5)
Pages/sec
表示为了解决硬错误而从硬盘上读取或写入硬盘的页数(参考值:00~20)

必须同时监视 Available Bytes、Pages/sec 和 Paging File % Usage,以便确定是否发生这种情况。如果正在读取非缓存内存映射文件,还应该查看缓存活动是否正常。

Cathe Bytes
文件系统的缓存(默认为50%的可用物理内存)

内存泄露

· Memory\Available Bytes

· Memory\ Committed Bytes

如果您怀疑有内存泄露,请监视 Memory\Available Bytes 和 Memory\ Committed Bytes,以观察内存行为,并监视你认为可能在泄露内存的进程的 Process\ Private Bytes、Process\ Working Set 和Process\ Handle Count。如果您怀疑是内核模式进程导致了泄露,则还应该监视 Memory\ Pool Nonpaged Bytes、Memory\ Pool Nonpaged Allocs 和 Process(process_name)\ Pool Nonpaged Bytes。

private Bytes
进程无法与其他进程共享的字节数量。该计数器的值较大时,有可能是内存泄露的信号

检查过于频繁的页交换

由于过多的页交换要使用大量的硬盘空间,因此有可能将导致将页交换内存不足,这容易与导致页交换的磁盘瓶颈混淆。因此,在研究内存不足不太明显的页交换的原因时,您必须跟踪如下的磁盘使用情况计数器和内存计数器:

· Physical Disk\ % Disk Time

· Physical Disk\ Avg.Disk Queue Length

例如,包括 Page Reads/sec 和 % Disk Time 及 Avg.Disk Queue Length。如果页面读取操作速率很低,同时 % Disk Time 和 Avg.Disk Queue Length的值很高,则可能有磁盘瓶径。但是,如果队列长度增加的同时页面读取速率并未降低,则内存不足。

要确定过多的页交换对磁盘活动的影响,请将 Physical Disk\ Avg.Disk sec/Transfer 和 Memory\ Pages/sec 计数器的值增大数倍。如果这些计数器的计数结果超过了 0.1,那么页交换将花费百分之十以上的磁盘访问时间。如果长时间发生这种情况,那么您可能需要更多的内存。

研究程序的活动

接下来,检查正在运行的程序导致的过多的页交换。如果可能,请停止具有最高工作集值的程序,然后查看页交换速率是否有显著变化。如果您怀疑存在过多的页交换,请检查 Memory\ Pages/sec 计数器。该计数器显示由于页面不在物理内存中而需要从磁盘读取的页面数。(注意该计数器与 Page Faults/sec 的区别,后者只表明数据不能在内存的指定工作集中立即使用。)

性能测试之处理器篇(windows)

监视“处理器”和“系统”对象计数器可以提供关于处理器使用的有价值的信息,帮助您决定是否存在瓶颈。需要包含下列内容:

  • Processor\ % Total Processor Time 获得处理器整体使用情况。

该计数值用于体现服务器整体的处理器利用率,对多处理器的系统而言,该计数值体现的是所有CPU的平均利用率。如果该值的数值持续超过90%,则说明整个系统面临着处理器方面的瓶颈,需要通过增加处理器来提高性能。

要注意的是,由于操作系统本身的特性,在某些多CPU系统中,该数据本身并不大,但此时CPU之间的负载状况极不均衡,此时也应该视作系统产生了处理器方面的瓶颈。

  • 监视 Processor\ % Processor Time、Processor\ % User Time 和 % Privileged Time 以获得详细信息。

Processor\ % User Time是指系统的非核心操作消耗的CPU时间,如果该值较大,可以考虑是否通过优化算法等方法降低这个值。如果该服务器是数据库服务器,Processor\ % User Time大的原因很可能是数据库的排序或是函数操作消耗了过多的CPU时间,此时可以考虑对数据库系统进行优化。

  • System\ Processor Queue Length 用于瓶颈检测。
%Total Processor Time
系统中所有处理器都处于繁忙状态的时间百分比,对于多处理器系统来说,该值可以反映所有处理器的平均繁忙状态,该值为100%,如果有一半的处理器为繁忙状态,该值为50%

File Data Operations/sec
计算机对文件系统进行读取和写入操作的频率,但是不包括文件控制操作

Process Queue Length
线程在等待分配CPU资源所排队列的长度,此长度不包括正在占有CPU资源的线程。如果该队列的长度大于处理器个数+1,就表示处理器有可能处于阻塞状态(参考值:<=处理器个数+1)

%Processor Time
CPU利用率,该计数器最为常用,可以查看处理器是否处于饱和状态,如果该值持续超过 95%,就表示当前系统的瓶颈为CPU,可以考虑增加一个处理器或更换一个性能更好的处理器。(参考值:<80%)

%Priviliaged Time
CPU在特权模式下处理线程所花的时间百分比。一般的系统服务,进城管理,内存管理等一些由操作系统自行启动的进程属于这类

%User Time
与%Privileged Time计数器正好相反,指的是在用户状态模式下(即非特权模式)的操作所花的时间百分比。如果该值较大,可以考虑是否通过算法优化等方法降低这个值。如果该服务器是数据库服务器,导致此值较大的原因很可能是数据库的排序或是函数操作消耗了过多的CPU时间,此时可以考虑对数据库系统进行优化。

%DPC Time
处理器在网络处理上消耗的时间,该值越低越好。在多处理器系统中,如果这个值大于50%并且%Processor Time非常高,加入一个网卡可能会提高性能。

观察处理器使用情况的值

要测量处理器的活动,请查看 Processor\ % Processor Time 计数器。该计数器显示处理器忙于执行非空闲线程所耗时间的百分比。

检查处理器使用时,请考虑计算机的角色和所完成[url=]工作[/url]的类型。根据计算机进行的工作,较高的处理器值意味着系统正有效地处理较重的工作负载或正在努力维持。例如,如果正在监视用户的计算机,并且该计算机用于计算,计算程序可能容易使用 100% 的处理器时间。即使这会造成该计算机中[url=]其他[/url]应用程序的性能受到影响,但可以通过改变负载来解决。

另一方面,在处理许多客户请求的服务器计算机中,100% 左右的值表示这些过程在队列中,正在等待处理器时间,并且造成瓶颈。如此持续高层次的处理器使用对服务器而言是无法接受的。

考察处理器瓶颈

进程的线程所需要的处理器周期超出可用周期时,处理器瓶颈将逐步显示出来。可以建立较长的处理器队列,并且系统响应会受到影响。处理器瓶颈两种常见的原因是 CPU 限制程序和产生过多中断的驱动程序或子系统组件。

要决定是否由于对处理器时间的要求较高而存在处理器瓶颈,请查看 System\ Processor Queue Length 计数器。队列中包含两个或更多的项目则表明存在瓶颈。如果多个程序进程竞争大多数处理器时间,安装更快速的处理器会提高吞吐量。如果正在运行多线程的进程,附加处理器会有所帮助,但是请注意,附加处理器可能只有有限的益处。

此外,跟踪计算机的服务器工作队列当前长度的 Server Work Queues\ Queue Length 计数器会显示出处理器瓶颈。队列长度持续大于 4 则表示可能出现处理器拥塞。此计数器是特定时间的值,而不是一段时间的平均值。

要决定中断活动是否造成瓶颈,请观察 Processor\ Interrupts/sec 计数器的值,该计数器测量来自输入/输出 (I/O) 设备的服务请求的速度。如果此计数器的值明显增加,而系统活动没有相应增加,则表明存在硬件问题。

也可以对生成中断的磁盘驱动器、网卡和其他设备活动的间接指示器监视 Processor\ % Interrupt Time 时间。

注意

要检测可能影响处理器性能的硬件问题,例如 IRQ 冲突,请观察 System\ File Control Bytes/second 的值。

监视多处理器系统

要观察多处理器计算机的效率,请使用下列附加计数器。

计数器

说明

Process\ % Processor Time

过程的所有线程在每个处理器上的处理器时间总和。

Processor(_Total)\ % Processor Time

计算机中所有处理器的处理器活动的度量。
"N[{y8_0此计数器采样间隔期间的所有处理器平均非空闲时间的总和,并用处理器数目除以该和。51Testing软件测试网


t#e_5I:N2y8@"a:X:Y
例如,如果所有处理器平均忙半个采样间隔,则显示 50%。如果半数处理器忙整个间隔,而其他的处理器空闲,则也显示 50%。

Thread\ % Processor Time

线程的处理器时间数


性能测试之磁盘篇(windows)

监测对象:PhysicalDisk
如果分析的计数器指标来自于数据库服务器、文件服务器或是流媒体服务器,磁盘I/O对这些系统来说更容易成为瓶颈。

每磁盘的I/O数可用来与磁盘的I/O能力进行对比,如果经过计算得到的每磁盘I/O数超过了磁盘标称的I/O能力,则说明确实存在磁盘的性能瓶颈。

下表给出了每磁盘I/O的计算公式:

RAID类型

计算方法

RAID0

(Reads+Writes)/Number of Disks

RAID1

(Reads+2*Writes)/2

RAID5

[Reads+(4*Writes)]/Number of Disks

RAID10

[Reads+(2*Writes)]/Number of Disks


%Disk Time
表示磁盘驱动器为读取或写入请求提供服务所用的时间百分比,如果只有%Disk Time比较大,硬盘有可能是瓶颈

Average Disk Queue Length
表示磁盘读取和写入请求提供服务所用的时间百分比,可以通过增加磁盘构造磁盘阵列来提高性能(<=磁盘数的2倍)

Average Disk Read Queue Length
表示磁盘读取请求的平均数

Average Disk write Queue Length
表示磁盘写入请求的平均数

Average Disk sec/Read
磁盘中读取数据的平均时间,单位是s

Disk Bytes/sec 提供磁盘系统的吞吐率。
决定工作负载的平衡
要平衡网络服务器上的负载,需要了解服务器磁盘驱动器的繁忙程度。使用 Physical Disk\ % Disk Time 计数器,该计数器显示驱动器活动时间的百分比。如果 % Disk Time 较高(超过 90%),请检查 Physical Disk\ Current Disk Queue Length 计数器以查看正在等待磁盘访问的系统请求数量。等待 I/O 请求的数量应当保持在不大于组成物理磁盘的主轴数的 1.5 到 2 倍。

Average Disk sec/Transfer
磁盘中写入数据的平均时间,单位是s

计数器反映磁盘完成请求所用的时间。较高的值表明磁盘控制器由于失败而不断重试该磁盘。这些故障会增加平均磁盘传送时间。一般来说,定义该值小于15ms最为优异,介于15-30ms之间为良好,30-60ms之间为可以接受,超过60ms则需要考虑更换硬盘或硬盘的RAID方式了

 

Average Disk Bytes/Transfer

值大于 20 KB 表示该磁盘驱动器通常运行良好;如果应用程序正在访问磁盘,则会产生较低的值。例如,随机访问磁盘的应用程序会增加平均 Disk sec/Transfer 时间,因为随机传送需要增加搜索时间。

性能测试之网络篇(windows)

监测对象:Network Interface
网络分析是一件[url=]技术[/url]含量很高的[url=]工作[/url],在一般的组织中都有专门的网络管理人员进行网络分析,对测试工程师来说,如果怀疑网络是系统的瓶颈,可以要求网络仍有来写真进行网络方面的检测。

Network Interface\Bytes Total/sec为发送和接收字节的速率(包括帧字符在内)。可以通过该计数器的值判断网络连接速度是否是瓶颈,具体操作方法是用该计数器的值与目前的网络带宽进行比较。

 

Byte Total/sec
表示网络中接受和发送字节的速度,可以用该计数器来判断网络是否存在瓶颈(参考值:该计数器和网络带宽相除,<50%)


性能测试之进程篇(windows)

查看进程的%Processor Time值

每个进程的%Processor Time反映进程所消耗的处理器时间。用不同进程所消耗的处理器时间进行对比,可以很容易的看出具体是哪个进程在[url=]性能测试[/url]过程中消耗了最多的处理器时间,从而可以据此针对应用进行优化。

查看每个进程产生的页面失效

可以用每个进程产生的页面失效(通过Process\Page Failures/sec计数器获得)和系统的页面失效(可通过Memory\Page Failures/sec计数器获得)的比值,来判断哪个进程产生了最多的失效页面,这个进程要么是需要大量内存的进程,要么是非常活跃的进程,可以对其进行中的分析。

了解进程的Process\Private Bytes

Process\Private Bytes是指进程所分配的无法与其他进程共享的当前字节数量。该计数器主要用拉判断进程在性能测试过程中有无内存泄漏。

例如:对于一个IIS之上的web应用,我们可以重点监控inetinfo进程的Private Bytes,如果在性能测试过程中,该进程的Private Bytes计数器值不断增加,或是性能测试停止后一段时间,该进程的Private Bytes仍然持续在高水平,则说明应用存在内存泄漏。

(备注:进程分析方法用到的计数器主要有:Process\%Processor Time、Page Failures/sec、Page Failures/sec、Private Bytes)


相关链接:
① 内存映射文件机制
内存映射文件是利用虚拟内存把文件映射到进程的地址空间中去,在此之后进程操作文件,就像操作进程空间里的地址一样了,省去了读和写I/O的时间。

比如使用memcpy等内存操作的函数。这种方法能够很好的应用在需要频繁处理一个文件或者是一个大文件的场合,这种方式处理IO效率比普通IO效率要高。

利用内存映射文件您可以认为操作系统已经为您把文件全部装入了内存,然后您只要移动文件指针进行读写即可了。这样您甚至不需要调用那些分配、释放内存块和文件输入/输出的API函数,另外您可以把这用作不同的进程之间共享数据的一种办法。运用内存映射文件实际上没有涉及实际的文件操作,它更象为每个进程保留一个看得见的内存空间。至于把内存映射文件当成进程间共享数据的办法来用,则要加倍小心,因为您不得不处理数据的同步问题,否则您的应用程序也许很可能得到过时或错误的数据甚至崩溃。

内存映射文件本身还是有一些局限性的,譬如一旦您生成了一个内存映射文件,那么您在那个会话期间是不能够改变它的大小的。所以内存映射文件对于只读文件和不会影响其大小的文件操作是非常有用的。当然这并不意味着对于会引起改变其大小的文件操作就一定不能用内存影射文件的方法,您可以事先估计操作后的文件的可能大小,然后生成这么大小一块的内存映射文件,然后文件的长度就可以增长到这么一个大小。我们的解释够多的了,接下来我们就看看实现的细节:

  • 调用CreateFile打开您想要映射的文件。
  • 调用CreateFileMapping,其中要求传入先前CreateFile返回的句柄,该函数生成一个建立在CreateFile函数创建的文件对象基础上的内存映射对象。
  • 调用MapViewOfFile函数映射整个文件的一个区域或者整个文件到内存。该函数返回指向映射到内存的第一个字节的指针。
  • 用该指针来读写文件。
  • 调用UnmapViewOfFile来解除文件映射。
  • 调用CloseHandle来关闭内存映射文件。注意必须传入内存映射文件的句柄。
  • 调用CloseHandle来关闭文件。注意必须传入由CreateFile创建的文件的句柄。

基础监控:

Processor:
% Processor Time CPU当前利用率,百分比

Memory:
Available MBytes 当前可用内存,兆字节(虚拟内存不需要监控,只有当物理内存不够时才会使用虚拟内存,物理内存已有监控)

LogicalDisk:
% Free Space 逻辑分区可用空间,百分比(物理磁盘IO由于RAID级别不同,或者有的机器没有RAID,无法定义统一的监控阈值)

Network Interface:
Bytes Total/sec 网卡流量:发送+接收,字节

TCPv4:
Connections Established 当前连接数(Established + Close-Wait)


==================================================

CPU:

%Processor Time

%Priviliaged Time
CPU在特权模式下处理线程所花的时间百分比。一般的系统服务,进城管理,内存管理等一些由操作系统自行启动的进程属于这类

%User Time
%Privileged Time计数器正好相反,指的是在用户状态模式下(即非特权模式)的操作所花的时间百分比。如果该值较大,可以考虑是否通过算法优化等方法降低这个值。如果该服务器是数据库服务器,导致此值较大的原因很可能是数据库的排序或是函数操作消耗了过多的CPU时间,此时可以考虑对数据库系统进行优化。

%DPC Time
处理器在网络处理上消耗的时间,该值越低越好。在多处理器系统中,如果这个值大于50%并且%Processor Time非常高,加入一个网卡可能会提高性能。

Memory:

Available Bytes

Pages/sec

该计数器显示由于页面不在物理内存中而需要从磁盘读取的页面数。Pages/sec 的值很大不一定表明内存有问题,而可能是运行使用内存映射文件的程序所致,操作系统经常会利用磁盘交换的方式提高系统可用的内存量或是提高内存的使用效率。(注意该计数器与 Page Faults/sec 的区别,后者只表明数据不能在内存的指定工作集中立即使用,包括硬错误和软错误)

Page Faults/sec计数器可以确保磁盘活动不是由分页导致的。在 Windows 中,换页的原因包括:配置进程占用了过多内存 或者 文件系统活动。

如果在同一硬盘上有多个逻辑分区,需要使用 Logical Disk计数器而非 Physical Disk计数器。查看逻辑磁盘计数器有助于确定哪些文件被频繁访问。当发现磁盘有大量读/写活动时,请查看读写专用计数器以确定导致每个逻辑卷负荷增加的磁盘活动类型,例如,Logical Disk: Disk Write Bytes/sec

Page Input/sec
表示为了解决硬错误而写入硬盘的页数(参考值:>=Page Reads/sec)


Page Reads/sec
表示为了解决硬错误而从硬盘上读取的页数。(参考值: <=5)

  如果怀疑有内存泄露,请监视 Memory/Available Bytes 和 Memory/ Committed Bytes,以观察内存行为,并监视你认为可能在泄露内存的进程的 Process/ Private Bytes、Process/ Working Set 和Process/ Handle Count。如果怀疑是内核模式进程导致了泄露,则还应该监视 Memory/ Pool Nonpaged Bytes、Memory/ Pool Nonpaged Allocs 和 Process(process_name)/ Pool Nonpaged Bytes

  如果发生了内存泄漏,process\private bytes计数器和process\working set 计数器的值往往会升高,同时avaiable bytes的值会降低

private Bytes
是指进程所分配的无法与其他进程共享的当前字节数量。该计数器主要用来判断进程在性能测试过程中有无内存泄漏。

例如:对于一个IIS之上的web应用,我们可以重点监控inetinfo进程的Private Bytes,如果在性能测试过程中,该进程的Private Bytes计数器值不断增加,或是性能测试停止后一段时间,该进程的Private Bytes仍然持续在高水平,则说明应用存在内存泄漏。

Disk:

PhysicalDisk\Avg. Disk sec/Read

以秒计算的在此盘上读取数据的所需平均时间。

Physical Disk\ Disk Reads/sec

在读取操作时从磁盘上传送的字节平均数。


PhysicalDisk\ Avg. Disk sec/Write

以秒计算的在此盘上写入数据的所需平均时间。

Physical Disk\ DiskWrites/sec

在写入操作时从磁盘上传送的字节平均数。

Physical Disk\ Avg.Disk sec/Transfer

反映磁盘完成请求所用的时间。较高的值表明磁盘控制器由于失败而不断重试该磁盘。这些故障会增加平均磁盘传送时间。

%Disk Time和Avg.Disk Queue Length

RAID 磁盘中的 % Disk Time 计数器会指示大于 100% 的值。如果出现这种情况,则使用 PhysicalDisk: Avg.Disk Queue Length计数器来确定等待进行磁盘访问的平均系统请求数量。

如果不是RAID,则使用 % Disk Time 和 Current Disk Queue Length计数器确定是否磁盘存在瓶颈,如果这两个计数器的值一直很高,则可能是磁盘存在瓶颈

Physical Disk:
DiskTransfers/sec 磁盘IOPS
% Disk Time 当前物理磁盘利用率,如果是RAID,该值会大于100%
Current Disk Queue Length 等待进行磁盘访问的当前系统请求数量
Avg.Disk Queue Length 等待进行磁盘访问的平均系统请求数量,用于RAID

Disk counters to monitor

 

Monitor the following counters to ensure the health of disks. Note that the following values represent values measured over time — not values that occur during a sudden spike and not values that are based on a single measurement.

  • Physical Disk: % Disk Time: DataDrive   This counter shows the percentage of elapsed time that the selected disk drive is busy servicing read or write requests. Monitor this counter to ensure that it remains less than two times the number of disks.

  • Logical Disk: Disk Transfers/sec   This counter shows the rate at which read and write operations are performed on the disk. Use this counter to monitor growth trends and forecast appropriately.

  • Logical Disk: Disk Read Bytes/sec and Logical Disk: Disk Write Bytes/sec   These counters show the rate at which bytes are transferred from the disk during read or write operations.

  • Logical Disk: Avg. Disk Bytes/Read   This counter shows the average number of bytes transferred from the disk during read operations. This value can reflect disk latency — larger read operations can result in slightly increased latency.

  • Logical Disk: Avg. Disk Bytes/Write   This counter shows the average number of bytes transferred to the disk during write operations. This value can reflect disk latency — larger write operations can result in slightly increased latency.

  • Logical Disk: Current Disk Queue Length   This counter shows the number of requests outstanding on the disk at the time that the performance data is collected. For this counter, lower values are better. Values above 2 per disk may indicate a bottleneck and should be investigated. This means that a value of up to 8 may be acceptable for a LUN comprised of 4 disks. Bottlenecks can create a backlog that can spread beyond the current server that is accessing the disk, and result in long wait times for users. Possible solutions to a bottleneck are to add more disks to the RAID array, replace existing disks with faster disks, or move some data to other disks.

  • Logical Disk: Avg. Disk Queue Length   This counter shows the average number of both read and write requests that were queued for the selected disk during the sample interval. The rule is that there should be two or fewer outstanding read and write requests per spindle, but this can be difficult to measure because of storage virtualization and differences in RAID levels between configurations. Look for larger than average disk queue lengths in combination with larger than average disk latencies. This combination can indicate that the storage array cache is being overused or that spindle sharing with other applications is affecting performance.

  • Logical Disk: Avg. Disk sec/Read and Logical Disk: Avg. Disk sec/Write   These counters show the average time, in seconds, of a read or write operation to the disk. Monitor these counters to ensure that they remain below 85 percent of the disk capacity. Disk access time increases exponentially if read or write operations are more than 85 percent of disk capacity. To determine the specific capacity for your hardware, refer to the vendor documentation, or use the SQLIO Disk Subsystem Benchmark Tool to calculate it. For more information, see SQLIO Disk Subsystem Benchmark Tool(http://go.microsoft.com/fwlink/?LinkID=105586).

    • Logical Disk: Avg. Disk sec/Read   This counter shows the average time, in seconds, of a read operation from the disk. On a well-tuned system, ideal values are from 1-5 milliseconds (ms) for logs (ideally 1 ms on a cached array), and 4-20 ms for data (ideally less than 10 ms). Higher latencies can occur during peak times, but if high values occur regularly, you should investigate the cause.

    • Logical Disk: Avg. Disk sec/Write   This counter shows the average time, in seconds, of a write operation to the disk. On a well-tuned system, ideal values are from 1-5 ms for logs (ideally 1 ms on a cached array), and 4-20 ms for data (ideally less than 10 ms). Higher latencies can occur during peak times, but if high values occur regularly, you should investigate the cause.

    When you are using RAID configurations with the Avg. Disk sec/Read or Avg. Disk sec/Write, use the formulas listed in the following table to determine the rate of input and output on the disk.

     

    RAID level Formula

    RAID 0

    I/Os per disk = (reads + writes) / number of disks

    RAID 1

    I/Os per disk = [reads + (2 * writes)] / 2

    RAID 5

    I/Os per disk = [reads + (4 * writes)] / number of disks

    RAID 10

    I/Os per disk = [reads + (2 * writes)] / number of disks

    For example, if you have a RAID 1 system that has two physical disks, and your counters are at the values that are shown in the following table:

     

    Counter Value

    Avg. Disk sec/Read

    80

    Logical Disk: Avg. Disk sec/Write

    70

    Avg. Disk Queue Length

    5

    The I/O value per disk can be calculated as follows: (80 + (2 * 70))/2 = 110

    The disk queue length can be calculated as follows: 5/2 = 2.5

    In this situation, you have a borderline I/O bottleneck.

  • From:http://technet.microsoft.com/en-us/library/dd723635(v=office.12).aspx

猜你喜欢

转载自www.cnblogs.com/liangqihui/p/9502928.html
今日推荐