caching - 提交时防止 solr 缓存刷新

标签 caching search solr

我的应用程序的写入吞吐量较低,我可以在 2-3 分钟内完成更改以反射(reflect)在 solr 搜索结果中。
目前,我通过索引应用程序进行提交(在每批文档之后),并且还在 solr 端配置了以下内容:

solr.autoSoftCommit.maxTime : -1 (disabling auto soft commit)
solr.autoCommit.maxTime : 300000 (5 mins of hard auto commit interval)
opensearcher : false

选择该配置的原因来自于我对以下方面的理解:

  1. 我的应用程序被大量读取,需要大量缓存,而我无法承担刷新缓存的费用。因此,我完全禁用了软提交。
  2. 我已经再次禁用了 opensearcher,如果我不这样做,它将使顶级缓存失效,这是不可取的

在生产中,我观察到,只要我的应用程序尝试索引 1 个文档(或一批),然后(从我的应用程序)发出提交语句,我的所有顶级缓存都会被删除。
我想也许仅仅依靠硬自动提交会有帮助,但根据这个 stack overflow link

Hard commits are about durability, soft commits are about visibility. There are really two flavors here, openSearcher=true and openSearcher=false. First we’ll talk about what happens in both cases. If openSearcher=true or openSearcher=false, the following consequences are most important:

The tlog is truncated: A new tlog is started. Old tlogs will be deleted if there are more than 100 documents in newer, closed tlogs. The current index segment is closed and flushed. Background segment merges may be initiated. The above happens on all hard commits. That leaves the openSearcher setting

openSearcher=true: The Solr/Lucene searchers are re-opened and all caches are invalidated. Autowarming is done etc. This used to be the only way you could see newly-added documents.

openSearcher=false: Nothing further happens other than the four points above. To search the docs, a soft commit is necessary.

总而言之,软提交将刷新缓存,opensearcher=true 的自动硬提交也会刷新缓存。虽然使用 opensearcher=false 进行自动硬提交将不允许反射(reflect)我添加的更改。

如果我有任何误解,请指出。

现在这是我的问题:

  1. 是否没有办法确保当某些文档添加到索引并同时具有可用更改时,顶级过滤器缓存不会被删除?
  2. 如果是这样的话,那么我是否需要始终依赖缓存预热来获取缓存中的某些文档?
  3. 除了人们通常做的热身之外,还有其他方法可以避免这种情况吗?他们是否想要构建快速可搜索的产品并具有一定的写入吞吐量?

我已经阅读了一些文档链接和文章,但我找不到任何合适的文章来解释在不同场景中使用哪些设置。如果有人可以解释我做错了什么并指导我找到正确的解决方案,那将非常有帮助。

最佳答案

你的理解是对的。

Solr caches are associated with a specific instance of an Index Searcher, a specific view of an index that doesn’t change during the lifetime of that searcher. As long as that Index Searcher is being used, any items in its cache will be valid and available for reuse.

When a new searcher is opened, the current searcher continues servicing requests while the new one auto-warms its cache. The new searcher uses the current searcher’s cache to pre-populate its own. When the new searcher is ready, it is registered as the current searcher and begins handling all new search requests. The old searcher will be closed once it has finished servicing all its requests.

  1. 如果您需要让搜索者访问新添加的文档,您 需要打开一个新的搜索器。这可以通过使用软来完成 使用 openSearcher=true 提交或硬提交。缺点是 您的顶级缓存将失效。这就是你的价格 为获得曝光度而付费。

  2. 是的,预热是之前填充缓存的最佳方法 打开一个新的搜索器。你应该确定哪些是最重要的 系统中常用的查询,并让这些查询自动预热新的 缓存。

  3. 如果您不想要实时搜索并且可以容忍这一点,您应该关闭软提交并使用 opensearcher=true 的硬提交。硬提交的间隔取决于您的应用程序可以容忍的延迟时间。如果您不关心在 t=t1 建立索引的文档会在 t=t1+x 分钟之前出现。您应该每 x 分钟提交一次。

每个选项都有一个缺点。您需要弄清楚什么最适合您。

天下没有免费的午餐。

关于caching - 提交时防止 solr 缓存刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49993681/

相关文章:

search - 如何在 Solr Dismax 查询中正确提升结果

solr - 如何可扩展地实现诸如 Google 警报之类的功能?

Python函数缓存?

performance - 是否可以使用 CompUnit 模块收集数据?

c - 如何使用 C 测量 L1、L2 和 L3 缓存延迟?

java - 当用户开始输入时滚动/​​搜索 JList

php - 如何创建一个搜索功能来搜索 mysql 数据库中的表

android - 在 Android 中缓存对象?

java - 在 Java 中搜索大型 csv 的最佳/有效方法

maven - SolrJ 与 Maven