Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tune Sitecore prefetch caches

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?

like image 903
Paul George Avatar asked May 18 '11 09:05

Paul George


People also ask

What is prefetch cache in Sitecore?

Sitecore populates prefetch caches on application initialization and maintains those caches over the life of the application. To configure the Prefetch cache values: Create a patch file for cache size values.

Which cache is populated when application starts in Sitecore?

The Prefetch caches are initially populated on application startup and continue to be populated during the lifetime of the application.


2 Answers

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.

like image 31
jrap Avatar answered Sep 20 '22 02:09

jrap


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)

like image 103
Mark Ursino Avatar answered Sep 19 '22 02:09

Mark Ursino