CN115391048A - Micro-service instance dynamic horizontal expansion and contraction method and system based on trend prediction - Google Patents
Micro-service instance dynamic horizontal expansion and contraction method and system based on trend prediction Download PDFInfo
- Publication number
- CN115391048A CN115391048A CN202211144029.8A CN202211144029A CN115391048A CN 115391048 A CN115391048 A CN 115391048A CN 202211144029 A CN202211144029 A CN 202211144029A CN 115391048 A CN115391048 A CN 115391048A
- Authority
- CN
- China
- Prior art keywords
- load
- micro
- trend
- trend prediction
- contraction
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/505—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
本公开提供了一种基于趋势预测的微服务实例动态水平扩展收缩方法及系统,其属于云计算技术领域,所述方案包括:基于Exporter进程周期性的获取云平台内宿主机和微服务实例的负载指标;其中,所述Exporter进程为存在于宿主机和微服务实例中的指标收集进程,并对外提供指标数据接口;将获得的负载指标按照时序存储于时序数据库中;基于所述时序数据库中的负载指标,利用预先构建的负载趋势预测模型获得相应服务的负载趋势;基于获得的负载趋势,实现微服务实例的扩展或收缩。
The disclosure provides a method and system for dynamic horizontal expansion and contraction of microservice instances based on trend prediction, which belongs to the field of cloud computing technology. The solution includes: periodically obtaining the load of the host machine and microservice instances in the cloud platform based on the Exporter process indicator; wherein, the Exporter process is an indicator collection process existing in the host machine and the microservice instance, and provides an indicator data interface to the outside; the obtained load indicator is stored in the time series database according to time series; based on the time series database Load indicators, use the pre-built load trend prediction model to obtain the load trend of the corresponding service; based on the obtained load trend, realize the expansion or contraction of the microservice instance.
Description
技术领域technical field
本公开属于云计算技术领域,尤其涉及一种基于趋势预测的微服务实例动态水平扩展收缩方法及系统。The disclosure belongs to the technical field of cloud computing, and in particular relates to a method and system for dynamic horizontal expansion and contraction of microservice instances based on trend prediction.
背景技术Background technique
本部分的陈述仅仅是提供了与本公开相关的背景技术信息,不必然构成在先技术。The statements in this section merely provide background information related to the present disclosure and do not necessarily constitute prior art.
随着云计算的快速发展,在云平台中基于微服务架构开发部署业务系统逐渐成为潮流。微服务架构将传统的单体应用拆分为独立的子系统,降低了功能模块之间的耦合度。容器技术将微服务及其依赖环境打包为镜像,通过镜像仓库共享镜像并下载运行,减少了微服务的成本,提高了开发部署的灵活性。随着微服务架构中的容器数量不断增加,以Kubernetes(k8s)最为代表的容器云平台应运而生,云平台可以在集群中对容器进行调度和管理,其中平台级项目必备的一个编排能力就是实现微服务实例的“水平扩展/收缩”(即根据负载的真实水平调整微服务实例的数量),可以随着业务系统的真实负载,增加或者删除微服务实例的个数,在保证服务质量的同时,实现了资源的按需分配。With the rapid development of cloud computing, it has gradually become a trend to develop and deploy business systems based on the microservice architecture in the cloud platform. The microservice architecture splits traditional monolithic applications into independent subsystems, reducing the degree of coupling between functional modules. Container technology packages microservices and their dependent environments into mirrors, and shares and downloads and runs the mirrors through mirror warehouses, which reduces the cost of microservices and improves the flexibility of development and deployment. As the number of containers in the microservice architecture continues to increase, the container cloud platform represented by Kubernetes (k8s) has emerged as the times require. The cloud platform can schedule and manage containers in the cluster, and an orchestration capability is necessary for platform-level projects. It is to realize the "horizontal expansion/contraction" of microservice instances (that is, to adjust the number of microservice instances according to the real load level), and to increase or delete the number of microservice instances according to the real load of the business system, while ensuring service quality At the same time, the allocation of resources on demand is realized.
发明人发现,现有的实现微服务实例“水平扩展/收缩”最基本的手段就是运维人员根据业务系统对未来进行合理规划,手动设定实例数量,采用这种人工预测的方式,会因为运维人员能力存在差异和业务系统复杂程度的不同,导致结果往往不尽如人意;除了这种人工预测方法外,也可以通过设定特定资源阈值的方式实现响应式伸缩,比如对微服务实例的CPU使用率设定阈值,当超过这个阈值时,就自动增加实例数量,来增加整体的服务负载能力,但是此类方式的调度存在滞后性,只有当阈值达到时动态伸缩才会发生,导致增加服务响应时间,浪费系统资源等问题。The inventors found that the most basic way to achieve "horizontal expansion/shrinkage" of microservice instances is that the operation and maintenance personnel make reasonable plans for the future according to the business system and manually set the number of instances. There are differences in the capabilities of operation and maintenance personnel and the complexity of business systems, resulting in unsatisfactory results; in addition to this manual prediction method, responsive scaling can also be achieved by setting specific resource thresholds, such as for microservice instances The CPU usage sets a threshold. When the threshold is exceeded, the number of instances is automatically increased to increase the overall service load capacity. However, there is a lag in scheduling in this way. Dynamic scaling will only occur when the threshold is reached, resulting in Increase service response time, waste system resources and other issues.
发明内容Contents of the invention
本公开为了解决上述问题,提供了一种基于趋势预测的微服务实例动态水平扩展收缩方法及系统,所述方案通过采集特定的负载指标,使用指标预测出负载的趋势特征,在负载高峰低谷到来前提前实现微服务实例的水平扩展/收缩,具有更好的前瞻性和灵活度;同时,所述方案在保证微服务服务质量的同时,可以更加高效的利用系统资源。In order to solve the above problems, the present disclosure provides a method and system for dynamic horizontal expansion and contraction of microservice instances based on trend prediction. The solution collects specific load indicators and uses the indicators to predict the trend characteristics of the load. The horizontal expansion/contraction of microservice instances is realized in advance, which has better foresight and flexibility; at the same time, the scheme can make more efficient use of system resources while ensuring the service quality of microservices.
根据本公开实施例的第一个方面,提供了一种基于趋势预测的微服务实例动态水平扩展收缩方法,包括:According to the first aspect of the embodiments of the present disclosure, a method for dynamic horizontal expansion and contraction of microservice instances based on trend prediction is provided, including:
基于Exporter进程周期性的获取云平台内宿主机和微服务实例的负载指标;其中,所述Exporter进程为存在于宿主机和微服务实例中的指标收集进程,并对外提供指标数据接口;Based on the Exporter process, periodically obtain the load indicators of the host computer and the microservice instance in the cloud platform; wherein, the Exporter process is an indicator collection process existing in the host computer and the microservice instance, and provides an indicator data interface externally;
将获得的负载指标按照时序存储于时序数据库中;Store the obtained load indicators in the time series database according to the time series;
基于所述时序数据库中的负载指标,利用预先构建的负载趋势预测模型获得相应服务的负载趋势;Based on the load indicators in the time series database, using a pre-built load trend prediction model to obtain the load trend of the corresponding service;
基于获得的负载趋势,实现微服务实例的扩展或收缩。Based on the obtained load trend, the expansion or contraction of the microservice instance is realized.
进一步的,所述负载指标包括宿主机的硬件指标、微服务实例所在容器的负载使用率以及体现服务相应能力的应用层负载指标。Further, the load index includes the hardware index of the host machine, the load utilization rate of the container where the microservice instance is located, and the application layer load index reflecting the corresponding capability of the service.
进一步的,所述宿主机的硬件指标及微服务实例所在容器的负载使用率,具体包括CPU使用率、内存使用率以及网络IO;所述体现服务相应能力的应用层负载指标包括每秒查询数以及响应时间。Further, the hardware index of the host machine and the load utilization rate of the container where the microservice instance is located specifically include CPU utilization rate, memory utilization rate and network IO; the application layer load index reflecting the corresponding capability of the service includes the number of queries per second and response time.
进一步的,所述Exporter进程为一个与相关微服务一起部署的API服务,对内收集负载指标,对外向指标监控组件提供查询接口。Further, the Exporter process is an API service deployed together with related microservices, collects load indicators internally, and provides query interfaces for external indicator monitoring components.
进一步的,所述负载趋势预测模型采用多个时间序列预测算法组成的混合模型,具体由Holt-Winters、ARIMA以及STL模型组成。Further, the load trend prediction model adopts a hybrid model composed of multiple time series prediction algorithms, specifically consisting of Holt-Winters, ARIMA and STL models.
进一步的,所述负载趋势预测模型的训练,具体为:Further, the training of the load trend prediction model is specifically:
基于预先获得的历史负载指标数据构建训练集;Build a training set based on pre-acquired historical load indicator data;
基于所述训练集分别对若干时间序列预测模型进行训练;Training several time series prediction models respectively based on the training set;
基于SMAPE算法对若干时间序列预测模型的训练结果进行评价,从中选择最优的模型作为最终的负载趋势预测模型。Based on the SMAPE algorithm, the training results of several time series forecasting models are evaluated, and the optimal model is selected as the final load trend forecasting model.
根据本公开实施例的第二个方面,提供了一种基于趋势预测的微服务实例动态水平扩展收缩系统,包括:According to the second aspect of the embodiments of the present disclosure, a system for dynamic horizontal expansion and contraction of microservice instances based on trend prediction is provided, including:
数据获取单元,其用于基于Exporter进程周期性的获取云平台内宿主机和微服务实例的负载指标;其中,所述Exporter进程为存在于宿主机和微服务实例中的指标收集进程,并对外提供指标数据接口;A data acquisition unit, which is used to periodically acquire the load indicators of the host computer and the microservice instance in the cloud platform based on the Exporter process; wherein, the Exporter process is an indicator collection process existing in the host computer and the microservice instance, and provides external Indicator data interface;
数据存储单元,其用于将获得的负载指标按照时序存储于时序数据库中;A data storage unit, which is used to store the obtained load index in a time series database according to time series;
负载趋势预测单元,其用于基于所述时序数据库中的负载指标,利用预先构建的负载趋势预测模型获得相应服务的负载趋势;A load trend prediction unit, which is used to obtain the load trend of the corresponding service based on the load index in the time series database by using a pre-built load trend prediction model;
微服务实例扩展或收缩控制单元,其用于基于获得的负载趋势,实现微服务实例的扩展或收缩。The microservice instance expansion or contraction control unit is used for realizing the expansion or contraction of the microservice instance based on the obtained load trend.
根据本公开实施例的第三个方面,提供了一种电子设备,包括存储器、处理器及存储在存储器上运行的计算机程序,所述处理器执行所述程序时实现所述的一种基于趋势预测的微服务实例动态水平扩展收缩方法。According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including a memory, a processor, and a computer program stored on the memory, and the processor implements the trend-based Predictive method for dynamic horizontal scaling of microservice instances.
根据本公开实施例的第四个方面,提供了一种非暂态计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现所述的一种基于趋势预测的微服务实例动态水平扩展收缩方法。According to a fourth aspect of the embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the aforementioned microservice based on trend prediction is implemented. Instance dynamic horizontal scaling method.
与现有技术相比,本公开的有益效果是:Compared with the prior art, the beneficial effects of the present disclosure are:
(1)本公开提供了一种基于趋势预测的微服务实例动态水平扩展收缩方法及系统,所述方案通过采集特定的负载指标,使用指标预测出负载的趋势特征,在负载高峰低谷到来前提前实现微服务实例的水平扩展/收缩,具有更好的前瞻性和灵活度;同时,所述方案在保证微服务服务质量的同时,可以更加高效的利用系统资源。(1) This disclosure provides a method and system for dynamic horizontal expansion and contraction of microservice instances based on trend prediction. The solution collects specific load indicators and uses the indicators to predict the trend characteristics of the load. Realizing the horizontal expansion/contraction of microservice instances has better foresight and flexibility; at the same time, the solution can utilize system resources more efficiently while ensuring the service quality of microservices.
(2)本公开所述方案在通过指标数据进行趋势预测的过程中,通过结合Holt-Winters、ARIMA和STL三种算法,并对训练过程进行合理优化,得到一个最优的预测模型;上述所选择的这三种算法在使用场景和优缺点上实现了相互补充,各自拟合出的预测数据会进一步的进行相关校验,保证预测的尽可能准确。(2) In the process of trend prediction through index data, the solution described in this disclosure combines the three algorithms of Holt-Winters, ARIMA and STL, and rationally optimizes the training process to obtain an optimal prediction model; the above-mentioned The three selected algorithms complement each other in terms of use scenarios and advantages and disadvantages. The predicted data fitted by each will be further checked to ensure that the prediction is as accurate as possible.
本公开附加方面的优点将在下面的描述中部分给出,部分将从下面的描述中变得明显,或通过本公开的实践了解到。Advantages of additional aspects of the disclosure will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the disclosure.
附图说明Description of drawings
构成本公开的一部分的说明书附图用来提供对本公开的进一步理解,本公开的示意性实施例及其说明用于解释本公开,并不构成对本公开的不当限定。The accompanying drawings constituting a part of the present disclosure are used to provide a further understanding of the present disclosure, and the exemplary embodiments and descriptions of the present disclosure are used to explain the present disclosure, and do not constitute improper limitations to the present disclosure.
图1为本公开实施例中所述的基于趋势预测的微服务实例动态水平扩展收缩方法流程示意图;FIG. 1 is a schematic flowchart of a method for dynamic horizontal expansion and contraction of a microservice instance based on trend prediction described in an embodiment of the present disclosure;
图2为本公开实施例中所述的指标收集流程图;FIG. 2 is a flow chart of indicator collection described in an embodiment of the present disclosure;
图3为本公开实施例中所述的预测模型训练过程示意图。FIG. 3 is a schematic diagram of a prediction model training process described in an embodiment of the present disclosure.
具体实施方式Detailed ways
下面结合附图与实施例对本公开做进一步说明。The present disclosure will be further described below in conjunction with the accompanying drawings and embodiments.
应该指出,以下详细说明都是例示性的,旨在对本公开提供进一步的说明。除非另有指明,本文使用的所有技术和科学术语具有与本公开所属技术领域的普通技术人员通常理解的相同含义。It should be noted that the following detailed description is exemplary and intended to provide further explanation of the present disclosure. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure belongs.
需要注意的是,这里所使用的术语仅是为了描述具体实施方式,而非意图限制根据本公开的示例性实施方式。如在这里所使用的,除非上下文另外明确指出,否则单数形式也意图包括复数形式,此外,还应当理解的是,当在本说明书中使用术语“包含”和/或“包括”时,其指明存在特征、步骤、操作、器件、组件和/或它们的组合。It should be noted that the terminology used herein is only for describing specific embodiments, and is not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly dictates otherwise, the singular is intended to include the plural, and it should also be understood that when the terms "comprising" and/or "comprising" are used in this specification, they mean There are features, steps, operations, means, components and/or combinations thereof.
在不冲突的情况下,本公开中的实施例及实施例中的特征可以相互组合。In the case of no conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other.
实施例一:Embodiment one:
本实施例的目的是提供一种基于趋势预测的微服务实例动态水平扩展收缩方法。The purpose of this embodiment is to provide a method for dynamic horizontal expansion and contraction of microservice instances based on trend prediction.
一种基于趋势预测的微服务实例动态水平扩展收缩方法,包括:A method for dynamic horizontal expansion and contraction of microservice instances based on trend prediction, including:
基于Exporter进程周期性的获取云平台内宿主机和微服务实例的负载指标;其中,所述Exporter进程为存在于宿主机和微服务实例中的指标收集进程,并对外提供指标数据接口;Based on the Exporter process, periodically obtain the load indicators of the host computer and the microservice instance in the cloud platform; wherein, the Exporter process is an indicator collection process existing in the host computer and the microservice instance, and provides an indicator data interface externally;
将获得的负载指标按照时序存储于时序数据库中;Store the obtained load indicators in the time series database according to the time series;
基于所述时序数据库中的负载指标,利用预先构建的负载趋势预测模型获得相应服务的负载趋势;Based on the load indicators in the time series database, using a pre-built load trend prediction model to obtain the load trend of the corresponding service;
基于获得的负载趋势,实现微服务实例的扩展或收缩。Based on the obtained load trend, the expansion or contraction of the microservice instance is realized.
进一步的,所述负载指标包括宿主机的硬件指标、微服务实例所在容器的负载使用率以及体现服务相应能力的应用层负载指标。Further, the load index includes the hardware index of the host machine, the load utilization rate of the container where the microservice instance is located, and the application layer load index reflecting the corresponding capability of the service.
进一步的,所述宿主机的硬件指标及微服务实例所在容器的负载使用率,具体包括CPU使用率、内存使用率以及网络IO;所述体现服务相应能力的应用层负载指标包括每秒查询数以及响应时间。Further, the hardware index of the host machine and the load utilization rate of the container where the microservice instance is located specifically include CPU utilization rate, memory utilization rate and network IO; the application layer load index reflecting the corresponding capability of the service includes the number of queries per second and response time.
进一步的,所述Exporter进程为一个与相关微服务一起部署的API服务,对内收集负载指标,对外向指标监控组件提供查询接口。Further, the Exporter process is an API service deployed together with related microservices, collects load indicators internally, and provides query interfaces for external indicator monitoring components.
进一步的,所述负载趋势预测模型采用多个时间序列预测算法组成的混合模型,具体由Holt-Winters、ARIMA以及STL模型组成。Further, the load trend prediction model adopts a hybrid model composed of multiple time series prediction algorithms, specifically consisting of Holt-Winters, ARIMA and STL models.
进一步的,所述负载趋势预测模型的训练,具体为:Further, the training of the load trend prediction model is specifically:
基于预先获得的历史负载指标数据构建训练集;Build a training set based on pre-acquired historical load indicator data;
基于所述训练集分别对若干时间序列预测模型进行训练;Training several time series prediction models respectively based on the training set;
基于SMAPE算法对若干时间序列预测模型的训练结果进行评价,从中选择最优的模型作为最终的负载趋势预测模型。Based on the SMAPE algorithm, the training results of several time series forecasting models are evaluated, and the optimal model is selected as the final load trend forecasting model.
具体的,为了便于理解,以下结合附图对本实施例所述方案进行详细说明:Specifically, for ease of understanding, the scheme described in this embodiment will be described in detail below in conjunction with the accompanying drawings:
基于现有技术存在的问题,本实施例提供了一种基于趋势预测的微服务实例动态水平扩展收缩方法,如图1所示为基于趋势预测的自动水平扩展/收缩的微服务架构的整体概览图,与普通的微服务部署相比,区别在于增加了一个负载趋势预测模块,而这个模块基于的数据来自于指标收集模块收集到的存在于时序数据库中的指标数据。而指标收集模块通过服务发现模块获得具体微服务实例的访问路径。负载趋势预测模块预测到特定趋势后,就会通过实例控制器动态实现微服务实例的水平扩展/收缩。基于此可以发现,本实施例所述方案的关键点有两个,一是需要定义如何收集可以影响到实例扩展/收缩的负载指标,二是采用怎样的算法来训练出最佳的预测模型。Based on the problems existing in the prior art, this embodiment provides a method for dynamic horizontal expansion and contraction of microservice instances based on trend prediction, as shown in Figure 1, which is an overall overview of the microservice architecture based on automatic horizontal expansion/shrinkage based on trend prediction Figure, compared with ordinary microservice deployment, the difference is that a load trend prediction module is added, and the data based on this module comes from the indicator data collected by the indicator collection module and exists in the time series database. The indicator collection module obtains the access path of the specific microservice instance through the service discovery module. After the load trend prediction module predicts a specific trend, it will dynamically realize the horizontal expansion/contraction of the microservice instance through the instance controller. Based on this, it can be found that there are two key points in the solution described in this embodiment. One is to define how to collect load indicators that can affect instance expansion/shrinkage, and the other is to use an algorithm to train the best prediction model.
首先,如附图2所示,为指标收集流程图,其中的Exporter是存在于宿主机和微服务实例中的指标收集进程,这些Exporter进程向内收集所在宿主机和微服务实例的负载指标,向外提供API接口暴露指标数据,供指标收集模块采集,指标收集模块最后将数据存入时序数据库中。Exporter进程一个跟相关微服务一起部署的一个API服务,对内收集指标,对外向Prometheus这种指标监控软件提供查询接口。其在以Prometheus为代表的指标监控软件中这种设计思想被广泛使用,可以通过微服务供应商或者开源社区获取对应的Exporter进程。First, as shown in Figure 2, it is a flow chart of indicator collection, where Exporter is an indicator collection process that exists in the host machine and microservice instance, and these Exporter processes collect the load indicators of the host machine and microservice instance inwardly. Provide API interface exposure indicator data to the outside for collection by the indicator collection module, and the indicator collection module finally stores the data in the time series database. The Exporter process is an API service deployed together with related microservices, collects indicators internally, and provides query interfaces to indicator monitoring software such as Prometheus externally. This design idea is widely used in indicator monitoring software represented by Prometheus, and the corresponding Exporter process can be obtained through microservice providers or open source communities.
对于负载指标的定义,主要分为两类,其一是宿主机的硬件指标和实例所在容器的负载使用率。采集的负载指标通常包括CPU使用率、内存使用率和网络IO等,不同的微服务实例的这些基础负载指标应该定义为相同的。其二是体现服务响应能力的应用层负载指标,例如每秒查询数(Query per Second,QPS)、响应时间(Response Time,RT)等,这些服务层的负载指标因服务类型不同而不同。The definition of load indicators is mainly divided into two categories, one is the hardware indicators of the host machine and the load utilization rate of the container where the instance is located. The collected load indicators usually include CPU usage, memory usage, network IO, etc. These basic load indicators of different microservice instances should be defined as the same. The second is the application layer load indicators that reflect the service responsiveness, such as Query per Second (QPS), Response Time (RT), etc. The load indicators of these service layers vary with different service types.
有了可以进行趋势预测的具体指标,下一步就是确定根据负载指标判断微服务实例是否需要水平扩展/收缩的具体算法。如图3所示,为趋势预测模型训练过程图,其中的历史数据便是上一步我们采集到的那些负载指标数据,这些负载指标,大部分是平稳的时间序列数据或者可以转换为平稳的时间序列数据,我们可以基于时序数据采用一些特定算法训练出一个最优模型,便可以进行有效的预测。With the specific indicators for trend prediction, the next step is to determine the specific algorithm for judging whether the microservice instance needs to be expanded/shrunk horizontally based on the load indicators. As shown in Figure 3, it is a graph of the training process of the trend prediction model. The historical data in it are the load index data we collected in the previous step. Most of these load indicators are stable time series data or can be converted into stable time For sequence data, we can use some specific algorithms to train an optimal model based on time series data, and then we can make effective predictions.
如趋势预测模型训练过程图所展示的,我们主要结合了三种时间序列预测算法,即Holt-Winters、ARIMA(AutoRegressive Integrated Moving Average)以及STL(Seasonal-Trend decomposition using LOESS);具体的:As shown in the trend prediction model training process diagram, we mainly combine three time series prediction algorithms, namely Holt-Winters, ARIMA (AutoRegressive Integrated Moving Average) and STL (Seasonal-Trend decomposition using LOESS); specifically:
Holt-Winters是一种时间序列分析和预报方法。该方法可以用于预测含有线性趋势和周期波动的非平稳序列,利用指数平滑法(EMA)让模型参数不断适应非平稳序列的变化,拟合出针对趋势性和周期性的预测函数,并对未来趋势进行预报。Holt-Winters is a time series analysis and forecasting method. This method can be used to predict non-stationary sequences with linear trends and periodic fluctuations. The exponential smoothing method (EMA) is used to make the model parameters continuously adapt to the changes of non-stationary sequences, and a prediction function for trend and periodicity is fitted. forecast future trends.
ARIMA模型的预测原理是分析输入的时序序列自身,提取序列中所有相关性的信息来拟合函数,并用该函数进行预测。ARIMA(p,d,q)模型是ARMA(p,q)模型的扩展,而ARMA则是AR模型和MA模型的结合,其中,AR(p)模型,全称是p阶回归模型;MA(q)模型,全称是q阶移动平均模型;ARMA模型,全称是自回归移动平均模型。在ARMA的基础上使预测成为平稳序列需要进一步做差分,进而最终得到ARIMA。The prediction principle of the ARIMA model is to analyze the input time series itself, extract all the correlation information in the sequence to fit a function, and use this function to make predictions. The ARIMA(p, d, q) model is an extension of the ARMA(p, q) model, and ARMA is a combination of the AR model and the MA model. The full name of the AR(p) model is the p-order regression model; the MA(q ) model, the full name is the q-order moving average model; the ARMA model, the full name is the autoregressive moving average model. On the basis of ARMA, it is necessary to make further differences to make the forecast a stationary sequence, and finally get ARIMA.
STL(Seasonal and Trend decomposition using Loess)是一个非常通用和稳健的分解时间序列的方法,STL可以对季节因子和趋势因子都进行了局部多项式回归。其中LOESS(locally weighted scatterplot smoothing,LOWESS or LOESS)为局部多项式回归拟合,是对两维散点图进行平滑的常用方法,它结合了传统线性回归的简洁性和非线性回归的灵活性。当要估计某个响应变量值时,先从其预测变量附近取一个数据子集,然后对该子集进行线性回归或二次回归,回归时采用加权最小二乘法,即越靠近估计点的值其权重越大,最后利用得到的局部回归模型来估计响应变量的值。用这种方法进行逐点运算得到整条拟合曲线。STL (Seasonal and Trend decomposition using Loess) is a very general and robust method for decomposing time series. STL can perform local polynomial regression on both seasonal and trend factors. Among them, LOESS (locally weighted scatterplot smoothing, LOWESS or LOESS) is local polynomial regression fitting, which is a common method for smoothing two-dimensional scatterplots. It combines the simplicity of traditional linear regression and the flexibility of nonlinear regression. When estimating the value of a response variable, first take a subset of data from the vicinity of its predictor variable, and then perform linear regression or quadratic regression on the subset, and use weighted least squares method for regression, that is, the value closer to the estimated point The greater its weight, the resulting local regression model is finally used to estimate the value of the response variable. In this way, the point-by-point operation is performed to obtain the entire fitting curve.
本实施例所述方案中的趋势预测在算法选择上不存在“银弹”,所选择的这三种算法在使用场景和优缺点上实现了相互补充,各自拟合出的预测数据会进一步的进行相关校验,保证预测的尽可能准确。There is no "silver bullet" in algorithm selection for trend prediction in the solution described in this example. The three selected algorithms complement each other in terms of usage scenarios and advantages and disadvantages, and the predicted data fitted by each will further improve Carry out relevant checks to ensure that the predictions are as accurate as possible.
整体的训练流程是设定一些定时任务,同时对Holt-Winters、ARIMA和STL三个算法进行训练,将2/3的历史数据作为训练数据,将1/3的数据作为测试数据。针对每一种算法循环传入一些特定参数,对每种算法的每一个参数都训练得到模型,然后使用SMAPE(Symmetric Mean Absolute Percentage Error)作为模型的评价,这样我们就最终得到一个最优模型,然后就可以基于此模型进行趋势预测。The overall training process is to set some timing tasks and train the three algorithms of Holt-Winters, ARIMA and STL at the same time, using 2/3 of the historical data as training data and 1/3 of the data as testing data. For each algorithm, some specific parameters are looped in, the model is trained for each parameter of each algorithm, and then SMAPE (Symmetric Mean Absolute Percentage Error) is used as the evaluation of the model, so that we finally get an optimal model. Trend predictions can then be made based on this model.
其中,SMAPE是一种基于百分比(或相对)误差的准确度度量方法,我们使用它来作为预测评价指标。通俗的讲,准确度度量就是基于预测数值和准确数值的偏差进行评判模型的优劣。而对预测模型的评价最可靠的数据自然是已经获得的真实时序数据,我们可以把历史时序数据分成两部分,一部分用来训练模型,另一部分用来检验模型。如果我们有4周(28天)的数据,我们使用前3周(前21天)的数据用来调整算法训练模型,再用模型逐步预测最后7天的数据,最好采用滚动预测的方法,每次预测前进一天,总共可以进行7次模拟检验,通过这种检验方式,最终得到一个最优的预测模型。Among them, SMAPE is an accuracy measurement method based on percentage (or relative) error, and we use it as a prediction evaluation indicator. In layman's terms, the accuracy measurement is to judge the quality of the model based on the deviation between the predicted value and the accurate value. The most reliable data for evaluating the prediction model is naturally the real time series data that has been obtained. We can divide the historical time series data into two parts, one part is used to train the model, and the other part is used to test the model. If we have 4 weeks (28 days) of data, we use the data of the first 3 weeks (the first 21 days) to adjust the algorithm training model, and then use the model to gradually predict the data of the last 7 days. It is best to use the rolling forecast method. Each forecast advances one day, and a total of 7 simulation tests can be carried out. Through this test method, an optimal forecast model is finally obtained.
进一步的,如果我们采集到的负载指标数据量足够大的话,也可以选择训练类似RNN、LSTM这样的神经网络模型,供预测使用。Furthermore, if the amount of load index data we collect is large enough, we can also choose to train neural network models such as RNN and LSTM for prediction.
到此为止,我们就能做到基于历史负载指标数据,预测出相应服务的负载趋势,根据具体趋势就可以很直观的做出扩展还是收缩的决定,而这些决定通过实例控制器模块来最终实现。So far, we can predict the load trend of the corresponding service based on the historical load index data, and make an intuitive decision to expand or shrink according to the specific trend, and these decisions are finally realized through the instance controller module .
以上就是整个基于趋势预测来自动做到微服务实例水平扩展/收缩的全过程,其中有两个关键技术点:一是我们需要定义真正能反应出微服务真实负载水平的指标数据,包括宿主机和微服务实例层面的,也包括物理资源和应用层指标层面的,然后我们通过指标收集模块将这些时序数据收集到数据库,待下一步预测使用。二是选择合适的算法训练出准确度高的预测模型,然后使用上一步的指标数据进行负载的趋势预测,根据对未来的预测来提前实现实例的扩展/收缩。The above is the whole process of automatic horizontal expansion/shrinkage of microservice instances based on trend prediction. There are two key technical points: First, we need to define index data that can truly reflect the real load level of microservices, including the host And at the level of microservice instances, as well as at the level of physical resources and application layer indicators, and then we collect these time series data into the database through the indicator collection module, which will be used in the next prediction. The second is to select a suitable algorithm to train a high-accuracy prediction model, and then use the index data in the previous step to predict the load trend, and realize the expansion/contraction of the instance in advance according to the future prediction.
实施例二:Embodiment two:
本实施例的目的是提供一种基于趋势预测的微服务实例动态水平扩展收缩系统。The purpose of this embodiment is to provide a system for dynamic horizontal expansion and contraction of microservice instances based on trend prediction.
根据本公开实施例的第二个方面,提供了一种基于趋势预测的微服务实例动态水平扩展收缩系统,包括:According to the second aspect of the embodiments of the present disclosure, a system for dynamic horizontal expansion and contraction of microservice instances based on trend prediction is provided, including:
数据获取单元,其用于基于Exporter进程周期性的获取云平台内宿主机和微服务实例的负载指标;其中,所述Exporter进程为存在于宿主机和微服务实例中的指标收集进程,并对外提供指标数据接口;A data acquisition unit, which is used to periodically acquire the load indicators of the host computer and the microservice instance in the cloud platform based on the Exporter process; wherein, the Exporter process is an indicator collection process existing in the host computer and the microservice instance, and provides external Indicator data interface;
数据存储单元,其用于将获得的负载指标按照时序存储于时序数据库中;A data storage unit, which is used to store the obtained load index in a time series database according to time series;
负载趋势预测单元,其用于基于所述时序数据库中的负载指标,利用预先构建的负载趋势预测模型获得相应服务的负载趋势;A load trend prediction unit, which is used to obtain the load trend of the corresponding service based on the load index in the time series database by using a pre-built load trend prediction model;
微服务实例扩展或收缩控制单元,其用于基于获得的负载趋势,实现微服务实例的扩展或收缩。The microservice instance expansion or contraction control unit is used for realizing the expansion or contraction of the microservice instance based on the obtained load trend.
进一步的,本实施例所述系统与实施例一中所述方法相对应,其技术细节在实施例一中已经进行了详细说明,故此处不再赘述。Further, the system described in this embodiment corresponds to the method described in Embodiment 1, and its technical details have been described in detail in Embodiment 1, so details will not be repeated here.
在更多实施例中,还提供:In further embodiments, there is also provided:
一种电子设备,包括存储器和处理器以及存储在存储器上并在处理器上运行的计算机指令,所述计算机指令被处理器运行时,完成实施例一中所述的方法。为了简洁,在此不再赘述。An electronic device includes a memory, a processor, and computer instructions stored in the memory and run on the processor. When the computer instructions are run by the processor, the method described in Embodiment 1 is completed. For the sake of brevity, details are not repeated here.
应理解,本实施例中,处理器可以是中央处理单元CPU,处理器还可以是其他通用处理器、数字信号处理器DSP、专用集成电路ASIC,现成可编程门阵列FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that in this embodiment, the processor can be a central processing unit CPU, and the processor can also be other general-purpose processors, digital signal processors DSP, application specific integrated circuits ASIC, off-the-shelf programmable gate array FPGA or other programmable logic devices , discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
存储器可以包括只读存储器和随机存取存储器,并向处理器提供指令和数据、存储器的一部分还可以包括非易失性随机存储器。例如,存储器还可以存储设备类型的信息。The memory may include read-only memory and random access memory, and provide instructions and data to the processor, and a part of the memory may also include non-volatile random access memory. For example, the memory may also store device type information.
一种计算机可读存储介质,用于存储计算机指令,所述计算机指令被处理器执行时,完成实施例一中所述的方法。A computer-readable storage medium is used for storing computer instructions, and when the computer instructions are executed by a processor, the method described in the first embodiment is completed.
实施例一中的方法可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器、闪存、只读存储器、可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。为避免重复,这里不再详细描述。The method in Embodiment 1 can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor. The software module may be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware. To avoid repetition, no detailed description is given here.
本领域普通技术人员可以意识到,结合本实施例描述的各示例的单元即算法步骤,能够以电子硬件或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those skilled in the art can appreciate that the units of the examples described in this embodiment, that is, the algorithm steps, can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present application.
上述实施例提供的一种基于趋势预测的微服务实例动态水平扩展收缩方法及系统可以实现,具有广阔的应用前景。The method and system for dynamic horizontal expansion and contraction of microservice instances based on trend prediction provided by the above embodiments can be realized and have broad application prospects.
以上所述仅为本公开的优选实施例而已,并不用于限制本公开,对于本领域的技术人员来说,本公开可以有各种更改和变化。凡在本公开的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本公开的保护范围之内。The above descriptions are only preferred embodiments of the present disclosure, and are not intended to limit the present disclosure. For those skilled in the art, the present disclosure may have various modifications and changes. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present disclosure shall be included within the protection scope of the present disclosure.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211144029.8A CN115391048A (en) | 2022-09-20 | 2022-09-20 | Micro-service instance dynamic horizontal expansion and contraction method and system based on trend prediction |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211144029.8A CN115391048A (en) | 2022-09-20 | 2022-09-20 | Micro-service instance dynamic horizontal expansion and contraction method and system based on trend prediction |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115391048A true CN115391048A (en) | 2022-11-25 |
Family
ID=84125870
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211144029.8A Pending CN115391048A (en) | 2022-09-20 | 2022-09-20 | Micro-service instance dynamic horizontal expansion and contraction method and system based on trend prediction |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115391048A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116627660A (en) * | 2023-07-24 | 2023-08-22 | 湖北省楚天云有限公司 | A microservice resource configuration method based on cloud data center |
CN116893865A (en) * | 2023-09-11 | 2023-10-17 | 中移(苏州)软件技术有限公司 | Microservice instance adjustment method, device, electronic equipment and readable storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108920153A (en) * | 2018-05-29 | 2018-11-30 | 华南理工大学 | A kind of Docker container dynamic dispatching method based on load estimation |
CN110149396A (en) * | 2019-05-20 | 2019-08-20 | 华南理工大学 | A kind of platform of internet of things construction method based on micro services framework |
US20190347134A1 (en) * | 2017-01-26 | 2019-11-14 | Huawei Technologies Co., Ltd. | Capacity Expansion Method and Apparatus |
CN112000459A (en) * | 2020-03-31 | 2020-11-27 | 华为技术有限公司 | Method for expanding and contracting service and related equipment |
CN112529053A (en) * | 2020-11-26 | 2021-03-19 | 苏州浪潮智能科技有限公司 | Short-term prediction method and system for time sequence data in server |
CN113064700A (en) * | 2021-04-30 | 2021-07-02 | 中国工商银行股份有限公司 | Container deployment method and device |
-
2022
- 2022-09-20 CN CN202211144029.8A patent/CN115391048A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20190347134A1 (en) * | 2017-01-26 | 2019-11-14 | Huawei Technologies Co., Ltd. | Capacity Expansion Method and Apparatus |
CN108920153A (en) * | 2018-05-29 | 2018-11-30 | 华南理工大学 | A kind of Docker container dynamic dispatching method based on load estimation |
CN110149396A (en) * | 2019-05-20 | 2019-08-20 | 华南理工大学 | A kind of platform of internet of things construction method based on micro services framework |
CN112000459A (en) * | 2020-03-31 | 2020-11-27 | 华为技术有限公司 | Method for expanding and contracting service and related equipment |
CN112529053A (en) * | 2020-11-26 | 2021-03-19 | 苏州浪潮智能科技有限公司 | Short-term prediction method and system for time sequence data in server |
CN113064700A (en) * | 2021-04-30 | 2021-07-02 | 中国工商银行股份有限公司 | Container deployment method and device |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116627660A (en) * | 2023-07-24 | 2023-08-22 | 湖北省楚天云有限公司 | A microservice resource configuration method based on cloud data center |
CN116893865A (en) * | 2023-09-11 | 2023-10-17 | 中移(苏州)软件技术有限公司 | Microservice instance adjustment method, device, electronic equipment and readable storage medium |
CN116893865B (en) * | 2023-09-11 | 2023-12-12 | 中移(苏州)软件技术有限公司 | Micro-service example adjusting method and device, electronic equipment and readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112000459B (en) | Method for expanding and shrinking capacity of service and related equipment | |
CN113033643B (en) | Concept drift detection method, system and electronic device based on weighted sampling | |
CN111198808B (en) | Method and device for predicting performance index, storage medium and electronic equipment | |
CN113128678A (en) | Self-adaptive searching method and device for neural network | |
CN103778474A (en) | Resource load capacity prediction method, analysis prediction system and service operation monitoring system | |
CN117175588B (en) | Electricity load forecasting method and device based on spatiotemporal correlation | |
CN115391048A (en) | Micro-service instance dynamic horizontal expansion and contraction method and system based on trend prediction | |
CN111327655A (en) | Multi-tenant container resource quota prediction method and device and electronic equipment | |
CN118939438A (en) | Intelligent scheduling method and system for heterogeneous equipment system | |
CN116627630A (en) | Resource demand prediction model training, demand prediction and resource scheduling method and system | |
CN112905343A (en) | Resource scheduling system based on load characteristics in industrial cloud environment | |
WO2025015849A1 (en) | Network data analysis model scheduling method and apparatus, and computer device | |
CN104254083B (en) | Predict the method and device of traffic hotspots | |
CN118502918A (en) | Workflow intelligent management system based on artificial intelligence | |
CN118193211A (en) | Distributed database cluster resource management method, apparatus, device, storage medium and program product | |
CN104932898B (en) | A kind of component selection method to be increased based on improvement multi-objective particle | |
CN119401452A (en) | Power load forecasting method, system equipment and medium based on multi-source heterogeneous data feature fusion | |
CN112308337A (en) | Prediction method, prediction device and processor for probabilistic short-term load of power system | |
CN118917627B (en) | Logistics demand prediction method and device based on multi-scale space-time diagram convolution network | |
Min et al. | A novel 5g digital twin approach for traffic prediction and elastic network slice management | |
Guo et al. | Short-Term Water Demand Forecast Based on Deep Neural Network:(029) | |
CN117081942A (en) | Network traffic prediction method, device, equipment and medium | |
Noble et al. | Machine learning based techniques for workload prediction in serverless environments | |
CN118170550B (en) | Node water level line threshold value adjusting method and device and related equipment | |
CN116957166B (en) | Tunnel traffic condition prediction method and system based on Hongmon system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |