Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loadbalancer and Solrcloud

Tags:

solr

solrcloud

I am wondering how loadbalancer can be set up on top of SolrCloud or a load-balancer is not needed?

If the former, shard leaders need to be added to the loadbalancer? Then what if the shard leader changes for some reason? Or all machines in the cluster (including replica) better be added to the load balancer?

If the latter, I guess a cname needs to point to the SolrCloud cluster and it should be round robin DNS?

Any advice from some actual Solrcloud operation experience would be really appreicated.

like image 720
kee Avatar asked Mar 20 '14 04:03

kee


People also ask

What is SolrCloud?

SolrCloud is flexible distributed search and indexing, without a master node to allocate nodes, shards and replicas. Instead, Solr uses ZooKeeper to manage these locations, depending on configuration files and schemas. Queries and updates can be sent to any server.

What is load balancer in Solr?

Load Balancer A load balancer distributes incoming queries across Solr nodes. Putting a load balancer on top of your Solr cluster helps you achieve a truly distributed and highly-available architecture.

What is a Loadbalancer URL?

Description. Web application load balancer URL. Specifies the Web application load balancer URL. If a value is not specified, then API Gateway uses the default hostname and port number during publish of an API Gateway asset from CentraSite to API Gateway. For example, http://myHostname:9072.

Do I need a Loadbalancer?

Every application needs a load balancer, so your system for provisioning an app should include a load balancer automatically, whether as software or a configuration within a hardware load balancer.


Video Answer


4 Answers

Usually SolrCloud is used with combination of ZooKeeper, the client uses CloudSolrServer to access to SolrCloud.

The query will be done in following flow.

Note that I only read the source code of Solr partially and there are lot of guesses. Also what I read was source code of Solr 4.1, so it might be outdated.

  1. ZooKeeper holds the list of IPAddress:Port of all SolrCloud servers.
  2. (Client Side) The instance of CloudSolrServer retrieves the list of servers from ZooKeeper.
  3. (Client Side) The instance of CloudSolrServer chooses one of SolrCloud server randomly and sends query to it. (Also LBHttpSolrServer chooses the server in round-robin?)
  4. (Server Side) The SolrCloud server which recieved the query chooses randomly from replica of shards (one server per shard) from server list and redirects the query to it. (Note that all the SolrCloud server holds the server list which can be recieved from ZooKeeper)

The update will be done in same manner as above but also be populated to all servers.

Note that as for SolrCloud, the leader and replica has small difference and we can send query/update to any of the server. It is automatically redirected to other servers.

In short, the loadbalancing is done in both client side and server side. So you don't need to worry about it.

like image 170
ymonad Avatar answered Sep 28 '22 12:09

ymonad


A Load Balancer is needed and would be implemented by Zookeeper used in conjunction with SolrCloud.

When you use SolrCloud you must setup sharding and replication through the use of Zookeeper either using the embedded Zookeeper server that comes bundled with SolrCloud or you use a stand-alone Zookeeper ensemble (which is recommended for redundancy).

Then you would use SolrCloudClient to send your queries to Zookeeper which will then forward your query to the correct shard among your cluster. SolrCloudClient will require the name and address of all your Zookeeper instances upon instantiation and your Load-Balancing will be handled as appropriate from there.

Please see the following excllent tutorial: http://www.francelabs.com/blog/tutorial-solrcloud-amazon-ec2/

Solr Docs: https://cwiki.apache.org/confluence/display/solr/Setting+Up+an+External+ZooKeeper+Ensemble

like image 34
jpalmer4444 Avatar answered Sep 28 '22 13:09

jpalmer4444


This quote refers to latest version of Solr, at time of writing was ver. 7.1

Solrcloud - Distributed Requests

When a Solr node receives a search request, the request is routed behind the scenes to a replica of a shard that is part of the collection being searched.

The chosen replica acts as an aggregator: it creates internal requests to randomly chosen replicas of every shard in the collection, coordinates the responses, issues any subsequent internal requests as needed (for example, to refine facets values, or request additional stored fields), and constructs the final response for the client.

Solrcloud - Read Side Fault Tolerance

In a SolrCloud cluster each individual node load balances read requests across all the replicas in collection. You still need a load balancer on the 'outside' that talks to the cluster, or you need a smart client which understands how to read and interact with Solr’s metadata in ZooKeeper and only requests the ZooKeeper ensemble’s address to start discovering to which nodes it should send requests. (Solr provides a smart Java SolrJ client called CloudSolrClient.)

like image 29
freedev Avatar answered Sep 28 '22 13:09

freedev


I am in a similar situation where I can't rely on CloudSolrServer for loadbalancing, a possible solution that I am evaluating is to use Airbnb's synapse (http://nerds.airbnb.com/smartstack-service-discovery-cloud/) to reconfigure dynamically an existing haproxy loadbalancer based on the status of the SolrCloud cluster that we get from Zookeeper.

like image 44
Luca Avatar answered Sep 28 '22 12:09

Luca