Monitoring ASP.NET Performance

Applies To: Windows Server 2003, Windows Server 2003 with SP1

ASP.NET includes a number of performance counters that you can use to track the execution of your Web applications. When you do steady-state running analysis, you might want to ignore the first request and also any one-time initialization costs for objects. For example, when an ASP.NET page is requested for the first time, there is always the cost of compiling an instance of the Page class. After the initial cost is incurred, performance improves for subsequent requests.

Note

You can also use the built-in ASP.NET tracing feature to track code execution for a page or an application.

Two performance objects are defined for ASP.NET, supporting two types of performance counters:

  • The ASP.NET performance object contains system counters that monitor events on the state server. These global counters are not bound to a particular application instance.

  • The ASP.NET Applications performance object contains application counters.

For example, there is a significant difference between the State Server Sessions counters for the ASP.NET performance object, which apply only to the computer on which the state server is running, and the Sessions counters for the ASP.NET Applications performance object, which apply only to user sessions that occur in process.

Unlike the ASP performance counters discussed earlier, which are exposed globally for the entire server computer, most of the ASP.NET performance counters are exposed per application.

Use System Monitor to view the counters for ASP.NET. If your Web server serves multiple applications, you need to specify a particular application instance when selecting a counter to monitor. In addition, System Monitor provides a __Total__ application instance, which aggregates the counter values for all applications on a server.

Useful Counters for Monitoring ASP.NET Applications

When monitoring the performance of your ASP.NET Web applications, try tracking the performance counters described in Table 6.26.

Table 6.26 ASP.NET Performance Counters

Object\Counter Value

ASP.NET\Application Restarts

The aggregate number of restarts for all ASP.NET applications during the Web servers lifetime.

ASP.NET\Requests Queued

The number of ASP.NET requests waiting to be processed.

ASP.NET\Worker Process Restarts

The number of times that a worker process has restarted on the computer.

ASP.NET Applications\Errors Total

The total number of errors that have occurred in ASP.NET applications.

ASP.NET Applications\Requests/Sec

The number of requests executed per second for ASP.NET applications.

Application restarts, as reported by the ASP.NET\Application Restarts counter, are incremented with each Application_OnEnd event. An application restart can occur because changes were made to the Web.config file or to assemblies stored in the applications \Bin directory, or because too many changes occurred in Web Forms pages. A sudden increase in this counter can mean that your Web application is shutting down. If an unexpected increase occurs, be sure to investigate it promptly. This value is reset every time that IIS is restarted.

Note

The value of each ASP.NET performance counter is updated every 400milliseconds.

Useful Counters for Troubleshooting ASP.NET Performance Problems

Table 6.27 describes some additional performance counters that you can use to troubleshoot performance problems with your Web applications.

Table 6.27 Performance Counters for Troubleshooting ASP.NET Applications

Object\Counter Indicates

ASP.NET Applications\Pipeline Instance Count

The number of active pipeline instances.

.NET CLR Exceptions\# of Exceps Thrown

The total number of exceptions thrown since the start of the application. Collects data both on .NET exceptions and on unmanaged exceptions that are converted to .NET exceptions. For example, a null pointer reference exception in unmanaged code is rethrown in managed code as a .NET SystemNullReferenceException. Exceptions that are rethrown are recounted. This counter collects data from both handled and unhandled exceptions.

System\Context Switches/sec

The rate at which thread contexts are switched by all CPUs in the Web server. A high number usually indicates either high contention for locks or many switches between user and kernel mode by the thread. Be sure to investigate these problems by using sampling profiles and other tools.

Although exceptions occur infrequently, you might want to monitor the # of Exceps Thrown counter, because exceptions can have performance implications. Some code paths, however, rely on exceptions for their proper functioning. For example, the HttpResponse.Redirect method always throws an exception, ThreadAbortException. Therefore, it can be more useful to track the number of exceptions thrown by using the Errors Total counter to see if the exception generated an error for the application.

For more information about the ASP.NET performance counters discussed in this section, as well as other ASP.NET performance counters, see IIS 6.0 Performance Counters.