Complex scene-oriented Pod horizontal automatic capacity expansion and contraction method and computer equipment

By using incremental PID controller and microservice Pod resource utilization model in K8S cluster, dynamically adjusting the number of Pods, solving the problem of automatic expansion and scaling of Pods in complex IoT business scenarios, and achieving efficient resource utilization and waste reduction .

CN119201439APending Publication Date: 2024-12-27E SURFING IOT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411236218.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The existing technology is difficult to achieve rapid and effective Pod level automatic scaling in complex IoT business scenarios, and cannot meet the dynamic resource management needs of large-scale microservice clusters with high request and concurrency.

Method used

Using the microservice Pod resource utilization model based on K8S cluster, combined with the incremental PID controller, a closed-loop feedback control system is established by integrating CPU, memory and QPS usage, and dynamically adjusting the number of pods to achieve more refined and adaptive scaling. Contains strategy.

Benefits of technology

It provides more dynamic and adaptive Pod horizontal scaling control to meet the fast response needs in complex business scenarios, ensure resource utilization is within a reasonable range, reduce cloud resource waste, and is suitable for large-scale microservice cluster environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201439A_ABST
    Figure CN119201439A_ABST
Patent Text Reader

Abstract

The invention discloses a Pod horizontal automatic capacity expansion and contraction method for a complex scene and computer equipment, and the method comprises the steps: S1, building a micro-service Pod resource utilization model A based on a K8S cluster, and obtaining a comprehensive average index T; s2, the Texp serves as the input of a control system, the Tact serves as the output of the control system, and an error e is obtained; s3, adding an incremental PID controller, and establishing a micro-service Pod resource utilization model B combined with an incremental PID algorithm; and S4, when the micro-service faces an external service request or a complex service scene, the incremental PID controller acts on the horizontal capacity expansion and contraction controller, the control quantity increment of the incremental PID controller is delta u (k), the horizontal capacity expansion and contraction controller adjusts the number of Pod, the output adjustment quantity is mapped into the variable quantity delta n (k) of the Pod, and the mapping relation between the delta u (k) and the delta n (k) is obtained. According to the method, the change of the business volume can be quickly responded, and green low-carbon cloud resource application is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Internet of Things cloud computing, and in particular to a Pod horizontal automatic expansion and contraction method and computer equipment for complex scenarios. Background Art

[0002] A single microservice in a K8S cluster is deployed on a cloud host as a Pod. Each microservice can be regarded as a linear time-invariant control system with a single variable. Its input is the call to the microservice-related resources, such as using its CPU and memory resources for calculation and storage, and transmitting data through its traffic in and out interfaces. The output is the utilization rate of its CPU, memory, and network traffic. If the utilization rate of the CPU, memory and other resources of the current microservice is high, it is necessary to perform horizontal expansion operations, that is, increase the number of Pods, and keep the resource utilization rate of each Pod not higher than the upper limit of the reasonable range to ensure the normal and stable operation of the service; if the utilization rate of the CPU, memory and other resources of the current existing Pods is lower than the lower limit of the reasonable range, it is necessary to perform horizontal Pod reduction operations to reduce the number of Pods to save cloud resources for microservices with other needs.

[0003] In the prior art, in addition to manual scaling, the automatic horizontal scaling (or horizontal scaling) of Pods is triggered by the HPA of K8S based on the configured scaling strategy. Usually, after the scaling trigger conditions are met, the number of Pods is gradually adjusted to the set value in the configuration. There is a lack of automatic and rapid adjustment strategies for the changing trends of processing requirements in business scenarios. In simple business scenarios, business requests generally change in a low frequency and a small range, so the consumption of microservice computing, storage, and communication resources does not change much, and the configuration-based scaling method can better meet the needs; but in the face of complex IoT business scenarios, due to the variety of access devices and different protocols, high and low frequency requests, large concurrency, and high real-time requirements, a more efficient, fast, and stable scaling method is needed. Summary of the invention

[0004] The present invention provides a method and computer device for automatic horizontal scaling of Pods for complex scenarios, which can automatically, quickly and effectively respond to the horizontal scaling needs of microservice Pods, maximize the utilization of cloud resources and minimize waste, and can solve at least one of the above-mentioned technical problems.

[0005] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0006] A method for automatic horizontal expansion and contraction of Pods for complex scenarios includes the following steps:

