Skip to content
April 16, 2011 / kiranpatils

Basics of Cache Size Tuning


You might know that Sitecore has really good implementation of Caching. [If you don’t know, not to worry, read my earlier post on Sitecore Caching Basics].

We are fighting with performance issues on our CM and CD Servers, and decided to increase cache size. But we were not aware how to proceed and which pattern to use for increasing cache size.

We were knowing about Cache Administration Page. But frankly I was not clear how to interpret this data [Same with you? Then this post is for you only!]. Let me share my learnings with you. So, you can also fine tune your cache optimally and improve performance of your application and finally have a happy client(s). 🙂


First, you need to open Cache Administration page (http:///sitecore/admin/cache.aspx)

The Cache Administration page reports the following details for each cache:
Name — A unique string that identifies each cache. Sitecore cache works on collection. Suppose you are dealing with HashTable where you have Key/Value Pair. Where Key is an identifier and Value is an Object. This name indicates Key.
Count — The number of items in the cache.
Size — The approximate current size of the cache.
Delta — The approximate change in the size of the cache since the last refresh of the cache administration page. In Bytes. Open page first time and then click on refresh [By clicking on Refresh button at top]. If Delta value goes in negative then it means that Sitecore removed some values from Cache entries to allocate another cache values. It indicates your Cache Size for that key is not enough. Will discuss more on this in a while.
MaxSize — The approximate limit to the size of the cache. Comes from your Caching Configuration.

Sounds clear? If not please open Cache Administration page and try to understand. Don’t move to next section until and unless you are clear. If still not clear drop me a comment.

Okay as per Sitecore Caching guide []. The best document on the earth! I strongly recommend you to read it! below symptoms indicates that you need to increase cache size:

1. In the Cache Administration page, if the Delta for a cache fluctuates constantly

2. if the size of a cache is consistently above 80% of the size limit for that cache, then increase the size of the cache by at least 50%. (Size/MaxSize *100 > 80%)

Let me try to explain above theory by example:

We got following data from Cache Administration page [Opened page then clicked on Refresh].

SqlDataProvider – Prefetch data(master) 8952 480MB 9249686 500MB

Name = SqlDataProvider – Prefetch data(master)
Count = 8952
Size = 480MB
Delta = -9249686  (i.e. 9MB)
Max Size = 500MB

Now, let’s apply Caching recommendation theory:
As you can see Size of the cache is about to limit of 500Mb. 480/500 = 96% of max size.
This means that your cache size is not enough to handle all the data (96%>80%). The guide recommends to increase size by 50% i.e. to 750 Mb

Delta is going to minus because Sitecore want to put fresh data into the cache, but it can’t because of cache size. So Sitecore have to delete some data from cache and put new data. Indicates to increase cache size.

We’ve developed one tool which we run on our Servers and decide what cache sizes needs fine tuning and in how much amount of?

Here’s the Pseudo code for the same:

If (Cache.Size/Cache. MaxSize > 80% || Cache.Delta fluctuates)
// It’s time to fine tune your cache size and Cache Guide from Sitecore suggests to increase Cache.MaxSize by 50%. But If you have plenty of RAM available It’s not harm in increasing it by 100%.

Few points to be noted :

  1. If you Increase Pref-etch cache heavily, it may affect your startup time. But will make application smoother ones started.
  2. Be aware that large caches that consume all memory of the application can lead to out of memory exception. [(item 3.3)
    “When the memory consumed by all application pools exceeds available memory on the system, Windows swaps memory to disk and can raise out-of-memory and other errors. Paging can adversely affect performance. Tune cache size limits to prevent paging and out-of-memory conditions.”]

For point#2 – We can put MemoryMonitorHook to limit w3wp process to don’t consume all memory. As per below configuration we kept it to use 6 GB as we have 8 GB RAM available. So, it instructs w3wp to use 6 GB only, and when it reaches the limit it cleans up cache.


So, now whenever you get following log entries in Log files, it means then MemoryMonitorHook is working.

4996 02:21:26 WARN  Memory usage exceeded the MemoryMonitor threshold.
4996 02:21:26 WARN  Memory usage: 4,351,668,224
4996 02:21:26 WARN  Number of suppressed logs due to the minimum time between log entries: 10

Few Caching benefits I would like to share:
  • More Cache Size == More performance.
  • Cache Increases load on memory and decreases load on processor and other system resources.
  • Sitecore Cache works based on layered manner [First it tries to find item at first layer and if found return result from Cache itself, If data not found then it will go till Database and it can add network connectivity, Database Connectivity and puts load on Database.]
  • More Cache means less Database calls and fast response.
  • Improves performance, and decreases the load on SQL Server.

I hope I’ve covered all points. If you come across any new points do share with the world!

Happy Cache Tuning! 🙂



Leave a Comment
  1. Anonymous / Apr 11 2012 2:28 pm

    Thanks mate! that does really helped me


  1. Cache Tuner User Guide « Sitecore basics!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: