What is LBHttpSolrServer?
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?的更多相关文章
- Solr Cloud - SolrCloud
关于 Solr Cloud Zookeeper 入门,介绍 原理 原封不动转自 http://wiki.apache.org/solr/SolrCloud/ ,文章的内存有些过时,但是了解原理. Th ...
- solrj-WiKi
solrj是一个访问solr的客户端,它提供了一个接口,用于添加.更新.删除索引数据. solrj跨版本兼容 solrj一般保持向后兼容,所以你可以使用新版本的solrj访问老版本的solr服务,也可 ...
- Solr入门之SolrServer实例化方式
随着solr版本的不断升级, 差异越来越大, 从以前的 solr1.2 到现在的 solr4.3, 无论是类还是功能都有很大的变换, 为了能及时跟上新版本的步伐, 在此将新版本的使用做一个简单的入门说 ...
- SolrServer SolrRequest
SolrServer实现类 HttpSolrServer HttpSolrServer uses the Apache Commons HTTPClient to connect to solr. H ...
- solr 基本命令二(权重查找)
package zr.com.solr.utils; import java.io.IOException; import java.util.HashMap; import java.util.Li ...
- solrserver实例化
以下是httpClient实例化方式,需要tomcat运行Solr服务 1.ConcurrentUpdateSolrServer实例化SolrServer,该类实例化多用于更新删除索引操作 Concu ...
- Solr 6.7学习笔记(03)-- 样例配置文件 solrconfig.xml
位于:${solr.home}\example\techproducts\solr\techproducts\conf\solrconfig.xml <?xml version="1. ...
- Solr 18 - 通过SolrJ局部更新Solr中的文档 (原子操作、非覆盖操作)
目录 1 需求分析 2 需求实现 2.1 pom.xml依赖 2.2 Java代码示例 3 补充说明 3.1 关于文档中_version_的取值说明 3.2 store=true/false的区别 1 ...
随机推荐
- textarea(多行文本域)
多行文本域<textarea>: <textarea name="..." rows="..." cols="..." . ...
- HDU - 4454: Stealing a Cake (圆上三分)
pro:给定一个蛋糕,一个矩阵房子,一只蚂蚁.最开始三者两两相离,问蚂蚁触摸到蛋糕后再触摸矩阵的最短距离.结果保留两位小数,坐标的绝对值<1e4: sol:由于坐标不大,而且精度要求不高,不难想 ...
- ZOJ - 4082:Little Sub and his Geometry Problem (双指针)
Little Sub loves math very much, and has just come up with an interesting problem when he is working ...
- deque中的细节问题,以及reverse和max_element的使用
deque中使用迭代器进行运算的函数都默认以.end()为结束,而实际上.end()所返回的是最后一个元素的下一个位置,所以进行数据比较时,应对其-1才是对应的最后一个数据,而函数中则是直接使用.en ...
- (17)模型层 -ORM之msql 单表的增、删、改、查 及其他操作
单表操作-增.删.改.查 ret=models.User.objects.filter(id=1) #这里的结果是一个queryset对象 ret=modles.User.Objects.filte ...
- LG4213 【【模板】杜教筛(Sum)】
sum\(\mu\)求法 设 \[S(n)=\sum_{i=1}^n \mu(i)\] 回顾公式 \[\sum_{d|n}\mu(d)=[n=1]\] 对\(n\)求和 \[\sum_{i=1}^n\ ...
- win7启动老是自动进入Boot Menu无法进入系统
如图 进入bios设置 点击startup 选择UEFI/Legacy Boot 那里的Legacy Only选项,选择另一个就会出现这种问题 正常进入系统
- pack 方便的npm 构建工具
一般我们都是使用nodejs 自身的npm 或者yarn进行 npm 包的开发(包括构建),但是随着强类型的开发模式 在实际web 的开发中越来越重要,大家一般都会选择使用typescript 等 ...
- 使用distillery&&docker 部署phoenix 应用
distillery 发布了2.0 了,有好多的新的功能 config prodiver 进行环境变量的配置 appup tansforms 插件系统,方便在release 构建的时候进行修改 m ...
- str的用法
## 字符串的索引切片以及常用的操作方法都是形成新的字符串,和原字符串没有关系 # 切片和索引 # 按照索引取值 #按照切片取值 ,顾头不顾尾, #切片加步长 # 只要倒叙取值就要加上反向步长 ...