[0007] S1: Establish a microservice Pod resource utilization model A based on the K8S cluster. The microservice Pod resource utilization model A includes the horizontal scaling controller and microservices. The CPU, memory, and QPS usage of the K8S cluster are comprehensively considered by the weight method to obtain the comprehensive average index T of the microservice Pod resource utilization model A.

[0008] S2: Consider the microservice Pod resource utilization model A as a control system. Let the expected range of T in the control system be [T expmin , T expmax ], take T exp =(T expmin +T expmax ) / 2,T exp As the input of the control system, let the actual detection value of T in the control system be T act , T act As the output of the control system, the error e is obtained, e = T exp -T act ;

[0009] S3: Based on microservice Pod resource utilization model A, an incremental PID controller is added to establish a microservice Pod resource utilization model B combined with the incremental PID algorithm;

[0010] S4: The microservice Pod resource utilization model B is regarded as a closed-loop feedback control system. In the kth sampling period, e(k) is used as the input of the closed-loop feedback control system, e(k) = T exp -T act (k), the control amount of the incremental PID controller is u(k). When the microservice faces external business requests or complex business scenarios, the incremental PID controller acts on the horizontal scaling controller. The control amount increment of the incremental PID controller is Δu(k). The horizontal scaling controller adjusts the number of Pods, and the output adjustment amount is mapped to the change in the Pod, that is, the increment in the number of Pods Δn(k), and the mapping relationship between Δu(k) and Δn(k) is obtained: Δn(k)=Δu(k)%u scale ;

[0011] S5: After adjustment by the incremental PID algorithm, the CPU, memory, and QPS usage of the K8S cluster are integrated through the weight method to obtain the comprehensive standard deviation index V of the microservice Pod resource utilization model B. According to the value of V, the interval value method is used to calculate u scale The value of is set in stages. scale The value is used to calculate the number of Pods in the next cycle, reflecting the resource utilization distribution of the Pods and verifying the control effect of microservice Pod resource utilization model B.

[0012] Furthermore, in S1, n Pods have been allocated to a microservice MS in the K8S cluster in the initial startup state, and the configuration of each Pod is: the CPU upper limit is C max , the memory limit is M max , QPS upper limit is Q max , and the CPU usage of the i-th Pod is C i , the memory usage is M i , QPS utilization rate is Q i ;

[0013] in:

[0014] C i =C iu / C max , C iu is the actual CPU usage of the i-th Pod;

[0015] M i =M iu / M max , M iu is the actual memory usage of the i-th Pod;

[0016] Q i =Q iu / Q max , Q iu is the actual QPS of the i-th Pod.

[0017] Furthermore, in S1, the comprehensive average index T=k c *AVG(C)+k m *AVG(M)+k q *AVG(Q), k c , k m , k q are their respective weight coefficients, and k c +k m +k q =1;

[0018] in:

[0019] AVG(C) is the average CPU usage of all Pods;

[0020] AVG(M) is the average memory usage of all Pods;

[0021] AVG(Q) is the average QPS usage of all Pods.

[0022] Furthermore, in S4, in the microservice Pod resource utilization model B, the incremental PID algorithm adjustment satisfies:

[0023] u(k)=K P e(k)+K I Sum(ei)+K D [e(k)-e(k-1)]

[0024] Δu(k)=u(k)-u(k-1)

[0025] Δu(k)=K P [e(k)-e(k-1)]+K I e(k)+K D [e(k)2e(k-1)+e(k-2)]

[0026] Δn(k)=Δu(k)%u scale

[0027] n new =n(k)+Δn(k)

[0028] in:

[0029] K P is the proportional term coefficient, K I is the integral term coefficient, K D is the coefficient of the differential term;

[0030] k is the sampling period, and the value of k should be greater than the cooling time of the HPA expansion and contraction;

[0031] u(k) is the control quantity in the kth sampling period;

[0032] Δu(k) is the control quantity increment in the kth sampling period, which is affected by Δu max With Δu min Upper and lower limit constraints, Δu max With Δu min are the maximum and minimum boundaries of the control quantity increment;

[0033] u scale is a proportional factor set based on experience to adapt the mapping of the control quantity increment Δu(k) to the actual Pod quantity adjustment;

[0034] Δn(k) is the increment of the number of Pods, and u is increased by Δu(k). scale Modulo, it is a constrained integer, subject to Δn max With Δn min Upper and lower limit constraints, Δn max With Δn min The maximum and minimum boundaries of a single adjustment quantity are set to prevent drastic fluctuations in resource usage and ensure smooth expansion and contraction.

