Reserve ApacheSolr servers for Drupal

Reserve ApacheSolr servers for Drupal

First of all, what is Apache Solr?

Apache Solr – is the advanced search platform with open primary code by Apache Lucene project.

Why Apache Solr?

The main criteria for us to choose this platform was the fact that Apache Solr is optimized for work with big loading and that replication is already in platform core, and this gives big opportunities for scaling.

One of our projects made us come across a question: “What will happen if our main Solr server will suddenly stop responding? Will all search system on site die in that case?”

Sometimes it’s possible to switch on search of Drupal core (this kind of functional is in Apache Solr Search Integration module), but it can’t be done with big projects because it will create deadly load on database – so this option is set aside at once.

As another option, if the main Solr-server is down, the administrator sets up a new one ASAP (or makes a master-server out of a slave-server) and writes a new connect in Drupal.

But there are 2 problems with that. Firstly, the administrator can’t be online 24/7, secondly in setting up a new server re-indexation of material might take several dozens of hours…

Our decision in this situation:

1) Adding the following lines in settings.php


Here, “main” and “reserve” are just the names of connections for a programmer, and they don’t affect anything.

If SOLR replication is not used on several servers, but a reserve server must be created, the information can be duplicated from the main server to a reserve server with the help of simple rsync’ folders. It’s enough to add a rule into a crontab:


2) Creating Drupal-module which will check connection to SOLR-server on hook_cron and if failure occurs it will switch it to one of the reserve servers.


In our case, Elysia Cron module is set to make a check every 3 minutes.


Maximum time of search absence on site if SOLR-server goes down is only several minutes without the interference of web developer or administrator.

11 votes, Rating: 4.9

Read also


While developing a real estate site for one of our clients we tried to import the complete world cities database into the taxonomy (that was the client's demand).


It’s a very helpful module, which allows inserting FileField right into the text editor. For example, in the process of writing this text an Insert button was pushed and the following image...


This kind of mistake can be seen on servers with nginx as frontend and Apache as backend. It’s usually considered to be a nginx problem which is tried to be strenuously solved. Quite often it’s...


Facebook Developer Blog published good news: from now on one can get user’s address and cell phone number.

Subscribe to our blog updates