views:

237

answers:

1

I'm in active development of an ASP.NET web application that is using server side caching and I'm trying to understand how I can monitor the size this cache during some scale testing. The cache stores XML documents of various sizes, some of which are multi-megabyte.

On the System.Web.Caching.Cache object of System.Web.Caching namespace I see various properties, including Count, which gets "the number of items stored in the cache" and EffectivePrivateBytesLimit, which gets "the number of bytes available for the cache." Nothing tells me the size in bytes of the cache.

In the Understanding Caching Technologies section of the "Caching Architecture Guide for .NET Framework Applications" guide, there is a "Managing the Cache Object" section with a table (Table 2.2: Application performance counters for monitoring a cache) listing a set of application performance counters, but I don't see any that give me the current size of the cache.

What is a good way to find the size this cache? Do I have to set a byte limit on the cache and look at one of the turnover rates? Am I thinking of this problem in the wrong way? Is the answer to How to determine total size of ASP.Net cache really the best way to go?

+1  A: 

I was about to give a less detailed account of the answer you refer to in your question until I read that. I would refer you to this, seems spot on to me. No better way than seeing the physical size on the server, anything else might not be accurate.

You might want to set up some monitoring, for which a Powershell script might be handy to record and send on to yourself in a report. This way you could run various tests overnight say and summarise it.

On a side note, they sound like very large documents to be putting in a memory cache. Have you considered a disk based cache for these larger items and leaving the memory for smaller items which is more ideal for it. If your disks are reasonably fast this should be fairly performant.

dove
Is there any built in .NET class for a disk based cache I should look for?
Kevin Hakanson
@Kevin updated the answer with a link to what I had in mind. I haven't used this and I'm thinking there might even be a more simple solution. Indeed a cheap linux box stacked with memory and running memcached could be considered, thouhg it does not like very big objects, more primed for ones < 1mb as far as i remember, though this cap can be lifted.
dove
@Kevin got curious and you might find this of interest too, it's a few years back but still seems current. http://blogs.msdn.com/dmitryr/archive/2005/12/13/503411.aspx
dove
@dove thanks for the links - the dmitryr blog post referred to a CodePlex project that no longer seems to exist: http://www.codeplex.com/AspNetDiskOutputCach
Kevin Hakanson