[0035] n new is the number of Pods after adjustment, affected by nmax With n min Upper and lower limit constraints, n max With n min is the maximum and minimum limit of the number of Pods, and n min Cannot be less than 1.

[0036] Furthermore, in S4, in the kth sampling cycle, according to the calculated increment Δn(k) of the number of Pods, the horizontal scaling operation of the microservice Pod is performed, and in the (k+1)th sampling cycle, the corresponding variables are updated, and Δn(k+1) in the current sampling cycle is recalculated.

[0037] Furthermore, in S5, regarding u scale The value of further includes:

[0038] S51: Combined with the expected range of T [T expmin , T expmax ], if the value of T is within the expected range, then Δn(k)=Δu(k)%u scale The value of should be less than 1, that is, the number of Pods will not change. Otherwise, Δn(k)=Δu(k)%u scale The value of should be no less than 1, which means increasing or decreasing the number of Pods;

[0039] S52: Comprehensively consider the distribution of CPU, memory, and QPS usage of the K8S cluster. Here, the comprehensive standard deviation index V is used to measure the distribution of the above indicators. V = d c *SD(C)+d m *SD(M)+d q *SD(Q), d c ,d m ,d q are their respective weight coefficients, and d c +d m +d q =1;

[0040] in:

[0041] SD(C) is the standard deviation of CPU usage of all Pods;

[0042] SD(M) is the standard deviation of memory usage of all Pods;

[0043] SD(Q) is the standard deviation of the QPS usage of all Pods;

[0044] The value ranges of CPU, memory, and QPS are all [0, 1]. It can be deduced that the value ranges of SD(C), SD(M) and SD(Q) are all [0, 1], so the value range of V is also [0, 1].

[0045] S53: Describe the distribution differences of Pod resource utilization based on the value of V:

[0046] The larger the V value, the more uneven the resource utilization distribution in all Pods. In this case, an alarm needs to be sent to the K8S cluster to indicate that the current business volume received by each Pod node is uneven.

[0047] If the V value is close to 0, it means that the resource utilization distribution in all Pods is basically the same. In this case, the average value can better reflect the actual resource utilization.

[0048] S54:u scale There is a positive relationship between the value and V, and the interval value method is used to design Vu scale Segmented mapping relationship:

[0049] u scale =u scale1 , V∈[0,0.1), the distribution is basically uniform;

[0050] u scale =u scale2 , V∈[0.1,0.3), the distribution is generally uniform;

[0051] u scale =u scale3 , V∈[0.3,1], the distribution is extremely uneven;

[0052] u scale1 、u scale2 、u scale3 The specific value of must be determined based on specific business scenarios and a large number of simulation experiments, and u scale1 scale2 <us cale3 That is, the greater the difference in resource utilization between Pods, the less likely it is that the average value will reflect the resource utilization, and the less likely it is that expansion and contraction operations should be performed. At this time, the K8S cluster management node will be prompted to optimize the business load distribution strategy to ensure that business requests can be evenly distributed to different Pod nodes. The u of this cycle scale The value is used to calculate the number of Pods in the next cycle.

[0053] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned Pod horizontal automatic scaling method for complex scenarios.

[0054] The beneficial effects of the present invention are embodied in:

[0055] ​1. Comprehensively considering the main microservice performance indicators such as CPU, memory, QPS, etc., an incremental PID control algorithm is integrated into the K8S resource management field. Combined with K8S's existing HPA, it can provide a more refined, dynamic, and adaptive automatic, fast, and effective Pod horizontal expansion and contraction control strategy, which can meet the control needs in complex business scenarios, and has the advantages of better dynamic response characteristics, zero steady-state error control, stronger adaptability and flexibility to business scenarios, higher robustness and accuracy, and stronger adaptability.

[0056] 2. It is particularly suitable for the automatic expansion and contraction of Pods in large-scale microservice cluster environments under complex business scenarios. It can not only meet the business access needs during peaks and valleys, but also save cloud resources and human resources, which is in line with the company's green and low-carbon strategy.

[0057] 3. When calculating the number of horizontal expansion and contraction based on Pod resource utilization, the distribution differences of Pod resource utilization are taken into account. When the resource utilization of each Pod is relatively balanced, the output of the present invention is more inclined to horizontally expand and contract the Pod, that is, to change the number of Pods more actively. Otherwise, it is not inclined to change the number of Pods. This design is also consistent with the standard for manually adjusting the number of Pods. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] The drawings described herein are used to provide further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application.

[0059] Figure 1 It is an overall flow chart of the method for automatic horizontal expansion and contraction of Pods for complex scenarios according to an embodiment of the present invention.

