Azure PaaS Cache Optimization
Cache yourself before you wreck yourself. - Cache Cube
Caching in Sitecore: the source of much confusion amongst developers and content authors alike.
The cache settings in Sitecore are a critical part of the performance tuning process, and they can be a bit tricky to get right. In this post, we'll cover the basics of caching in Sitecore and how to optimize your cache settings for Azure PaaS.
High Level Optimization Steps
- Become familiar with the default cache sizes (the default cache sizes are smaller than what Sitecore recommends as a starting point)
- Set
Caching.DisableCacheSizeLimits
totrue
on your local environment to get a feel for how large your caches naturally grow to - Review any existing optimizations that your solution may already have
- Identify caches that are too small on your upstream environments
- Push configuration changes to your environments
- Monitor logs, memory usage, and database usage
- Iterate and increase / decrease sizes as needed
- Set up continuous monitoring or schedule regular reviews of cache sizes and infrastructure load
Search Application Insights for Offending Caches
The most reliable way to find the caches that are too small is to look at the logs in Application Insights. You can use the following Kusto Query Language (KQL) to find the offending caches:
This query identifies which caches were automatically cleared via the DefaultScavengeStrategy due to hitting the max size limit, on which role (CM/CD), and how many times over the specified time period.
Mapping the Settings / Example Config
I did the hard work for you and did all the research required to map out which cache names on cache.aspx
map to which settings in the Sitecore configuration. This config also separates out the cache sizes by role and database.
Adjust as needed for your solution.
Decimals don't work in cache sizes. Sitecore essentially performs a string replace on dots within values, so if you use decimals, your cache size will be set to at least 10x more than you were intending.
Stay cachey, San Diego.
-MG