Elasticsearch运维系列_ES之max_result_window 含义-对性能影响及参数调整

如果你觉得这篇文章能给你带来收获,请关注我公众号:

image.png

这篇文章主要给大家介绍max_result_window参数及其对性能影响。

Part1 背景描述

当前某个业务xxxdb单个索引值较大,每日单个索引大小在二三百G,当前索引保留15天,如果拉取一个15天的范围周期,会查询到几个T的数据量,并且该索引未做副本,这种大查询会导致ES负载较高,严重影响性能。

单日索引大小

检查发现xxx_access_xxx_xxx 索引使用的索引模版xxx_xxx_access_xxx_template 有个参数max_result_window 比较异常,设置值较大。

-- 查询xxx_xxxx_access_xxx_template索引模版信息

GET /_template/xxx_xxx_access_xxx_template
-- 上述命令执行结果如下:
{
  "xxx_xxx_access_xxx_template" : {
    "order" : 8,
    "index_patterns" : [
      "xxx_xxx_access_xxx_*"
    ],
    "settings" : {
      "index" : {
        "lifecycle" : {
          "name" : "5d_cold_15d_delete_policy"
        },
        "refresh_interval" : "30s",
        "number_of_shards" : "10",
        "translog" : {
          "sync_interval" : "60s"
        },
        "merge" : {
          "scheduler" : {
            "max_thread_count" : "1"
          },
          "policy" : {
            "max_merged_segment" : "500m"
          }
        },
        "max_result_window" : "1000000",
        "analysis" : {
          "analyzer" : {
            "comma_analyzer" : {
              "filter" : [
                "lowercase"
              ],
              "char_filter" : [
                "replace_comma"
              ],
              "type" : "custom",
              "tokenizer" : "standard"
            },
            "file_analyzer" : {
              "filter" : [
                "lowercase"
              ],
              "char_filter" : [
                "file_sep"
              ],
              "type" : "custom",
              "tokenizer" : "standard"
            }
          },
          "char_filter" : {
            "file_sep" : {
              "type" : "mapping",
              "mappings" : [
                "/ => ' '",
                ". => ' '"
              ]
            },
            "replace_comma" : {
              "type" : "mapping",
              "mappings" : [
                ". => ' '",
                ", => ' '",
                "# => ' '",
                "$ => ' '",
                "% => ' '",
                "' => ' '",
                "( => ' '",
                ") => ' '",
                "* => ' '",
                "+ => ' '",
                "- => ' '",
                "/ => ' '",
                ": => ' '",
                "; => ' '",
                "< => ' '",
                "= => ' '",
                "> => ' '",
                "? => ' '",
                "@ => ' '",
                "[ => ' '",
                "] => ' '",
                "^ => ' '",
                "{ => ' '",
                "} => ' '",
                "~ => ' '",
                "` => ' '",
                "| => ' '",
                "& => ' '",
                "! => ' '",
                "\" => ' '",
                "_ => ' '"
              ]
            }
          }
        },
        "number_of_replicas" : "0"
      }
    },
    "mappings" : {
      "properties" : {
        "schema" : {
          "type" : "text"
        },
        "netSendTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "checkLengthTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "routeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "type" : {
          "type" : "text"
        },
        "databaseTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "resultSetSize" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "sql" : {
          "analyzer" : "comma_analyzer",
          "type" : "text"
        },
        "minNodeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "dbExeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "host" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "ignore_above" : 256,
              "type" : "keyword"
            }
          }
        },
        "startTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "sqlRows" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "mergeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "sqlStartTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "dataNodeNum" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "funcDbTime" : {
          "ignore_malformed" : true,
          "type" : "integer"
        },
        "dataNode" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "ignore_above" : 256,
              "type" : "keyword"
            }
          }
        },
        "maxReceiveNodeResultsTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "MaxNodeTime" : {
          "ignore_malformed" : true,
          "type" : "integer"
        },
        "allTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "funcRedisTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "selectRowTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "fddbTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "sqlType" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "calcTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "endTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "minReceiveNodeResultsTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "extern1" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "user" : {
          "type" : "text"
        },
        "executeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        }
      }
    },
    "aliases" : { }
  }
}

1 max_result_window 解释

通过上面命令可以看到 max_result_window 值设置过大,当前设置为 1000000 (一百万)。

max_result_window 这个参数是什么意思,是用来做什么的呢?

