Solr with Sitecore Checklist
We have been using Solr with Sitecore for our latest Sitecore implementations as it offers better index synchronization across all CD/CM servers since its a standalone web app with HTTP access, which means that all CD/CM servers will have up-to-date indexed content, unlike lucene where each Sitecore server is responsible of synchronizing its lucene index, which sometimes breaks and causes content to be out-dated.
This blog is not about how to configure Solr with Sitecore, there are many blogs talking on this subject, This blog is about some considerations and best practices that you need to take into account when you setup Solr with Sitecore.
First, Disable Indexing on CD's
With Solr/Sitecore setup, you only need to enable indexing on CM, and disable it on CD servers, By default after any publish operation, Sitecore will store (item changed/added) event into Event Queue table, and each Sitecore instance will pick that and trigger index job for that item, With Solr we only need CM to trigger index job.
To disable indexing on CD, you need to change the indexing strategy for each index to be "Manual", like :
<strategies hint="list:AddStrategy"> <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/manual" /> </strategies>
Second, Allocated Memery
We were using bitnami Apache Solr, and by default it is configured to use 256MB for the memory heap, This is not enough for Sitecore production environment, As you will start to see errors like "OutOfMemory", I usually set the initial allocated memory to 1GB, and maximum to 8GB, you can change this based on the size of your content, To configure Bitnami Solr allocated memory you need to do the following:
/Bitnami/solr-VERSION/apache-solr/scripts/serviceinstall.batfile, and edit (or add if does not exists) the following java options:
- Make sure SOLR is running on JAVA 64-bit runtime, By default, Bitnami SOLR will install 32-bit java version and use that if Java is not installed, which will limit the maximum Memory size that Solr can use, Download JAVA 64-bit version and install it, then in '
serviceinstall.bat' file, you need to change :
Or to whatever your java installation folder is.
- Now you need to re-install Solr service, Open command prompt (Administration mode) and run the following commands:
Third, Solr Cores
With sitecore, you can use one Solr core for all of your content indexes (web, master, core), however i would advise you to use separate core for each one, this will prevent having 1 big core which keeps growing fast , instead you will have smaller cores, which improve your Indexing/Search operations, Create three separate Cores in Solr, and update Solr Index configurations, so that each index points to it's own Core.
Also, In production environment, you need to enable "Switch On Rebuild" in sitecore , so that while you rebuild your indexes, Sitecore will switch any search operation to run on a back-up core until the indexing is finished, This will keep your front end pages that uses search running without any errors.
To do this,Create a new core in Solr , name it "itembuckets_sec" for example, Then you need to change your index "type" attribute and add a new param "rebuildccore" in solr indexes configuration (usually we do this for web index) as following:
<index id="sitecore_web_index" type="Sitecore.ContentSearch.SolrProvider.SwitchOnRebuildSolrSearchIndex, Sitecore.ContentSearch.SolrProvider"> <param desc="name">$(id)</param> <param desc="core">itembuckets</param> <param desc="rebuildcore">itembuckets_sec</param> .... .... .... </index>
Fourth, Common error
Almost on every production environment we had, we were seeing this error in Solr:
Error opening new searcher. Exceeded limit of maxWarmingSearchers=2, try again later.It appears that sitecore indexing perform lots of commits to solr concurrently, causing this error when the searchers that are warming in the background exceed 2 (the default value is 2), We usually increase that to solve the issue.
You will need to go to : "Bitnami\solr-[VERSION]\apache-solr\solr\[CORE NAME]\conf\solrconfig.xml" file and change the value in"maxWarmingSearchers" to higher value.
Have something else to add to this checklist? share it in the comments!