[0060] Figure 2 It is a schematic diagram of a microservice Pod resource utilization model B combined with an incremental PID algorithm according to an embodiment of the present invention.

[0061] Figure 3 It is a structural block diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0062] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. In the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0063] See also Figure 1-Figure 2 The embodiment of the present invention provides a method for automatic horizontal expansion and contraction of Pods for complex scenarios, including the following steps:

[0064] S1: Establish a microservice Pod resource utilization model A based on the K8S cluster. The microservice Pod resource utilization model A includes the horizontal scaling controller and microservices. The CPU, memory, and QPS usage of the K8S cluster are comprehensively considered by the weight method to obtain the comprehensive average index T of the microservice Pod resource utilization model A.

[0065] S2: Consider the microservice Pod resource utilization model A as a control system. Let the expected range of T in the control system be [T expmin , T expmax ], take T exp =(T expmin +T expmax ) / 2,T exp As the input of the control system, let the actual detection value of T in the control system be T act , T act As the output of the control system, the error e is obtained, e = T exp -T act ;

[0066] S3: Based on microservice Pod resource utilization model A, an incremental PID controller is added to establish a microservice Pod resource utilization model B combined with the incremental PID algorithm;

[0067] S4: The microservice Pod resource utilization model B is regarded as a closed-loop feedback control system. In the kth sampling period, e(k) is used as the input of the closed-loop feedback control system, e(k) = T exp -T act (k), the control amount of the incremental PID controller is u(k). When the microservice faces external business requests or complex business scenarios, the incremental PID controller acts on the horizontal scaling controller. The control amount increment of the incremental PID controller is Δu(k). The horizontal scaling controller adjusts the number of Pods, and the output adjustment amount is mapped to the change in the Pod, that is, the increment in the number of Pods Δn(k), and the mapping relationship between Δu(k) and Δn(k) is obtained: Δn(k)=Δu(k)%u scale ;

[0068] S5: After adjustment by the incremental PID algorithm, the CPU, memory, and QPS usage of the K8S cluster are integrated through the weight method to obtain the comprehensive standard deviation index V of the microservice Pod resource utilization model B. According to the value of V, the interval value method is used to calculate u scale The value of is set in stages. scaleThe value is used to calculate the number of Pods in the next cycle, reflecting the resource utilization distribution of the Pods and verifying the control effect of microservice Pod resource utilization model B.

[0069] The PID algorithm and its derivative algorithms are the most widely used algorithms in the control field at present. They are usually applicable to the output control of linear time-invariant systems with a single variable. Compared with other single adjustment means or complex adaptive control algorithms, they have the advantages of simple modeling, easy implementation, low cost, flexible adjustment, fast response, and strong robustness. Therefore, the present invention applies it to the resource allocation business of microservices. The incremental PID algorithm is an improvement based on the PID algorithm. On the one hand, it is naturally suitable for discrete control decision-making problems and can better adapt to the adjustment of the number of Pods. On the other hand, it can effectively prevent the integral saturation problem, avoid excessive adjustment and response delay, and improve the response speed and stability of the control system.

[0070] On the one hand, the present invention avoids the shortcomings of existing configuration-based adjustment strategies that are not smooth and cannot be adjusted according to business volume change trends. On the other hand, it can quickly respond to business volume changes. By adjusting the number of Pods, it can ensure that microservices can ensure effective and stable operation in complex business scenarios while the business volume changes dynamically, thereby realizing green and low-carbon cloud resource applications and maximizing the utilization of cloud resources and minimizing waste.

[0071] In this embodiment, in S1, n Pods have been allocated to a microservice MS in the K8S cluster in the initial startup state, and the configuration of each Pod is: the CPU upper limit is C max , the memory limit is M max , QPS upper limit is Q max , and the CPU usage of the i-th Pod is C i , the memory usage is M i , QPS utilization rate is Q i ;

[0072] in:

[0073] C i =C iu / C max , C iu is the actual CPU usage of the i-th Pod;

[0074] M i =M iu / M max , M iu is the actual memory usage of the i-th Pod;

[0075] Q i =Q iu / Q max , Qiu is the actual QPS of the i-th Pod.

[0076] The main indicators for determining Pod horizontal scaling include CPU, memory, and QPS. Currently, in K8S clusters, the CPU, memory and other resource usage and QPS of microservice Pods are mainly collected through components such as cAdvisor and metrics server, so the indicator collection process is ignored.

