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

查看:103
本文介绍了需要了解使用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内存
  • index size is 1.4G
  • Centos, 5G memory

搜索1000个关键字,平均/最小/最大响应时间(ms)在此处

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

  • FSDirectory
    • 首次运行:351/7/2611
    • 第二次跑步:47/7/837
    • 第三次运行(重新启动应用):53/7/2343
    • FSDirectory
      • first run: 351/7/2611
      • second run: 47/7/837
      • third run(restart app): 53/7/2343
      • 首次运行:38/7/1133
      • 第二次比赛:34/7/189
      • 第三次运行(重新启动应用):38/7/959

      因此,您可以看到RAMDirectory比FSDirectory做得更快,但是在操作系统文件缓存预热"之后,速度差距并不明显. 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天全站免登陆