max_result_window 是 Elasticsearch 中的一个参数,它决定了可以从单个查询中请求的最大结果窗口的大小。换句话说,它控制了可以通过 from 和 size 参数获取的最大文档数量。这对于防止过度内存使用和性能问题非常重要,因为请求大量数据会消耗大量内存并影响集群性能。

示例:

如果有一个索引并希望从该索引中检索文档,可以使用 from 和 size 参数来控制分页:

GET /index_name/_search
{
   "from": 0,
   "size": 100
}

这将返回前 100 个文档。from 参数指定要跳过的文档数,size 参数指定要返回的文档数。



但如果尝试执行如下操作:

GET /index_name/_search
{
    "from": 10000,
    "size": 100
}

在默认配置下,这将返回一个错误,因为 from + size 超过了 max_result_window 的限制。


如果希望更改更大的结果窗口,可以在索引中调整 max_result_window 参数,比如:

PUT /index_name/_settings
{
    "index": {
    "max_result_window": 50000
    }
}

这将 max_result_window 设置为 50,000。

在 Elasticsearch 7.12.1 版本中,max_result_window 的默认值是 10,000。这意味着默认情况下,您可以请求的结果窗口最大为 10,000 个文档。如果尝试请求超过这个限制的结果窗口,Elasticsearch 会返回一个错误。

max_result_window 支持的最大返回数是 2^31-1,也就是2147483647,生产不建议对 max_result_window 设置过大的值,过大的max_result_window值会对ES带来性能问题,可能会因为值设置过大导致ES内存问题和性能下降。

可以通过设置 from 和 size 参数可以进行分页查询。例如:from=num_a, size=num_b,则获取的结果是从第 num_a + 1 条到第 num_a + num_b 条数据。

2 参数调整

根据对上面max_result_window 参数的分析,计划对 max_result_window值进行调整,将其调整为默认大小。

最简单的方法是通过修改索引模版json信息,将该参数从索引模版删除,调整为默认值,执行如下修改命令:

PUT /_template/xxx_xxx_access_xxx_template
{
    "order" : 8,
    "index_patterns" : [
      "xxx_xxx_access_xxx_*"
    ],
    "settings" : {
      "index" : {
        "lifecycle" : {
          "name" : "5d_cold_15d_delete_policy"
        },
        "refresh_interval" : "30s",
        "number_of_shards" : "10",
        "translog" : {
          "sync_interval" : "60s"
        },
        "merge" : {
          "scheduler" : {
            "max_thread_count" : "1"
          },
          "policy" : {
            "max_merged_segment" : "500m"
          }
        },
        "analysis" : {
          "analyzer" : {
            "comma_analyzer" : {
              "filter" : [
                "lowercase"
              ],
              "char_filter" : [
                "replace_comma"
              ],
              "type" : "custom",
              "tokenizer" : "standard"
            },
            "file_analyzer" : {
              "filter" : [
                "lowercase"
              ],
              "char_filter" : [
                "file_sep"
              ],
              "type" : "custom",
              "tokenizer" : "standard"
            }
          },
          "char_filter" : {
            "file_sep" : {
              "type" : "mapping",
              "mappings" : [
                "/ => ' '",
                ". => ' '"
              ]
            },
            "replace_comma" : {
              "type" : "mapping",
              "mappings" : [
                ". => ' '",
                ", => ' '",
                "# => ' '",
                "$ => ' '",
                "% => ' '",
                "' => ' '",
                "( => ' '",
                ") => ' '",
                "* => ' '",
                "+ => ' '",
                "- => ' '",
                "/ => ' '",
                ": => ' '",
                "; => ' '",
                "< => ' '",
                "= => ' '",
                "> => ' '",
                "? => ' '",
                "@ => ' '",
                "[ => ' '",
                "] => ' '",
                "^ => ' '",
                "{ => ' '",
                "} => ' '",
                "~ => ' '",
                "` => ' '",
                "| => ' '",
                "& => ' '",
                "! => ' '",
                "\" => ' '",
                "_ => ' '"
              ]
            }
          }
        },
        "number_of_replicas" : "0"
      }
    },
    "mappings" : {
      "properties" : {
        "schema" : {
          "type" : "text"
        },
        "netSendTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "checkLengthTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "routeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "type" : {
          "type" : "text"
        },
        "databaseTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "resultSetSize" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "sql" : {
          "analyzer" : "comma_analyzer",
          "type" : "text"
        },
        "minNodeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "dbExeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "host" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "ignore_above" : 256,
              "type" : "keyword"
            }
          }
        },
        "startTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "sqlRows" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "mergeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "sqlStartTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "dataNodeNum" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "funcDbTime" : {
          "ignore_malformed" : true,
          "type" : "integer"
        },
        "dataNode" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "ignore_above" : 256,
              "type" : "keyword"
            }
          }
        },
        "maxReceiveNodeResultsTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "MaxNodeTime" : {
          "ignore_malformed" : true,
          "type" : "integer"
        },
        "allTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "funcRedisTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "selectRowTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "fddbTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "sqlType" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "calcTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "endTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "minReceiveNodeResultsTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "extern1" : {
          "ignore_malformed" : true,
          "type" : "long"
        },
        "user" : {
          "type" : "text"
        },
        "executeTime" : {
          "ignore_malformed" : true,
          "type" : "long"
        }
      }
    },
    "aliases" : { }
  }

