How to limit the memory size for asp.net cache

N

ningjun.wang

I set outputcache to 30 minutes for all .aspx pages on my asp.net 2.0
websites. If a search engine (such as Google) crawl my site, it can hit

thousands of pages within a few minutes and thus produce a large amount

of page caches. This could use a lot of memory and impact other
websites running on the same machine. My question is: how can I limit
the memory size (e.g. to 100MB) used by the cache?

I can set the following in web.config:
<cache privateBytesLimit = "128000000" />


This means the cache starts flushing expired items and attempting to
reclaim memory when memory size exceed 100MB. However if all cached
pages are unexpired, then no memory are reclaimed and memory size will
continue to grow as new pages get cached. How can I force cache to
remove items even if they are not expired yet so that memory will never

exceed 100MB? Is there a configuration setting to achieve this?


Ningjun
 
A

Alvin Bruney [MVP]

To the best of my knowledge, this functionality is not supported. In any
case, a google crawl session will expire and the memory will be reclaimed so
you may want to lower the session time-out to have the reclaim be more
aggressive. Either that or stop worrying about it.
 
N

ningjun.wang

I need to worry about memory during a Google crawl because there are
other web applications running on the same machine. Suppose the
machine's physical memory is 1GB and there are 3 web applications
running on it, I want to make sure that my application donot exceed
500MB.

My questions is this:
If I set <cache privateBytesLimit = "512000000" /> in web.config file,
can my application's memory ever exceed 512000000 bytes (500MB) during
a Google crawl? I expect ASP.NET to do the following in case memory
exceed 500MB

1. Remove all expired cache items.
2. If memory still exceed 500MB, then remove non expired cache items
until memory fall back to 500MB.

Is this true or not?

Ningjun
 
A

Alvin Bruney [MVP]

Firstly, what does your application do that it requires 1/2 a gig of ram.
You realize that this is on the high side right? An applicaiton like this is
certainly not scalabe since 5 users will bring it to its knees, or worse,
crash the server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top