Industrial APP operation load control method and system
By periodically obtaining the operating indicators of industrial APPs and pre-calculating the expanded operating indicators, selecting the optimal expansion method, the problem of difficulty in achieving full automatic expansion in the existing technology is solved, and efficient resource utilization and system stability are achieved.
Patent Information
- Application Number
- CN202411624719.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art is difficult to achieve fully automatic horizontal or vertical expansion, resulting in waste of resources and disturbances in production services, especially in planned server resource environments.
By periodically obtaining the current operating indicators of the industrial APP, comparing them with preset conditions, determining the expansion direction and pre-expanding/pre-reducing amount, and pre-calculating the operating indicators after horizontal/vertical expansion, and selecting the optimal expansion method to operate.
It realizes fully automatic scaling under different load conditions, improves resource utilization, improves system stability and flexibility, and ensures accurate control of the operating load of industrial APPs.
Smart Images

Figure CN119645562A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a method and system for controlling the running load of an industrial APP. Background Art
[0002] With the vigorous development of cloud-native technology, industrial apps are widely used in cloud-native infrastructure. Kubernetes (k8s) is a portable, scalable, open source infrastructure platform based on container orchestration technology. It provides a series of means such as service registration and discovery, load balancing strategies, rolling upgrades, automatic expansion and contraction, etc., to meet the extremely high requirements of cloud-native for flexibility, scalability, and portability. Therefore, deploying and running industrial apps in k8s has become the preferred solution for major industrial software vendors. However, since most of the domestic industrial software is still deployed in a privatized mode, this leads to large differences in the deployment environment, and the business needs and business scale of each project are different, and privatized deployment cannot unify the operation and maintenance team. The existence of the above factors puts forward higher requirements on how to achieve workload control of industrial apps according to changes in external environmental factors.
[0003] Currently, Kubernetes (k8s) officially provides two control methods for scaling the workload of service Pods: horizontal scaling (HPA) and vertical scaling (VPA). Horizontal scaling refers to the horizontal scaling of applications by increasing or decreasing the number of running replicas of industrial apps to meet the operating requirements of the business; vertical scaling refers to the horizontal scaling of applications by increasing or decreasing the operating size of the CPU and memory resources of industrial apps to meet the operating requirements of the business.
[0004] In the prior art, most of the operating resources are adjusted through horizontal expansion and contraction, vertical expansion and contraction, and their combination. For example, the horizontal expansion and contraction solutions include: CN202210435975.1 "A method and device for improving the horizontal elastic scaling capability of Kubernetes containers", etc. The vertical expansion and contraction solutions include: CN202311699090.3 "Data update method, device, equipment and medium for existing Pods in Kubernetes", etc. The horizontal and vertical expansion and contraction solutions include: CN202410498784.9 "A method, device, equipment and readable storage medium for expanding and contracting Kubernetes containers", etc.
[0005] However, regardless of single-node mode or multi-node mode, existing technologies are unable to dynamically implement horizontal or vertical scaling capabilities based on actual node resource requirements, which can easily lead to resource waste and may also cause disturbances to actual production operations.
[0006] Therefore, in the environment of planned server resources, how to adapt to different modes, realize fully automatic horizontal or vertical expansion and contraction in any mode, make full use of limited server resources, improve resource utilization, and increase system stability is a technical problem that urgently needs to be solved. Summary of the invention
[0007] In view of the large limitations of the existing technology and the difficulty in achieving fully automatic horizontal or vertical scaling, the present invention provides a method and system for industrial APP operation load control, which determines the scaling direction and the corresponding pre-expansion / pre-shrinkage through the judgment results of the current operating indicators and preset conditions, and pre-calculates the operating indicators after the horizontal / vertical scaling is executed based on the above information to judge the rationality of the scaling method, and then selects the optimal scaling method in the horizontal / vertical scaling to perform the scaling operation. Since the present invention pre-calculates the results of different scaling methods, it can select the optimal scaling method for operation, and then can adapt to different modes, and finally achieve fully automatic horizontal or vertical scaling.
[0008] The following is the technical solution of the present invention.
[0009] A method for controlling an industrial APP operation load, comprising the following steps: S1: Periodically obtain current operating indicators; S2: Determine the expansion / contraction direction and the corresponding pre-expansion / pre-contraction amount based on the judgment result of the current operation index and the preset conditions; S3: according to the expansion direction and the corresponding pre-expansion amount / pre-shrinkage amount, the operation index after the horizontal / vertical expansion is calculated and judged, and the optimal expansion method in the horizontal / vertical expansion is selected; S4: Scaling is performed based on the selection result, the scaling direction, and the corresponding pre-expansion amount / pre-shrinkage amount.
[0010] The present invention periodically obtains the current operating indicators of the industrial APP, compares them with the preset conditions, and determines the expansion direction and pre-expansion / pre-shrinkage. Before expansion, the operating indicators after horizontal expansion and vertical expansion are pre-calculated, and the optimal expansion method is selected based on these calculation results. This method effectively solves the problem in the prior art that it is difficult to fully automatically adapt to different modes for horizontal or vertical expansion. Through precise calculation and selection, it ensures the efficient use of resources, improves the stability and flexibility of the system, and realizes precise control of the operating load of the industrial APP.
[0011] Preferably, the S1: periodically obtaining current operating indicators includes: periodically obtaining operating indicator items including CPU and memory of industrial APPs and nodes, and calculating average CPU usage and average memory usage.
[0012] Preferably, the step S2: determining the expansion / contraction direction and the corresponding pre-expansion / pre-contraction amount based on the judgment result of the current operation index and the preset condition, comprises: When the default indicator calculation mode is executed: According to the average CPU usage and average memory usage in the current operating indicators, compare them with the upper and lower limits of the preset operating indicators. If the usage exceeds the upper limit, it is necessary to expand the capacity; if the usage is lower than the lower limit, it is necessary to reduce the capacity; After determining the expansion / contraction direction, take the median of the upper and lower limits of the preset operating indicators as the target, calculate the preset amount of CPU or memory to be increased or decreased, and obtain the corresponding pre-expansion / pre-contraction amount.
[0013] Preferably, the step S2: calculating the expansion / contraction direction and the corresponding pre-expansion amount / pre-contraction amount based on the comparison result between the current operation index and the preset operation index threshold value includes: When executing the custom indicator calculation mode: Preset expansion expression and reduction expression. When the expansion expression is calculated as true, the expansion operation is performed; when the reduction expression is calculated as true, the reduction operation is performed; When the calculation results of the above two expressions are both negative, the default scaling calculation strategy is executed.
[0014] Preferably, the preset expansion expression and reduction expression include: selecting an indicator item, and customizing condition parameters and judgment conditions, and when the relationship between the indicator item and the condition parameters meets the judgment condition, the expression calculation result is true.
[0015] Preferably, the step S3: calculating and judging the operation index after the horizontal / vertical scaling is executed according to the scaling direction and the corresponding pre-scaling amount / pre-scaling amount, and selecting the optimal scaling method in the horizontal / vertical scaling, includes: If capacity expansion is required, the expected operating indicators of the node after vertical expansion are first calculated based on the pre-expansion amount. If it exceeds the preset first critical value, horizontal expansion is used, otherwise vertical expansion is used; If scaling down is required, the expected operating indicators of the node after horizontal scaling down are first calculated based on the pre-scaling amount, and the expected operating indicators of other replicas after reducing one replica are calculated. If the expected operating indicators are lower than the preset second critical value and the expected operating indicators of other replicas are lower than the third critical value, horizontal scaling down is used, otherwise vertical scaling down is used.
[0016] Preferably, if horizontal scaling is used, the number of replicas of the Pod's Deployment resources is modified to increase or decrease the number of replicas; if vertical scaling is used, the Pod container runs CRI to directly control the configuration items of the Linux kernel cgroup to limit the use of CPU and memory.
[0017] Preferably, before S1, S0 is also included: Based on the CRD mechanism of K8S, declare and register RL extension resources to K8S; When installing and deploying, the industrial app declares RL resource instance data according to the RL resource definition specification; Based on the CRD+Operator mechanism of K8S, two controllers, RPA and RLC, are deployed.
[0018] Preferably, the RPA is used to execute steps S1 to S3, and its calculation results are updated to the RL resource instance declared by the corresponding industrial APP through the RL resource operation interface of the APIServer; the RLC is used to execute step S4 and run on each node in DaemonSet mode, and monitors the changes of the RL resource instance declared by the industrial APP through the Watch mechanism of K8S. When changes occur, scaling operations are performed by analyzing the changes in the number of copies of the RL resource instance and the resource limit value.
[0019] The present invention also provides a system for controlling the operation load of an industrial APP. When the system is running, the above-mentioned method for controlling the operation load of an industrial APP is executed.
[0020] The present invention also provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps of the above-mentioned method for controlling the operation of an industrial APP are implemented.
[0021] The present invention also provides a storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the steps of the above-mentioned method for industrial APP operation load control are implemented.
[0022] The substantial effects of the present invention include: The present invention combines the advantages of horizontal scaling (HPA) and vertical scaling (VPA), and realizes fully automatic scaling under different load conditions by real-time monitoring and dynamic analysis of the operating indicators of industrial apps. This not only improves the response speed of the system, but also ensures the efficient use of resources and avoids resource waste.
[0023] By setting upper and lower limits and the median line, the present invention can accurately control the operating resources of industrial apps, ensuring the smooth operation of the business while also improving the efficiency of resource utilization. This feature is particularly suitable for planned server resource environments, ensuring the rational allocation and utilization of resources.
[0024] Before the scaling operation, the present invention pre-calculates the operating indicators after horizontal scaling and vertical scaling, and selects the optimal scaling method according to the calculation results. This pre-calculation strategy effectively avoids the potential problems caused by blind scaling and ensures the rationality and effectiveness of the scaling operation.
[0025] Regardless of the single-node or multi-node deployment mode, the present invention can select the most appropriate expansion and contraction strategy through dynamic analysis and calculation. This flexibility enables the present invention to adapt to various complex industrial application environments and meet the needs of different business scenarios.
[0026] Through the CRD and Operator mechanisms, the present invention provides high scalability and customizability. Users can customize the scaling strategy according to actual needs and implement automated scaling operations through RPA and RLC controllers. This design not only enhances the flexibility of the system, but also reduces operation and maintenance costs.
[0027] To sum up, the present invention realizes precise control and efficient management of industrial APP running load through a series of innovative technical means, significantly improves the stability, flexibility and resource utilization of the system, and significantly optimizes the resource management and application expansion strategy in the cloud native environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a technical architecture diagram of an embodiment of the present invention; Figure 2 is a flow chart of an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution will be clearly and completely described below in combination with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0030] It should be understood that in various embodiments of the present invention, the size of the sequence number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0031] It should be understood that in the present invention, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0032] It should be understood that in the present invention, "plurality" refers to two or more than two. "And / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "Contains A, B and C", "Contains A, B, C" means that A, B, and C are all included, "Contains A, B or C" means that one of A, B, and C is included, and "Contains A, B and / or C" means that any one, any two, or any three of A, B, and C are included.
[0033] Terminology explanation: K8S, short for kubernets, is an open source container orchestration system for automatic deployment, scheduling and management.
[0034] Pod is the smallest manageable deployment computing unit in k8s.
[0035] Node, a node, is generally the same as a physical machine.
[0036] CRD, Custom Resource Definition, is an open resource definition interface that supports extensions provided by k8s.
[0037] Deployment is a declarative resource in k8s that defines Pod deployment. There are other system deployment resources in k8s such as Statefulset, DaemonSet, Job, etc.
[0038] Kubelet, one of the core components of k8s, is responsible for managing the Pod operation in a single node. It meets the k8s Pod scheduling and deployment by monitoring k8s resources and events.
[0039] Cgroup is a Linux kernel function that is used as the basis for containerized computing resource isolation.
[0040] RPA, RealtimePodAutoscaler, a custom-developed indicator analysis scaling scheduler.
[0041] RL, RealtimeLoadResource, load resource defined based on CRD extension technology.
[0042] RLC, RealtimeLoadSet, is a controller developed based on Operator extension technology for monitoring RL resource changes, which is used to ultimately control the scaling of services.
[0043] The technical solution of the present invention is described in detail with specific embodiments below. The embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0044] Embodiment 1: This embodiment provides a method for controlling the load of an industrial APP operation. The technical architecture is as follows: Figure 1 As shown, before formal execution, you need to do the following Figure 1 The relevant deployment shown is as follows: Deploy Metrics Server to collect various operating indicators of the K8S cluster from Kubelet, and make them available to the public through the Metrics API by K8S APIServer.
[0045] Based on K8S's CRD definition, an extended resource that declares the running load configuration of industrial apps is defined: RL (RealtimeLoadResource). This resource describes the information related to the running load of the Pod of the industrial app, such as the number of replicas, CPU and memory limits, pull cycle strategy, custom indicator strategy, etc. The detailed definition information of RL is as follows: scaleTargetRef: The resource reference of the scheduled target POD. Contains resource version (apiVersion), resource type (kind), resource name (name), custom Metrics acquisition interface (customMetricsApi), and custom Metrics acquisition strategy (pullMetricsPolicy). The function of this parameter is that when the scaling action is triggered, the load controller (RLC) can find the service resources that need to be controlled according to the definition of this parameter, such as the deployment control resources (Deployment) of the POD.
[0046] 、hpaPolicy: Modular expansion and contraction policy configuration. Contains the minimum number of replicas (minReplicas), the maximum number of replicas (maxReplicas), the current number of replicas (replicas), the expansion condition calculation expression (upMetricsCalcExpression), and the reduction condition calculation expression (downMetricsCalcExpression). Supports the use of Common Expression Language (CEL) to declare some special Metrics indicator calculations to drive modular expansion and contraction, such as object.cpu.usage>0.75 triggers expansion.
[0047] , vpaPolicy: vertical expansion policy configuration. This configuration supports separate policy settings for multiple containers in the service POD. The configuration of each container includes the container name, CPU policy configuration, and memory policy configuration.
[0048] The CPU policy configuration includes the lower usage threshold (minUsageRatio), the upper usage threshold (maxUsageRatio), the median usage threshold (medianUsageRatio), the current usage upper limit (limit), the expansion condition calculation expression (upMetricsCalcExpression), and the reduction condition calculation expression (downMetricsCalcExpression).
[0049] The memory policy configuration includes the lower usage threshold (minUsageRatio), the upper usage threshold (maxUsageRatio), the median usage threshold (medianUsageRatio), the current usage upper limit (limit), the expansion condition calculation expression (upMetricsCalcExpression), and the reduction condition calculation expression (downMetricsCalcExpression).
[0050] The Metrics Scaling Scheduler (RPA) calculates and compares the CPU and memory thresholds defined above, combined with the real-time service load data collected from the Metrics Server. When the relevant calculation indicators are below the lower limit or above the upper limit, the service is scaled vertically, or the expression calculation is performed on the data according to the scaling condition calculation expression, and the scaling is driven when the calculation result is true.
[0051] When the industrial APP is installed and deployed, it declares the RL resource instance according to the RL CRD definition specification.
[0052] Based on the CRD+Operator mechanism of K8S, RPA (RealtimePodAutoscaler) and RLC (RealtimeLoadSet) are developed, where RPA is deployed and run in the form of Deployment, and RLC is deployed and run in the form of DaemonSet. The main purpose of running RLC in DaemonSet is that it needs to modify the Linux kernel cgroup file of each Node. RPA (RealtimePodAutoscaler) periodically obtains the indicator data of the running load of the industrial APP and calculates the scaling target in combination with the declaration strategy of RL. According to the specification of RL, RPA supports two modes: default indicator calculation mode and custom indicator calculation mode.
[0053] A method for controlling the load of an industrial APP operation in this embodiment is as follows: Figure 2 As shown, including: Periodically obtain the current running indicators.
[0054] Includes: periodically obtaining operating indicators of industrial apps and nodes, including CPU and memory, and calculating the average CPU usage and average memory usage.
[0055] Average CPU usage: in: P stands for service POD, represents the average CPU usage value, n represents the sample data of CPU usage per unit time, n-2 means removing the maximum and minimum values, and i represents the number of samples.
[0056] Average memory usage: in: P stands for service POD, Represents the average memory usage value, n represents the sample data of memory usage per unit time, n-2 means removing the maximum and minimum values, and i represents the number of samples.
[0057] The expansion / contraction direction and the corresponding pre-expansion / pre-contraction amount are determined based on the judgment results of the current operating indicators and preset conditions.
[0058] When the default indicator calculation mode is executed: According to the average CPU usage and average memory usage in the current operating indicators, compare them with the upper and lower limits of the preset operating indicators. If the usage exceeds the upper limit, it is necessary to expand the capacity; if the usage is lower than the lower limit, it is necessary to reduce the capacity; After determining the expansion / contraction direction, take the median of the upper and lower limits of the preset operating indicators as the target, calculate the preset amount of CPU or memory to be increased or decreased, and obtain the corresponding pre-expansion / pre-contraction amount.
[0059] Specifically, the average CPU and memory usage is compared with the upper and lower limits (minUsageRatio, maxUsageRatio) of the CPU and memory configured in the RL declared by the industrial APP. If the usage rate exceeds the upper limit, it is necessary to expand the capacity; if the usage rate is lower than the lower limit, it is necessary to reduce the capacity.
[0060] Expansion rate is greater than the upper limit: The shrinkage is less than the lower limit: Formula Description: Pc_u=average CPU usage, Pc = CPU limit value defined in RL's vpaPolicy; Pm_u=average memory usage, Pm = memory limit value (limit) defined in RL's vpaPolicy; When the average CPU or memory usage is greater than the upper usage threshold defined in the RL's vpaPolicy, expansion is triggered; when the average CPU and memory usage is less than the lower usage threshold defined in the RL's vpaPolicy, reduction is triggered.
[0061] When scaling is required, the preset amount of CPU or memory that needs to be increased or decreased is calculated based on the median (medianUsageRatio) defined in the vpaPolicy of the RL declared by the industrial app.
[0062] Expand the preset amount (round up): Pc_e=ceil(Pc×(1+(Pc_u-Pc_median)))Pm_e=ceil(Pm×(1+(Pm_u-Pm_median)))Preset reduction amount (round down): Pc_s=floor(Pc×(1-(Pc_median-Pc_u))) Pm_s=floor(Pm×(1-(Pm_median-Pm_u))) Formula Description: Pc = the current CPU limit value defined in RL's vpaPolicy, Pm = the current memory limit value defined in RL's vpaPolicy; Pc_u=average CPU usage, Pm_u=average memory usage; Pc_median=the median threshold of CPU usage defined in the vpaPolicy of the RL, and Pm_median=the median threshold of memory usage defined in the vpaPolicy of the RL.
[0063] When performing capacity expansion, the pre-expansion amount (Pc_e or Pm_e) will be the current limit of the POD plus the "difference between the average utilization rate and the median utilization rate threshold"; When performing a shrinking operation, the pre-shrinkage amount (Pc_s or Pm_s) will be the current limit of the POD and then reduce the "difference between the median utilization threshold and the average utilization" by 2.
[0064] According to the scaling direction and the corresponding pre-scaling / pre-scaling amount, the operation indicators after horizontal / vertical scaling are calculated and judged, and the optimal scaling method in horizontal / vertical scaling is selected.
[0065] include: If capacity expansion is required, the expected operating indicators of the node after vertical expansion are first calculated based on the pre-expansion amount. If it exceeds the preset first critical value, horizontal expansion is used, otherwise vertical expansion is used; If scaling down is required, the expected operating indicators of the node after horizontal scaling down are first calculated based on the pre-scaling amount, and the expected operating indicators of other replicas after reducing one replica are calculated. If the expected operating indicators are lower than the preset second critical value and the expected operating indicators of other replicas are lower than the third critical value, horizontal scaling down is used, otherwise vertical scaling down is used.
[0066] Specifically, when scaling vertically, it is necessary to evaluate whether the current running nodes of the industrial app will exceed 70% of their overall operating load due to resource expansion based on the preset capacity. If so, it is necessary to consider horizontal scaling.
[0067] The judgment condition for horizontal scaling is that the CPU or memory usage of all POD copies running the industrial APP is lower than the lower limit (minUsageRatio). In addition, it is necessary to analyze the impact of reducing one copy on the overall operating load of the industrial APP, because reducing copies while the business volume remains unchanged will lead to an increase in the business volume of other copies, which in turn leads to an increase in the resource usage of other copies.
[0068] CPU and memory usage budget after replica reduction by 1: Formula Description: n refers to the number of currently running copies of the POD, that is, the number of currently running copies (replicas) defined in the hpaPolicy of the RL; Refers to the average CPU usage. Refers to the average memory usage; Pc = the current CPU limit value defined in RL's vpaPolicy, Pm = the current memory limit value defined in RL's vpaPolicy; Based on the average usage calculated in the previous section, calculate the ratio of the average usage after reducing one replica to the current usage to see if it exceeds the maximum usage ratio (maxUsageRatio) defined in the RL's vpaPolicy. If it exceeds, it means that reducing the replica will cause the POD load to exceed the maximum limit. At this time, the modular expansion operation cannot be performed, and the vertical expansion operation needs to be switched.
[0069] If the above conditions cannot be met, consider vertically scaling down all running POD copies of the industrial APP.
[0070] Calculate the average usage of all POD copies: Calculate the total limit of all POD copies: Calculate the overall utilization of all POD replicas: Calculate POD pre-shrinkage: Formula Description: n refers to the number of currently running copies of the POD, that is, the number of currently running copies (replicas) defined in the hpaPolicy of the RL; Refers to the average CPU usage. Refers to the average memory usage; Pc refers to the current CPU limit value defined in the vpaPolicy of the RL, and Pm refers to the current memory limit value defined in the vpaPolicy of the RL; Pc_median refers to the median threshold of CPU usage defined in the vpaPolicy of RL, and Pm_median refers to the median threshold of memory usage defined in the vpaPolicy of RL.
[0071] By dividing the total average usage of all POD replicas ( and ), the total limit amount (Pc_total and Pm_total) is used to calculate the overall average usage rate (Pc_u and Pm_u); The average pre-shrinkage required for each POD is calculated based on the difference between the average utilization rate (Pc_u and Pm_u) and the median utilization rate (Pc_median and Pm_median).
[0072] In addition, when executing the custom indicator calculation mode: Preset expansion expression and reduction expression. When the expansion expression is calculated as true, the expansion operation is performed; when the reduction expression is calculated as true, the reduction operation is performed; When the calculation results of the above two expressions are both negative, the default scaling calculation strategy is executed.
[0073] The preset expansion expression and reduction expression include: selecting an indicator item, and customizing condition parameters and judgment conditions. When the relationship between the indicator item and the condition parameters meets the judgment condition, the expression calculation result is true.
[0074] Specifically, the custom indicator calculation mode refers to periodically obtaining the operating indicator items of the industrial APP through the custom indicator pull address (scaleTargetRef.customMetricsUrl) declared in RL, and performing scaling calculations based on the custom indicator calculation expression declared in RL. Custom expressions support CEL (Common Expression Language). Its judgment logic is as follows: When the calculation result of the up-scaling expression (policy.upMetricsCalcExpression) is true, the up-scaling operation is performed. The expression is configured based on the service-defined Metrics indicator items, as shown below: The service is judged by the HTTP request QPS. The indicator item is defined as server.http.qps and the expression is defined as server.http.qps>30, which means that when the HTTP request QPS of the service is greater than 30, the condition is true and capacity expansion is performed.
[0075] The judgment is made based on the data volume of a certain business of the service. The indicator item is defined as server.data.size, and the expression is defined as server.data.size>10000, which means that when the data volume of a certain business of the service is greater than 10,000, the condition is true and the capacity is expanded.
[0076] In summary, the definition of the expression is configured according to the Metrics indicator items defined by the service itself, and the format only needs to comply with the CEL specification.
[0077] When the down-capacity expression (policy.downMetricsCalcExpression) evaluates to true, down-capacity is performed. As with the up-capacity expression, the configuration is based on the Metrics items defined by the service itself, and the format complies with the CEL specification.
[0078] When the calculation results of the above two expressions are both negative, the default scaling calculation strategy is executed.
[0079] Scaling is performed based on the selection result, scaling direction, and corresponding pre-scaling / pre-scaling amount.
[0080] If horizontal scaling is used, the number of replicas of the Pod's Deployment resources is modified to increase or decrease the number of replicas. If vertical scaling is used, the Pod container runs CRI to directly control the configuration items of the Linux kernel cgroup to limit the use of CPU and memory.
[0081] This embodiment periodically obtains the current operating indicators of the industrial APP, compares them with the preset conditions, and determines the expansion direction and pre-expansion / pre-shrinkage. Before expansion, the operating indicators after horizontal expansion and vertical expansion are pre-calculated, and the optimal expansion method is selected based on these calculation results. This method effectively solves the problem in the prior art that it is difficult to fully automatically adapt to different modes for horizontal or vertical expansion. Through precise calculation and selection, it ensures efficient use of resources, improves the stability and flexibility of the system, and realizes precise control of the operating load of the industrial APP.
[0082] Embodiment 2: This embodiment also provides a system for industrial APP operation load control, the deployment method is shown in Figure 1 When the system is running, the above-mentioned method of industrial APP operation load control is executed.
[0083] Among them, RPA is responsible for periodically obtaining the operating load indicator data of the industrial APP from the K8S API Server, and performing scaling analysis and calculations based on the RL resource instance data information declared by the industrial APP. The calculation results are updated to the RL resource instance declared by the corresponding industrial APP through the RL resource operation interface of the API Server.
[0084] RLC (Realtime Load Set) runs on each Node node in DaemonSet mode, and monitors the changes of RL resource instances declared by industrial apps through the Watch mechanism of K8S. When changes occur, scaling operations are performed by analyzing the changes in the number of replicas and resource limit values (cpu.limit or memory.limit) of the RL instance.
[0085] The vertical scaling of RLC is based on the CRI mechanism of the container, and the Linux kernel cgroup file is directly modified to limit the CPU and memory. It should be noted that since the VPA of the lower version of kubernetes cannot achieve the ability of in-place update, the industrial APP will restart due to the modification of resource configuration, resulting in business interruption, thereby affecting the user's business development. Therefore, this embodiment is not based on the VPA capability of k8s.
[0086] Embodiment 3: This embodiment also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor calls the computer program in the memory, the steps of the above-mentioned method for controlling the operation of an industrial APP are implemented.
[0087] Embodiment 4: This embodiment also provides a storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the steps of the above-mentioned method for industrial APP operation load control are implemented.
[0088] In summary, the substantial effects of this embodiment include: This embodiment combines the advantages of horizontal scaling (HPA) and vertical scaling (VPA), and realizes fully automatic scaling under different load conditions by real-time monitoring and dynamic analysis of the operating indicators of industrial apps. This not only improves the response speed of the system, but also ensures the efficient use of resources and avoids resource waste.
[0089] By setting upper and lower limits and the median line, this embodiment can accurately control the operating resources of the industrial APP, ensuring the smooth operation of the business while also improving the efficiency of resource utilization. This feature is particularly suitable for planned server resource environments, ensuring the rational allocation and utilization of resources.
[0090] Before the scaling operation, this embodiment pre-calculates the operating indicators after horizontal scaling and vertical scaling, and selects the optimal scaling method according to the calculation results. This pre-calculation strategy effectively avoids potential problems caused by blind scaling and ensures the rationality and effectiveness of the scaling operation.
[0091] Regardless of the single-node or multi-node deployment mode, this embodiment can select the most appropriate expansion and contraction strategy through dynamic analysis and calculation. This flexibility enables this embodiment to adapt to various complex industrial application environments and meet the needs of different business scenarios.
[0092] Through the CRD and Operator mechanisms, this embodiment provides high scalability and customizability. Users can customize the scaling strategy according to actual needs and implement automated scaling operations through RPA and RLC controllers. This design not only enhances the flexibility of the system, but also reduces operation and maintenance costs.
[0093] To summarize, this embodiment achieves precise control and efficient management of industrial APP running loads through a series of innovative technical means, significantly improves the stability, flexibility and resource utilization of the system, and significantly optimizes the resource management and application expansion strategies in the cloud-native environment.
[0094] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the specific device can be divided into different functional modules to complete all or part of the functions described above.
[0095] In the embodiments provided in the present application, it should be understood that the disclosed structures and methods can be implemented in other ways. For example, the embodiments of the structure described above are only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another structure, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, structures or units, which can be electrical, mechanical or other forms.
[0096] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0097] In addition, each functional unit in the embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0098] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0099] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for controlling the load of industrial APP operation, characterized in that: The following steps are involved: S1: Periodically obtain current operating indicators; S2: Determine the expansion / contraction direction and the corresponding pre-expansion / pre-contraction amount based on the judgment result of the current operation index and the preset conditions; S3: according to the expansion direction and the corresponding pre-expansion amount / pre-shrinkage amount, the operation index after the horizontal / vertical expansion is calculated and judged, and the optimal expansion method in the horizontal / vertical expansion is selected; S4: Scaling is performed based on the selection result, the scaling direction, and the corresponding pre-expansion amount / pre-shrinkage amount.
2. The method for controlling the load of an industrial APP according to claim 1, characterized in that: The S1: periodically obtains the current operating indicators, including: periodically obtains the operating indicator items including CPU and memory of the industrial APP and nodes, and calculates the average CPU usage and the average memory usage.
3. The method for controlling the operation load of an industrial APP according to claim 1, characterized in that: S2: determining the expansion / contraction direction and the corresponding pre-expansion / pre-contraction amount based on the judgment result of the current operation index and the preset condition, including: When the default indicator calculation mode is executed: According to the average CPU usage and average memory usage in the current operating indicators, compare them with the upper and lower limits of the preset operating indicators. If the usage exceeds the upper limit, it is necessary to expand the capacity; if the usage is lower than the lower limit, it is necessary to reduce the capacity; After determining the expansion / contraction direction, take the median of the upper and lower limits of the preset operating indicators as the target, calculate the preset amount of CPU or memory to be increased or decreased, and obtain the corresponding pre-expansion / pre-contraction amount.
4. The method for controlling the operation load of an industrial APP according to claim 1, characterized in that: S2: calculating the expansion / contraction direction and the corresponding pre-expansion / pre-contraction amount based on the comparison result between the current operation index and the preset operation index threshold, including: When executing the custom indicator calculation mode: Preset expansion expression and reduction expression. When the expansion expression is calculated as true, the expansion operation is performed; when the reduction expression is calculated as true, the reduction operation is performed; When the calculation results of the above two expressions are both negative, the default scaling calculation strategy is executed.
5. The method for controlling the operation load of an industrial APP according to claim 4 is characterized in that: The preset expansion expression and reduction expression include: selecting an indicator item, and customizing condition parameters and judgment conditions. When the relationship between the indicator item and the condition parameters meets the judgment condition, the expression calculation result is true.
6. The method for controlling the load of an industrial APP according to claim 1, characterized in that: S3: according to the scaling direction and the corresponding pre-scaling amount / pre-scaling amount, calculating and judging the operation index after the horizontal / vertical scaling is executed, and selecting the optimal scaling method in the horizontal / vertical scaling, including: If capacity expansion is required, the expected operating indicators of the node after vertical expansion are first calculated based on the pre-expansion amount. If it exceeds the preset first critical value, horizontal expansion is used, otherwise vertical expansion is used; If scaling down is required, the expected operating indicators of the node after horizontal scaling down are first calculated based on the pre-scaling amount, and the expected operating indicators of other replicas after reducing one replica are calculated. If the expected operating indicators are lower than the preset second critical value and the expected operating indicators of other replicas are lower than the third critical value, horizontal scaling down is used, otherwise vertical scaling down is used.
7. The method for controlling the load of industrial APP operation according to claim 6 is characterized in that: If horizontal scaling is used, the number of replicas of the Pod's Deployment resources is modified to increase or decrease the number of replicas. If vertical scaling is used, the Pod container runs CRI to directly control the configuration items of the Linux kernel cgroup to limit the use of CPU and memory.
8. The method for controlling the load of an industrial APP according to claim 1, characterized in that: Before said S1, S0 is also included: Based on the CRD mechanism of K8S, declare and register RL extension resources with K8S; When installing and deploying, the industrial app declares RL resource instance data according to the RL resource definition specification; Based on the CRD+Operator mechanism of K8S, two controllers, RPA and RLC, are deployed.
9. The method for controlling the load of industrial APP operation according to claim 8 is characterized in that: The RPA is used to execute steps S1 to S3, and its calculation results are updated to the RL resource instance declared by the corresponding industrial APP through the RL resource operation interface of the APIServer; the RLC is used to execute step S4 and run on each node in DaemonSet mode, monitoring the changes of the RL resource instance declared by the industrial APP through the Watch mechanism of K8S. When changes occur, scaling operations are performed by analyzing the changes in the number of copies of the RL resource instance and the resource limit value.
10. A system for industrial APP operation load control, characterized in that: When the system is running, a method for controlling the operation load of an industrial APP according to any one of claims 1 to 9 is executed.
Citation Information
Patent Citations
Method and device for improving horizontal elastic expansion and contraction capacity of Kubernetes container
CN115033447A
Data updating method, device and equipment for Pod in Kubernetes and medium
CN117827240A
Method, device and equipment for expanding and shrinking capacity of Kubernetes container and readable storage medium
CN118509338A