Sitecore cache settings for slackers

Reason

Whether or not a solution uses HTML caching the “data caches” used by Sitecore should never be left on their original settings, as these are far too low even for a development environment. A lot of performance can be gained for both website visitors (via the web database caches) and editors (via the core and master database caches) by increasing these cache sizes

Unfortunately most of the solutions I’ve seen don’t use HTML caching at all and on top of that run with default data cache sizes, which can cause performance issues due to frequent cache clearing and fails to utilize server memory properly.

The 32-bit example should work with all versions of Sitecore 6; the 64-bit example works with Sitecore 6.4.1 Update-4 and later.

Code

On 64-bit systems, disabling the cache size limits is the easiest way of allowing Sitecore to consume memory:

If true, Sitecore does not limit cache size growth and ignores any maximum cache sizes specified in the web.config file.
Enabling this setting can improve the application’s performance in 64-bit environments by allowing Sitecore to take full advantage of the available memory.
After setting this value to true, monitor the system at regular intervals, as this configuration can cause Sitecore to consume too much memory and cause Out Of Memory errors.
It is only recommended to set the setting to true in 64-bit environments.

This can be done by saving the configuration shown below to a .config-file (e.g. “cache.config”) and place it in the “App_Config/Include”-folder.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="Caching.DisableCacheSizeLimits" value="true"/>
    </settings>
  </sitecore>
</configuration>

On 32-bit systems (or if fine grained cache sizing is required), the configuration shown below can be used. It should be saved to a .config-file as described earlier.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <!-- Caches - set sizes to whatever values make sense -->
    <databases>
      <!-- core -->
      <database id="core">
        <cacheSizes hint="setting">
          <data>40MB</data>
          <items>20MB</items>
          <paths>1MB</paths>
          <itempaths>20MB</itempaths>
          <standardValues>1MB</standardValues>
        </cacheSizes>
      </database>
      <!-- master -->
      <database id="master">
        <cacheSizes hint="setting">
          <data>500MB</data>
          <items>500MB</items>
          <paths>10MB</paths>
          <itempaths>50MB</itempaths>
          <standardValues>10MB</standardValues>
        </cacheSizes>
      </database>
      <!-- web -->
      <database id="web">
        <cacheSizes hint="setting">
          <data>1GB</data>
          <items>1GB</items>
          <paths>10MB</paths>
          <itempaths>50MB</itempaths>
          <standardValues>10MB</standardValues>
        </cacheSizes>
      </database>
    </databases>

    <!-- Memory monitor hook - set Threshold to whatever value makes sense -->
    <hooks>
      <hook type="Sitecore.Diagnostics.MemoryMonitorHook, Sitecore.Kernel">
        <param desc="Threshold">3000MB</param>
        <param desc="Check interval">00:00:05</param>
        <param desc="Minimum time between log entries">00:01:00</param>
        <ClearCaches>false</ClearCaches>
        <GarbageCollect>false</GarbageCollect>
        <AdjustLoadFactor>false</AdjustLoadFactor>
      </hook>
    </hooks>
  </sitecore>
</configuration>

Example

Checking the current cache sizes and cache usage can be done by accessing “/sitecore/admin/cache.aspx”.

Cache settings - core

Cache settings - master

Cache settings - web

One thought on “Sitecore cache settings for slackers

  1. Pingback: Controlling Sitecore’s isLanguageFallbackValid cache size | Horizontal Integration

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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