当前位置: 代码网 > it编程>游戏开发>ar > ElasticSearch的一些限制及推荐配置

ElasticSearch的一些限制及推荐配置

2024年08月06日 ar 我要评论
ElasticSearch的一些限制及推荐配置more。

限制

数组字段,数组大小无限制。

there is no hard limit but it’s definitely recommended to keep those arrays “reasonable”. when performing an update, elasticsearch needs to fetch the entire doc, apply the update, then index the updated document and replicate the entire updated document to the replica, so very large arrays would come with a performance penalty indeed.

文档大小限制:2gb

given that the default http.max_content_length is set to 100mb, elasticsearch will refuse to index any document that is larger than that. you might decide to increase that particular setting, but lucene still has a limit of about 2gb.

https://stackoverflow.com/questions/28841221/what-is-the-maximum-elasticsearch-document-size/28841656#28841656

https://www.elastic.co/guide/en/elasticsearch/reference/current/general-recommendations.html

单字段大小限制

未找到资料,感觉整个文档不超就好

推荐配置

模板参考配置

从es 5.x开始,索引级设置需要写在模板中,或者在创建索引时指定,我们把各个索引通用的配置写到了模板中,这个模板匹配全部的索引,并且具有最低的优先级,让用户定义的模板有更高的优先级,以覆盖这个模板中的配置。

{
  "template": "*",
  "order": 0,
  "settings": {
    "index.merge.policy.max_merged_segment": "2gb",
    "index.merge.policy.segments_per_tier": "24",
    "index.number_of_replicas": "1",
    "index.number_of_shards": "24",
    "index.optimize_auto_generated_id": "true",
    "index.refresh_interval": "120s",
    "index.translog.durability": "async",
    "index.translog.flush_threshold_size": "1000mb",
    "index.translog.sync_interval": "120s",
    "index.unassigned.node_left.delayed_timeout": "5d"
  }
}

避免热索引分片不均

默认情况下,es的分片均衡策略是尽量保持各个节点分片数量大致相同。但是当集群扩容时,新加入集群的节点没有分片,此时新创建的
索引分片会集中在新节点上,这导致新节点拥有太多热点数据,该节点可能会面临巨大的写入压力。因此,对于一个索引的全部分片,我们需要控制单个节点上存储的该索引的分片总数,使索引分片在节点上分布得更均匀一些。

例如,10个节点的集群,索引主分片数为5,副本数量为1,那么平均下来每个节点应该有(5×2)/10=1个分片,考虑到节点故障、分片迁
移的情况,可以设置节点分片总数为2:

curl --location --request put 'http://127.0.0.1:9200/myindex/_settings' \
--header 'content-type: application/json' \
--data '{
  "index": {
    "routing.allocation.total_shards_per_node": "2"
  }
}'
(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com