Lesson 4: Monitoring Cache Performance
To use caching effectively, you must balance three factors:
Available memory
Frequency of requests for specific items
Volatility of those requested items
To enable you to weigh these factors, ASP.NET provides caching performance counters that you can use to monitor how items are served from the cache. In this lesson, you ll learn how to use the Microsoft Management Console (MMC) Performance Logs and Alerts snap-in to monitor how effectively caching is used within your application.
After this lesson, you will be able to
Monitor an application s use of caching for Web forms and user controls
Monitor an application s use of caching for application data
Use the Turnover Rate counter to flag inefficient use of caching
Estimated lesson time: 5 minutes
Using the Performance Monitor
You can use the Performance Logs and Alerts snap-in to view the number of cache entries, the number of cache hits, and the ratio of requests served from the cache at the application level. These performance counters can help you evaluate the effectiveness of your caching policy.
For information about starting and using the Performance Logs and Alerts snap-in, see Lesson 3 in Chapter 9, Building and Deploying Web Applications. ASP.NET provides cache performance counters for individual Web applications. To monitor the cache performance counters for a Web application:
From the Performance Logs and Alerts snap-in, click the + (Add) button. The snap-in displays the Add Counters dialog box, as shown in Figure 12-1.
Figure 12-1. Adding cache performance counters for an application
From the Performance Object list, select ASP.NET Applications, and then select the cache counters from the counters list and the application to monitor from the instances list.
Click Add to add the selected cache counters to the monitor.
Click Close when you have finished adding counters to the snap-in.
Choosing Cache Performance Counters
ASP.NET provides three categories of cache performance counters:
Return statistics that combine cached Web forms, user controls, application data, and internal use of the cache by ASP.NET.
Return statistics representing application data stored in the Cache object.
Return statistics representing Web forms and user controls stored in the cache.
Table 12-6 describes the individual performance counters available for each of these three categories.
Counter | Description |
Entries | Number of items that are currently cached |
Hits | Number of requests served from the cache |
Misses | Number of requests for cached items that could not be served from the cache |
Hit Ratio | Number of hits divided by the number of misses |
Turnover Rate | Number of new entries plus the number of removed entries per second |
You can use the preceding counters to determine whether an application uses caching effectively. For example, if there are a lot of entries in the output cache, but the hit ratio is very small, your application might be caching Web forms that are not frequently used. If the turnover rate is very high, your server might want to reduce the number of items you store in the cache, make the period they are stored in the cache longer, or increase the memory available on your server.