Optimizing Your Index Configurations in Sitecore 7

April 3, 2015 | Conor Marron

Sitecore API Search Configuration IndexThe Sitecore Content Search API provides an easy-to-implement and scalable way of utilizing indexes on your Sitecore instance. Sitecore API is an extensive topic, and in previous posts, my colleague, Stefan, has addressed key points regarding programmatic utilization of indexing.

In this post, I will address global configuration files and their impact on site performance. Keeping the following index configuration points in mind will be beneficial to any developer looking to ensure a Sitecore indexing implementation goes as smoothly as possible.

The first aspect to consider is making sure that when your site's indexes are updated or fully rebuilt, that it occurs in a different directory than the one referenced by your production site. Otherwise, automatic indexing updates could very likely result in locking errors when users attempt to load pages that utilize indexes.

To do this, locate the following configuration files (by default they should be in the /App_Config/Include directory of your site):

  • Sitecore.ContentSearch.Lucene.Index.Core.config
  • Sitecore.ContentSearch.Lucene.Index.Master.config
  • Sitecore.ContentSearch.Lucene.Index.Web.config

In each of these files, you will want to modify the "type" attribute of the "index" element. Using the Web index configuration file as an example, change the following line:

index id="sitecore_web_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider

..to be...

index id="sitecore_web_index" type="Sitecore.ContentSearch.LuceneProvider.SwitchOnRebuildLuceneIndex, Sitecore.ContentSearch.LuceneProvider

After making these changes, rebuild your Sitecore indexes from within the content editor control panel. You can confirm this change is effective by checking on the index directory of your site (by default, defined by the $dataFolder attribute in the web.config). If you see new directories created for your core, master and Web indexes with "_sec" appended, then Sitecore is effectively rebuilding/updating indexes in a separate directory. Upon completing the indexing operation, Sitecore will take the changes from the "_sec" folder of each index and copy it to the primary folder for each index.

The other points to consider are the strategies utilized by your indexes. These are defined in the same config files referenced above. The strategies built into Sitecore can be found at the following App_Config/Include file: Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config.

For example, the following demonstrates how one would set an index to use the "onPublishEndAsync" strategy.

strategies hint="list:AddStrategy"
!-- NOTE: order of these controls the execution order --
strategy ref="contentSearch/indexUpdateStrategies/onPublishEndAsync" /
/strategies

The strategies being utilized by your indexes should be reviewed to ensure optimal performance of your site. One area in particular to consider is the strategy utilized by your master index, as by default it is set to "syncMaster." This is the most expensive indexing strategy in regards to server resources, and generally should be changed to another strategy since the Web index should be exclusively utilized in production environments. You may want to set the strategy for your master index to be "manual," which disables automatic indexing entirely for the index (indexes may still be run programmatically or through the control panel in the content editor).

Every Sitecore implementation is unique and the indexing strategies utilized should be evaluated on a per-implementation-basis. Taking the above-mentioned points into consideration will help ensure that you get the most out of your site indexes and optimize performance while also being kind to your hosting environment(s).

*Please note that the site's application pool will reset upon saving any of these changes. As such, you will want to coordinate these updates to occur during non-peak hours as to not disrupt public site users or content editors.

About the Author

Conor
Conor Marron

I’m a developer at TBG and enjoy working with Sitecore. In my free time I enjoy playing my drums, video games and pinball.

Leave A Reply

comments powered by Disqus