Reputation: 44605
I am currently running performance tests on a .net web application written in c#. I have test tool that simulates a load of 200 users on a windows server 2008.
This is resulting in very hign cpu useage of ~80% which is a concern for me. I feel it may be an issue in my code as its the work process for web application that is causing the high cpu useage.
How can I debug in to this further to help find what the issue may be with my code that is causing this? Are there any tools that I could use to assist me with this? I am running perf monitor on the server to collect states but this only goes so far in assisting me.
Upvotes: 3
Views: 1873
Reputation: 4084
Interesting answers so far. There is the Psscor4 tool - the successor of SOS.dll debugging extension. It helps investigating many live data from the CLR. I suggest some deep readings in Tess' od Toms blogs. Lot of stuff for ASP.NET debugging.
Also, take a look at the PerfView tool. I didn't test is yet, but it claims to be able to handle large sized heaps better than CLPProfiler.
Upvotes: 1
Reputation: 65534
If @Diego answer doesn't yeild the best results, bump it up from 200 to 200,000 users and run DebugDiag and set it up to capture the dump with high CPU Settings and crash the box. I was going to say this as a comment but I thought I'd give you the steps:
Defining High CPU Utilization Problems with IIS
High CPU is identified when an IIS process (INETINFO.EXE, DLLHOST.EXE, W3WP.EXE) stops responding to incoming requests and does not serve web pages due to excessive CPU Utilization. We will use the steps below to get the data needed.
Troubleshooting Steps
Install DebugDiag from http://www.microsoft.com/downloads/details.aspx?FamilyID=9bfa49bc-376b-4a54-95aa-73c9156706e7&DisplayLang=en on the server. The default install path is C:\Program Files\IIS Resources\DebugDiag and can be changed during the installation.
Set up Performance Monitor Logging before the issue occurs:
a) Open DebugDiag (Start -> Programs -> IIS Diagnostics)
b) Go to the Tools menu -> Options and Settings
c) Select the Performance Log tab
d) Click “Enable Performance Counter Data Logging”
e) Click OK
Note: The Data Sampling Interval and time to start monitoring is subjective to when the CPU spike reproduces.
Uncheck Debug Exception Catching (IIS5 and IIS5.1) with the following steps:
a) Open the MMC for IIS
b) Right-click the computer name and click Properties
c) Click the Edit button for the Master WWW properties
d) Go to the Home Directory tab
e) Click the Configuration button towards the bottom
f) Go to the "Process Options" tab and uncheck "Enable Debug Exception Catching"
g) Click OK
Create a Hang Rule with the following steps:
a) Open DebugDiag (Start -> Programs -> IIS Diagnostics)
b) Select "IIS Hang" and click Next
c) Click "Add URL" and enter a URL that reproduces the hang, e.g. http://ComputerName/HelloWorld.aspx, and click OK. Select YES when asked to "test the specified URL".
d) Click OK and click Next
e) Click "Add Dump Target" and select the desired Target Type
f) Click OK and click Next
g) Click Next for "Rule Name". The "Userdump Location" can be changed here.
h) Select "Activate the rule now" and click Finish
Notice the Status is Active. The Userdump Count will increase each time a dump file is created.
Get the Data Manually if the server is in a high CPU state at the time of the install. In DebugDiag, go to the Processes tab, right-click the process and select "Create Full Userdump".
Stop PerfMon Logging about two minutes after taking a dump of the processes:
a) Open DebugDiag (Start -> Programs -> IIS Diagnostics)
b) Go to the Tools menu -> Options and Settings
c) Select the Performance Log tab
d) Click "Disable Performance Counter Data Logging"
e) Click OK
Analyze the Dump by selecting the "Advanced Analysis" tab and clicking "Add Data Files". When the .dmp is added, select the "Crash/Hang Analyzers” script and click "Start Analysis". When finished, a report (.mht) will be created in C:\Program Files\IIS Resources\DebugDiag\Reports and displayed in Internet Explorer with the results and recommendations. If using custom DLL’s, the Symbol path (Tools menu -> Options and Settings -> Symbol Search Path) to the custom PDB files can be added.
Upvotes: 1
Reputation: 18349
Editions Ultimate and Premium of Visual Studio come with a profiler that can help you quickly find method calls that are consuming the most CPU. See: http://msdn.microsoft.com/en-us/library/ms182372.aspx
An alternative is ANTS Profiler, which has a 21-day trial and it's REALLY good. See: http://www.red-gate.com/supportcenter/content/ANTS_Profiler/articles/profiling_web_app
Upvotes: 3
Reputation: 3671
separate the client code (your test tool that simulates 200 users) from the server and put the client on a different machine.
often the client code is the bottleneck.
Upvotes: 2