除了以上方法,还可以通过使用 PUT Template API在操作系统上执行。 今天带大家分享了max_result_window参数含义,后续将会给大家带来更多分享。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/770678.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

初入Node.js必备知识

Node.js因什么而生&#xff0c;作用是干什么&#xff1f; Node.js是一个用c和c打造的一个引擎&#xff0c;他能够读懂JavaScript&#xff0c;并且让JavaScript能够和操作系统打交道的能力 JavaScript 原本只能在浏览器中运行,但随着Web应用程序越来越复杂,仅靠客户端JavaScri…

零基础入门怎么学习老挝语字母表?《老挝语翻译通》App真人发音教学,学习老挝语字母发音和词汇句子!

这段老挝文字翻译成中文是什么意思&#xff1f;有什么好用的老挝语翻译工具推荐吗&#xff1f; 快速翻译&#xff1a;中老语言无缝转换&#xff0c;实时翻译&#xff0c;让沟通更流畅。 学习工具&#xff1a;零基础入门到流利对话&#xff0c;老挝语真人发音&#xff0c;让你的…

MacOS 安装 mtr 网络检测工具

Install sudo brew install mtr sudo chown root $(which mtr) sudo chmod us $(which mtr) sudo chown root $(which mtr-packet) sudo chmod us $(which mtr-packet) Test mtr google.com

Build a Large Language Model (From Scratch)附录E(gpt-4o翻译版)

来源&#xff1a;https://github.com/rasbt/LLMs-from-scratch?tabreadme-ov-file https://www.manning.com/books/build-a-large-language-model-from-scratch

VTK学习日志:基于VTK9.3.0+Visual Studio c++实现DICOM影像MPR多平面重建+V R体绘制4个视图展示功能的实现(二)

前段时间对VTK9.3.0进行了编译&#xff0c;开发了MPRVR实现的demo,显示效果不是很理想&#xff0c;正好趁着周末有时间&#xff0c;再度对之前的程序进行优化和完善&#xff0c;先展示下效果&#xff1a; VTK实现MPRVR四视图 再次讲解下基于VTK的MPRVR实现的简单项目创建过程&a…

Kamailio-命令行指令kamctl与kamcmd

前文也有提到几种指令的用处&#xff0c;与web页面相比&#xff0c;它就是更原始、面向运维的&#xff0c;正常如果有管理页面也需要使用到&#xff1a; kamailio - SIP 服务器脚本kamdbctl - 创建和管理数据库的脚本&#xff0c;比如你使用MySQL作为其存储时就需要使用到这个…

每天五分钟计算机视觉:人体姿势识别

本文重点 人体姿势识别是计算机视觉领域的一个重要研究方向,旨在通过图像或视频数据自动检测并识别出人体的各种姿势和动作。随着深度学习技术的快速发展,基于神经网络的方法在这一领域取得了显著进展。神经网络,特别是卷积神经网络(CNN)和循环神经网络(RNN),因其强大…

安装opencv-python出错,怎么办?

安装opencv-python出错 解决方法&#xff1a; 具体版本号&#xff0c;python3.6对应的就是4.3.0.38 pip install opencv-python4.3.0.38 -i https://pypi.tuna.tsinghua.edu.cn/simple

检测水管缺水的好帮手-管道光电液位传感器

管道光电液位传感器是现代清水管道管理中的重要技术创新&#xff0c;不仅提高了检测液位的精确度&#xff0c;还解决了传统机械式和电容式传感器存在的诸多问题&#xff0c;成为检测管道缺水的可靠利器。 该传感器采用先进的光学感应原理&#xff0c;利用红外光学组件通过精密…

