locked
Web Caching size question ( optimal and maximous ) RRS feed

  • Question

  • User-600453776 posted
    Hello,
    Wich is the optimal size to use in the web cache ?

    I´m storing some xml documents, and txt files. I'm thinking to store about 200 xml documents of 10 kb each one.
    What do you think about these amount/size ?
     
    Thanks a lot,
    Ariel Con
    (excuseme for my baddly english)
    Posicionamiento en buscadores
    Service de TV
    Monday, February 13, 2006 9:46 AM

All replies

  • User229670690 posted

    Hello Ariel,

    The sizes that you suggest are fine.  Just be careful not to allocate short-lived objects that are larger than 85000 bytes, because these are allocated in the Large Object Heap and are very expensive to collect. You can use the CLR Profiler to see if all your objects are smaller than 85000 bytes (see the Histogram Allocated Types view).  Here are a few more things to consider:

    1. The ASP.NET Cache will drop entries and induce garbage collections when "Memory\Available MBytes" is less than or equal to 10% of the total physical RAM.  To be safe, you should not allow this performance counter to be within 15% of the total physical RAM.  In regard to performance, it would be better to reduce the number of cache entries/cache size, use an explicity expiration policy on cache entries, or to purchase more RAM than to allow the application to run in such low memory conditions.

    2.  The ASP.NET Cache will drop entries and induce garbage collections when "Process(w3wp/aspnet_wp)\Private Bytes" is greater than or equal to approximately 80% of the worker process memory limit (and/or cache privateBytesMemoryLimit in v2.0).  The worker process memory limit can be set in machine.config <processModel memoryLimit/> for aspnet_wp.exe, or in the IIS metabase for w3wp.exe (see "Maximum used memory (in megabytes)" on Application Pool Properties Recycling tab).  In v2.0, there is also a <cache privateBytesMemoryLimit/>.

    3. In v2.0, the private bytes limit used by the cache can be determined this way:

    • If both privateBytesLimit and worker process memory limit are undefined, the effective limit is:
      MIN(60% physical_ram, 1 TB)
      MIN(60% physical_ram, 800 MB) on x86 (with virtual address space <= 2GB)
      MIN(60% physical_ram, 1800 MB) on x86 (with virtual address space > 2GB)
    • If both are defined, it is the minimum of the two.
    • Else, one of them is defined and not the other, and we used the defined value.

    Also in v2.0, you can get the limit (that the cache is using) programmatically via Cache.EffectivePrivateBytesLimit.

    I recommend reading the following:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt06.asp?frame=true

    and

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/monitor_perf.asp?frame=true

    Thanks,
    Thomas

    Thursday, February 16, 2006 3:36 AM
  • User-2038451410 posted
    Hi.

    I've  been having some problems with my cache being cleared-out in a shared hosting envronment, as detailed in another post (http://forums.asp.net/thread/1332043.aspx) (hope this isn't considered a cross-post, I am writing each one separately!).

    Anyway, essentially in my shared hosting environment, my cache is being cleared-out almost as soon as I put anything in it. As stated above:

    The ASP.NET Cache will drop entries and induce garbage collections when "Memory\Available MBytes" is less than or equal to 10% of the total physical RAM


    Since I'm on a shared hosting environment, with probably 20 applications hosted on it, the memory available in my application pool will probably always be less than 10% of the total physical RAM!

    I could set the PercentagePhysicalMemoryUsedLimit config property to control this, but I'd probably need to set it to about 99.5%, assuming the total physical RAM on the machine is 1024MB (I have an allocation of 10MB in my application pool, of which it's probably safe to use about 5MB for the cache).

    Alternatively I could set the PercentagePhysicalMemoryUsedLimit setting to 100%, and set the PrivateBytesLimit setting to 5MB.

    Any thoughts? Do you think this would work?

    Regards.

    Neil.
    Wednesday, July 5, 2006 8:41 AM