Elasticsearch的索引速度慢

Pei*_*ong 15 lucene indexing performance elasticsearch

我们在3个EC2 c4.4xlarge(16个内核,32GB内存)节点上部署了ES 2.0,为ES分配了16G,在每个上分配了500GB和io1/4000 IOPS.

问题:我们期望从这个硬件配置中获得很好的性能,但是观察到非常慢的索引速度.

我们的文档大小约为10-50k,我们使用Java传输客户端进行插入.前50000的速度大约为1000 /秒,并且速度急剧下降到100-200 /秒.

与此同时,我们正在考虑资源消耗低:

  1. CPU仅约1-20%(16核CPU)
  2. IO写入仅约4-10Mb /秒
  3. 内存消耗仅约20-30%

要求:所以我无法理解为什么它如此缓慢而所有资源都是如此自由,我能做些什么来提高效率?谢谢.

这是我们使用的配置文件:

cluster.name: {{ env }}-{{ app }}
path.data: /data/es
path.logs: /data/es-logs
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["xxxx"]
bootstrap.mlockall: true
threadpool.search.queue_size: 300
threadpool.index.type: fixed
threadpool.index.size: 16
threadpool.index.queue_size: 250000
index.refresh_interval: 1s
index.translog.flush_threshold_ops: 50000
indices.memory.index_buffer_size: 30%
indices.memory.min_shard_index_buffer_size: 12mb
indices.memory.min_index_buffer_size: 96mb
script.inline: on
script.indexed: on
http.cors.enabled: true
http.cors.allow-origin: /https?:\/\/localhost(:[0-9]+)?/
Run Code Online (Sandbox Code Playgroud)

运行这个工作时,这是htop和iostat: HTOP

iostat的

Sum*_*mar 10

将ES升级到最新版本,因为在最近的版本中,它们使其更加生产友好,现在最稳定的版本是最新版本2.3

您可以尝试以下方法使索引更快:

  1. 创建一些主节点,与数据节点分开,因为它将减少所有群集的负载.
  2. 禁用操作系统交换,ES负责处理并检查所有计算机上的堆大小堆大小
  3. 检查您的文档总是大小相似,您可以使用批量索引并在那里调整设置,如chunk_size记录数或内存大小
  4. 如果您正在使用脚本尝试优化它,因为它们使索引变慢,您可以将脚本值存储(如果可能)作为预处理,因为ES不是为处理脚本而设计的.
  5. 检查每个节点的分片数,并尝试使用路由在节点之间平衡分片数
  6. 阅读更多关于ES人员如何建议生产就绪系统在生产中使用Elasticsearch的更多信息
  7. 另一篇关于增加Elasticsearch索引性能的博客有关Elasticsearch Indexing的性能注意事项

检查此答案以获得在三台服务器上设置ELK Stack的最佳方法.在三台服务器上设置ELK堆栈的最佳方法