In this blog post i will explain what is the solr replication and how to configure Solr Master-Slave replication with Sitecore with minimum number of servers.
First of all I want to explain when we should use Solr instead of lucene.
When Should We Use Solr Instead Of Lucene ?
As we know Sitecore support both Lucene and Solr engine, and the main LINQ query will remain the same, the differences only in the configurations, In most situations, we have a choice between using Solr or Lucene, based on Sitecore recommendation, there are some reasons to use Solr instead of Lucene :
- When you need to index large numbers of items (50,000 and up), Solr performs better.
- Solr is more robust. If your site depends on search as the primary interface, consider using Solr.
- If you use multiple content delivery servers (or plan to do so later), use Solr. Solr works automatically in such an environment. You could use Lucene, but you have to make sure that indexes are synchronized across servers yourself.
So we should therefore use Solr if you plan to scale our site (have a distributed setup with multiple servers).
More details on Sitecore documentation, checkout this link.
What is Solr Replication :
Solr Replication distributes complete copies of a master index to one or more slave servers. The master server continues to manage updates to the index. All querying is handled by the slaves. This division of labor enables Solr to scale to provide adequate responsiveness to queries against large search volumes.
In simple words, when the master Solr index is updated by the CM server, the slave Solr indexes will be updated to reflect those changes
- Splits read and write load and operations.
- Load distribution for search queries.
- High availability for searching.
- Any number of slave instances can be created to scale query performance.
- Usually less frequent index updates on the slaves and better use of the cache
Solr Master-Slave Architecture
Solr Consumes CPU resources specially if you have alot of items or the Wesbsite is purely driven by search, so it is better to have dedicated server for SOLR. but sometimes client has limited budget, he doesn’t want to add dedicated server for solr, so let’s assume that we have only one CM and two CDs as below :
in this situation we will have solr installed on CM server, we will configure it as solr-master and solr installed on each CD server we will configure it as solr-slave, so our architecture will be like this :
Important Note: If you are using Bitnami to install solr, make sure SOLR is
running on JAVA 64-bit runtime, By default, Bitnami SOLR will install 32-bit
java version. for more details about how to configure it to work on java 64-bit
checkout this blog post, Thanks Ahmed for the great post.
Solr Master-Slave Configurations :
No changes on solr-master on cm server, you just need to configure solr-slave on each cd like this :
- Open solrconfig.xml where your solr core installed (ex:C:\Bitnami\solr-4.10.3-0\apache-solr\solr\yourcore\conf\solrconfig.xml)
- Search for <requestHandler name=”/replication” class=”solr.ReplicationHandler”>
- inside this section uncomment the following section and provide the master url from cm server :
The slave continuously keeps polling the master (depending on the pollInterval parameter) to check the current index version of the master. by default it is every 60 seconds and you can change it.
after that when you open solr dashboard from master and slave it should look like this :
from Sitecore open Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config and make sure that ContentSearch.Solr.ServiceBaseAddress value is the local solr instance on each server.
I was talking in this post about solr replication, also there is another approach called solrcloud, and how to use zookeeper to make sure replication is done right, this blog post explains how you can configure Sitecore with solrcloud.
I hope you find this post helpful, If you have any additional knowledge on this subject, comments or questions, please let me know in the comments section below.