We use Solr 4.6 with SolrCloud configuration in a production system. You may say: “It is hight time you upgraded to the latest version, isn’t it?”. And you will be absolute right! But currently this is not the case because full reindexing costs! Our SolrCloud consists of one shard and five replicas as seen in the screenshot bellow:

The problem we were facing was that SolrJ library does balance the requests using round robin algorithm when using class LBHttpSolrServer. Furthermore, when a request to a node fails for any reason (timeout, http 403, http 404, etc), it puts the node to a zombie list for 60 seconds. This can become a burden when the SolrCloud has heavy loads and you will start to see in your application logs:
|
|
So we decided to put a HAProxy instance to load balance the query requests to the SolrCloud using leastconn (least connections) algorithm. After a lot of search and using a combination of official documentation and articles (link1, link2) and the official HAProxy Docker image we created a container using the following configuration:
|
|
Notes on configuration:
- Our HAProxy runs in
192.168.1.10and all the queries are handled by port8983. - We can see statistics about the distribution of requests using HAProxy statistics page which is accessible in http://192.168.1.10:8983/haproxy?stats. See:
1 2 3stats uri /haproxy?stats stats realm Strictly\ Private stats auth haproxyuser:haproxypassword - We check if every Solr node is alive by pinging it (see:
option httpchk GET /solr/paradise-papers/admin/ping?wt=json) - Check interval is 20 seconds (see:
inter 20s)
Now our search queries are handled better and we have already noticed an increase in query performance, faster response times and no downtime! This is a sample output from HAProxy statistics page:

We hope you find this article helpful!