zoukankan      html  css  js  c++  java
  • 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.

     

     

  • 相关阅读:
    50个jQuery 插件可将你的网站带到另外一个高度
    Web 开发中 20 个很有用的 CSS 库
    【算法】1、约瑟夫环
    智造微博
    银河系中央超大黑洞可能是个虫洞 其连接着两个不同的时空。
    创意文案:我害怕阅读的人
    解决Oracle ORA-00984: column not allowed here
    舌尖上的程序员
    技术贴 本地代码与svn关联教程 svn upgrade问题解决
    Aimp3的播放列表 按评分排序 落雨
  • 原文地址:https://www.cnblogs.com/huangfox/p/4347174.html
Copyright © 2011-2022 走看看