问题描述

在使用Cloud Service服务时,发现服务的CPU占用很高,在业务请求并不大的情况下,需要直到到底是什么进程占用了大量的CPU资源,已经如何获取IIS进程(w3wp.exe)的DUMP文件?

 

问题解答

一:收集云服务中CPU的性能数据

远程登录(RDP)到云服务的实例上,使用管理员身份运行以下命令:

Logman.exe create counter Perf-1Minute
  -f bincirc
  -max 500
  -c "\LogicalDisk(*)\*" "\Memory\*" "\Network Interface(*)\*" "\Paging File(*)\*" "\PhysicalDisk(*)\*" "\Server\*" "\System\*" "\Process(*)\*" "\Processor(*)\*" "\Cache\*"
  -si 00:01:00
  -o C:\PerfMonLogs\Perf-1Minute.blg

Logman start Perf-1Minute

  • 该命令会每隔1分钟收集一次系统性能日志,满500MB会自动覆盖之前的日志。
  • 请根据各磁盘空间大小来判断将该日志存储到哪个分区,默认为C:\PerfMonLogs文件夹。
  • 期间不要重启机器,如果重启了机器,请重新收集.
  • 可以使用使用指令停止Performance Monitor:Logman stop Perf-1Minute

收集完成,打开 C:\PerfMonLogs\Perf-1Minute.blg文件,可查看每一个进程对CPU资源的占用情况,如下图:

【Azure Cloud Service】在Azure云服务中收集CPU监控指标和IIS进程的DUMP方法_Memory

 

二:收集IIS进程Dump文件

1:抓取w3wp的进程dump,下载抓取工具:ProcDump - Sysinternals | Microsoft Learn

执行 procdump 命令

procdump -accepteula -ma -n 5 -s 5 w3wp.exe

这个指令会间隔5秒,连续抓取五次 (Dump文件的大小取决于应用对Memory的占用,可能高达几个GB的大小)

Use the -accepteula command line option to automatically accept the Sysinternals license agreement.

-ma :Write a 'Full' dump file.Includes all memory (Image, Mapped and Private). Includes all metadata (Process, Thread, Module, Handle, Address Space, etc.).

-n :Number of dumps to write before exiting.

-s :Consecutive seconds before dump is written (default is 10).

 

参考资料

ProcDump : https://learn.microsoft.com/en-us/sysinternals/downloads/procdump#using-procdump

logman : https://learn.microsoft.com/zh-cn/windows-server/administration/windows-commands/logman

 

 


当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!