Categories

Reserve ApacheSolr servers for Drupal

21.02.2011
Author:

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 data base – so this option is set aside at once.

As another option if main Solr-server is down the administrator sets up a new one ASAP (or makes a master-server out of 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

[snippet|type=php|csid=6|tagstyle=block|lineNumbering=1|numberStart=1]

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:

[snippet|type=c|csid=7|tagstyle=block|lineNumbering=|numberStart=]

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.

[snippet|type=php|csid=8|tagstyle=block|lineNumbering=|numberStart=]

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

Conclusion

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

5 votes, Rating: 5

Read also

1

While developing a real estate site for one of our clients we tried to import...

2

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...

3

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...

4

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

Subscribe to our blog updates