[0077] In this embodiment, in S1, the comprehensive average index T=k c *AVG(C)+k m *AVG(M)+k q *AVG(Q), k c , k m , k q are their respective weight coefficients, and k c +k m +k q =1;

[0078] in:

[0079] AVG(C) is the average CPU usage of all Pods;

[0080] AVG(M) is the average memory usage of all Pods;

[0081] AVG(Q) is the average QPS usage of all Pods.

[0082] Under normal circumstances, memory and QPS may be insufficient due to a surge in business volume, so k m and k q Can be set larger.

[0083] In this embodiment, in S4, in the microservice Pod resource utilization model B, the incremental PID algorithm adjustment satisfies:

[0084] u(k)=K P e(k)+K I Sum(ei)+K D [e(k)-e(k-1)]

[0085] Δu(k)=u(k)-u(k-1)

[0086] Δu(k)=K P [e(k)-e(k-1)]+K I e(k)+K D [e(k)2e(k-1)+e(k-2)]

[0087] Δn(k)=Δu(k)%u scale

[0088] n new =n(k)+Δn(k)

[0089] in:

[0090] K P is the proportional term coefficient, K I is the integral term coefficient, K D is the coefficient of the differential term;

[0091] k is the sampling period, and the value of k should be greater than the cooling time of the HPA expansion and contraction;

[0092] u(k) is the control quantity in the kth sampling period;

[0093] Δu(k) is the control quantity increment in the kth sampling period, which is affected by Δu max With Δu min Upper and lower limit constraints, Δu max With Δu min are the maximum and minimum boundaries of the control quantity increment;

[0094] u scale is a proportional factor set based on experience to adapt the mapping of the control quantity increment Δu(k) to the actual Pod quantity adjustment;

[0095] Δn(k) is the increment of the number of Pods, and u is increased by Δu(k). scale Modulo, it is a constrained integer, subject to Δn max With Δn min Upper and lower limit constraints, Δn max With Δn min The maximum and minimum boundaries of a single adjustment quantity are set to prevent drastic fluctuations in resource usage and ensure smooth expansion and contraction.

[0096] n new is the number of Pods after adjustment, affected by n max With n min Upper and lower limit constraints, n max With n min is the maximum and minimum limit of the number of Pods, and n min Cannot be less than 1.

[0097] In this embodiment, in S4, in the kth sampling cycle, the microservice Pod is horizontally expanded or reduced according to the calculated increment Δn(k) of the number of Pods, and in the (k+1)th sampling cycle, the corresponding variables are updated, and Δn(k+1) in the current sampling cycle is recalculated.

[0098] The mapping relationship Δu→Δn is crucial in this application and needs to be adjusted according to the actual business scenario to ensure the control effect and feasibility of the operation. The key lies in u scale For the specific value determination method, please refer to the next embodiment.

[0099] In this embodiment, in S5, regarding u scale The value of further includes:

[0100] S51: Combined with the expected range of T [T expmin , T expmax ], if the value of T is within the expected range, then Δn(k)=Δu(k)%u scale The value of should be less than 1, that is, the number of Pods will not change. Otherwise, Δn(k)=Δu(k)%u scale The value of should be no less than 1, which means increasing or decreasing the number of Pods;

[0101] S52: Comprehensively consider the distribution of CPU, memory, and QPS usage of the K8S cluster. Here, the comprehensive standard deviation index V is used to measure the distribution of the above indicators. V = d c *SD(C)+d m *SD(M)+d q *SD(Q), d c ,d m ,d q are their respective weight coefficients, and d c +d m +d q =1;

[0102] in:

[0103] SD(C) is the standard deviation of CPU usage of all Pods;

[0104] SD(M) is the standard deviation of memory usage of all Pods;

[0105] SD(Q) is the standard deviation of the QPS usage of all Pods;

[0106] The value ranges of CPU, memory, and QPS are all [0, 1]. It can be deduced that the value ranges of SD(C), SD(M) and SD(Q) are all [0, 1], so the value range of V is also [0, 1].

[0107] S53: Describe the distribution differences of Pod resource utilization based on the value of V:

[0108] The larger the V value, the more uneven the resource utilization distribution in all Pods. In this case, an alarm needs to be sent to the K8S cluster to indicate that the current business volume received by each Pod node is uneven.

[0109] If the V value is close to 0, it means that the resource utilization distribution in all Pods is basically the same. In this case, the average value can better reflect the actual resource utilization.

