【问题标题】:What's the difference: ConcurrentUpdateSolrServer vs HttpSolrServer vs CommonsHttpSolrServer?有什么区别:ConcurrentUpdateSolrServer vs HttpSolrServer vs CommonsHttpSolrServer?
【发布时间】:2014-07-01 14:11:19
【问题描述】:

SolrServer的以下实现有什么区别:

  1. ConcurrentUpdateSolrServer
  2. HttpSolrServer
  3. CommonsHttpSolrServer(注意:现在是否已弃用?)

documentation中提到的:

仅建议将 ConcurrentUpdateSolrServer 与 /update 请求一起使用。 HttpSolrServer 类更适合查询接口。

ConcurrentUpdateSolrServer 的文档建议使用它进行更新,使用 HttpSolrServer 进行查询。为什么是这样?

目前我使用HttpSolrServer 进行所有操作,使用ConcurrentUpdateSolrServer 进行更新会显着提高性能吗?

【问题讨论】:

    标签: java solr lucene solrj information-retrieval


    【解决方案1】:

    我们目前是 2017 年,Solr 社区将 SolrServer 重命名为 SolrClient,目前我们有 4 个实现:

    1. CloudSolrClient
    2. ConcurrentUpdateSolrClient
    3. HttpSolrClient
    4. LBHttpSolrClient

    文档建议使用ConcurrentUpdateSolrClient,因为它将所有更新请求缓冲到final BlockingQueue<Update> queue;,因此更新的操作时间将少于使用HttpSolrClient,它的行为是这样的 - 一旦它收到更新请求就立即开火。当然,我们相信文档,但很容易得到这个答案,这就是我进行性能测试的原因。

    但是,首先我将描述客户端的不同操作。如果你使用 SolrClient 的add 操作,创建HttpSolrClientConcurrentUpdateSolrClient 没有区别,因为这两种方法都会做同样的事情。 ConcurrentUpdateSolrClient 仅在您明确执行 UpdateRequest 时才会发光

    索引维基百科标题的测试结果 (code): 我的机器是:Intel i5-4670S 3.1 Ghz 16 Gb RAM

    ConcurrentUpdateSolrClient (5 threads, 1000 queue size) - 200 seconds    
    ConcurrentUpdateSolrClient (5 threads, 10000 queue size) - 150 seconds    
    ConcurrentUpdateSolrClient (10 threads, 1000 queue size) - 100 seconds    
    ConcurrentUpdateSolrClient (10 threads, 10000 queue size) - 30 seconds    
    HttpSolrClient (no bulk) - 7000 seconds    
    HttpSolrClient (bulk 1000 docs) - 150 seconds    
    HttpSolrClient (bulk 10000 docs) - 80 seconds
    

    总结:

    1. 如果您以类似的方式使用客户端,例如:client.add(doc);ConcurrentUpdateSolrClient 的执行速度至少快 10-20 倍,因为使用了 ThreadPool 和 Queue(又名 Bulk 操作)

    2. 如果您使用HttpSolrClient,您仍然可以通过手动创建多个客户端、运行其他线程和使用一些中间存储(如 List)来模仿这种行为。它肯定会提高性能,但需要额外的代码。

    3. 数字很可能没有什么意义,但我希望它能提供一些原始的比较。

    【讨论】:

      猜你喜欢
      • 2011-05-23
      • 2012-05-21
      • 2022-08-17
      • 2021-07-16
      • 2013-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多