I have a solution that I have been running gradually incrementing load-tests on (i.e. I am using jmeter to create some load but I'm incrementing the load slowly, rather than all at once) until CPU and memory usage max out. When my application finally gets up to peak memory consumption, rather than seeing the caches evicted (observing using the cache admin page and performance counters in perfmon) I am seeing the site simply fall over and the app pool recycle (which does clear the cache, but obviously not in the way that I am looking for).
Note that I did not set a default cache priority (via the Caching.Priority
setting; confirmed in the ShowConfig), so my cache entries should all have the Sitecore.Caching.CachePriority.Lowest
caching priority, though I don't think this is related (posting a separate question about the purpose of this enum).
Expectations After Reviewing the Sitecore.Caching
Namespace
From analyzing the types in the Sitecore.Caching
namespace of the Sitecore.Kernel assembly, it looks like Sitecore's caching leverages .NET's System.Runtime.Caching assembly (specifically, the MemoryCache
type) in order to support features like cache expiration and cache eviction when system resources are running low (see the Sitecore.Caching.MemoryCacheAdapter
class). However, if this is true then the application should be evicting objects from the caches when resources are running low.
Expected Behavior vs Cache Size Limits
I know that Sitecore allows developers to set various cache size limits and will automatically purge caches of entries when those size limits are reached. This is not the behavior that I'm looking for. I am looking to see if there is a way to get Sitecore to proactively respond to high server memory consumption by evicting items from its caches, which should be native functionality of the MemoryCache
class (given that all cache entries in Sitecore are given the System.Runtime.Caching.CacheItemPriority.Default
priority). For this reason, I have intentionally disabled cache size limits (via the Caching.DisableCacheSizeLimits
setting).
Question
I'm not sure if this is a bug, or if this is expected native behavior. Can anyone help to clarify the actual expected behavior and, if different from what I described, perhaps a way to customize Sitecore's caches so that they do react to system resource consumption?