1

I have solrCloud setup with 3 different machines. created collection with 3shards & 2replicas and indexed few documents into it. if I query using URL like below

http:machineIP:8983/solr/collection1/select?q=*:*

I get results. if I change machineIP to any one 3 machine IP it will work.

My question is if the machine while requesting solr (say machine 1)is down how to redirect the query requests to other available solr machines(machine 2 or 3).

I am looking for one common point (or URL) to send requests to solrcloud. which will take care if a machine (or node)is failed, pass request to other available machines.

Thanks in advance, vinod

Vinod
  • 1,965
  • 1
  • 9
  • 18

1 Answers1

4

One way of doing this would be to use a proxy server like Nginx.

Nginx allows you to create a pool of server locations to forward traffic to.

The configuration might look something like this:

upstream backend_hosts {
    server machineIP1:8983;
    server machineIP2:8983;
    server machineIP3:8983;
}

server {
    listen 80;
    server_name example.com;

    location /solr/ {
        proxy_pass http://backend_hosts;
    }
}

With this solution, a request like:

http://example.com/solr/collection1/select?q=:

Would be forwarded to one of the servers in the pool defined in the upstream block. If an error occurs in communicated with on of the servers, it will be forwarded to the next in the list. By default traffic is distributed in a round-robin style.

If you add another machine to SolrCloud, you can simply add it to the pool.

Digital Ocean has a good, clearly written intro to Nginx as a proxy and the upstream module.

Otherwise, the Nginx docs are the place to go.

chrxr
  • 1,374
  • 1
  • 10
  • 21
  • Thanks for the reply. Nginx, is it open source. ? can't we do load balancing with either solr or zookeeper. ? – Vinod Aug 24 '16 at 06:27
  • 1
    Yes, Nginx is open-source (under a BSD-like license), and no, that is not what Zookeeper or Solr are for. Zookeeper is simply managing the configuration files & administration for your SolrCloud setup. The client never hits the ZK IP directly. From the Solr side, SolrCloud is doing a kind of load balancing by distributing requests by shard. However, you still have to hit one of the SolrCloud IPs when querying, and if that machine has failed, the request will fail. You need to have your load balancer separate to forward on failed requests to the other machines. – chrxr Aug 24 '16 at 06:56
  • great, one last question. do we need use nginx client side or server side(like setting up new host which act as load balancer for other 3 solr nodes. all solr requests should go to that new nginx load balancer node.) – Vinod Aug 24 '16 at 07:15
  • Nginx is a fully functioning web server, so server side. All requests would be pointed at the load balancer, which would then distribute the requests to the Solr nodes and return the responses to the client. – chrxr Aug 24 '16 at 08:34
  • Thank you @Chris Rogers. – Vinod Aug 24 '16 at 10:06