[0110] S54:u scale There is a positive relationship between the value and V, but due to u scale As a measurement standard, it is not suitable to change frequently. Therefore, based on the value range of V, the interval value method is used to design Vu. scale Segmented mapping relationship:

[0111] u scale =u scale1 , V∈[0,0.1), the distribution is basically uniform;

[0112] u scale =u scale2 , V∈[0.1,0.3), the distribution is generally uniform;

[0113] u scale =u scale3 , V∈[0.3,1], the distribution is extremely uneven;

[0114] This application recommends the above interval settings, which can be adjusted according to actual business scenarios;

[0115] u scale1 、u scale2 、u scale3 The specific value of must be determined based on specific business scenarios and a large number of simulation experiments, and u scale1 scale2 <us cale3 That is, the greater the difference in resource utilization between Pods, the less likely it is that the average value will reflect the resource utilization, and the less likely it is that expansion and contraction operations should be performed. At this time, the K8S cluster management node will be prompted to optimize the business load distribution strategy to ensure that business requests can be evenly distributed to different Pod nodes. The u of this cycle scale The value is used to calculate the number of Pods in the next cycle.

[0116] In this embodiment, the configuration parameter K P , K I , K D and u scale ​Parameters such as these are open and configurable. For different business scenarios, a large number of scenario simulation experiments are needed, combined with existing parameter adjustment technologies, to determine and optimize the parameter values ​​in order to achieve the best control effect, rather than a single set of parameter settings being applicable to all scenarios.

[0117] In this embodiment, in actual business applications, the response time and stability of the system also need to be considered, and strategies such as anti-saturation mechanism and differential first need to be added.

[0118] It should be noted that this application is also applicable to scenarios where scaling decisions are made based on other Pod indicators in the K8S cluster, including but not limited to CPU, memory, and QPS usage.

[0119] Some of the terms in this application are explained as follows:

[0120] K8S: The abbreviation of Kubernetes, is an open source container orchestration management system used to automate the deployment, expansion and management of containerized applications. It was originally developed and open-sourced by Google in 2014 based on its internal container management system Borg. It aims to provide a series of powerful functions for containerized applications, including deployment and operation, resource scheduling, service discovery, load balancing, rolling updates and automatic recovery.

[0121] Microservices: Microservices is a software architecture style that splits large, complex applications into a set of small, independent services. Each service is built around specific business capabilities and can be deployed, run, and expanded independently, and services communicate and collaborate with each other through APIs (application programming interfaces). The microservice architecture emphasizes the design principles of loose coupling and high cohesion, in contrast to the traditional monolithic architecture.

[0122] Pod: It is the most basic workload and scheduling unit in K8S and the smallest unit that can be created and deployed. Pod represents a collection of one or more interrelated containers running in a cluster, which share the same network namespace (and therefore the same IP address and port space), storage volumes, and other operating system-level resources. Pod is designed to accommodate directly related processes required to run applications, which need to be able to interact closely, such as sharing storage or communicating through localhost.

[0123] HPA: Horizontal Pod Autoscaler is a core component in Kubernetes. It is responsible for automatically adjusting the number of Pod replicas based on the resource usage of the application (mainly CPU and memory utilization, or custom indicators), thereby achieving automatic horizontal expansion of the workload.

[0124] Incremental PID: PID stands for Proportional-Integral-Derivative control, which is a closed-loop control method widely used in the field of engineering control. It achieves precise control of physical processes by continuously or discretely calculating and adjusting the control output to minimize system errors. Incremental PID is an improved PID algorithm, suitable for discrete systems. It performs PID control on the increment of the control quantity (i.e., the difference between the control quantity at the current moment and the control quantity at the previous moment) to achieve stable control of the system and optimization of dynamic performance.

[0125] QPS: The abbreviation of "Queries Per Second" is a key indicator for measuring system performance. It indicates the number of query requests that the system can handle within one second, including database queries, HTTP requests, or other forms of data processing requests. The higher the QPS value, the stronger the system's ability to handle requests, and accordingly, the better the system's response speed and throughput. This indicator is often used to evaluate the concurrent processing capabilities of services and the scalability of systems. Especially in high-concurrency scenarios, QPS is an important basis for evaluating whether the system can carry the expected user visits. System designers and operation and maintenance personnel will adjust and optimize the system configuration according to the expected traffic demand to achieve the target QPS value and ensure service stability and user experience.

[0126] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor executes the steps of the above method.

[0127] See also Figure 3 An embodiment of the present invention further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above method.

