需要知道使用 RAMDirectory 的利弊 [英] Need to know pros and cons of using RAMDirectory

查看:32
本文介绍了需要知道使用 RAMDirectory 的利弊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要提高 Lucene 搜索查询的性能.我可以使用 RAMDirectory 吗?它会优化性能吗?是否有任何索引大小限制?如果有人能列出使用 RAMDirectory 的优缺点,我将不胜感激.

I need to improve performance of my Lucene search query. Can I use RAMDirectory?Does it optimize performance?Is there any index size limit for this? I would appreciate if someone could list pros and cons of using a RAMDirectory.

谢谢.

推荐答案

我比较FSDirectory和RAMDirectory.

I compare FSDirectory and RAMDirectory.

  • 索引大小为 1.4G
  • Centos,5G 内存

搜索1000个关键词,平均/最小/最大响应时间(ms)在这里

Search 1000 keywords, the average/min/max response time (ms) is here

  • FS目录
    • 首次运行:351/7/2611
    • 第二轮:47/7/837
    • 第三次运行(重启应用):53/7/2343
    • 首次运行:38/7/1133
    • 第二轮:34/7/189
    • 第三次运行(重启应用):38/7/959

    因此,您可以看到 RAMDirectory 的速度比 FSDirectory 快,但是在os file cache warm up"之后,速度差距并没有那么明显.RMADirectory 的缺点是什么?在我的测试中

    So, you can see RAMDirectory is do faster then FSDirectory, but after 'os file cache warm up', the speed gap is not so distinct. What's the disadvantage of RMADirectory? In my test

    • 它会占用更多内存,1.4G 的文件需要大约 2G 才能将其加载到内存中.而 FSDirectory 仅使用 700m.那么这意味着完整 gc 的时间更长.
    • 它需要更多的时间来加载,尤其是当索引文件很大的时候.打开索引时需要将数据从文件复制到内存.这意味着在重新启动应用程序时,请求将被阻止更长的时间.
    • 同时维护两个索引不太实际.因为我们的应用每隔几个小时就会切换一次索引.我们希望新索引正在预热,而旧索引仍在同一个 tomcat 中工作.

    这篇关于需要知道使用 RAMDirectory 的利弊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