How to tune Sitecore prefetch caches
Asked Answered
W

2

5

What is the best approach to using sitecore prefetch caches? Given a stand alone Sitecore server with local SQL Server, 8gb ram and 2,000 content items, should I aim to prefetch the bulk of website content up front on the assumption that it is more efficient to bulk load items? For the sake of a clearer scenario assume that prefetching all 2000 items would take up 2gb as reported by /sitecore/admin/cache.aspx

Also, does the configured prefetch cache size in relation to required size also affect performance i.e. if set 3x larger than necessary, does this result in a performance hit compared to being set at 1.1x required size?

Wigwam answered 18/5, 2011 at 9:16 Comment(0)
B
9

The prefetch is a bit of a gray area. If you prefetch A LOT of content, each app restart will take longer, because its populating the prefetch. If you have very little in the prefetch, app restarts will be quick but then you're getting little advantage from it. You should find a balance between them.

I recommend you prefetch anything that you need for the home page, e.g. the home item and its immediate children (likely for a main nav). Also, if there are other data items that are used on the home page and you know they are always used there, you can prefetch them too. I would start with the basics and slowly add to it and see how it affects performance and app restarts.

As for the sizing of the prefetch, it just define the max size. So if you set it to 3x the standard size, that means you could potentially get up to 3x more of data in the prefetch, it doesn't guarantee you will. But the more in the prefetch, the slower app restarts, regardless.

I highly recommend you watch the Sitecore Caching Technical Deep Dive webinar to understand the prefetch. There's only a few minutes in it about prefetch but its a really good video. It's available on the SPN (not the SDN)

Bilestone answered 18/5, 2011 at 12:2 Comment(2)
Hi, on the issue of sizing, I was curious about the impact of setting the cache size in relation to the amount of applicable data in scope of prefetch. So, if setting a 10gb limit results in 2gb (i.e. everything in scope of the configured prefetch criteria), what is then the impact of setting the cache size to be just big enough - 2.1Gb (is this better? or the same as a bigger limit?) or smaller than required - 1Gb (does this result in cache "churn")Wigwam
Say your prefetch says get all sub-items of home. If you add many more sub-items of home over time, the prefetch will grow maybe from 2.0 Gb to 2.1, or 2.2, or 2.3, etc. It's relative to how you configured it. I recommend you watch the video I referenced and make a judgment based on your specific configuration on how the content may change over time and how that affects the prefetch. If you have the home item and possibly just several subitems as main sections of the site, and over time you only really ever add sub-pages of those, then it will likely be a consistent prefetch.Bilestone
S
2

Some new information has come to light recently regarding the prefetch cache. In short, don't ever size it too small. It's the most important cache of Sitecore. Items are not only added to the prefetch cache at startup, on the contrary, they are added throughout the application lifetime.

Do not confuse the act of prefetching with the prefetch cache itself. In the linked blog post I argue that it should have been termed "item bootstrapping" instead of prefetch to not confuse it with the cache of the same name. Prefetching an item DOES add it to the prefetch cache but that's it. Any other operation with SQL also affects the prefetch cache (read an item, create an item, etc... including those not listed in the config).

As Mark's answer states- yes, prefetch your most impactful items. However, SIZE your prefetch cache based on the application statistics. Review your <data folder>\diagnostics\health_monitor\CacheStatus.<date>.html files to ensure you aren't exceeding the maximum size and then give yourself a buffer.

Sigismondo answered 2/12, 2021 at 17:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.