[0128] An embodiment of the present invention also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-mentioned methods for automatic horizontal expansion and contraction of Pods for complex scenarios.

[0129] It is understandable that the system, device and storage medium provided in the embodiments of the present invention correspond to the method provided in the embodiments of the present invention, and the explanation, examples and beneficial effects of the relevant contents can refer to the corresponding parts in the above methods.

[0130] It should be noted that those of ordinary skill in the art can understand that all or part of the steps implemented in the embodiments of the present invention can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).

[0131] In summary, the present invention designs a method for automatic horizontal expansion and contraction of microservice Pods based on K8S cluster. The main invention points include constructing a microservice state closed-loop feedback control system model based on the main operating status parameters of the microservices in the K8S cluster, using an incremental PID algorithm, and combining actual business scenario requirements and experience to add constraints and variable mappings, so as to achieve automatic, rapid and effective response to the horizontal expansion and contraction requirements of microservice Pods in complex business scenarios in the Internet of Things field when the business request volume changes frequently and the change range is large, ensuring that the main resource parameters of the microservices are stable within a reasonable and safe range, while reducing the consumption of cloud resources and human resources.

[0132] It should be understood that the examples and implementation modes described herein are for illustrative purposes only and are not intended to limit the present invention. Those skilled in the art may make various modifications or changes based on the examples and implementation modes. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. The Pod horizontal automatic expansion and contraction method for complex scenarios is characterized by: The following steps are involved: S1: Establish a microservice Pod resource utilization model A based on the K8S cluster. The microservice Pod resource utilization model A includes the horizontal scaling controller and microservices. The CPU, memory, and QPS usage of the K8S cluster are comprehensively considered by the weight method to obtain the comprehensive average index T of the microservice Pod resource utilization model A. S2: Consider the microservice Pod resource utilization model A as a control system. Let the expected range of T in the control system be [T expmin , T expmax ], take T exp =(T expmin +T expmax ) / 2,T exp As the input of the control system, let the actual detection value of T in the control system be T act , T act As the output of the control system, the error e is obtained, e = T exp -T act ; S3: Based on microservice Pod resource utilization model A, an incremental PID controller is added to establish a microservice Pod resource utilization model B combined with the incremental PID algorithm; S4: The microservice Pod resource utilization model B is regarded as a closed-loop feedback control system. In the kth sampling period, e(k) is used as the input of the closed-loop feedback control system, e(k) = T exp -T act (k), the control amount of the incremental PID controller is u(k). When the microservice faces external business requests or complex business scenarios, the incremental PID controller acts on the horizontal scaling controller. The control amount increment of the incremental PID controller is Δu(k). The horizontal scaling controller adjusts the number of Pods, and the output adjustment amount is mapped to the change in the Pod, that is, the increment in the number of Pods Δn(k), and the mapping relationship between Δu(k) and Δn(k) is obtained: Δn(k)=Δu(k)%u scale ; S5: After adjustment by the incremental PID algorithm, the CPU, memory, and QPS usage of the K8S cluster are integrated through the weight method to obtain the comprehensive standard deviation index V of the microservice Pod resource utilization model B. According to the value of V, the interval value method is used to calculate u scale The value of is set in stages. scale The value is used to calculate the number of Pods in the next cycle, reflecting the resource utilization distribution of the Pods and verifying the control effect of microservice Pod resource utilization model B.

2. The method for automatic horizontal expansion and contraction of Pods for complex scenarios as described in claim 1 is characterized in that: In S1, n Pods have been allocated to a microservice MS in the K8S cluster at the initial startup state, and the configuration of each Pod is: the CPU upper limit is C max , the memory limit is M max , QPS upper limit is Q max , and the CPU usage of the i-th Pod is C i , the memory usage is M i , QPS utilization rate is Q i ; in: C i =C iu / C max , C iu is the actual CPU usage of the i-th Pod; M i =M iu / M max , M iu is the actual memory usage of the i-th Pod; Q i =Q iu / Q max , Q iu is the actual QPS of the i-th Pod.

3. The method for automatic horizontal expansion and contraction of Pods for complex scenarios as described in claim 1 is characterized in that: In S1, the comprehensive average index T = k c *AVG(C)+k m *AVG(M)+k q *AVG(Q), k c , k m , k q are their respective weight coefficients, and k c +k m +k q =1; in: AVG(C) is the average CPU usage of all Pods; AVG(M) is the average memory usage of all Pods; AVG(Q) is the average QPS usage of all Pods.

