LBHttpSolrServer or "Load Balanced HttpSolrServer" is just a wrapper to CommonsHttpSolrServer. This is useful when you have multiple SolrServers and query requests need to be Load Balanced among them. It offers automatic failover when a server goes down and it detects when the server comes back up.

This should NOT be used for indexing in traditional master/slave architectures since updates have to be routed to the correct master. In SolrCloud architectures, use CloudSolrServer which will take advantage of this class automatically.

How to use?

SolrServer lbHttpSolrServer = new LBHttpSolrServer("http://host1:8080/solr/","http://host2:8080/solr","http://host3:8080/solr");
//or if you wish to pass the HttpClient do as follows
httpClient httpClient = new HttpClient();
SolrServer lbHttpSolrServer = new LBHttpSolrServer(httpClient,"http://host1:8080/solr/","http://host2:8080/solr","http://host3:8080/solr");

This can be used like any other SolrServer implementation.

How does the Load Balancing happen ?

This is a dumb round-robin Load Balancing. First request goes to 'host1' then to 'host2' and then 'host3' and it starts with 'host1' again.

【RR模式负载均衡】

How does failover happen?

LBHttpSolrServer does not keep pinging the servers to know if they are alive. If a request to a server fails by an Exception then the host is taken off the list of live servers and moved to a 'dead server list' and the request is resent to the next live server. This process is continued till it tries all the live servers. If atleast one server is alive the request succeeds , and if not it fails.

【LBHttpSolrServer并不定期检测server是否存活,在request过程中如果某个server执行失败,则将该server添加到‘dead server list’,并转移到下一个server执行,一直到执行成功。】

How does it know if a server has come back up ?

LBHttpSolrServer keeps pinging the dead servers once a minute (default value) to find if it is alive. The interval can be changed using

lbHttpSolrServer.setAliveCheckInterval(60*1000); //time in milliseconds

The ping is done in a separate thread.

【LBHttpSolrServer启动单独线程检测‘dead server’,默认一分钟检测一次。】

Can I add and remove servers ?

Yes, there are methods to add or remove servers to an existing LBHttpSolrServer;

example:

//remove one
lbHttpSolrServer.removeSolrServer("http://host2:8080/solr");
//and add another
lbHttpSolrServer.addSolrServer("http://host4:8080/solr");

When to use this ?

This can be used as a software load balancer when you do not wish to setup an external load balancer.

Alternatives to this built-in approach are to use a dedicated hardware load balancer or to use Apache httpd with mod_proxy_balancer as a load balancer. See Load balancing on Wikipedia.

What is LBHttpSolrServer?的更多相关文章

  1. Solr Cloud - SolrCloud

    关于 Solr Cloud Zookeeper 入门,介绍 原理 原封不动转自 http://wiki.apache.org/solr/SolrCloud/ ,文章的内存有些过时,但是了解原理. Th ...

  2. solrj-WiKi

    solrj是一个访问solr的客户端,它提供了一个接口,用于添加.更新.删除索引数据. solrj跨版本兼容 solrj一般保持向后兼容,所以你可以使用新版本的solrj访问老版本的solr服务,也可 ...

  3. Solr入门之SolrServer实例化方式

    随着solr版本的不断升级, 差异越来越大, 从以前的 solr1.2 到现在的 solr4.3, 无论是类还是功能都有很大的变换, 为了能及时跟上新版本的步伐, 在此将新版本的使用做一个简单的入门说 ...

  4. SolrServer SolrRequest

    SolrServer实现类 HttpSolrServer HttpSolrServer uses the Apache Commons HTTPClient to connect to solr. H ...

  5. solr 基本命令二(权重查找)

    package zr.com.solr.utils; import java.io.IOException; import java.util.HashMap; import java.util.Li ...

  6. solrserver实例化

    以下是httpClient实例化方式,需要tomcat运行Solr服务 1.ConcurrentUpdateSolrServer实例化SolrServer,该类实例化多用于更新删除索引操作 Concu ...

  7. Solr 6.7学习笔记(03)-- 样例配置文件 solrconfig.xml

    位于:${solr.home}\example\techproducts\solr\techproducts\conf\solrconfig.xml <?xml version="1. ...

  8. Solr 18 - 通过SolrJ局部更新Solr中的文档 (原子操作、非覆盖操作)

    目录 1 需求分析 2 需求实现 2.1 pom.xml依赖 2.2 Java代码示例 3 补充说明 3.1 关于文档中_version_的取值说明 3.2 store=true/false的区别 1 ...

随机推荐

  1. [LeetCode&Python] Problem 350. Intersection of Two Arrays II

    Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1 ...

  2. Gym 101655:2013Pacific Northwest Regional Contest(寒假自训第13场)

    A .Assignments 题意:给定距离D,以及N个飞机的速度Vi,单位时间耗油量Fi,总油量Ci.问有多少飞机可以到达目的地. 思路:即问多少飞机满足(Ci/Fi)*Vi>=D  ---- ...

  3. c++中的stl

    String Vector Set List Map 1.string char* s1 = "Hello SYSU!"; //创建指针指向字符串常量,这段字符串我们是不能修改的 ...

  4. html css input定位 文本框阴影 灰色不可编辑

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 20165313 《Java程序设计》第二周学习总结

    教材学习总结 这周我主要学习了教材上的二,三两章.其基本内容就是数据与语句的表达与基本的运用.其中重点要理解并掌握的是: 1.Scanner的运用:利用该类创建对象就可以完成要求用户输入这一要求.类似 ...

  6. ls -l 和du 的区别

    编程之路刚刚开始,错误难免,希望大家能够指出. 简单的来说,ls -l 显示的是实际文件(目录)大小,而du显示的是文件(目录)占用磁盘空间的大小. linux下一切皆文件. 首先,硬盘的最小存储单位 ...

  7. NDK: GCC 4.6 crashes

    used version: NDK r9b, arm-linux-androideabi-4.6 GCC,  with "-O2 -finline-limit=24". got t ...

  8. Eclipse和Intel idea的常用技巧

    使用Eclipse的几个必须掌握的快捷方式   “工若善其事,必先利其器”,感谢Eclipse,她 使我们阅读一个大工程的代码更加容易,在阅读的过程中,我发现掌握几个Eclipse的快捷键会使阅读体验 ...

  9. (原创) 使用pymongo 3.6.0连接MongoDB的正确姿势

    0.疑惑 前两天使用pymongo连接MongoDB的时候发现了一个奇怪的现象:我本机MongoDB并没有打开,但是使用pymong.MongoClient()进行连接时,并没有异常,我的服务端也正常 ...

  10. 初学者须知 常见的HTML5开发工具有哪些

    HTML5被看做是Web前端开发的最佳编程语言,具有多设备.跨平台.即时更新等优势.更重要的是HTML5入门简单,就业前景广.薪资福利高,这促使越来越多的人转行学习HTML5.学习要一步一个脚印,今天 ...