Resource adjustment method and device
By generating adversarial networks to train the resource usage status data of the Kubernetes platform, we can predict resource requirements for future cycles and automatically adjust them based on the number of Pods. This solves the problem of resource control relying on human experience in existing technologies and enables flexible, proactive control and efficient utilization of resources.
Patent Information
- Application Number
- CN202111532704.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-15
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-12-15
AI Technical Summary
The resource control method of the existing Kubernetes platform relies on human experience, lacks flexibility and initiative, and leads to resource waste and excessive business.
By generating adversarial networks to train the resource usage status data of the Kubernetes platform, resource requirements for future cycles are predicted and automatically adjusted based on the number of Pods.
It achieves flexible and proactive regulation of Kubernetes platform resources, improves resource utilization, and avoids resource waste and excessive business.
Smart Images

Figure CN114281474B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a resource adjustment method and apparatus. Background Art
[0002] Kubernetes (abbreviated as K8S) is an open-source, scalable container automation operations platform designed to provide automated deployment, scaling, and database management system operations across clusters of data center containerized applications (referred to as applications). As businesses grow, the scale of applications on various K8S platforms continues to expand. Applications' demand for platform resources fluctuates dynamically with factors such as user size, usage habits, and time. To address the conflict between the relatively limited K8S platform resources and the dynamic resource demands of each application, and to maximize K8S platform resource utilization, precise application scaling has become a pressing issue. Currently, K8S natively provides automatic scaling, which primarily relies on monitoring application resource usage and manually setting thresholds and parameters. This approach not only relies on administrators' observational experience to control applications, resulting in low flexibility, but also passively responds to resource usage changes, lacking the agility of proactive adjustments. This can easily lead to both resource waste and business overload.
[0003] Therefore, there is an urgent need for a flexible and proactive solution to reasonably regulate resources on the K8S platform. Summary of the Invention
[0004] This application provides a resource adjustment method and device for flexibly and proactively adjusting resources on the K8S platform.
[0005] In a first aspect, an embodiment of the present application provides a resource adjustment method applicable to various applications in a K8S platform, wherein the K8S platform includes multiple Pods; the method includes: obtaining historical resource usage status data of a first application in the K8S platform in N-1 consecutive cycles through a monitoring tool; the first application is any application among the applications in the K8S platform, and N is a positive integer greater than 1; the N-1 historical resource usage status data of the first application are input into a first network, and the predicted resource usage status data of the first application in the Nth cycle are obtained through the first network; the first network is obtained by adversarial training in conjunction with the second network; the predicted resource usage status data is input into a third network, and the number of standby Pods of the first application in the Nth cycle is obtained through the third network; the third network is trained based on the resource usage status data of multiple applications in the K8S platform and the corresponding number of Pods.
[0006] In the above scheme, by using a monitoring tool to obtain the historical resource usage status data of any application (i.e., the first application) on the K8S platform in N-1 consecutive cycles, the N-1 historical resource usage status data is then input into the first network. Since the first network is obtained by adversarial training in conjunction with the second network, the first network's N-1 historical resource usage status data on the first application can output the predicted resource usage status data of the first application in the Nth cycle. Finally, by inputting the predicted resource usage status data into the third network, the number of Pods in the K8S platform required by the first application in the Nth cycle (i.e., the number of standby Pods) can be quickly output. Since the prediction of the resources in the K8S platform required by the first application in the Nth cycle has been completed before the Nth cycle of the first application actually arrives, when the Nth cycle of the first application arrives, the number of Pods required by the first application in the K8S platform is adjusted to the number of standby Pods, thereby achieving the goal of flexibly and proactively regulating the resources on the K8S platform.
[0007] In one possible implementation method, the first network and the second network are trained in the following manner, including: for G applications in the K8S platform, obtaining the real resource usage status data of the G applications in N test cycles; G is a positive integer greater than 1; training the initial generation network based on the real resource usage status data of the G applications in the first N-1 test cycles to obtain the predicted resource usage status data of the G applications in the Nth test cycle, and each first loss value; training the initial discrimination network based on the real resource usage status data of the G applications in the Nth test cycle and the predicted resource usage status data in the Nth test cycle to obtain each second loss value; the initial discrimination network is used to distinguish the authenticity of the resource usage status data; determining the comprehensive loss value based on the first loss values and the second loss values; if the comprehensive loss value does not meet the first setting requirement, continuing to train the new generation network and the discrimination network; when the comprehensive loss value under the P-generation generation network and the P-generation discrimination network meets the first setting requirement, determining the P-generation generation network as the first network and the P-generation discrimination network as the second network.
[0008] In the above scheme, the generation process of the first network and the second network is described, including obtaining the real resource usage status data of G applications in the K8S platform in N test cycles, and then training the initial generation network based on the real resource usage status data of the G applications in the first N-1 test cycles, and obtaining the predicted resource usage status data and each first loss value of the G applications in the Nth test cycle, and then training the initial discriminant network through the real resource usage status data of the G applications in the Nth test cycle and the predicted resource usage status data in the Nth test cycle. The second loss value of the initial discriminant network under the G applications can be obtained respectively. Finally, by judging whether the comprehensive loss value of the initial generation network and the initial discriminant network (wherein the comprehensive loss value is obtained based on each first loss value and each second loss value) meets the first set requirement, if it is determined that the former does not meet the latter, then after adjusting the parameters of the initial generation network and / or the initial discriminant network, continue a new round of adversarial training of the generation-discriminant network until the comprehensive loss value of the P-generation generation network and the P-generation discriminant network meets the first set requirement, then the P-generation generation network can be used as the first network and the P-generation discriminant network as the second network. In this method, the generation-discriminant network is adversarially trained based on the real resource usage status data of multiple applications in the K8S platform in N test cycles in advance. When the trained P-generation generation network and P-generation discriminant network meet the set requirements, the P-generation generation network can be applied to the accurate prediction of the resource usage status data of each application in the K8S platform, thereby realizing the generalization of the solution when used.
[0009] In one possible implementation method, the initial generation network is trained based on the real resource usage status data of the G applications in the first N-1 test cycles to obtain the predicted resource usage status data of the G applications in the Nth test cycle, as well as each first loss value, including: for any application among the G applications, the real resource usage status data of the application in the first N-1 test cycles and the corresponding random sequence are input into the initial generation network, thereby obtaining the predicted resource usage status data of the application in the Nth test cycle, and generating the first loss value accordingly; the training of the initial generation network based on the real resource usage status data of the G applications in the Nth test cycle and the corresponding random sequence are input into the initial generation network, thereby obtaining the predicted resource usage status data of the application in the Nth test cycle, and generating the first loss value accordingly; The method comprises the following steps: training an initial discriminant network using the real resource usage status data of each test cycle and the predicted resource usage status data of the Nth test cycle to obtain each second loss value, including: for any application among the G applications, respectively forming a first sequence with the real resource usage status data of the application in the first N-1 test cycles and the real resource usage status data of the application in the Nth test cycle, and forming a second sequence with the predicted resource usage status data of the application in the Nth test cycle, and inputting the first sequence and the second sequence into the initial discriminant network for training to obtain a second loss value.
[0010] The above scheme describes the process of training a generation network (such as an initial generation network) and a discrimination network (such as an initial discrimination network) by taking one of the G applications in the K8S platform as an example, including inputting the real resource usage status data of the application in the first N-1 test cycles and the corresponding random sequence into the initial generation network, so as to obtain the predicted resource usage status data of the application in the Nth test cycle, and then inputting the real resource usage status data of the N test cycles as a sequence, and the real resource usage status data of the N-1 test cycles and the predicted resource usage status data of the Nth test cycle as another sequence into the initial discrimination network, so as to obtain the recognition results of the initial discrimination network for the two sequences. If the initial discrimination network recognizes the sequence containing the predicted resource usage status data as true, it means that the initial generation network is effective in generating the predicted resource usage status data and has successfully deceived itself (self refers to the initial discrimination network); and If the initial discriminant network identifies the sequence containing the predicted resource usage status data as false, it means that the effect of the initial generation network for generating the predicted resource usage status data is average or even not very good, because it has not been able to deceive itself (self refers to the initial discriminant network). At the same time, it means that the effect of the initial discriminant network for identifying the true and the false is quite good. Based on the mutual restraint and mutual influence characteristics between the initial generation network and the initial discriminant network, by calculating the comprehensive loss value of the initial generation network and the initial discriminant network, and comparing the calculated comprehensive loss value with the set requirements, it can be known whether the initial generation network and the initial discriminant network can be applied; if not, it is necessary to adjust the parameters of the initial generation network and / or the initial discriminant network, and retrain a new round of generation network and discriminant network until the comprehensive loss value between the generation network and the discriminant network trained in a certain generation meets the set requirements, which means that the current generation network can accurately predict the resource status usage data and can be put into use.
[0011] In one possible implementation method, the third network is trained in the following manner, including: for any application in the K8S platform, obtaining the first maximum external access volume and the first resource usage of the application under the set first Pod number through the monitoring tool; taking the first maximum external access volume and the first resource usage of each application under the first Pod number as input, and the first Pod number as the label value, to train the initial neural network to obtain the loss value of the initial neural network; if it is determined that the difference between the loss value of the Q-generation neural network and the loss value of the Q-1 generation neural network meets the second setting requirement, then the Q-generation neural network is determined to be the third network.
[0012] The above scheme describes the generation process of the third network, including obtaining the maximum external access and resource usage of an application under the set number of Pods used by the application in the K8S platform, and then training the initial neural network based on the maximum external access and resource usage of each application, and using the corresponding number of Pods as the label value. Then, by adjusting the parameters of the initial neural network, continue to train the same batch of data sets until the difference between the loss values of two adjacent rounds of neural networks (referring to the Q round and the Q-1 round) meets the set requirements (that is, the losses of two adjacent rounds are almost the same), then it can be determined that the Q-generation neural network is the second network. In this method, when the resources required by the application for the K8S platform have been obtained (i.e., the predicted resource usage status data), by inputting it into the third network, the third network will be able to accurately output the number of Pods occupied by the application on the K8S platform (i.e., the number of standby Pods), so that before the time really comes, the number of Pods in the K8S platform that the application needs to occupy can be adjusted to the number of standby Pods, which will satisfy the application to use the resources of the K8S platform in an optimal state, thereby achieving the purpose of automatic expansion and contraction of the K8S platform.
[0013] In one possible implementation method, obtaining the first maximum external access volume and the first resource usage of the application under the set first Pod number through the monitoring tool includes: setting the Pod number corresponding to the application to the first Pod number; sending a test message to the application under the first Pod number; if it is determined that the loss rate of the test message exceeds the set threshold, determining the current number of test messages as the first maximum external access volume of the application under the first Pod number, and obtaining the CPU usage and memory usage of the application as the first resource usage through the monitoring tool.
[0014] In the above scheme, for the process of obtaining the third network by training the neural network, the data set for training the neural network can be obtained by stress testing, including for an application, by fixing the number of Pods used by the application, and then sending test messages to the application based on the set Pods. If it is determined that the loss rate of the test message exceeds the set threshold, the current number of test messages can be used as the maximum external access volume of the application under the set Pod. At the same time, the CPU usage and memory usage of the application can be obtained through monitoring tools and used as resource usage. Based on the stress testing method, as many data sets as possible for training the neural network can be obtained, so that the training of the neural network can be accurate, that is, the subsequent third network can accurately determine the number of Pods required for the application in the K8S platform based on the predicted resource usage status data. On the other hand, because the data set as much as possible for training the neural network includes stress testing data of each application, the trained third network will have generalization capabilities.
[0015] In one possible implementation method, for any one of the G applications, the real resource usage status data of the application in the first N-1 test cycles and the corresponding random sequence are input into the initial generation network, thereby obtaining the predicted resource usage status data of the application in the Nth test cycle, including: for any one of the G applications, the real resource usage status data of the application in the first N-1 test cycles and the corresponding random sequence are input into the initial generation network; and the historical time series features of the N-1 real resource usage status data are extracted through the RNN unit and the fully connected network in the initial generation network, thereby obtaining the predicted resource usage status data of the application in the Nth test cycle.
[0016] In the above scheme, by inputting the resource usage status data in the form of a sequence into the discriminant network for training, it can be ensured that the predicted value of the resource usage status data at the time to be tested will be relatively accurate, because the network has already taken into account the previous and next dependencies of the resource usage status data during the training process.
[0017] In one possible implementation method, the number of Pods used by the first application in the Nth cycle is adjusted based on the number of standby Pods; actual resource usage status data of the first application in the Nth cycle is obtained through the monitoring tool; and whether to update the first network is determined based on the second network's judgment of the predicted resource usage status data based on the Nth cycle and the actual resource usage status data in the Nth cycle.
[0018] In the above scheme, when the first network is applied to the prediction of the resource usage status data of the first application in the Nth cycle to obtain the predicted resource usage status data, and the predicted resource usage status data is processed by the third network, the number of Pods in the K8S platform required by the first application in the Nth cycle (i.e., the number of standby Pods) can be obtained. Then, by adjusting the number of Pods required by the first application to the number of standby Pods before the Nth cycle actually arrives, the first application can be satisfied with running in the K8S platform with a better resource occupancy state in the Nth cycle; wherein, when the first application is running in the Nth cycle, the real resource usage status data of the first application in the Nth cycle can also be monitored at the same time, and then the second network judges the real resource usage status data and the predicted resource usage status data of the first application in the Nth cycle to determine whether the first network needs to be updated. This method can achieve the goal of continuing to be optimized during the process of the first network being put into use, so as to better adapt to the status of the application in the K8S platform using resources in the K8S platform.
[0019] In the second aspect, an embodiment of the present application provides a resource adjustment device, which is applicable to various applications in the K8S platform, and the K8S platform includes multiple Pods; the device includes: a historical resource usage status data acquisition unit, which is used to obtain the historical resource usage status data of the first application in the K8S platform in N-1 consecutive cycles through a monitoring tool; the first application is any application among the various applications in the K8S platform, and N is a positive integer greater than 1; a predicted resource usage status data determination unit, which is used to input the N-1 historical resource usage status data of the first application into a first network, and obtain the predicted resource usage status data of the first application in the Nth cycle through the first network; the first network is obtained by adversarial training in conjunction with the second network; a standby resource determination unit, which is used to input the predicted resource usage status data into a third network, and obtain the number of standby Pods of the first application in the Nth cycle through the third network; the third network is trained based on the resource usage status data and corresponding Pod numbers of multiple applications in the K8S platform.
[0020] In a third aspect, an embodiment of the present application provides a computing device, including:
[0021] a memory for storing program instructions;
[0022] The processor is used to call the program instructions stored in the memory and execute any implementation method of the first aspect according to the obtained program.
[0023] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute any implementation method of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0025] Figure 1 A schematic diagram of a resource adjustment method provided in an embodiment of the present application;
[0026] Figure 2 A schematic diagram of a resource adjustment device provided in an embodiment of the present application;
[0027] Figure 3 A schematic diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] To make the objectives, technical solutions, and advantages of this application more clear, this application will be further described in detail below with reference to the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this application.
[0029] As their businesses continue to grow and expand, some companies have begun adopting the Kubernetes platform to deploy individual applications. The Kubernetes platform uses pods as the smallest deployment unit for applications. During operation, applications deployed on the Kubernetes platform's resource demands dynamically change with the size of the user base, usage habits, and time. Currently, the primary method for addressing this is through the native autoscaling feature of Kubernetes, which monitors application resource usage and manually sets thresholds and parameters to scale applications up and down. This resource adjustment method not only requires administrators to have rigorous observation and experience in controlling applications, but also passively responds to changes in resource usage, lacking the agility of proactive adjustments. This can lead to resource waste and excessive workloads.
[0030] In view of the above technical problems, the embodiment of the present application provides a resource adjustment method applicable to various applications in the K8S platform, which includes multiple Pods. Figure 1FIG. 1 is a schematic diagram of a resource adjustment method provided in an embodiment of the present application, the method comprising the following steps:
[0031] Step 101: Obtain historical resource usage status data of the first application in the K8S platform in N-1 consecutive cycles through a monitoring tool.
[0032] Among them, the first application is any application among the applications in the K8S platform, and N is a positive integer greater than 1.
[0033] In this step, the first application in the K8S platform may receive external access requests during operation, and then use the corresponding CPU, memory, etc. to respond to the external requests. Therefore, before adjusting the number of Pods in the K8S platform required by the first application in the Nth cycle, the monitoring tool can be used to obtain the historical resource usage status data of the first application in N-1 consecutive cycles. Then, by processing the obtained N-1 historical resource usage status data, the number of Pods in the K8S platform required by the first application in the Nth cycle can be obtained. Among them, the historical resource usage status data may include at least two items: the historical external access request volume and resource usage; further, the resource usage may include at least two items: CPU usage and memory usage.
[0034] Step 102: input N-1 historical resource usage status data of the first application into a first network, and obtain predicted resource usage status data of the first application in the Nth cycle through the first network.
[0035] The first network is obtained by performing adversarial training in conjunction with the second network.
[0036] In this step, after obtaining the historical resource usage status data of the first application over N-1 consecutive cycles, the N-1 historical resource usage status data can be input into the first network to obtain the predicted resource usage status data of the first application in the Nth cycle through the first network. Since the first network is obtained through adversarial training in conjunction with the second network, the first network obtained through adversarial training can be used to accurately predict the resource usage status data of the application in the Nth cycle based on the historical resource usage status data of the application over N-1 consecutive cycles, thereby obtaining the predicted resource usage status data.
[0037] Step 103: Input the predicted resource usage status data into a third network, and obtain the number of standby Pods of the first application in the Nth cycle through the third network.
[0038] Among them, the third network is trained based on the resource usage status data of multiple applications in the K8S platform and the corresponding Pod quantity.
[0039] In this step, after obtaining the accurate predicted value of the resource usage status data of the first application in the Nth cycle, that is, the predicted resource usage status data, the predicted resource usage status data can be input into the third network, so that the third network processes the predicted resource usage status data, and the amount of resources in the K8S platform that the first application needs to use in the Nth cycle can be output to the outside, that is, the third network can output the number of standby Pods, and then before the first application is about to enter the Nth cycle, the number of Pods required by the first application in the K8S platform can be adjusted to the number of standby Pods output by the third network, so that the first application can use the resources in the K8S platform well and reasonably in the Nth cycle to respond to external access requests. In this way, since the third network is trained based on the resource usage status data and corresponding Pod numbers of multiple applications in the K8S platform, when the third network is used to calculate the number of resources in the K8S platform required by the first application in the Nth cycle, that is, the number of standby Pods, the calculated number of standby Pods can be objective and reasonable.
[0040] In the above scheme, by using a monitoring tool to obtain the historical resource usage status data of any application (i.e., the first application) on the K8S platform in N-1 consecutive cycles, the N-1 historical resource usage status data is then input into the first network. Since the first network is obtained by adversarial training in conjunction with the second network, the first network's N-1 historical resource usage status data on the first application can output the predicted resource usage status data of the first application in the Nth cycle. Finally, by inputting the predicted resource usage status data into the third network, the number of Pods in the K8S platform required by the first application in the Nth cycle (i.e., the number of standby Pods) can be quickly output. Since the prediction of the resources in the K8S platform required by the first application in the Nth cycle has been completed before the Nth cycle of the first application actually arrives, when the Nth cycle of the first application arrives, the number of Pods required by the first application in the K8S platform is adjusted to the number of standby Pods, thereby achieving the goal of flexibly and proactively regulating the resources on the K8S platform.
[0041] The following will explain the above steps in detail with examples.
[0042] In order to achieve the goal of automatically and reasonably scaling applications in the K8S platform, the embodiment of the present application proposes to train a model based on data on the use of resources in the K8S platform by various applications in the K8S platform in historical stages (i.e., resource usage status data). When the trained model meets the requirements, the trained model can be used to accurately predict the resources in the K8S platform that any application in the K8S platform will need to use during actual use. Among them, regarding the selection of the model, the embodiment of the present application proposes to use a generative adversarial network (GAN) solution to predict the resources in the K8S platform that the application needs to use. Therefore, the process of training the generative adversarial network required for this application will be described in detail below.
[0043] In one implementation of the above-mentioned step 102, the first network and the second network are trained in the following manner, including: for G applications in the K8S platform, obtaining the real resource usage status data of the G applications in N test cycles; G is a positive integer greater than 1; training the initial generation network based on the real resource usage status data of the G applications in the first N-1 test cycles to obtain the predicted resource usage status data of the G applications in the Nth test cycle, and each first loss value; training the initial discrimination network based on the real resource usage status data of the G applications in the Nth test cycle and the predicted resource usage status data in the Nth test cycle to obtain each second loss value; the initial discrimination network is used to distinguish the authenticity of the resource usage status data; determining the comprehensive loss value based on the first loss values and the second loss values; if the comprehensive loss value does not meet the first set requirement, continuing to train the new generation network and the discrimination network; when the comprehensive loss values under the P-generation generation network and the P-generation discrimination network meet the first set requirement, determining the P-generation generation network as the first network and the P-generation discrimination network as the second network.
[0044] For example, with the vigorous development of business, technicians can deploy multiple applications in the K8S platform to meet the needs of business expansion. Therefore, in the scenario where the K8S platform includes multiple applications, in order to achieve the goal of enabling the trained generation network to be used by multiple applications in the K8S platform, that is, to make the trained generation network have generalization capabilities, the generation network can be trained based on the historical resource usage status data of multiple applications in the K8S platform during training. For example, in the embodiment of the present application, the historical resource usage status data of G applications in the K8S platform is used to train the network, and the training process is as follows:
[0045] First, the real resource usage status data of G applications in the K8S platform in N test cycles can be obtained. For example, for any application among the G applications (for the convenience of description, let the application be application A), application A can be allowed to perform business services for a period of time, and the monitoring tool can record the external access request volume and resource usage of application A. In this embodiment of the application, the external access request volume and resource usage recorded for a certain application at the same time are defined as a resource usage status data. In this embodiment of the application, the resource usage status data of application A at time t can be represented by vector The resource usage status data of application A in the window of size c before time t can be expressed as At this time, the real resource usage status data obtained for application A in N (N=c+1) test cycles are:
[0046] Next, the initial generative network can be trained using the actual resource usage status data of G applications in the previous N-1 test cycles. For example, following the previous example, the previous N-1 resource usage status data of application A (i.e., the resource usage status data of application A in a window of size c before time t) can be trained using the actual resource usage status data of G applications in the previous N-1 test cycles. The sequence formed and a random sequence are input into the initial generation network; after inputting into the initial generation network, the RNN unit and the fully connected network in the initial generation network can be used to extract the historical time series features in the sequence where the resource usage status data is located, thereby generating the predicted value of the resource usage status data of application A at time t ( The initial generative network's loss for application A, i.e., predicted resource usage status data, is calculated. This loss is the first loss. Following the same processing logic as for application A, after the initial generative network completes training on a sequence consisting of N-1 resource usage status data corresponding to each of the G applications, the total loss of the initial generative network during this training process can be obtained, denoted as loss1. One possible implementation is to calculate loss1 as the sum of the first loss values corresponding to each of the G applications.
[0047] Next, the initial discriminant network can be trained based on the real resource usage status data of G applications in N test cycles and the predicted resource usage status data in the Nth test cycle. Optionally, for any application among the G applications, the real resource usage status data of the application in the first N-1 test cycles and the real resource usage status data of the application in the Nth test cycle form a first sequence, and the real resource usage status data of the application in the Nth test cycle form a second sequence, and the first sequence and the second sequence are input into the initial discriminant network for training to obtain a second loss value. For example, following the above example, the real resource usage status data of application A in N test cycles can be trained. Constitute the first sequence And the actual resource usage status data of the first N-1 test cycles of application A and the predicted value of resource usage status data of application A in the Nth test cycle Constitute the second sequence The two sequences are input into the initial discriminant network. The initial discriminant network is used to identify the predicted value of the resource usage status data of application A in the Nth test cycle. The authenticity of the network includes: if the initial discriminant network identifies the sequence containing the predicted resource usage status data as true, then the initial generation network is quite effective in generating the predicted resource usage status data and has successfully deceived itself (self refers to the initial discriminant network); if the initial discriminant network identifies the sequence containing the predicted resource usage status data as false, then the initial generation network is generally effective or even not very good in generating the predicted resource usage status data because it has not been able to deceive itself (self refers to the initial discriminant network), and at the same time, the initial discriminant network is quite effective in distinguishing authenticity. After training the initial discriminant network based on the first and second sequences, the loss value of the initial discriminant network under application A can be obtained, i.e., the second loss value. According to the same processing logic as application A, after the initial discriminant network completes training on the first and second sequences corresponding to G applications, the total loss value of the initial discriminant network during this training process can be obtained, which is recorded as loss2; one possible implementation method is that loss2 is the accumulation of the second loss values corresponding to the G applications.
[0048] Then, based on each first loss value and each second loss value, a comprehensive loss value can be determined. One possible implementation method is that the comprehensive loss value can be the accumulation of each first loss value and each second loss value, that is, the comprehensive loss value can be expressed as loss1+loss2. After obtaining the comprehensive loss value loss1+loss2, the comprehensive loss value can be compared with the preset first setting requirement, wherein the first setting requirement is set by technical personnel in this field according to actual training requirements. If it is determined that the comprehensive loss value does not meet the first setting requirement, it means that the initial generation network cannot yet be used to predict the data of the application in the K8S platform using the platform resources, so it is necessary to continue training the new generation of generation network and discrimination network. Among them, after adjusting the parameters of the initial generation network and / or the initial discriminant network, the second-generation generation network can be trained based on the data set used to train the initial generation network, and the second-generation discriminant network can be trained based on the data set used to train the initial discriminant network. Then, the comprehensive loss value of the second-generation generation network and the second-generation discriminant network is calculated and compared with the first set requirement. If the comprehensive loss value still does not meet the first set requirement, the third-generation generation network and the discriminant network are trained. This cycle continues until the comprehensive loss value of the P-generation generation network and the P-generation discriminant network meets the first set requirement. Then, the P-generation generation network can be determined as the first network and the P-generation discriminant network can be determined as the second network. That is, the data on the use of platform resources by applications in the K8S platform can be predicted based on the P-generation generation network (i.e., predicted resource usage status data).
[0049] In the above solution, the superior model optimization capabilities and long-term iterative characteristics of the generative adversarial network are used to achieve accurate and real-time prediction of application resource demand patterns, thereby promoting the platform to quickly and reasonably adjust application resource allocation, avoiding the difficulty of manually adjusting and maintaining the decision-making mechanism.
[0050] The above describes how the present application trains the first network for predicting the data of platform resource usage by applications in the K8S platform. Therefore, through the first network, the embodiment of the present application can accurately predict the resource usage status data of any application in the K8S platform in the Nth cycle. After the first network completes the accurate prediction of the resource usage status data of the application in the Nth cycle, the embodiment of the present application proposes that the resources required to occupy the K8S platform for the predicted resource usage status data of the application in the Nth cycle can be determined based on the third network, where the resources in the K8S platform can be quantified by the number of Pods. If the resources occupied by the application in the K8S platform are relatively small, the number of Pods in the K8S platform required to be used is also relatively small. If the resources occupied by the application in the K8S platform are relatively large, the number of Pods in the K8S platform required to be used is also relatively large. Specifically, the relationship between the resource usage status data and the number of Pods can be determined by the third network. The reason why the third network can be used to determine the relationship between the resource usage status data and the number of Pods is mainly because the third network is obtained through supervised learning based on the relationship between historical resource usage status data and the corresponding number of Pods. The generation process of the third network will be described in detail below.
[0051] First, a data set for training the third network can be obtained. In the embodiment of the present application, the data set can be obtained by performing stress testing on the application, including: setting the number of Pods corresponding to the application to a first number of Pods; sending a test message to the application under the first number of Pods; if it is determined that the loss rate of the test message exceeds a set threshold, determining the current number of test messages as the first maximum external access volume of the application under the first number of Pods, and obtaining the CPU usage and memory usage of the application as the first resource usage through the monitoring tool.
[0052] For example, in an embodiment of the present application, a stress testing tool (e.g., a possible stress testing tool is Fortio) and the application to be tested can be deployed on two working nodes respectively. For example, the initial state can be set to make the number of Pod copies of the application to be tested 1. Under the control of the master node script, the stress testing tool gradually increases the access frequency of the application to be tested in each round of experiments, that is, continuously increases the number of test messages sent to the application to be tested until the loss rate of the test messages is higher than the set standard. The access frequency at this time (i.e., the current number of test messages) is the load limit under the current number of Pod copies, that is, the maximum external access volume of the application to be tested under 1 Pod; at the same time, the resource usage of the application to be tested under the load limit, including CPU usage and memory usage, can be sampled through a monitoring tool (e.g., a possible stress testing tool is Prometheus), that is, the resource usage of the application to be tested under 1 Pod is obtained.
[0053] It is explained that under a set number of Pod copies, multiple applications in the K8S platform can be used as a test application, which can improve the generalization ability of the neural network; at the same time, under the set number of Pod copies, multiple stress tests can be performed on the same test application, which can greatly expand the data set used to train the initial neural network.
[0054] Then, the first maximum external access volume and the first resource usage can be input into the initial neural network, and the first Pod can be used as the label value to perform supervised training on the initial neural network. Since supervised training is an existing technology, it will not be described here. After completing the training of the initial neural network, the loss value of the initial neural network during this training process can be obtained. If it is determined that the loss value of the initial neural network does not meet the second setting requirement, then after adjusting the parameters of the initial neural network, the second generation neural network after parameter adjustment can be supervised trained based on the data set for training the initial neural network, and the loss value of the second generation initial neural network can be determined, and the difference between the loss value of the second generation neural network and the loss value of the initial neural network can be determined. If it does not meet the second setting requirement, then after adjusting the parameters of the second generation neural network, the third generation neural network after parameter adjustment can be supervised trained again based on the data set for training the initial neural network. The training continues until the difference between the loss value of the Q generation neural network and the loss value of the Q-1 generation neural network meets the second setting requirement, and then the Q generation neural network can be determined as the third network. In other words, the number of Pods in the K8S platform occupied by the resource usage status data of the application in the Nth cycle predicted by the first network can be accurately determined based on the third network.
[0055] The above solution proposes a neural network-based application resource demand analysis model, known as the third network. This network model establishes a reasonable mapping between application access volume and platform resource usage, and the number of pods. This network model automatically determines platform scaling decisions, eliminating the risk of errors associated with manually defining scaling behaviors.
[0056] The above describes the generation process of the third network. Through the generated third network, after the first network predicts the resource usage status data of the application in the Nth cycle, the number of Pods in the K8S platform occupied by the resource status data can be accurately predicted based on the third network. That is, the number of Pods used by the first application in the K8S platform in the Nth cycle can be obtained, that is, the number of standby Pods can be obtained. Therefore, before the Nth cycle really arrives, the number of Pods required by the first application in the K8S platform can be adjusted to the number of standby Pods. After that, the monitoring tool can be used to obtain the number of Pods used by the first application in the Nth cycle. The real resource usage status data in the Nth cycle is obtained. Since the predicted resource usage status data of the first application in the Nth cycle and the real resource usage status data of the first application in the Nth cycle are available, a second sequence and a first sequence can be respectively formed based on the two and the real resource usage status data of the first application in the previous N-1 cycles, and input into the second network for judgment to determine whether to adjust the second network. This method ensures that during the actual use of the first network, there is still an operation to determine and adjust the accuracy of the first network (if necessary), thereby ensuring the high accuracy of the first network during actual use.
[0057] Based on the same concept, the embodiment of the present application provides a resource adjustment device suitable for various applications in the K8S platform, wherein the K8S platform includes multiple Pods; Figure 2 , which is a schematic diagram of a resource adjustment device provided by an embodiment of the present application, the device includes a historical resource usage status data acquisition unit 201, a predicted resource usage status data determination unit 202, and a standby resource determination unit 203;
[0058] A historical resource usage status data acquisition unit 201 is configured to acquire, through a monitoring tool, historical resource usage status data of a first application in the K8S platform over N-1 consecutive cycles; the first application is any application in the K8S platform, and N is a positive integer greater than 1;
[0059] The predicted resource usage status data determining unit 202 is configured to input N-1 historical resource usage status data of the first application into a first network, and obtain the predicted resource usage status data of the first application in the Nth cycle through the first network; the first network is obtained by performing adversarial training in conjunction with the second network;
[0060] The standby resource determination unit 203 is used to input the predicted resource usage status data into a third network, and obtain the number of standby Pods of the first application in the Nth cycle through the third network; the third network is trained based on the resource usage status data and corresponding Pod numbers of multiple applications in the K8S platform.
[0061] Furthermore, the device further includes a first network and a second network training unit 204; the first network and the second network training unit 204 are used to: for G applications in the K8S platform, obtain the real resource usage status data of the G applications in N test cycles; G is a positive integer greater than 1; train the initial generation network according to the real resource usage status data of the G applications in the first N-1 test cycles, and obtain the predicted resource usage status data of the G applications in the Nth test cycle, as well as each first loss value; according to the real resource usage status data of the G applications in the Nth test cycle, the predicted resource usage status data of the G applications is obtained. The initial discriminant network is trained with the actual resource usage status data and the predicted resource usage status data in the Nth test cycle to obtain each second loss value; the initial discriminant network is used to distinguish the authenticity of the resource usage status data; a comprehensive loss value is determined based on the each first loss value and the each second loss value; if the comprehensive loss value does not meet the first setting requirement, the new generation of generation network and discrimination network continues to be trained; when the comprehensive loss value under the P-generation generation network and the P-generation discrimination network meets the first setting requirement, the P-generation generation network is determined to be the first network, and the P-generation discrimination network is determined to be the second network.
[0062] Furthermore, for the device, the first network and second network training units 204 are specifically used to: for any application among the G applications, input the real resource usage status data of the application in the first N-1 test cycles and the corresponding random sequence into the initial generation network, thereby obtaining the predicted resource usage status data of the application in the Nth test cycle, and generate a first loss value accordingly, and for any application among the G applications, respectively, form a first sequence with the real resource usage status data of the application in the first N-1 test cycles and the real resource usage status data of the application in the Nth test cycle, and form a second sequence with the predicted resource usage status data of the application in the Nth test cycle, and input the first sequence and the second sequence into the initial discriminant network for training to obtain a second loss value.
[0063] Furthermore, the device also includes a third network training unit 205; the third network training unit 205 is used to: for any application in the K8S platform, obtain the first maximum external access volume and the first resource usage of the application under the set first Pod number through the monitoring tool; use the first maximum external access volume and the first resource usage of each application under the first Pod number as input, and the first Pod number as the label value to train the initial neural network to obtain the loss value of the initial neural network; if it is determined that the difference between the loss value of the Q generation neural network and the loss value of the Q-1 generation neural network meets the second setting requirement, then determine that the Q generation neural network is the third network.
[0064] Furthermore, for the device, the third network training unit 205 is specifically used to: set the number of Pods corresponding to the application to the first number of Pods; send a test message to the application under the first number of Pods; if it is determined that the loss rate of the test message exceeds the set threshold, then determine the current number of test messages as the first maximum external access volume of the application under the first number of Pods, and obtain the CPU usage and memory usage of the application as the first resource usage through the monitoring tool.
[0065] Furthermore, for the device, the first network and second network training units 204 are specifically used to: for any application among the G applications, input the real resource usage status data of the application in the first N-1 test cycles and the corresponding random sequence into the initial generation network; extract the historical time series features of the N-1 real resource usage status data through the RNN unit and the fully connected network in the initial generation network, so as to obtain the predicted resource usage status data of the application in the Nth test cycle.
[0066] Furthermore, the device also includes a first network update unit 206; the first network update unit 206 is used to: adjust the number of Pods used by the first application in the Nth cycle based on the number of standby Pods; obtain the real resource usage status data of the first application in the Nth cycle through the monitoring tool; determine whether to update the first network based on the second network's judgment of the predicted resource usage status data in the Nth cycle and the real resource usage status data in the Nth cycle.
[0067] The present application also provides a computing device, which may be a desktop computer, a portable computer, a smart phone, a tablet computer, a personal digital assistant (PDA), etc. The computing device may include a central processing unit (CPU), a memory, input / output devices, etc. The input device may include a keyboard, a mouse, a touch screen, etc. The output device may include a display device, such as a liquid crystal display (LCD), a cathode ray tube (CRT), etc.
[0068] The memory may include a read-only memory (ROM) and a random access memory (RAM), and provides the processor with program instructions and data stored in the memory. In an embodiment of the present application, the memory may be used to store program instructions of the resource adjustment method;
[0069] The processor is configured to call the program instructions stored in the memory and execute the resource adjustment method according to the obtained program.
[0070] like Figure 3 FIG. 1 is a schematic diagram of a computing device provided in an embodiment of the present application, wherein the computing device includes:
[0071] Processor 301, memory 302, transceiver 303, bus interface 304; wherein the processor 301, memory 302 and transceiver 303 are connected via bus 305;
[0072] The processor 301 is configured to read the program in the memory 302 and execute the resource adjustment method;
[0073] The processor 301 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and an NP. It may also be a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0074] The memory 302 is used to store one or more executable programs and can store data used by the processor 301 when performing operations.
[0075] Specifically, the program may include program code, which includes computer operating instructions. Memory 302 may include volatile memory, such as random-access memory (RAM); memory 302 may also include non-volatile memory, such as flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); and memory 302 may also include a combination of the aforementioned types of memory.
[0076] The memory 302 stores the following elements, executable modules or data structures, or a subset or an extension thereof:
[0077] Operation instructions: include various operation instructions, used to implement various operations.
[0078] Operating system: includes various system programs used to implement various basic services and process hardware-based tasks.
[0079] The bus 305 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0080] The bus interface 304 may be a wired communication access port, a wireless bus interface, or a combination thereof. The wired bus interface may be, for example, an Ethernet interface. The Ethernet interface may be an optical interface, an electrical interface, or a combination thereof. The wireless bus interface may be a WLAN interface.
[0081] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the resource adjustment method.
[0082] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0083] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0084] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0085] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0086] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0087] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A resource adjustment method, applicable to various applications in a K8S platform, wherein the K8S platform includes multiple Pods; characterized in that: include: Obtain historical resource usage status data of a first application in the K8S platform in N-1 consecutive cycles through a monitoring tool; the first application is any application in the K8S platform, and N is a positive integer greater than 1; Inputting N-1 historical resource usage status data of the first application into a first network, and obtaining predicted resource usage status data of the first application in the Nth cycle through the first network; the first network is obtained by performing adversarial training in conjunction with the second network; Inputting the predicted resource usage status data into a third network, and obtaining the number of standby Pods of the first application in the Nth cycle through the third network; The third network is trained in the following manner, including: under the first Pod number corresponding to the first application, using a stress testing tool to gradually increase the number of test messages sent to the first application through multiple rounds of experiments until the loss rate of the test messages is higher than the set threshold, then using the current number of test messages as the first maximum external access volume of the first application under the first Pod number, and obtaining the CPU usage and memory usage of the first application at the first maximum external access volume through a monitoring tool as the first resource usage; using the first maximum external access volume and the first resource usage of each application under the first Pod number as input, and the first Pod number as a label value, to train the initial neural network to obtain the loss value of the initial neural network; if it is determined that the difference between the loss value of the Q-generation neural network and the loss value of the Q-1 generation neural network meets the second setting requirement, then determining that the Q-generation neural network is the third network; When the Nth cycle of the first application arrives, the number of Pods required by the first application in the K8S platform is adjusted to the number of standby Pods to achieve automatic expansion and contraction of the first application.
2. The method according to claim 1, wherein The first network and the second network are trained in the following manner, including: For G applications in the K8S platform, obtain the real resource usage status data of the G applications in N test cycles; G is a positive integer greater than 1; Training the initial generation network based on the actual resource usage status data of the G applications in the first N-1 test cycles to obtain the predicted resource usage status data of the G applications in the Nth test cycle and each first loss value; Training an initial discriminant network based on the actual resource usage status data of the G applications in the Nth test cycle and the predicted resource usage status data in the Nth test cycle to obtain respective second loss values; the initial discriminant network is used to distinguish the authenticity of the resource usage status data; Determining a comprehensive loss value based on the first loss values and the second loss values; if the comprehensive loss value does not meet the first set requirement, continuing to train the new generation of the generative network and the discriminative network; When the comprehensive loss values under the P-generation generation network and the P-generation discrimination network meet the first setting requirement, the P-generation generation network is determined to be the first network, and the P-generation discrimination network is determined to be the second network.
3. The method according to claim 2, wherein The initial generation network is trained based on the actual resource usage status data of the G applications in the first N-1 test cycles to obtain the predicted resource usage status data of the G applications in the Nth test cycle, as well as each first loss value, including: For any application among the G applications, input the actual resource usage status data of the application in the first N-1 test cycles and the corresponding random sequence into the initial generation network, thereby obtaining the predicted resource usage status data of the application in the Nth test cycle, and generating a first loss value accordingly; The training of the initial discriminant network based on the actual resource usage status data of the G applications in the Nth test cycle and the predicted resource usage status data in the Nth test cycle to obtain each second loss value includes: For any application among the G applications, the real resource usage status data of the application in the first N-1 test cycles and the real resource usage status data of the application in the Nth test cycle are respectively used to form a first sequence, and the real resource usage status data of the application in the Nth test cycle are used to form a second sequence, and the first sequence and the second sequence are input into the initial discriminant network for training to obtain a second loss value.
4. The method according to claim 3, wherein For any application among the G applications, inputting the real resource usage status data of the application in the first N-1 test cycles and the corresponding random sequence into the initial generation network, thereby obtaining the predicted resource usage status data of the application in the Nth test cycle, including: For any application among the G applications, input the real resource usage status data of the application in the first N-1 test cycles and the corresponding random sequence into the initial generation network; The historical time series features of the N-1 real resource usage status data are extracted through the RNN unit and the fully connected network in the initial generation network, thereby obtaining the predicted resource usage status data of the application in the Nth test cycle.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Adjusting the number of Pods used by the first application in the Nth cycle based on the number of standby Pods; Obtaining, by the monitoring tool, real resource usage status data of the first application in the Nth cycle; Whether to update the first network is determined according to the judgment of the second network based on the predicted resource usage status data in the Nth cycle and the actual resource usage status data in the Nth cycle.
6. A resource adjustment device, applicable to various applications in a K8S platform, wherein the K8S platform includes multiple Pods; characterized in that: include: A historical resource usage status data acquisition unit is used to acquire historical resource usage status data of a first application in the K8S platform in N-1 consecutive cycles through a monitoring tool; the first application is any application in the K8S platform, and N is a positive integer greater than 1; a predicted resource usage status data determining unit, configured to input N-1 historical resource usage status data of the first application into a first network, and obtain predicted resource usage status data of the first application in the Nth cycle through the first network; the first network is obtained by performing adversarial training in conjunction with the second network; a standby resource determination unit, configured to input the predicted resource usage status data into a third network, and obtain the number of standby Pods of the first application in the Nth cycle through the third network; the third network is trained in the following manner, including: under the first Pod number set for the first application, using a stress testing tool to gradually increase the number of test messages sent to the first application through multiple rounds of experiments until the loss rate of the test messages is higher than a set threshold, then using the current number of test messages as the first maximum external access volume of the first application under the first Pod number, and obtaining the CPU usage and memory usage of the first application at the first maximum external access volume as the first resource usage through a monitoring tool; using the first maximum external access volume and the first resource usage of each application under the first Pod number as input, and the first Pod number as a label value, to train the initial neural network to obtain the loss value of the initial neural network; if it is determined that the difference between the loss value of the Q-generation neural network and the loss value of the Q-1-generation neural network meets the second setting requirement, then determining that the Q-generation neural network is the third network; When the Nth cycle of the first application arrives, the number of Pods required by the first application in the K8S platform is adjusted to the number of standby Pods to achieve automatic expansion and contraction of the first application.
7. A computer device, characterized in that: include: Memory for storing computer programs; A processor is configured to call a computer program stored in the memory and execute the method according to any one of claims 1 to 5 according to the obtained program.
8. A computer-readable storage medium, characterized in that The storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Generative adversarial network training method and device and power load prediction method
CN112163715A