4. The method for automatic horizontal expansion and contraction of Pods for complex scenarios as claimed in claim 1, characterized in that: In S4, in the microservice Pod resource utilization model B, the incremental PID algorithm adjustment satisfies: u(k)=K P e(k)+K I Sum(e)+K D [e(k)–e(k–1)] Δu(k)=u(k)-u(k-1) Δu(k)=K P [e(k)-e(k-1)]+K I e(k)+K D [e(k)2e(k-1)+e(k-2)] Δn(k)=Δu(k)%u scale n new =n(k)+Δn(k) in: K P is the proportional term coefficient, K I is the integral term coefficient, K D is the coefficient of the differential term; k is the sampling period, and the value of k should be greater than the cooling time of the HPA expansion and contraction; u(k) is the control quantity in the kth sampling period; Δu(k) is the control quantity increment in the kth sampling period, which is affected by Δu max With Δu min Upper and lower limit constraints, Δu max With Δu min are the maximum and minimum boundaries of the control quantity increment; u scale is a proportional factor set based on experience to adapt the mapping of the control quantity increment Δu(k) to the actual Pod quantity adjustment; Δn(k) is the increment of the number of Pods, and u is increased by Δu(k). scale Modulo, it is a constrained integer, subject to Δn max With Δn min Upper and lower limit constraints, Δn max With Δn min The maximum and minimum boundaries of a single adjustment quantity are set to prevent drastic fluctuations in resource usage and ensure smooth expansion and contraction. n new is the number of Pods after adjustment, affected by n max With n min Upper and lower limit constraints, n max With n min is the maximum and minimum limit of the number of Pods, and n min Cannot be less than 1.

5. The method for automatic horizontal expansion and contraction of Pods for complex scenarios as described in claim 1 is characterized in that: In S4, in the kth sampling cycle, according to the calculated increment Δn(k) of the number of Pods, the microservice Pod is horizontally expanded or reduced, and in the (k+1)th sampling cycle, the corresponding variables are updated, and Δn(k+1) in the current sampling cycle is recalculated.

6. The method for automatic horizontal expansion and contraction of Pods for complex scenarios as claimed in claim 1, characterized in that: In S5, about u scale The value of further includes: S51: Combined with the expected range of T [T expmin , T expmax ], if the value of T is within the expected range, then Δn(k)=Δu(k)%u scale The value of should be less than 1, that is, the number of Pods will not change. Otherwise, Δn(k)=Δu(k)%u scale The value should be no less than 1, which means increasing or decreasing the number of Pods; S52: Comprehensively consider the distribution of CPU, memory, and QPS usage of the K8S cluster. Here, the comprehensive standard deviation index V is used to measure the distribution of the above indicators. V = d c *SD(C)+d m *SD(M)+d q *SD(Q), d c ,d m ,d q are their respective weight coefficients, and d c +d m +d q =1; in: SD(C) is the standard deviation of CPU usage of all Pods; SD(M) is the standard deviation of memory usage of all Pods; SD(Q) is the standard deviation of the QPS usage of all Pods; The value ranges of CPU, memory, and QPS are all [0, 1]. It can be deduced that the value ranges of SD(C), SD(M) and SD(Q) are all [0, 1], so the value range of V is also [0, 1]. S53: Describe the distribution differences of Pod resource utilization based on the value of V: The larger the V value, the more uneven the resource utilization distribution in all Pods. In this case, an alarm needs to be sent to the K8S cluster to indicate that the current business volume received by each Pod node is uneven. If the V value is close to 0, it means that the resource utilization distribution in all Pods is basically the same. In this case, the average value can better reflect the actual resource utilization. S54:u scale There is a positive relationship between the value and V, and the interval value method is used to design Vu scale Segmented mapping relationship: u scale =u scale1 , V∈[0,0.1), the distribution is basically uniform; u scale =u scale2 , V∈[0.1,0.3), the distribution is generally uniform; u scale =u scale3 , V∈[0.3,1], the distribution is extremely uneven; u scale1 、u scale2 、u scale3 The specific value of must be determined based on specific business scenarios and a large number of simulation experiments, and u scale1 scale2 <us cale3 That is, the greater the difference in resource utilization between Pods, the less likely it is that the average value will reflect the resource utilization, and the less likely it is that expansion and contraction operations should be performed. At this time, the K8S cluster management node will be prompted to optimize the business load distribution strategy to ensure that business requests can be evenly distributed to different Pod nodes. The u of this cycle scale The value is used to calculate the number of Pods in the next cycle.​ 7. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 6.