第一 有关内存
修改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花销越大,这将是不稳定因素)node
第二:关于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吧)app
第三:关于SWAP
建议:Swapping is very bad for performance and for node stability, so it should be avoided at all costs.
(swapping 对性能和节点稳定性是至关有影响的,so必定要禁掉它。less
第四:关于查询elasticsearch
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)ide
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是不限制大小的,你能够限制,限制是为了预警,而不是内存不足的解决方案,我理解的意思就是:若是你的数据很大,仍是建议不要用排序)性能