Elasticsearch的索引速度慢

时间:2015-11-27 07:16:33

标签: performance indexing elasticsearch lucene

我们在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%
  4. 要求:所以我无法理解为什么它如此缓慢,而所有资源都是如此自由, 我该怎样做才能提高效率? 谢谢。

    以下是我们使用的配置文件:

    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]+)?/
    

    这是运行作业时的htop和iostat: htop

    iostat

1 个答案:

答案 0 :(得分:10)

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

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

  1. 制作一些主节点,与数据节点分开,因为它会减少所有群集的负载。
  2. 禁用操作系统交换,ES负责处理并检查所有计算机上的堆大小Heap Sizing
  3. 检查您的文档总是大小相似,您可以使用批量索引并在那里调整设置,例如chunk_size的记录数或内存大小
  4. 如果您正在使用脚本尝试优化它,因为它们使索引变慢,您可以将脚本值存储为可能的预处理,因为ES不是为处理脚本而设计的。
  5. 检查每个节点的分片数,并尝试使用路由
  6. 在节点之间平衡分片数
  7. 详细了解ES人员如何建议生产就绪系统工作Elasticsearch in Production
  8. 关于提高Elasticsearch Indexing性能的另一篇博客Performance Considerations for Elasticsearch Indexing
  9. 检查此答案,了解在三台服务器上设置ELK Stack的最佳方法。 Optimal way to set up ELK stack on three servers

相关问题