2G 3G 4G常用知识点

名词解释 LTE网络、WCDMA网络、2G、3G 4G 区别及联系? 2G (第二代移动通信技术) 2G是最早的数字移动电话标准&#xff0c;主要支持语音通话和短信服务。代表性技术有GSM (Global System for Mobile Communications) 和CDMA (Code Division Multiple Access)。 3G (第三代移动…

相亲交友APP系统婚恋交友社交软件开发语音视频聊天平台定制开发-婚恋相亲交友软件平台介绍——app小程序开发定制

互联网飞速发展的时代&#xff0c;相亲交友软件成为了许多年轻人首选的相亲方式&#xff0c;越来越多的单身男女希望在婚恋交友软件平台上寻找灵魂伴侣&#xff0c;相亲交友软件因此具有很高的市场价值。 多客婚恋相亲交友系统是一款定位高端&#xff0c;到手就能运营的成熟婚恋…

Java入门编码10个注意点,大家注意“避坑”

插&#xff1a; AI时代&#xff0c;程序员或多或少要了解些人工智能&#xff0c;前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家(前言 – 人工智能教程 ) 坚持不懈&#xff0c;越努力越幸运&#xff0c;大家…

FileZilla的安装和使用(快速上手版)

下载 登陆官网下载下载 - FileZilla中文网 服务端 我们选择一个中文安装最新版本下载 客户端 我们选择绿色免安装版进行下载 安装 安装服务端 双击运行下载好的服务端安装包 点击 我接受 点击 下一步 设置好安装路径&#xff0c;点击 下一步 这里默认即可&#xff0c;点击…

智慧园区可视化:构建全方位智能管理体系

通过图扑的 2D、 3D 和 GIS 可视化技术结合倾斜摄影、数字孪生和视频融合等技术&#xff0c;将园区各类数据集成展示&#xff0c;实时监控和分析环境与设施状况&#xff0c;提升管理效能和安全水平&#xff0c;实现智慧园区的全方位智能化运营。

属性加密技术:保障数据安全的新利器

随着信息技术的飞速发展&#xff0c;数据安全已成为我国乃至全球关注的焦点。在众多数据安全技术中&#xff0c;属性加密技术以其独特的优势&#xff0c;逐渐成为保障数据安全的新利器。本文将从属性加密技术的原理、特点及其应用场景三个方面进行介绍&#xff0c;以期为读者提…

SpringBoot 集成Swagger在线接口文档 接口注解

介绍 Swagger接口文档是一种自动生成、描述、调用和可视化的RESTful风格Web服务接口文档的工具。它通过一系列的规范和自动化工具&#xff0c;极大地简化了后端开发人员与前端开发人员之间的协作。 依赖 <!--swagger--> <dependency><groupId>io.springfo…

高考志愿填报,选热门专业还是选自己喜欢的专业

对于每一个结束高考的学生来说&#xff0c;都要面临选专业这个严峻的挑战。选专业可以说是妥妥的大工程&#xff0c;因为这关系到接下来的几年要学什么内容&#xff0c;关键是未来的几十年要从事什么样的工作。 所以在谈及选专业这个问题的时候&#xff0c;每个人的内心都有些…

加权 KNN 算法的原理与详解

加权kNN&#xff0c;k近邻算法的增强改进版本。 加权KNN算法 近邻算法&#xff08;k-Nearest Neighbors, kNN&#xff09;是一种用于分类和回归的非参数方法。它的基本思想是“看邻居”&#xff0c;即通过查找离目标点最近的 K 个数据点&#xff0c;来判断目标点的类别或数值。…

kimi,让论文写作不再是一场苦旅【下】

学境思源&#xff0c;一键生成论文初稿&#xff1a; AcademicIdeas - 学境思源AI论文写作 今天我们继续昨天的内容&#xff1a;kimi&#xff0c;让论文写作不在是一场苦旅【上】&#xff0c;为大家列举与Kimi互动的示例。 8. 文献综述&#xff1a; 1. 文献搜索策略&#xff1…

育才兴业,助力数字产业蓬勃发展

成都树莓集团通过校企合作、建设人才项目转化中心、推动一线多园战略以及提供全方位服务等举措&#xff0c;积极培养数字产业人才&#xff0c;为行业发展提供了有力支持。 一、校企合作&#xff0c;打造人才培养高地 树莓集团深知企业协同育人的重要性&#xff0c;积极与高校建…