A microservice resource adaptive adjustment method based on hyper-heuristic algorithm
By using hyper-heuristic algorithms and microservice performance prediction model SMPP for resource adjustment under cloud native architecture, the problem of low resource utilization of microservice nodes under cloud native architecture is solved, and efficient resource management and service quality assurance is achieved.
Patent Information
- Application Number
- CN202411937909.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-26
AI Technical Summary
Under the cloud-native architecture, it is difficult to ensure the end-to-end service quality of tasks and the resource utilization of microservice nodes.
Adaptive adjustment method of microservice resource based on hyperheuristic algorithm is adopted, and the node response time is predicted by combining the microservice performance prediction model SMPP model. When the response time does not meet the QoS requirements, resource adjustment is used using the AWS model.
It realizes the resource utilization rate of microservice nodes while meeting the end-to-end service quality of tasks.
Smart Images

Figure CN119356801B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a microservice resource adaptive adjustment method based on a hyper-heuristic algorithm, belonging to the technical field of microservice resource dynamic management. Background Art
[0002] Cloud computing centrally manages computing, storage, network and other resources through virtualization, which has the advantages of flexibility, convenience and economy. This model can support elastic expansion and allow users to rent resources that meet their needs. When users rent resources, they will sign a service level agreement (SLA) with the service provider, which stipulates the quality of service (QoS). Violation of this agreement will cause the cloud provider to face economic or reputational losses.
[0003] At present, with the popularization and application of cloud computing and big data, users' requirements for cloud platforms are gradually increasing, and the demand services are also changing. The massive computing data and increasingly complex computing needs have brought new challenges to the data processing capabilities of container cloud platforms. In this environment, a new generation of cloud computing technology, Cloud Native, has gradually evolved. Cloud Native is a software architecture and development methodology designed to support the construction and operation of applications in a cloud environment. It emphasizes the realization of a high degree of automation, elasticity, scalability and maintainability on cloud computing infrastructure, and can effectively solve the problems of slow application updates and bloated system architecture in traditional cloud systems. Cloud Native covers a series of cloud computing technologies and management methods. Among them, microservice is a typical architectural pattern. It decouples complex, multi-module monolithic applications into multiple independent modular microservices, and develops and deploys them in different containers, thereby effectively reducing the interdependence between modules, shortening the software development cycle, and improving the flexibility and maintainability of the system.
[0004] In the microservice architecture, in order to improve the overall efficiency of the system and meet the end-to-end QoS of the application, the key is to make effective resource scheduling and management for each container node. However, this process has the following difficulties and challenges: First, in the current cloud-native architecture, the annotation and acquisition of microservice resource performance data still face certain difficulties. Most existing studies rely on technologies such as Docker and Kubernetes to deploy microservice benchmark programs, and simulate multi-dimensional resource competition by introducing artificial interference in different microservice nodes, so as to collect resource-performance data of a single node, and use these data to build a machine learning model to optimize resource allocation, but this method has challenges in the data acquisition process. First, the interference introduced by simulating resource competition may cause data noise or inconsistency, which makes the acquisition and annotation cost of training data high. Second, the existing methods fail to fully consider the QoS requirements of microservice tasks, which may affect the actual availability and effect of the optimization results; second, the complex interactions between microservice nodes further increase the difficulty of resource management. The microservice architecture consists of multiple services, each of which has different resource requirements and characteristics. There are complex dependencies between these microservices. A microservice may be called by multiple upstream services at the same time, and it also needs to call multiple downstream services. In addition, since the load of microservice applications often changes dynamically, different services may face peaks or valleys in the number of requests at different times and in different environments. This uncertainty makes it difficult to accurately predict resource requirements in a short period of time, thus affecting the formulation of the best resource adjustment strategy. Therefore, how to flexibly and effectively manage and coordinate these services to respond to load changes in a timely manner and achieve dynamic resource adjustment and reasonable allocation is a key issue.
[0005] In the prior art, there are two main methods for microservice resource management. One is to use machine learning and heuristic algorithms to dynamically adjust resources; the other is to use a 0 / 1 linear programming model to implement microservice interactive perception scheduling. The microservice resource management methods in the prior art are summarized as follows:
[0006] "An Intelligent Scheduling Strategy for Microservice Resources Based on Container Cloud Platform", Chinese Invention Patent (CN117459477A), 2023, uses the message passing mechanism to transmit features to the microservice network, combines graph embedding and DNN algorithms to build a microservice response time evaluation model, and combines heuristic algorithms to obtain the optimal solution for microservice node resources in the next time period under QoS constraints and allocate resources. However, they only use the container's request volume, CPU and memory as indicators, and do not consider the specific usage of other resources.
[0007] "A cloud computing resource prediction method, system, device and storage medium", Chinese invention patent (CN115686856A), 2023, collects data on the load of various services on the cloud platform to predict future business types, and formulates resource allocation plans accordingly. Combine the prediction results with the plan to build a model to correct the prediction, and determine the final resource allocation plan after error processing. However, when facing large-scale and complex business scenarios, the training efficiency and real-time performance of the prediction model still need to be optimized.
[0008] "Interaction-aware containerized microservice resource scheduling method for cloud computing", Chinese invention patent (CN112783649A), 2021, generates load monitoring call behaviors between microservices through load testing scripts, and constructs microservice interaction graphs. Using a quadratic programming model with 0 / 1 linear constraints, microservices that meet resource conditions and their dependent instances are preferentially deployed on the same node to reduce the communication cost between physical nodes and minimize request response time. However, this method faces the challenge of computational complexity under large-scale microservice clusters in practical applications, and it is difficult to accurately predict the dynamic interaction pattern between services.
[0009] Hyper-heuristic algorithms have been widely used in the field of resource management in recent years. However, there is no report on the performance prediction of microservice nodes based on self-training-semi-supervision, and the scheme of maximizing the resource utilization of microservice nodes under the premise of meeting the end-to-end QoS of tasks in combination with hyper-heuristic algorithms. Therefore, the present invention proposes a microservice resource adaptive adjustment method based on a hyper-heuristic algorithm, which can improve the resource utilization of microservice nodes while meeting the end-to-end service quality of tasks. Summary of the invention
[0010] The main purpose of the present invention is to provide a microservice resource adaptive adjustment method based on a hyper-heuristic algorithm, aiming to solve the technical problem that it is difficult to ensure the end-to-end service quality of tasks and the resource utilization of microservice nodes under a cloud native architecture.
[0011] To achieve the above purpose, the present invention proposes a method for adaptively adjusting microservice resources based on a hyper-heuristic algorithm. The method combines the prediction results of the microservice performance prediction model SMPP model. When the node response time is not within the QoS specified range, the hyper-heuristic algorithm-based microservice resource adjustment (AWSH) model is used to adaptively adjust the CPU, memory, I / O and other resources of the microservice node that needs to be adjusted. The specific steps are:
[0012] Step 1: Run the benchmark tool to simulate the actual application running scenario;
[0013] Step 2: Use monitoring tools to collect microservice "resource-performance" data in the application running scenario;
[0014] Step 3: Combine the collected microservice "resource-performance" data to build an SMPP model to predict the response time of the microservice node;
[0015] Step 4: When the predicted response time of the microservice node does not meet the preset service quality requirements, a resource adjustment decision is generated in combination with the AWSH model;
[0016] Step 5: Based on the resource adjustment decision, use resource management tools to schedule CPU resources, memory resources, and I / O resources.
[0017] The Step 3 is specifically as follows:
[0018] Step 3.1: Based on the Generative Adversarial Network (GAN) model, a regressor is introduced to form an optimized CTAB-GAN+ model;
[0019] Specifically, the CTAB-GAN+ model consists of three deep neural networks: a generator G, a discriminator D, and a regressor R. Among them, the generator G is responsible for generating a Gaussian distribution data set that is consistent with the original microservice "resource-performance" data. On the one hand, the obtained microservice "resource-performance" data is encoded by an encoder according to different features to process mixed, continuous and classified data before being input into the discriminator D and the regressor R, and the processed data is used as the real data. On the other hand, by inputting a noise vector plus a conditional vector, the generator G outputs synthetic data that is as close to the real data as possible. Subsequently, the real data and the synthetic data are spliced with the conditional vector, and the discriminator D outputs the judgment on whether the input data is real or synthetic. The regressor R is used to determine whether there is a semantic inconsistency between multiple behavioral features in the generated data set.
[0020] Step 3.2: Optimize the generator and discriminator in the CTAB-GAN+ model. The generator and the discriminator have the same structure and are both composed of CNN convolutional neural networks. The input of the generator is a conditional vector and a noise vector randomly sampled from a standard normal distribution. The output of the generator is the generated synthetic data as the input of the discriminator. The output of the discriminator is a confidence assessment of the input belonging to the real data distribution. The generator and the discriminator are optimized by calculating their loss functions.
[0021] Specifically, the discriminator receives data that has been processed by feature encoding, which includes data generated from the generator and real data, and needs to receive the same conditional vector as the generator as input. The output of the discriminator is a confidence assessment that the input belongs to the real data distribution, that is, the output is a value close to 1 for real samples and a value close to 0 for generated samples.
[0022] Step 3.3: Optimize the regressor in the CTAB-GAN+ model. The input of the regressor is the encoded and processed feature vector in the synthetic data generated by the generator. The output of the regressor is the continuous prediction value for the given input feature, and optimizes the performance of the downstream task. The regressor is optimized by calculating the loss function of the regressor.
[0023] Specifically, during the training process of the CTAB-GAN+ model, the goal of the generator G is to minimize its loss function to generate higher quality synthetic data. The goal of the discriminator D is to maximize its loss function to improve the ability to distinguish between real data and synthetic data. Although the optimization of the regressor R does not directly participate in the loop judgment of the discriminator D, it indirectly affects the quality of the synthetic data by optimizing the performance of downstream tasks. High-quality synthetic data can better simulate the statistical characteristics and semantic integrity of real data, which is crucial for the discriminator D to distinguish between real data and synthetic data in loop judgment. Therefore, optimizing the regressor R helps to improve the performance of the entire system.
[0024] Step 3.4: Repeat Step 3.2-Step 3.3, and continuously optimize the generator, discriminator, and regressor. When the generated data distribution is the same as the real data distribution, or the predetermined number of training iterations is reached, enter step 3.5, and the CTAB-GAN+ model outputs a labeled auxiliary data set with a Gaussian distribution that is consistent with the "resource-performance" data of the microservice;
[0025] Specifically, during the training process of the CTAB-GAN+ model, the generator G and the discriminator D are optimized by adversarial learning. The goal of the generator is to generate synthetic data that is as realistic as possible to deceive the discriminator; while the discriminator distinguishes between real data and synthetic data generated by the generator. During the training process, the generator and the discriminator are updated alternately. The generator improves the quality of synthetic data by minimizing its loss function, and the discriminator improves its discrimination ability by maximizing its loss function. When the discriminator cannot effectively distinguish between real data and synthetic data, that is, when the discriminator's judgment on generated data is close to that on real data, the training reaches an equilibrium state, at which point the synthetic data output by the generator is highly similar to the real data in terms of statistical characteristics and semantic integrity. The training process is iterative until the data generated by the generator is good enough that the discriminator cannot distinguish between real data and generated data, or until the predetermined number of training iterations is reached.
[0026] Step 3.5: Build the self-training part of the SMPP model to learn the latent semantic representation between the calls of each microservice resource to reduce the cost of data annotation.
[0027] Step 3.6: Using the labeled auxiliary dataset and the latent semantic representation, construct the semi-supervised part of the SMPP model, thereby completing the construction of the entire SMPP model and realizing the prediction of the response time of the microservice node.
[0028] The Step 3.5 is specifically as follows:
[0029] Step 3.5.1: Input unlabeled dataset as sample;
[0030] Step 3.5.2: The mask generator generates a binary mask vector, and the binary mask vector is combined with the input sample to obtain a masked and damaged sample; and part of the features of the damaged sample are randomly replaced with features or noise of other samples in the data set, which helps to improve the performance of the model;
[0031] Step 3.5.3: Use an encoder to convert the masked and damaged samples into latent semantic representations to capture the correlation between the features of the original sample data, train the mask vector estimator by minimizing the cross entropy loss, train the feature vector estimator by minimizing the reconstruction loss, and train the encoder by minimizing the weighted sum of the cross entropy loss and the reconstruction loss, wherein the mask vector estimator and the feature vector estimator are both trained based on the output of the encoder;
[0032] Specifically, the encoder is a component that maps input samples (whether original or masked and corrupted) to a low-dimensional, abstract representation space, namely the latent semantic representation. This mapping process is achieved by learning complex relationships and patterns between the features of the input samples.
[0033] Both the mask vector estimator and the feature vector estimator are trained based on the output of the encoder. The mask vector estimator uses the output of the encoder to predict the mask vector, with the goal of predicting which features are masked; the feature vector estimator uses the output of the encoder to reconstruct the original sample, with the goal of predicting the original value of the masked feature.
[0034] The two loss functions, mask vector estimation loss and feature vector reconstruction loss, jointly guide the encoder to learn latent semantic representations that can solve these two tasks. And the encoder is trained by minimizing the weighted sum of these two losses.
[0035] Furthermore, the role of the encoder is to convert the masked and corrupted samples (i.e., the masked samples) into latent semantic representations that capture the correlations between the features of the original data.
[0036] In self-supervised learning, this approach helps the model identify and understand patterns and structures in the data even when some information is obscured or corrupted.
[0037] In semi-supervised learning, the latent semantic representation generated by the encoder is used for consistency regularization, which encourages the model to produce similar outputs for original samples and masked and corrupted samples, helping to utilize unlabeled data to improve model performance.
[0038] Step 3.5.4: Output the trained encoder to map the original input samples into latent semantic representations between microservice resource calls.
[0039] The Step 3.6 is specifically as follows:
[0040] Step 3.6.1: Input the unlabeled dataset and the labeled dataset. For each unlabeled sample in the unlabeled dataset, the mask generator generates binary mask vectors, and each mask vector is combined with an unlabeled sample through a mask generator to generate a masked and corrupted sample;
[0041] Step 3.6.2: Use the trained encoder to map the damaged samples to latent semantic representations, and then train the SMPP model by minimizing the supervision loss of the labeled dataset and the consistency loss of the unlabeled dataset;
[0042] Step 3.6.3: Output the trained SMPP model and predict the response time of the microservice node.
[0043] Specifically, the present invention divides the response time into three categories according to the duration: when the response time is in the range of 0~0.5ms, it means that the resources of the current microservice node are sufficient and there is a waste of resources, and the resource allocation of the microservice node needs to be reduced; when the response time is in the range of 0.5~10ms, it means that the current resources can just meet the normal operation of the microservice node and there is no need to adjust the resources; when the response time is greater than 10ms, it means that the currently allocated resources of the microservice node cannot meet its normal operation and more resources need to be allocated to it.
[0044] The Step 4 is specifically as follows:
[0045] Step 4.1: Initialize resource allocation scheme set As a solution space, For the resource allocation solutions, each low-level heuristic samples from them for learning, and the solution space is updated at each iteration by the selected low-level heuristic according to its strategy of searching for the optimal resource allocation solution;
[0046] Step 4.2: Evaluate the fitness function value of each resource allocation scheme. The fitness function is used to measure the quality of the resource allocation scheme. The smaller the fitness function value, the better the resource allocation scheme. With the goal of minimizing the response time of microservice nodes and optimizing the overall resource utilization of the system, the fitness function The optimal solution is the optimal resource allocation scheme, and the calculation formula is as follows:
[0047] ,
[0048] Among them, T represents time, U represents resource utilization, , It is the weight coefficient that balances the two. Resource utilization U is composed of CPU, Memory, and IO utilization. The calculation formula is as follows:
[0049]
[0050]
[0051]
[0052]
[0053] in, , , They are the weights of CPU, Memory, and IO respectively. is the CPU utilization, cpu.id represents the idle time, is the memory utilization, is the virtual memory usage, is the amount of virtual memory allocated, It is the utilization rate of IO, and cpu.wa indicates the CPU time occupied by waiting for IO.
[0054] Step 4.3: The AWSH model uses the ant colony algorithm as a high-level heuristic to perform In the process, one of the three low-level heuristics is selected based on its prior performance. When a low-level heuristic performs better, its pheromone is denser, and its probability of being selected is higher. Conversely, its pheromone is weaker and its probability of being selected is lower. Subsequently, the selected low-level heuristic uses its own search strategy to find the optimal resource allocation solution for the resource allocation problem and updates the solution space. The probability of the low-level heuristic being selected by the pheromone is The calculation formula is as follows:
[0055]
[0056] Where A is the number of low-level heuristics, is the current low-level heuristic with a low-level heuristic that the next possible choice pheromone concentration between;
[0057] Step 4.4: After the low-level heuristic selection is completed, update the pheromone assigned by the low-level heuristic , the calculation formula is as follows:
[0058]
[0059] In the formula, is the pheromone volatility coefficient, is the pheromone increment, and the calculation formula is as follows:
[0060]
[0061] in, and Low-level heuristics and The fitness function value of the optimal resource allocation solution in the updated solution space;
[0062] Step 4.5: Repeat Step 4.1-Step 4.4. When the number of iterations reaches the maximum number of iterations, the iteration is terminated. The AWSH model output makes the fitness function value The smallest optimal resource allocation plan is used as the optimal microservice node resource adjustment plan.
[0063] The beneficial effects of the present invention are: first, relying on the container engine to run the benchmark tool to simulate the real application operation scenario, the microservice "resource-performance" data of the microservice nodes under different workloads in the cloud native architecture are collected; secondly, the generative adversarial network is used to enhance the existing microservice "resource-performance" data, thereby generating auxiliary label training samples to improve the performance prediction effect of the microservice nodes; then, a "self-training-semi-supervised" microservice node performance prediction model is constructed to realize the performance prediction of microservice node resources; finally, a microservice resource adjustment model based on the hyper-heuristic algorithm is constructed to realize the adaptive adjustment of microservice node resources, thereby achieving the purpose of improving the resource utilization of microservice nodes while meeting the end-to-end service quality of the task. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 is a flow chart of the steps of the present invention;
[0065] Figure 2 It is a framework diagram of CTAB-GAN+ of the present invention;
[0066] Figure 3 It is a structural diagram of the SMPP model of the present invention;
[0067] Figure 4 It is a structural diagram of the resource allocation model based on the hyper-heuristic algorithm of the present invention. DETAILED DESCRIPTION
[0068] The present invention will be further described below in conjunction with the accompanying drawings and specific implementation methods.
[0069] Example 1: Figure 1 As shown in the figure, a method for adaptively adjusting microservice resources based on a hyper-heuristic algorithm is provided, and the specific steps are as follows:
[0070] Step 1: Run the benchmark tool to simulate the actual application running scenario;
[0071] The benchmark tool in the present invention can use DeathStarBench, which is an open source, cloud-native high-performance benchmark framework that builds six interactive, delay-sensitive services based on microservice architecture, such as social networks, hotel reservations, and media services, covering the current popular cloud and edge applications, and based on this, analyzes the impact of application design on microservices. Each application in DeathStarBench is composed of multiple microservice nodes, and this embodiment deploys social network and media service applications on a local server based on Docker Swarm.
[0072] Step 2: Use monitoring tools to collect microservice "resource-performance" data in the application running scenario;
[0073] The present invention can use Docker's Cgroups mechanism, Linux performance monitoring tool vmstat and distributed tracking system Jaeger to collect microservice "resource-performance" data. The specific data is shown in Table 1:
[0074] Table 1 Microservice “resource-performance” data
[0075]
[0076] Furthermore, the performance data of the microservices, namely the response time Time of the corresponding nodes, is collected through the distributed tracing system Jaeger, and 10 microservice “resource-performance” data instances are obtained as shown in Table 2.
[0077] Table 2 Microservice “resource-performance” data example
[0078]
[0079] Among them, shares is the priority of the container to use the CPU, cpus is the number of CPU cores, swappiness is the threshold of the memory swap area, swp is the virtual memory usage, free is the current free physical memory, si is the size of the memory written from the swap area per second, so is the size of the memory written from the memory to the swap area per second, bi is the number of blocks read per second (reading disk), bo is the number of blocks written per second (writing disk), us is the percentage of CPU time consumed by user process execution, and sy is the percentage of CPU time used by the system.
[0080] Step 3: Combine the collected microservice "resource-performance" data to build an SMPP model to predict the response time of the microservice node; Figure 2 As shown, the specific steps are as follows:
[0081] Step 3.1: Based on the GAN model, introduce the regressor to form the optimized CTAB-GAN+ model;
[0082] Specifically, a regressor R is added to the GAN model to obtain a revised model, which is denoted as the CTAB-GAN+ model. The CTAB-GAN+ model consists of three deep neural networks: a generator G, a discriminator D, and a regressor R. Among them, the generator G is responsible for generating a Gaussian distribution data set that is consistent with the original microservice "resource-performance" data. On the one hand, the obtained microservice "resource-performance" data is encoded by an encoder according to different features before being input into the discriminator D and the regressor R to process mixed, continuous and classified data, and the processed data is used as the real data. On the other hand, by inputting a noise vector plus a conditional vector, the generator G outputs synthetic data that is as close to the real data as possible. Subsequently, the real data and the synthetic data need to be spliced with the conditional vector, and then the discriminator D outputs the judgment on whether the input data is real or synthetic. The regressor R is used to determine whether there is semantic inconsistency between multiple behavioral features in the generated data set.
[0083] Step 3.2: Optimize the generator and discriminator in the CTAB-GAN+ model. The generator and the discriminator have the same structure and are both composed of CNN convolutional neural networks. The input of the generator is a conditional vector and a noise vector randomly sampled from a standard normal distribution. The output of the generator is the generated synthetic data as the input of the discriminator. The output of the discriminator is a confidence assessment of the input belonging to the real data distribution. The generator and the discriminator are optimized by calculating their loss functions.
[0084] Specifically, the input of the generator G is a conditional vector and a noise vector randomly sampled from a standard normal distribution. , the probability distribution of the noise vector is recorded as The output of the discriminator D is a confidence assessment that the input belongs to the real data distribution, that is, it outputs a value close to 1 for real samples and a value close to 0 for generated samples.
[0085] For the discriminator D, its loss function As shown in formula (1):
[0086] (1)
[0087] In the formula, is the discriminator D to the distribution from the generator Sampled in assessment, is the discriminator from the real data distribution Sampled in assessment. is the weight of the gradient penalty, is the discriminator in The gradient at . is and Interpolation between .
[0088] in, It is a real sample sampled from real data, representing the distribution of real data , is used to calculate the score of the discriminator D on the real data during the training process, helping the discriminator learn to distinguish between real data and synthetic data.
[0089] In the real sample and synthetic data The samples are uniformly sampled on the straight line between to ensure the Lipschitz continuity of the discriminator D. They do not belong to the original real data distribution. or generator distribution , but somewhere in between. is generated by the generator G, is a noise vector randomly sampled from a standard normal distribution.
[0090] For the generator G, its loss function includes information loss , Downstream losses and the generator loss , as follows:
[0091] For information loss , calculated as shown in formula (2), measures the difference between the first-order (mean) and second-order (standard deviation) statistical properties of the generated data and the true data.
[0092] (2)
[0093] In the formula, and are the outputs of the discriminator for real samples and synthetic data, respectively. and Represent the real samples and synthetic data Features, Indicates expected value. Represents the standard deviation, which is used to measure the difference in distribution between the generated data and the real data.
[0094] For downstream losses , calculated as shown in formula (3), it measures the difference between the synthetic data and the predicted value, and is used to ensure the semantic consistency of the synthetic data in downstream tasks.
[0095] (3)
[0096] in Representing synthetic data The difference between the predicted output in the downstream task and the true target value. R is a regressor used to ensure the semantic integrity of the synthetic data in downstream analysis. is the output of the encoder, which is used to measure the performance of synthetic data in downstream tasks. is the noise vector randomly sampled from the standard normal distribution according to the input of the generator Generated synthetic data.
[0097] For the generator loss , calculated as shown in formula (4), which measures the difference between the given conditional vector and the generator output category.
[0098] (4)
[0099] in, and are the given conditional vector and the generated conditional vector respectively, represents the calculation of the cross entropy loss, which is designed to ensure that the data categories generated by the generator are consistent with the categories specified by the conditional vector.
[0100] Step 3.3: Optimize the regressor in the CTAB-GAN+ model. The input of the regressor is the encoded and processed feature vector in the synthetic data generated by the generator. The output of the regressor is the continuous prediction value for the given input feature, and optimizes the performance of the downstream task. The regressor is optimized by calculating the loss function of the regressor.
[0101] Specifically, the input features include categorical data, continuous data, and mixed data that have been specifically encoded. The output of the regressor R is the predicted value for a given input feature. ,in For the prediction values, the loss function of the regressor As shown in formula (5):
[0102] (5)
[0103] In the formula, is a regressor, is the true target value, are input features, is the feature encoded by the regressor prediction. is the expected value operator.
[0104] Step 3.4: Repeat Step 3.2-Step 3.3, and continuously optimize the generator, discriminator, and regressor. When the generated data distribution is the same as the real data distribution, or the predetermined number of training iterations is reached, enter step 3.5, and the CTAB-GAN+ model outputs a labeled auxiliary data set with a Gaussian distribution that is consistent with the "resource-performance" data of the microservice;
[0105] Step 3.5: Build the self-training part of the SMPP model to learn the latent semantic representation between the calls of each microservice resource;
[0106] Specifically, the self-training part trains the encoder through pre-tasks (feature vector estimation and mask vector estimation) to learn the latent semantic representation of microservice node resources, capture the complex relationships and features between node resources, and reduce the cost of data annotation. The specific steps are:
[0107] Step 3.5.1: Input unlabeled dataset as sample;
[0108] Input unlabeled dataset ,in , that is, the number of unlabeled data No less than labeled data , Represents the first samples, is the sample space, Indicates the number of feature dimensions. Indicates that each sample is a dimensional vector.
[0109] Step 3.5.2: Mask generator Generate binary mask vector , through the binary mask vector and the input sample Combined, the sample is masked and damaged. ;
[0110] Step 3.5.3: Use the encoder The covered and damaged samples Convert to latent semantic representation , capturing the correlation between the features of the original sample data, and training the mask vector estimator by minimizing the cross entropy loss , thereby predicting which features are masked; train the feature vector estimator by minimizing the reconstruction loss , thereby using the relevant unmasked features to predict the value of the damaged features. The encoder is trained by minimizing the weighted sum of the cross entropy loss and the reconstruction loss, where both the mask vector estimator and the feature vector estimator are trained based on the output of the encoder;
[0111] Step 3.5.4: Output the trained encoder to map the original input samples into latent semantic representations between microservice resource calls.
[0112] Furthermore, the loss function is divided into mask vector estimation loss and the feature vector estimation loss .
[0113] For the mask vector estimation loss , calculated as shown in formula (6):
[0114] (6)
[0115] In the formula, d represents the number of feature dimensions, It is a sample Middle The true value of a feature. The model predicts The value of a feature, that is, the predicted value when the feature is masked. Mask vector estimation loss The model is encouraged to learn how to accurately predict the value of each feature from the corrupted samples, rather than just identifying which features are masked, thereby optimizing the accuracy of the predicted values.
[0116] Estimating loss for feature vector (Reconstruction loss), calculated as shown in formula (7):
[0117] (7)
[0118] In the formula, d represents the number of feature dimensions, is the encoder, is a feature vector estimator based on the encoder Output To predict the original sample. For each feature dimension, calculate the first The true value of the feature With the predicted value The square of the difference is calculated by summing the squared errors of all feature dimensions and taking the average value. The average value is the feature vector estimation loss. This loss function encourages the model to learn how to recover the original feature values from the damaged samples.
[0119] Total loss Estimate the loss for the mask vector and the feature vector estimation loss The weighted sum of is calculated as shown in formula (8):
[0120] (8)
[0121] in, is used to balance the mask vector estimation loss and the feature vector estimation loss Hyperparameters of .
[0122] Step 3.6: Using the labeled auxiliary dataset and the latent semantic representation, the semi-supervised part of the SMPP model is constructed, thereby completing the construction of the entire SMPP model and realizing the prediction of the response time of the microservice node. The structure of the SMPP model is as follows: Figure 3 shown.
[0123] The semi-supervised part uses the learned latent semantic representation and unlabeled data to further train the prediction model and optimize the model parameters by minimizing the supervision loss and consistency loss to enhance the prediction performance. The specific steps are:
[0124] Step 3.6.1: Input unlabeled dataset And labeled datasets , for each unlabeled sample in the unlabeled dataset , generated by the mask generator binary mask vector , and each mask vector passes through the mask generator With unlabeled samples Combining the generated masked and corrupted samples , K represents the total number of mask samples generated by each unlabeled sample;
[0125] Step 3.6.2: Use the trained encoder Map the corrupted samples to latent semantic representations , , that is, K different augmented samples Then by minimizing the labeled data set supervised loss and unlabeled dataset The consistency loss is used to train the predictor f;
[0126] Step 3.6.3: Output the trained SMPP model and predict the response time of the microservice node.
[0127] Specifically, the SMPP model The loss function is divided into supervised loss and consistency loss , calculated as follows:
[0128] Monitoring loss The calculation of is shown in formula (9):
[0129] (9)
[0130] In the formula, the samples of supervision loss come from the labeled dataset , Indicates labeled samples And its corresponding label The joint probability distribution of Represents the joint probability distribution The sample pairs drawn from is the eigenvector, is the corresponding label. is the sample size, It is The true target value of samples, The model is The loss function calculates the MSE (Mean Squared Error) of the model on the entire labeled data set, with the goal of minimizing the difference between the predicted value and the true value.
[0131] Consistency loss (unsupervised loss) The calculation of is shown in formula (10):
[0132] (10)
[0133] In the formula, the samples of consistency loss come from the unlabeled dataset . It is an unlabeled dataset Unlabeled samples in is to apply a mask vector from unlabeled samples The generated brightening sample, Represents the feature probability distribution from unlabeled samples Extract the feature vector of unlabeled samples from Represents the binary mask vector Distribution Extract the mask vector from Indicates that by applying a mask To the unlabeled sample r to obtain the mask sample (damaged sample), Represents the sum of squares of the differences between the predicted values of masked samples and the predicted values of unlabeled samples for all unlabeled samples.
[0134] Total loss To monitor losses and consistency loss The weighted sum of is calculated as shown in formula (11):
[0135] (11)
[0136] in, is a hyperparameter used to balance supervision loss and consistency loss.
[0137] Based on the error function formulas (9)-(11), the predictor is transformed into After multiple rounds of iterative optimization, the optimal predictor f is obtained. Finally, the SMPP model outputs the predicted response time of the microservice node, and the response time refers to the time required for the microservice node to respond from obtaining the task. When the resources of the microservice node are less, the time to process the task is longer; and when the resources are sufficient, the speed of processing the task is faster. In addition, the response time is collected by the Jaeger monitoring tool. The present invention divides the response time into three categories according to the duration: when the response time is in the range of 0~0.5ms, it means that the resources of the current microservice node are sufficient and there is a waste of resources, and the resource allocation of the microservice node needs to be reduced; when the response time is in the range of 0.5~10ms, it means that the current resources can just meet the normal operation of the microservice node, and there is no need to adjust the resources; when the response time is greater than 10ms, it means that the currently allocated resources of the microservice node cannot meet its normal operation, and more resources need to be allocated to it.
[0138] Furthermore, the present invention collects microservice “resource-performance” data and predicts the response time of all microservice “resource-performance” data in turn. The predicted response time of the data is , and then calculate the first The actual response time of the data and prediction results The error between them is used to continuously train and optimize the predictor f. After reaching the maximum number of iterations, the predicted response time output by the SPMM model is Recorded in Table 3, the time unit is ms.
[0139] Table 3 Data for constructing the SPMM model
[0140]
[0141] The response time specified by QoS should be less than 10ms, and the response time of data instance 7 predicted by the SPMM model is 11.33. This exceeds the specified range of QoS. Therefore, Step 4 is executed to perform adaptive management of resources.
[0142] Step 4: When the predicted response time of the microservice node does not meet the preset service quality requirements, a resource adjustment decision is generated in combination with the AWSH model; Figure 4 As shown, the specific steps are as follows:
[0143] Step 4.1: Initialize resource allocation scheme set As a solution space, For the resource allocation schemes, each lower level heuristic (LLH) samples from them for learning, and the solution space S is updated by the selected lower level heuristic in each iteration according to its strategy of searching for the optimal resource allocation scheme. Indicates Resource allocation plan, , , , Indicates The allocation of the 1st to 4th resources in the resource allocation scheme. In detail:
[0144]
[0145]
[0146]
[0147]
[0148] Among them, cpu.cfs_quota indicates the period of cpu allocation; cpu.cfs_period_us indicates the time limit for occupancy; cpuset.cpus refers to the number of CPU cores; Refers to the amount of virtual memory allocated; memory.swappiness refers to the threshold of the memory swap area.
[0149] The update method of each solution is shown in formula (12):
[0150] (12)
[0151] in, Representation scheme No. resources, and They represent the upper and lower bounds of the solution space respectively. The floor function is used to round down the maximum integer that is not greater than the result of the expression in the brackets. rand is a randomly generated number in the interval [0,1], which is used to randomly generate an initial solution within the given upper and lower bounds.
[0152] Step 4.2: Evaluate the fitness function value of each resource allocation scheme to find the current optimal resource allocation scheme. The fitness function is used to measure the quality of resource allocation schemes. The smaller the fitness function value, the better the resource allocation scheme. With the goal of minimizing the response time of microservice nodes and optimizing the overall resource utilization of the system, the fitness function The optimal solution is the optimal resource allocation solution, which is calculated as shown in formula (13):
[0153] , (13)
[0154] Among them, T represents time, U represents resource utilization, , is the weight coefficient for balancing the two. Resource utilization U is composed of CPU, Memory, and IO utilization, and is calculated as shown in formulas (14), (15), (16), and (17):
[0155] (14)
[0156] (15)
[0157] (16)
[0158] (17)
[0159] in, , , They are the weights of CPU, Memory, and IO respectively. is the CPU utilization, cpu.id represents the idle time, is the memory utilization, is the virtual memory usage, is the amount of virtual memory allocated, It is the utilization rate of IO, and cpu.wa indicates the CPU time occupied by waiting for IO.
[0160] Step 4.3: Model AWSH uses the ant colony algorithm as a high-level heuristic to perform In the process, one of the three low-level heuristics is selected based on its prior performance. When a low-level heuristic performs better, its pheromone is denser, and its probability of being selected is higher. Conversely, when the pheromone is weaker, its probability of being selected is lower. Subsequently, the selected low-level heuristic uses its own search strategy to find the optimal resource allocation solution for the resource allocation problem and updates the solution space. , the probability of being selected by the low-level heuristic through pheromone The calculation formula is as follows:
[0161] (18)
[0162] Where A is the number of low-level heuristics, is the current low-level heuristic with a low-level heuristic that the next possible choice The pheromone concentration between is set to 1.
[0163] Step 4.4: After the low-level heuristic selection is completed, update the pheromone assigned to the low-level heuristic , calculated as formula (19):
[0164] (19)
[0165] In the formula, is the pheromone volatility coefficient, is the pheromone increment, calculated as shown in formula (20):
[0166] (20)
[0167] in, and Low-level heuristics and The fitness function value of the optimal resource allocation solution in the updated solution space.
[0168] Step 4.5: Repeat Step 4.1-Step 4.4. When the number of iterations reaches the maximum number of iterations, the iteration is terminated. The AWSH model output makes the fitness function value The smallest optimal resource allocation plan is used as the optimal microservice node resource adjustment plan.
[0169] Furthermore, according to the prediction result of Step 3, the node resources of data instance 7 are adjusted. The resource amount of this microservice node is , based on the physical resources of the local server, determine the adjustment range of the CPU resources, memory resources, and I / O resources of the microservice node as follows: , , , set up three resource adjustment plans as follows:
[0170]
[0171]
[0172]
[0173] Next, set the , , , and use formulas (13)-(17) and the response time T of the microservice node predicted by the SPMM model to calculate the fitness function value F corresponding to the above three resource adjustment schemes. The results are as follows.
[0174] Adoption plan When , , ,therefore , Therefore, the fitness .
[0175] Adoption plan When , , ,therefore , Therefore, the fitness .
[0176] Adoption plan When , , ,therefore , Therefore, the fitness .
[0177] Through the above calculation, we can get the resource adjustment plan The fitness function value obtained when is the smallest, therefore, Scheme 2 is finally selected as the resource adjustment strategy.
[0178] Step 5: Based on the resource adjustment decision, use resource management tools to schedule CPU resources, memory resources, and I / O resources.
[0179] The present invention utilizes Cgroups and Intel CAT to implement the scheduling of CPU resources, memory resources and I / O resources. Specifically, through Step 4, the optimal adjustment strategy of CPU resources, memory resources and I / O resources can be obtained, and the strategy needs to be implemented with the help of different resource management tools.
[0180] Specifically, for CPU adjustment, the present invention uses the CPU subsystem commands cpu.cfs_period_us and cpu.cfs_quota_us in the Linux kernel management tool Cgroups to implement it; for memory and LLC adjustment, Intel's CAT tool is used to implement it; for I / O adjustment, the blkio subsystem in Cgroups is used to adjust the hard disk throughput.
[0181] Furthermore, by using the corresponding Cgroups and Intel CAT instructions, the number of CPUs is adjusted to 8, the memory capacity is adjusted to 1GB, and the I / O capacity is adjusted to 2GB.
[0182] The specific implementation modes of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above implementation modes, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.
Claims
1. A method for adaptively adjusting microservice resources based on a hyper-heuristic algorithm, characterized in that: The method includes: Step 1: Run the benchmark tool to simulate the actual application running scenario; Step 2: Use monitoring tools to collect microservice "resource-performance" data in the application running scenario; Step 3: Combine the collected microservice "resource-performance" data to build an SMPP model to predict the response time of the microservice node; Step 4: When the predicted response time of the microservice node does not meet the preset service quality requirements, a resource adjustment decision is generated in combination with the AWSH model; Step 5: Based on the resource adjustment decision, use resource management tools to schedule CPU resources, memory resources, and I / O resources; The Step 3 is specifically as follows: Step 3.1: Based on the GAN model, introduce the regressor to form the optimized CTAB-GAN+ model; Step 3.2: Optimize the generator and discriminator in the CTAB-GAN+ model. The generator and the discriminator have the same structure and are both composed of CNN convolutional neural networks. The input of the generator is a conditional vector and a noise vector randomly sampled from a standard normal distribution. The output of the generator is the generated synthetic data as the input of the discriminator. The output of the discriminator is a confidence assessment of the input belonging to the real data distribution. The generator and the discriminator are optimized by calculating their loss functions. Step 3.3: Optimize the regressor in the CTAB-GAN+ model. The input of the regressor is the encoded and processed feature vector in the synthetic data generated by the generator. The output of the regressor is the continuous prediction value for the given input feature, and optimizes the performance of the downstream task. The regressor is optimized by calculating the loss function of the regressor. Step 3.4: Repeat Step 3.2-Step 3.3, and continuously optimize the generator, discriminator, and regressor. When the generated data distribution is the same as the real data distribution, or the predetermined number of training iterations is reached, enter step 3.5, and the CTAB-GAN+ model outputs a labeled auxiliary data set with a Gaussian distribution that is consistent with the "resource-performance" data of the microservice; Step 3.5: Build the self-training part of the SMPP model to learn the latent semantic representation between the calls of each microservice resource; Step 3.6: Using the labeled auxiliary data set and the latent semantic representation, construct the semi-supervised part of the SMPP model, thereby completing the construction of the entire SMPP model and realizing the prediction of the response time of the microservice node; The Step 4 is specifically as follows: Step 4.1: Initialize resource allocation scheme set As a solution space, For the resource allocation solutions, each low-level heuristic samples from them for learning, and the solution space is updated at each iteration by the selected low-level heuristic according to its strategy of searching for the optimal resource allocation solution; Step 4.2: Evaluate the fitness function value of each resource allocation scheme. The fitness function With the goal of minimizing the response time of microservice nodes and optimizing the overall resource utilization of the system, the fitness function The optimal solution is the optimal resource allocation scheme, and the calculation formula is as follows: , ; Among them, T represents time, U represents resource utilization, , It is the weight coefficient that balances the two. Resource utilization U is composed of CPU, Memory, and IO utilization. The calculation formula is as follows: ; ; ; ; in, , , They are the weights of CPU, Memory, and IO respectively. is the CPU utilization, cpu.id represents the idle time, is the memory utilization, is the virtual memory usage, is the amount of virtual memory allocated, It is the utilization of IO, cpu.wa indicates the CPU time occupied by waiting for IO; Step 4.3: The AWSH model uses the ant colony algorithm as a high-level heuristic to perform In the above, one of the three low-level heuristics is selected according to its prior performance. Then, the selected low-level heuristic uses its own search strategy to find the optimal resource allocation solution for the resource allocation problem and updates the solution space. The probability of the low-level heuristic being selected by pheromone is The calculation formula is as follows: ; Where A is the number of low-level heuristics, is the current low-level heuristic with a low-level heuristic that the next possible choice pheromone concentration between; Step 4.4: After the low-level heuristic selection is completed, update the pheromone assigned by the low-level heuristic , the calculation formula is as follows: ; In the formula, is the pheromone volatility coefficient, is the pheromone increment, and the calculation formula is as follows: ; in, and Low-level heuristics and The fitness function value of the optimal resource allocation solution in the updated solution space; Step 4.5: Repeat Step 4.1-Step 4.
4. When the number of iterations reaches the maximum number of iterations, the iteration is terminated. The AWSH model output makes the fitness function value The smallest optimal resource allocation plan is used as the optimal microservice node resource adjustment plan.
2. According to claim 1, a method for adaptively adjusting microservice resources based on a hyper-heuristic algorithm is characterized in that: The Step 3.5 is specifically as follows: Step 3.5.1: Input unlabeled dataset as sample; Step 3.5.2: The mask generator generates a binary mask vector, and the masked and damaged sample is obtained by combining the binary mask vector with the input sample; Step 3.5.3: Use an encoder to convert the masked and damaged samples into latent semantic representations to capture the correlation between the features of the original sample data, train the mask vector estimator by minimizing the cross entropy loss, train the feature vector estimator by minimizing the reconstruction loss, and train the encoder by minimizing the weighted sum of the cross entropy loss and the reconstruction loss, wherein the mask vector estimator and the feature vector estimator are both trained based on the output of the encoder; Step 3.5.4: Output the trained encoder to map the original input samples into latent semantic representations between microservice resource calls.
3. According to the method for adaptively adjusting microservice resources based on a hyper-heuristic algorithm according to claim 1, it is characterized in that: The Step 3.6 is specifically as follows: Step 3.6.1: Input the unlabeled dataset and the labeled dataset. For each unlabeled sample in the unlabeled dataset, the mask generator generates binary mask vectors, and each mask vector is combined with an unlabeled sample through a mask generator to generate a masked and corrupted sample; Step 3.6.2: Use the trained encoder to map the damaged samples to latent semantic representations, and then train the SMPP model by minimizing the supervision loss of the labeled dataset and the consistency loss of the unlabeled dataset; Step 3.6.3: Output the trained SMPP model and predict the response time of the microservice node.
Citation Information
Patent Citations
Cloud computing-oriented interactive perception containerized micro-service resource scheduling method
CN112783649A
Cloud computing resource prediction method, system and device and storage medium
CN115686856A
Intelligent micro-service resource scheduling strategy based on container cloud platform
CN117459477A
Resource allocation method for optimizing micro-service cost in cloud based on L-ACO
CN111913800A
Micro-service node performance prediction and resource adaptive adjustment method based on convolutional neural network
CN119127512A