三人行必有我师

使用Java rest-high-level-client查询文档时,from+size大于100000,报各种错~

Elasticsearch | 作者 apeletMarshal | 发布于2019年06月11日 | 阅读数:7574

在使用Java rest-high-level-client查询文档时,from+size大于100000,报各种错
1.  java.lang.OutOfMemoryError: GC overhead limit exceeded
20190611203222.png

2. java.lang.OutOfMemoryError: Java heap space
_20190611204617.png

这两个报错基本时一样的,就是说对内存不够用。我查询的结果集整体不到100M。但是我的堆内存设置了256M。为什么不够用呢?
3. java.io.IOException: entity content is too long [142047036] for the configured buffer limit [104857600]
20190611211055.png

 
这个错误是来自java rest-high-level-client 里的http jar包限制了返回结果不能超过100M.
 
我的es使用场景是日志中心。
我想问的是,我这这种返回超大结果集是不合理的设置吗?
还是有其他的解决方案。
 
 
已邀请:

ouyangchucai - Elasticsearch中文社区钉钉群号 : 21737292

赞同来自:

深度翻页问题,建议通过scroll或search_after解决。
Search After 
http://cwiki.apachecn.org/disp ... After
 
Elasticsearch: 权威指南 » 游标查询 Scroll 
https://www.elastic.co/guide/c ... .html

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

1、内存太小了,内存建议:Min(物理机内存,31GB);
2、from+size大于100000, 建议修改:max_result_window窗口值大小。
3、建议看一下官网的建议:
index.max_result_window
The maximum value of from + size for searches to this index. Defaults to 10000.
Search requests take heap memory and time proportional to from + size and this limits that memory.
See Scroll or Search After for a more efficient alternative to raising this.
https://www.elastic.co/guide/e ... .html

ridethewind

赞同来自:

用search_after

apeletMarshal - 小猿帅

赞同来自:

问题回复:
   1. scroll api之前就试过,但是没办法满足要求。客户需要无规则的翻页。scroll在查询大文档的时候,性能仍然不是很好
   2. search_after暂时也不用,综合考虑还是from+size方便
   3. elasticsearch集群每个节点是8核16G的,在高的话,甲方不给。硬件也是没办法。qaq。不过集群是用docker+k8s部署的,方便做横向扩展。这点还可以。目前6-8个es节点
   4. 针对集群,我进行的二次开发,用java rest-high-level-client写了一个符合我们要求的日志查询接口,以及集群监控接口。
说内存溢出业主要是我自己写的这个项目。跟elasticsearch集群本身的内存,没太大关系
 
解决办法:
1. 由于自己写的项目,在返回大量日志时,出现内存溢出情况(要求from+size查询10万条而不是官网建议,这个真没办法)
分页获取日志文档,每次返回5000条,然后在将数据进行拼接,最后返回了数据。
如果有更好办法,欢迎讨论qq:1090646861
 
 
 

要回复问题请先登录注册