ASP.Net IIS7 Obtaining CPU usage per request
I have an asp.net application running on a production server.
The cpu usage on the server is very high, 80-90%.
Each request however does not appear to be taking too long, unless the cpu has peaked at 100%.
I need to obtain some profiling data in order to determine if the high cpu usage is due to a small number of high cpu requests, or, if it is just general high load.
I can add more cores to the machine and also web farm the app but 开发者_如何学JAVAI will need evidence in order to justify any costs and future proofing the performance.
Is there a way of logging to a file the CPU usage for each page request?
Actually, you cannot directly determine CPU utilization for individual requests using counters. ASP.NET requests are handled by the worker process, whose load is distributed across all available CPU cores. You can measure CPU utilization per each core or per entire process, but not per request.
You may be able to isolate CPU-hungry requests indirectly using IIS7 Advanced Logging. You can download it from here. Read this blog to learn how to enable custom logging. You would need to add a “CPU Utilization” field to the log definition . The new IIS log file will show CPU utilization on each request line. This however is not the real CPU utilization for request processing, but merely the CPU utilization during the request processing. You still can use this information to determine suspicious requests that can be potentially CPU-hungry.
Further test these requests individually through load testing to see if any of them create excessive CPU usage under reasonable load. Microsoft load testing tools are included into VSTS 2010 Ultimate edition or VSTS 2008 Test Edition or Team Suite. Alternatively you can use WCAT – a free Microsoft command-line HTTP load generator. Also, we developed a free Fiddler extension for load testing called StresStimulus that replays Fiddler sessions with various load patterns and graphs performance metrics.
Be careful running load test in production. You can run each request under desirable load just for a few seconds. If you would not be able to find unoptimized pages, then use this factor to justify hardware upgrade.
精彩评论