Measuring ASP.NET and SharePoint Output Cache
Join the DZone community and get the full member experience.Join For Free
during asp.net output caching week in my local blog i wrote about how to measure asp.net output cache. as my posting was based on real work and real-life results then i thought that this posting is maybe interesting to you too. so here you can read what i did, how i did and what was the result.
caching is not effective without measuring it. as mvp henn sarv said in one of his sessions then you will get what you measure. and right he is. lately i measured caching on local microsoft community portal to make sure that our caching strategy is good enough in environment where this system lives. in this posting i will show you how to start measuring the cache of your web applications.
although the application measured is built on sharepoint server publishing infrastructure, all those counters have same meaning as similar counters under pure asp.net applications.
i used performance monitor and the following performance counters (their names are similar on asp.net and sharepoint wcms):
- total number of objects added – how much objects were added to output cache.
- total object discards – how much objects were deleted from output cache.
- cache hit count – how many times requests were served by cache.
- cache hit ratio – percent of requests served from cache.
the first three counters are cumulative while last one is coefficient. you can use also other counters to measure the full effect of caching (memory, processor, disk i/o, network load etc before and after caching).
the measuring i describe here started from freshly restarted web server. i measured application during 12 hours that covered also time ranges when users are most active. the time range does not include late evening hours and night because there is nothing to measure during these hours.
during measuring we performed no maintenance or administrative tasks on server. all tasks performed were related to usual daily content management and content monitoring. also we had no advertisement campaigns or other promotions running at same time.
you can see the results on following graphic.
|total number of objects added|
|total object discards|
|cache hit count|
|cache hit ratio|
you can see that adds and discards are growing in same tempo. it is good because cache expires and not so popular items are not kept in memory. if there are more popular content then the these lines may have bigger distance between them.
cache hit count grows faster and this shows that more and more content is served from cache. in current case it shows that cache is filled optimally and we can do even better if we tune caches more. the site contains also pages that are discarded when some subsite changes (page was added/modified/deleted) and one modification may affect about four or five pages. this may also decrease cache hit count because during day the site gets about 5-10 new pages.
cache hit ratio is currently extremely good. the suggested minimum is about 85% but after some tuning and measuring i achieved 98.7% as a result. this is due to the fact that new pages are most often requested and after new pages are added the older ones are requested only sometimes. so they get discarded from cache and only some of these will return sometimes back to cache. although this may also indicate the need for additional seo work the result is very well in technical means.
measuring asp.net output cache is not complex thing to do and you can start by measuring performance of cache as a start. later you can move on and measure caching effect to other counters such as disk i/o, network, processors etc. what you have to achieve is optimal cache that is not full of items asked only couple of times per day (you can avoid this by not using too long cache durations). after some tuning you should be able to boost cache hit ratio up to at least 85%.
Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.