第一 有关内存
修改ES_MIN_MEM 和 ES_MAX_MEM 建议:
in general, the more memory allocated to the process, the better(通常,越大越好)
It is recommended to set the min and max memory to the same value, and enable mlockall.(建议设置成相同的值,并且开启mlockall)
No more than 50% of available RAM (不要超过内存的一半)
No more than 32 GB: If the heap is less than 32 GB, the JVM can use compressed pointers, which saves a lot of memory: 4 bytes per pointer instead of 8 bytes.(不要超过32G,因为对于JVM,小于32G的时候会使用压缩指针,这个会节省很大内存)
Increasing the heap from 32 GB to 34 GB would mean that you have much less memory available, because all pointers are taking double the space. Also, with bigger heaps, garbage collection becomes more costly and can result in node instability.(从32G到34G,意味着你失去了更多的可用内存,因为所有的内存指针都变成了double,而且heap越大,GC花销越大,这将是不稳定因素)
第二:关于GC
建议 Don’t Touch These Settings!(不要触碰这些设置)
We would like to recommend G1GC someday, but for now, it is simply not stable enough to meet the demands of Elasticsearch and Lucene.(我们很期待以后某一天推荐G1 GC,但是对于现在,它对于elasticsearch和lucene来说不能足够稳定(你还是老实用CMS GC吧)
第三:关于SWAP
建议:Swapping is very bad for performance and for node stability, so it should be avoided at all costs.
(swapping 对性能和节点稳定性是相当有影响的,so一定要禁掉它。
第四:关于查询
It may surprise you to find that Elasticsearch does not load into fielddata just the values for the documents that match your query. It loads the values for all documents in your index, even documents with a different _type!
(elasticsearch并不是只把满足你查询条件的文档加载到内存,而是加载整个index的所有数据到内存,甚至是不同的_type,你可能很吃惊,事实就是这样)
To make sorting efficient, Elasticsearch loads all the values for the field that you want to sort on into memory. This is referred to as fielddata.(为了排序,elasticsearch会把这个字段的所有的值都加载到内存里,也就是所谓的fielddata)
indices.fielddata.cache.size: 40%
this setting is a safeguard, not a solution for insufficient memory.
If you don’t have enough memory to keep your fielddata resident in memory, Elasticsearch will constantly have to reload data from disk, and evict other data to make space. Evictions cause heavy disk I/O and generate a large amount of garbage in memory, which must be garbage collected later on.
(一大堆说明,意思就是fielddata的加载是很昂贵的,默认对fielddata是不限制大小的,你可以限制,限制是为了预警,而不是内存不足的解决方案,我理解的意思就是:如果你的数据很大,还是建议不要用排序)。
除非注明,赵岩的博客文章均为原创,转载请以链接形式标明本文地址
本文地址:https://zhaoyanblog.com/archives/735.html