Container dynamic allocation method and system based on machine learning

By adopting a dynamic allocation method based on machine learning in virtualized containers, the problem of unbalanced distribution of container resources is solved, and more efficient resource utilization and system stability are achieved.

CN119376892APending Publication Date: 2025-01-28QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES) +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411571128.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-06
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

During the resource allocation process of virtualized containers, there are unbalanced resource allocation and resource competition among workloads, resulting in poor resource utilization.

Method used

Using machine-learning-based container dynamic deployment methods, resource allocation through the combination of banker algorithms and priority, combined with BILSTM and particle group optimization algorithm predicting load conditions and scheduling containers, using Bilstm-OTENTION-Adaboost model to predict future resource requirements for resource requirements Essence

Benefits of technology

The resource utilization rate is improved, the time and performance consumption is reduced, and the more efficient resource allocation and container scheduling have been achieved, and the stability and availability of the system are ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119376892A_ABST
    Figure CN119376892A_ABST
Patent Text Reader

Abstract

The invention relates to a container dynamic allocation method and system based on machine learning. Comprising the following steps: receiving requests of workloads, and performing container resource allocation on each request of the workloads by adopting a method of combining a banker algorithm and priority; using BiLSTM to learn historical load data, and predicting future load conditions; dynamically scheduling the container by using an improved particle swarm optimization algorithm; performing feature extraction by using a machine learning technology, and learning features of historical data; according to the method, a BiLSTM-Attention-Adaboost model is used for predicting the use condition of future resources through data of a historical time sequence, and deployment is carried out in advance. According to the invention, resources can be allocated more accurately according to the demand of the workload, resource waste is avoided, and the resource utilization rate is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of research on efficient deployment of virtualized containers, and specifically relates to a method for improving resource utilization by allocating, scheduling, managing and predicting future resource demands of containers. Background Art

[0002] With the popularity of cloud computing and microservice architecture, enterprises have a growing demand for flexible and efficient IT infrastructure management. The traditional physical server deployment model has problems such as low resource utilization, long deployment cycle, and poor scalability. It cannot meet the needs of modern enterprises for rapid deployment and elastic scaling. Virtualization container technology has become an important part of modern IT infrastructure. Virtualization container technology allows developers to run applications in an isolated environment, which is called a "container." Each container contains all the libraries and dependencies required by the application, which allows the application to run in the same way on different systems and platforms.

[0003] However, as the number and complexity of containers increase, new challenges are raised for container management and deployment (also known as orchestration). For example, how to effectively distribute containers between physical servers and virtual machines, how to handle dependencies between containers, how to ensure service availability when a container fails, etc. These problems require an automated, scalable solution to meet the needs of large-scale, high-performance IT environments.

[0004] To solve these problems, some virtualized container deployment technologies have emerged, such as Kubernetes, DockerSwarm, and Apache Mesos. These technologies provide an automated way to deploy, scale, and manage containerized applications. However, these existing technologies still have some limitations and challenges, such as low resource utilization, inflexible deployment strategies, and inability to meet the needs of specific application scenarios.

[0005] Therefore, it is imperative to develop a new virtualized container deployment technology to address the limitations and challenges of existing technologies. This new technology needs to be highly automated, flexible, and scalable to meet the needs of the ever-changing IT environment. In addition, this new technology also needs to be able to support various types of applications and services, including traditional enterprise applications, big data processing, artificial intelligence, and machine learning. Summary of the invention

[0006] In view of the shortcomings of the existing container deployment technology, the present invention provides a container dynamic deployment method based on machine learning.

[0007] The present invention aims to solve the problems of unbalanced resource allocation, resource competition between workloads, large amount of time and performance consumption in the resource allocation process of virtualized containers, and the inability to effectively utilize the resources in the cluster during the scheduling of containers, resulting in excessive consumption of some node resources, while other node resources are wasted, resulting in poor resource utilization. The purpose is to dynamically adjust according to the load of the container during the operation of the server, improve resource utilization, further improve the efficiency of resource allocation, and reduce the time and performance consumed.

[0008] First, after the service is started, each service request can be regarded as an independent workload unit. Through the management unit module, according to the container requirements of each request, a combination of the banker algorithm and priority is used to allocate resources and find a suitable container node. If no suitable container is found, a new container is created and assigned to the new container. During the operation of the server, the load changes of each node may be different. In the scheduling unit module, a custom load balancer is deployed through Kubernetes to implement a more flexible and customized load balancing strategy, dynamically schedule containers, and make more efficient use of system resources. Then, the stored historical load data is obtained through the monitoring unit module. First, the historical load data is learned through BiLSTM in machine learning to predict future load patterns and improve the efficiency of container scheduling. Then, the improved particle swarm optimization algorithm is used to dynamically schedule containers. Then, the working status of the cluster is monitored again through the monitoring unit module to avoid a node failure that makes the system unable to work, so as to ensure the stability and availability of the cluster. Track the use of resources such as CPU and memory by containers to help administrators understand the utilization of cluster resources and store them, and pass the data to the data analysis unit module. The obtained data is analyzed and the BiLSTM-Attention-Adaboost model is used to take the workload historical data as the input sequence, such as CPU usage and memory usage, to predict the future resource requirements of the virtualized container (such as CPU, memory, etc.). Through the prediction, the server can reasonably schedule and allocate resources for the container in advance to reduce the time and performance consumed.

[0009] Terminology explanation:

[0010] 1. Banker's Algorithm: The banker's algorithm is a well-known algorithm for avoiding deadlock. Its core idea is to ensure the safe operation of the operating system by simulating the allocation strategy of the bank's lending system. In this algorithm, the operating system is compared to a banker, resources are like funds, and processes are customers who need loans. The banker's algorithm allows processes to apply for resources dynamically, but before allocating resources, the system will first calculate the security of this allocation. If the system is in a safe state after the allocation, the resources will be allocated; otherwise, the system will wait for a more appropriate time to allocate resources.

[0011] 2. Node: refers to the actual host running the containerized application. The node is responsible for receiving tasks from the Kubernetes cluster and executing them. The node has its own resources, such as CPU, memory, and storage space, which are shared by Pods (logical combination of containers). The Master node of Kubernetes is responsible for managing and monitoring all nodes and scheduling tasks to the appropriate nodes for execution. The nodes communicate with the Master node through the network to manage and coordinate the deployment and operation of containers. The number of nodes can be expanded as needed to adapt to applications of different scales and loads.

[0012] 3. Machine learning: It is a branch of artificial intelligence (AI) that aims to enable computer systems to learn patterns and rules from data so that they can learn and improve autonomously. Unlike traditional programming, machine learning systems can automatically identify patterns from large amounts of data and adjust and improve their algorithms through training to improve performance. This learning process is usually divided into several paradigms, including supervised learning, unsupervised learning, semi-supervised learning, and reinforcement learning.

[0013] 4. Particle Swarm Optimization (PSO) is an optimization algorithm based on swarm intelligence. The algorithm is inspired by the foraging behavior of bird flocks and simulates the social behavior of bird flocks to find the optimal solution. The core idea of ​​the PSO algorithm is that each particle represents a potential solution in the problem space. The particle moves in the search space and updates its position and speed by tracking two "extremes": individual extremes (pbest) and global extremes (gbest). The individual extreme is the optimal solution found by the particle itself, while the global extreme is the optimal solution found by all particles in the entire particle swarm.

[0014] 5. BiLSTM: Bidirectional Long Short-Term Memory Network is a special type of recurrent neural network (RNN) that can process sequence data and maintain long-term memory. Unlike traditional RNN models, BiLSTM considers both past and future information, allowing the model to better capture contextual relationships in sequence data. This structure is particularly suitable for tasks that require considering both contextual information, such as part-of-speech tagging, named entity recognition, and sentiment analysis in natural language processing.

[0015] 6. AdaBoost: It is a popular ensemble learning algorithm and a member of the Boosting family. It builds a strong learner by combining multiple weak learners to improve the performance of classification or regression tasks. The core idea of ​​the AdaBoost algorithm is to iteratively train a series of weak classifiers, and each subsequent classifier will focus on the samples that were misclassified by the previous classifier.

[0016] The technical solution of the present invention is:

[0017] A container dynamic allocation method based on machine learning, comprising:

[0018] Receive workload requests and use a combination of the banker algorithm and priority to allocate container resources to each workload request.

[0019] Use BiLSTM to learn historical load data and predict future load conditions;

[0020] Use the improved particle swarm optimization algorithm to dynamically schedule containers;

[0021] Use machine learning technology to extract features and learn the characteristics of historical data;

[0022] Use the BiLSTM-Attention-Adaboost model to predict future resource usage based on historical time series data and deploy in advance.

[0023] Preferably, according to the present invention, a method combining the banker algorithm and the priority is used to allocate container resources for each workload request; including:

[0024] Step 1: Obtain the CPU and memory resource size required by each workload request in the container. Each workload request clearly specifies the resource requirements, including the maximum and current requirements of each resource. At the same time, each workload request is assigned a priority.

[0025] Step 2: Create a first table to list all allocated workload requests and their corresponding resource requirements; the first table includes the identifier, maximum required memory, and maximum required CPU fields of each workload request; create a second table to record the quantity of each resource in the current system, including total memory, total CPU, remaining available memory, and remaining available CPU;

[0026] Step 3: Sort all pending workload requests by priority from high to low. The scheduler selects the highest priority request for resource allocation. If the highest priority request cannot be satisfied immediately due to insufficient resources, the scheduler chooses to wait or lower the priority for processing.

[0027] Step 4: Use the banker algorithm to predict whether the system is in a safe state after resource allocation; Use the banker algorithm to check whether the system has enough resources to meet the maximum requirements of all other workload requests after satisfying the current workload request; If there are not enough resources to meet the maximum requirements of all other workload requests after allocation, that is, the system will be in an unsafe state, then reject the current request and require the work request to wait or readjust its resource requirements;

[0028] Step 5: If the banker's algorithm is used to confirm that the system is in a safe state, the system will allocate the requested resources from the available resources to the workload request, and update the resource allocation table, i.e., the first table, and the available resource table, i.e., the second table; record the new number of allocated resources in the resource allocation table, and reduce the number of available resources in the available resource table accordingly;

[0029] Step 6: The workload requests to start executing its task, using the allocated memory and CPU resources.

[0030] Step 7: After the task is completed, the system automatically or manually releases the previously allocated resources, clears the resource allocation record of the task in the resource allocation table, and increases the corresponding resource quantity in the available resource table;

[0031] Step 8: Re-evaluate other workload requests in the waiting queue based on the updated resource allocation table and available resource table; select the next workload request to which resources can be safely allocated based on the current resource status and priority.

[0032] Preferably, according to the present invention, BiLSTM is used to learn historical load data and predict future load conditions; including:

[0033] Step 9: Use machine learning to learn historical load data, including average CPU load, CPU usage, memory usage; for Kubernetes environments, collect data about containers, Pods, services, and cluster nodes;

[0034] Step 10: Extract useful features from the collected data. Useful features include container CPU and memory usage, and CPU and memory usage of each Pod.

[0035] Step 11: Build a BiLSTM model. The BiLSTM model includes two LSTM layers, one LSTM layer is used to process the forward sequence, and the other LSTM layer is used to process the reverse sequence. Use the extracted useful features and historical load data to train the BiLSTM model.

[0036] Step 12: Input the current features into the BiLSTM model, which will predict future load changes based on the learned patterns.

[0037] Preferably, according to the present invention, an improved particle swarm optimization algorithm is used to dynamically schedule containers; including:

[0038] Step 13: Initialize the particle swarm, each particle represents a possible container scheduling solution; the position of each particle is represented by X i , where i represents the particle index, and the continuous particle position is mapped to the {0,1} interval through the Sigmoid function, indicating whether the container is scheduled on a specific node;

[0039] Step 14: Design a fitness function to evaluate the performance of the container scheduling solution, including resource utilization, load balancing, service response time, and fault tolerance;

[0040] Step 15: Update the particle position and velocity using the adaptive inertia weight strategy and T-distribution perturbation strategy;

[0041] The adaptive inertia weight strategy is:

[0042]

[0043] Among them, ω is the inertia weight, t is the current iteration number, and t max is the maximum number of iterations;

[0044] The T-distribution perturbation strategy is:

[0045]

[0046] Among them, X t i is the particle position after disturbance, h(t) is the value of T-distribution with current iteration number and t as the degree of freedom, X i Refers to the current scheduling plan of the i-th particle;

[0047] The particle position and velocity update formula is:

[0048] v′i,d =ω×v i,d +c1r1(p i,d -x i,d )+c2r2(g best,d -x i,d )

[0049] x′ i,d =x i,d +v i,d

[0050] Among them, v i,d ′ is the updated speed, x i,d ′ is the updated position, c1 and c2 are learning factors, r1 and r2 are random numbers between [0,1]; x i,d represents the current position of the ith particle in the dth dimension, p i,d represents the individual optimal position of the ith particle in the dth dimension, g best,d Indicates the optimal position of the group.

[0051] Step 16: Evaluate the fitness of all particles after each iteration, and update the global optimal solution and the individual optimal solution; after the iteration, select the particle with the highest fitness as the optimal scheduling solution, and apply the optimal scheduling solution to dynamically schedule the container.

[0052] Further preferably, in step 14, the fitness function is: fitness = α×error_rate+β×RF / D, wherein error_rate is the error rate of the scheduling scheme, RF is the resource utilization, D is the total resource demand, and α and β are weight coefficients.

[0053] Preferably, according to the present invention, the BiLSTM-Attention-Adaboost model is used to predict the future resource usage through the historical time series data; including:

[0054] Step 17: Data preprocessing: Collect historical resource usage data, clean the historical resource usage data, remove outliers and irrelevant data, and normalize the cleaned historical resource usage data;

[0055] Step 18: Build the BiLSTM model;

[0056] Step 19: Build the BiLSTM-Attention model;

[0057] The BiLSTM-Attention model includes the BiLSTM layer and the attention layer;

[0058] The input of the BiLSTM layer is the CPU and memory usage at N time points for each sample, and the output is a sequence of hidden states at each time point, where each state is a high-level representation of CPU and memory usage;

[0059] The input of the attention layer is the hidden state sequence output by the BiLSTM layer, and the output is the attention weight and a context vector for each time step. The context vector is used to predict future resource requirements.

[0060] Step 20: Input the data preprocessed in step 17 into the BiLSTM-Attention model for training. Through training, the BiLSTM-Attention model learns how to predict future resource requirements based on historical data.

[0061] Step 21: Integrate the Adaboost algorithm;

[0062] Use the Adaboost algorithm to integrate multiple BiLSTM-Attention models, each of which may focus on different features or data subsets; train the BiLSTM-Attention-Adaboost model;

[0063] Step 22: Use the trained BiLSTM-Attention-Adaboost model to predict resource requirements in the future.

[0064] Preferably, according to the present invention, the training process of the BiLSTM-Attention-Adaboost model includes:

[0065] Assign the same weight to each sample in the training data set, i.e., the data preprocessed in step 17;

[0066] In each iteration, a BiLSTM-Attention model is trained using the current weight distribution;

[0067] For each trained BiLSTM-Attention model, calculate its weighted error rate ∈ on the training data set, and calculate its weight α according to the error rate of each BiLSTM-Attention model. The weight calculation formula is: α=1 / 2ln((1-∈) / ∈);

[0068] According to the prediction results of each BiLSTM-Attention model, update the weight of each sample in the training data set; after each round of iteration, normalize the sample weights to ensure that the sum is 1; repeat the above steps until the predetermined number of weak learners is reached or the performance of the BiLSTM-Attention model is no longer improved; all trained BiLSTM-Attention models are weighted and combined according to their respective weights α to form a strong learner, that is, the trained BiLSTM-Attention-Adaboost model is obtained.

[0069] Preferably, according to the present invention, in step 22, the prediction result is obtained by weighted voting.

[0070] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of a container dynamic allocation method based on machine learning when executing the computer program.

[0071] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a method for dynamic container allocation based on machine learning.

[0072] A container dynamic allocation system based on machine learning, comprising:

[0073] The management module is configured to: receive workload requests, and allocate container resources to each workload request by using a method combining a banker algorithm and a priority;

[0074] The scheduling module is configured to: use BiLSTM to learn historical load data and predict future load conditions; use the improved particle swarm optimization algorithm to dynamically schedule containers;

[0075] Monitoring module: is configured to monitor the resource usage of the container, record CPU usage, memory usage, cache consumption, and network traffic usage indicators;

[0076] Data analysis module: It is configured to use machine learning technology to extract features and learn the characteristics of historical data; use the BiLSTM-Attention-Adaboost model to predict future resource usage through historical time series data and deploy in advance.

[0077] The beneficial effects of the present invention are:

[0078] Existing container deployment methods usually allocate resources based on static configuration or simple load balancing algorithms, and cannot dynamically adjust the allocated resources according to the current resource demand situation. Existing methods usually lack the ability to accurately predict task queues and cannot effectively improve the efficiency of container deployment and resource utilization. Compared with existing deployment models, the beneficial effects of the present invention are as follows:

[0079] 1. The present invention proposes to first use a method combining the banker's algorithm and priority to allocate container resources to work requests, which can more accurately allocate resources according to workload requirements, avoid waste of resources, and improve resource utilization.

[0080] 2. The present invention proposes a container dynamic scheduling method using Kubernetes extension, which can automatically allocate containers to available nodes according to the current resource utilization, ensure the best utilization of resources, and avoid resource waste. Automatic scheduling can balance the load of each node in the cluster, avoid overloading of some nodes and resulting in performance degradation, and improve the stability of the overall system. When a node fails or the load exceeds expectations, dynamic scheduling can quickly reallocate containers to other available nodes to achieve fault recovery and load adjustment. The dynamic scheduling system can realize the automated management of containers, reduce manual intervention, reduce management costs, and improve the automation level of the system.

[0081] 3. The present invention proposes to use machine learning models to predict future resource requirements, accurately predict future resource requirements based on historical data and current trends, and help the system allocate and adjust resources in advance to avoid resource shortages or surpluses. By real-time monitoring and updating the model, resource demand predictions can be made at any time based on the latest data to ensure that the system can respond promptly to changes in workloads. By accurately predicting future resource requirements, waste and over-purchasing of resources can be avoided, thereby saving costs and improving resource utilization efficiency. Predicting future resource requirements can help the system optimize resource allocation, ensure that each container can obtain sufficient resource support, and improve the performance of the overall system. BRIEF DESCRIPTION OF THE DRAWINGS

[0082] Figure 1 This is a schematic diagram of the overall architecture of a container dynamic allocation method based on machine learning in the present invention;

[0083] Figure 2 A schematic diagram of the LSTM layer, which is a partial component of the BiLSTM model;

[0084] Figure 3 Schematic diagram of using BiLSTM to predict future load patterns;

[0085] Figure 4Schematic diagram of using the BiLSTM-Attention-Adaboost model to predict resource demand in the future. DETAILED DESCRIPTION

[0086] The present invention will be further defined below in conjunction with the accompanying drawings and embodiments, but is not limited thereto.

[0087] Example 1

[0088] A method for dynamic container deployment based on machine learning, such as Figure 1 As shown, including:

[0089] Receive workload requests and use a combination of the banker algorithm and priority to allocate container resources to each workload request.

[0090] Use BiLSTM to learn historical load data and predict future load conditions to improve container scheduling efficiency.

[0091] Use the improved particle swarm optimization algorithm to dynamically schedule containers;

[0092] Use machine learning technology to extract features and learn the characteristics of historical data; make the model more intelligent in resource allocation management.

[0093] Use the BiLSTM-Attention-Adaboost model to predict future resource usage based on historical time series data and deploy in advance.

[0094] Example 2

[0095] The difference between the method for dynamic container allocation based on machine learning described in Example 1 is that:

[0096] The banker algorithm and priority are combined to allocate container resources for each workload request. This includes:

[0097] Step 1: Before machine learning, there is no relevant historical data. First, obtain the CPU and memory resource size required by each workload request in the container. Each workload request (or task) must clearly specify the resource requirements, including the maximum and current requirements of each resource; at the same time, each workload request is assigned a priority; some requests need to be completed within a specific time range, so they are given a higher priority. Take request A in the following example. If it needs to be completed within 5 minutes, and the current time is only 3 minutes away from the deadline, then its priority will be very high. The system will check whether there are enough resources to meet the needs of request A and allocate resources as much as possible to ensure that it can be completed before the deadline. If request A is successfully executed and completed on time, the system will release resources and re-evaluate other waiting tasks, such as request B and request C, to determine the next task to be executed based on their remaining time and resource requirements. For requests that do not need to be completed within a specific time range, analyze the amount of resources required by the request, and requests with smaller resource requirements may be more likely to be processed quickly. For example: A request that only requires 1GB of memory and 1 CPU core may be prioritized because it does not significantly affect system resources.

[0098] Step 2: Create a first table to list all allocated workload requests and their corresponding resource requirements; the first table includes the identifier, maximum required memory, and maximum required CPU fields of each workload request; create a second table to record the quantity of each resource in the current system, including total memory, total CPU, remaining available memory, and remaining available CPU; for example, if the total system memory is 32GB and the current available memory is 20GB, record this information in the available resources table.

[0099] Step 3: According to the defined priority rules, all pending workload requests are sorted from high to low priority, which may involve a priority queue, where high priority requests are ranked first. The scheduler selects the highest priority request for resource allocation. If the highest priority request cannot be satisfied immediately due to insufficient resources, the scheduler chooses to wait or lower the priority for processing; the workload request sends a resource request message to the scheduler to clarify its current demand for resources.

[0100] Step 4: Use the banker algorithm to predict whether the system is in a safe state after resource allocation; Use the banker algorithm to check whether the system has enough resources to meet the maximum requirements of all other workload requests after satisfying the current workload request; If there are not enough resources to meet the maximum requirements of all other workload requests after allocation, that is, the system will be in an unsafe state, then reject the current request and require the work request to wait or readjust its resource requirements;

[0101] Step 5: If the banker's algorithm is used to confirm that the system is in a safe state, the system will allocate the requested resources from the available resources to the workload request, and update the resource allocation table, i.e., the first table, and the available resource table, i.e., the second table; record the new number of allocated resources in the resource allocation table, and reduce the number of available resources in the available resource table accordingly;

[0102] Step 6: The workload requests to start executing its task, using the allocated memory and CPU resources.

[0103] Step 7: After the task is completed, the system automatically or manually releases the previously allocated resources, clears the resource allocation record of the task in the resource allocation table, and increases the corresponding resource quantity in the available resource table;

[0104] Step 8: Re-evaluate other workload requests in the waiting queue based on the updated resource allocation table and available resource table; select the next workload request to which resources can be safely allocated based on the current resource status and priority.

[0105] Example: Assume the system has 32GB of memory and 8 CPU cores. There are three workload requests:

[0106] Request A: requires 2GB of memory and 2 CPU cores, high priority.

[0107] Request B: requires 8GB of memory and 3 CPU cores, medium priority.

[0108] Request C: requires 5GB of memory and 1 CPU core, low priority.

[0109] Following the above steps, the system processes request A first because it has the highest priority. The system checks whether there are enough resources (yes, because there is enough memory and CPU cores available), and then uses the banker's algorithm to confirm whether the system is safe after the allocation. After confirming safety, the system allocates resources to request A and updates the resource allocation table and available resource table. After request A is executed, the resources are released, and the system evaluates requests B and C in the waiting queue again and repeats the above process.

[0110] Use BiLSTM to learn historical load data and predict future load conditions; the deployment model uses the container dynamic scheduling method extended by Kubernetes. Including:

[0111] During server operation, the load changes of each container node may be different. In Kubernetes, a more flexible and customized load balancing strategy can be implemented by deploying a custom load balancer. This method can select the appropriate load balancing algorithm according to specific needs and integrate more advanced functions to make more efficient use of system resources. Here, the actual CPU and memory utilization of each node is considered when making scheduling decisions through Kubernetes. Dynamic scheduling technology is used to achieve load balancing between nodes and reduce resource competition between services and requests.

[0112] Step 9: Use machine learning to learn historical load data, including average CPU load, CPU usage, memory usage; for Kubernetes environments, collect data about containers, Pods, services, and cluster nodes;

[0113] Step 10: Extract useful features from the collected data. Useful features include container CPU and memory usage, CPU and memory usage of each Pod; these features will help the model understand the load pattern.

[0114] Step 11: Build a BiLSTM model. The BiLSTM model includes two LSTM layers, one of which is used to process the forward sequence and the other is used to process the reverse sequence; this can capture the forward and backward dependencies in the time series data. Use the extracted useful features and historical load data to train the BiLSTM model; during the training process, an adaptive algorithm can be used to automatically adjust the learning rate and number of iterations to accelerate the convergence of the BiLSTM model and improve the prediction accuracy. Use the extracted features to train the machine learning model to predict future load patterns. The goal of BiLSTM model training is to be able to predict future load changes based on current and historical data.

[0115] Figure 2 A schematic diagram of the LSTM layer, which is a partial component of the BiLSTM model; Figure 2In the example, the forget gate is used to determine how much of the previous state to retain in order to filter out irrelevant information and reduce the impact of noise on predictions. The input gate is used to control the addition of new input information to ensure that the model can learn about changes in the current environment and update its understanding of resource requirements in a timely manner. The output gate is used to determine the output of the current unit, affect the input of the next layer, and ensure that the model focuses on key information in order to generate accurate resource demand predictions. The unit state C(t-1) of the previous time step is used to represent the long-term memory retained by the LSTM at the previous time step, which contains the resource demand information at the previous moment, so that the current time step can decide whether to continue to retain or update this information. The input X(t) of the current time step is used to represent the input data at the current moment, such as the historical resource usage data (such as CPU and memory usage) at the current time step. This helps the LSTM understand the current resource usage status as a basis for the next prediction. The hidden state h(t-1) of the previous time step is used to record the short-term memory (output state) of the previous moment, provide information from the previous time step, and help the model better associate the input data before and after to generate accurate predictions. C(t) represents the cell state at the current time step, and h(t) is the output at the current time step.

[0116] Step 12: Input the current features into the BiLSTM model, which will predict future load changes based on the learned patterns. Figure 3 Schematic diagram of using BiLSTM to predict future load patterns; Figure 3 In Chinese, the model is abbreviated in English: X1, X2, X3, X4: These represent the load indicator data collected at different time points in each time step in the historical load data set, such as CPU load and memory usage. Based on the prediction results, analyze future resource requirements and load patterns to identify possible bottlenecks or resource shortages. According to the predicted load changes, make resource adjustments in advance (such as expanding the number of Pods, increasing node resources, etc.) to ensure that the system can smoothly cope with the upcoming load changes. In order to make adjustments in advance.

[0117] Use the improved particle swarm optimization algorithm to dynamically schedule containers, including:

[0118] Step 13: Initialize the particle swarm, each particle represents a possible container scheduling solution; the position of each particle is represented by X i , where i represents the particle index, and the continuous particle position is mapped to the {0,1} interval through the Sigmoid function, indicating whether the container is scheduled on a specific node;

[0119] Step 14: Design a fitness function to evaluate the performance of the container scheduling solution, including resource utilization, load balancing, service response time, and fault tolerance;

[0120] Step 15: Update the particle position and velocity using the adaptive inertia weight strategy and T-distribution perturbation strategy;

[0121] The adaptive inertia weight strategy is:

[0122]

[0123] Among them, ω is the inertia weight, t is the current iteration number, and t max is the maximum number of iterations;

[0124] The T-distribution perturbation strategy is:

[0125]

[0126] Among them, X t i is the particle position after disturbance, h(t) is the value of T-distribution with current iteration number and t as the degree of freedom, X i Refers to the current scheduling plan of the i-th particle;

[0127] The particle position and velocity update formula is:

[0128] v′ i,d =ω×v i,d +c1r1(p i,d -x i,d )+c2r2(g best,d -x i,d )

[0129] x′ i,d =x i,d +v i,d

[0130] Among them, v i,d ′ is the updated speed, x i,d ′ is the updated position, c1 and c2 are learning factors, r1 and r2 are random numbers between [0,1]; x i,d represents the current position of the ith particle in the dth dimension, p i,d represents the individual optimal position of the ith particle in the dth dimension, g best,d Represents the optimal position of the group (the best solution obtained in all particle history iterations).

[0131] The adaptive inertia weight strategy and T-distribution perturbation strategy increase the exploration and development capabilities of the algorithm by adjusting the speed and position of particles, thereby affecting the movement of particles and indirectly affecting the evaluation results of the fitness function.

[0132] The particle position and velocity update formula directly adjusts the movement of particles according to the evaluation results of the fitness function to optimize the quality of the solution.

[0133] The fitness function provides a feedback mechanism to evaluate the performance of the particle according to its current position (solution) and guide the search direction and strategy adjustment of the particle swarm algorithm.

[0134] Step 16: Evaluate the fitness of all particles after each iteration, and update the global optimal solution and the individual optimal solution; after the iteration, select the particle with the highest fitness as the optimal scheduling solution, and apply the optimal scheduling solution to dynamically schedule the container.

[0135] In step 14, the fitness function is: fitness = α×error_rate+β×RF / D, where error_rate is the error rate of the scheduling scheme, RF is the resource utilization, D is the total resource demand, and α and β are weight coefficients.

[0136] The BiLSTM-Attention-Adaboost model is used to predict future resource usage through historical time series data; including: the deployment model uses machine learning to predict the future resource requirements of containers. The machine learning model is used to predict the future resource requirements of virtualized containers (such as CPU, memory, etc.). Through prediction, the server can allocate resources to the container in advance to ensure effective resource allocation, avoid excess or insufficient resources, and improve resource utilization. This can significantly reduce performance degradation caused by resource reallocation and improve the overall efficiency of the server.

[0137] The BiLSTM-Attention-Adaboost model is used here, which combines the powerful sequence learning ability of the bidirectional long short-term memory network (BiLSTM), the ability of the attention mechanism (Attention) to focus on key information, and the integrated learning advantage of the Adaboost algorithm, which helps to improve the accuracy of predicting resource demand trends.

[0138] Step 17: Data preprocessing: Collect historical resource usage data, such as CPU, memory and other resource usage, as well as resource utilization and load, clean the historical resource usage data, remove outliers and irrelevant data, such as resource usage under certain abnormal conditions. And normalize the cleaned historical resource usage data to reduce the impact of data of different dimensions and reduce noise.

[0139] Step 18: Build the BiLSTM model;

[0140] The BiLSTM model consists of two LSTM layers, which process the forward (past to future) and reverse (future to past) information of the sequence respectively. This structure enables the BiLSTM model to capture long-term dependencies in time series data, whether these dependencies are forward or backward. In the forward LSTM, the data is input in chronological order, and the LSTM unit is able to remember past information and pass it to subsequent units. In the reverse LSTM, the data is input in the opposite order of chronological order, which enables the LSTM unit to remember future information and pass it to the previous unit. In the reverse LSTM, the data is input in the opposite order of chronological order, which enables the LSTM unit to remember future information and pass it to the previous unit.

[0141] Step 19: Build the BiLSTM-Attention model;

[0142] The model calculates an attention weight for each time step in the sequence, which indicates the importance of each time step to the final prediction target. The calculation of the weights usually involves a score function (such as the softmax function), which converts the attention score of each time step into weights that sum to 1. The calculated attention weights are then applied to the output of the BiLSTM. The output of each time step is multiplied by the corresponding attention weight, and then all weighted outputs are summed to obtain a context vector that integrates the information of the entire sequence. This context vector contains information from all time steps in the sequence, but after being weighted by the attention mechanism, the information of time steps that are more important to the prediction target is strengthened. This vector can then be used as the input of subsequent prediction layers.

[0143] The BiLSTM-Attention model includes the BiLSTM layer and the attention layer;

[0144] The input of the BiLSTM layer is the CPU and memory usage at N time points for each sample, and the output is a sequence of hidden states at each time point, where each state is a high-level representation of CPU and memory usage;

[0145] The input of the attention layer is the hidden state sequence output by the BiLSTM layer, and the output is the attention weight and a context vector for each time step. The context vector is used to predict future resource requirements.

[0146] The output of the BiLSTM layer is used as the input of the attention layer to ensure that the attention layer can receive and process the output of each time step from the BiLSTM.

[0147] Step 20: Input the data preprocessed in step 17 into the BiLSTM-Attention model for training. Through training, the BiLSTM-Attention model learns how to predict future resource requirements based on historical data.

[0148] Step 21: Integrate the Adaboost algorithm;

[0149] Use the Adaboost algorithm to integrate multiple BiLSTM-Attention models, each of which may focus on different features or data subsets; train the BiLSTM-Attention-Adaboost model;

[0150] Figure 4 Schematic diagram of using the BiLSTM-Attention-Adaboost model to predict resource demand in the future. The input data X1, X2, X3, …, Xn are feature vectors of historical resource usage. The BiLSTM-Attention-Adaboost model includes several weak learners and one strong learner. The input data of the BiLSTM-Attention-Adaboost model is the feature vector of historical resource usage (for example, X1, X2, X3, …, Xn). Each weak learner includes a BiLSTM layer and an Attention mechanism. The outputs of each weak learner are integrated through the Adaboost algorithm to form a strong learner. The output of the strong learner is the final prediction result. This output may be a predicted value of future resource usage, which is used to support resource scheduling and optimization decisions.

[0151] Step 22: Use the trained BiLSTM-Attention-Adaboost model to predict resource requirements in the future. Based on the prediction results, the server can allocate appropriate resources to the container in advance to avoid excess or insufficient resources.

[0152] The training process of the BiLSTM-Attention-Adaboost model includes:

[0153] Assign the same weight to each sample in the training data set, i.e., the data preprocessed in step 17; for example, the weight of each sample is 1 / N, where N is the total number of samples.

[0154] In each iteration, a BiLSTM-Attention model is trained using the current weight distribution; these BiLSTM-Attention models may be trained using different feature subsets or data subsets to increase the diversity of the model.

[0155] For each trained BiLSTM-Attention model, calculate its weighted error rate ∈ on the training data set, and calculate its weight α according to the error rate of each BiLSTM-Attention model. The weight calculation formula is: α=1 / 2ln((1-∈) / ∈);

[0156] According to the prediction results of each BiLSTM-Attention model, the weight of each sample in the training data set is updated; the weight of the samples that are misclassified is increased, and the weight of the samples that are correctly classified is reduced. After each round of iteration, the sample weights are normalized to ensure that the sum is 1; repeat the above steps until the predetermined number of weak learners is reached or the performance of the BiLSTM-Attention model is no longer improved; all the trained BiLSTM-Attention models are weighted and combined according to their respective weights α to form a strong learner, that is, the trained BiLSTM-Attention-Adaboost model is obtained.

[0157] In step 22, the prediction result is obtained by weighted voting. Given the historical resource usage data, each weak learner will capture the time-dependent characteristics of the data based on its internal BiLSTM layer and use the Attention mechanism to select the most important time step for prediction. In Adaboost, weak learners are assigned different weights based on their performance. The learner with a higher weight has a greater impact on the final prediction result. When making a prediction, the model performs a weighted aggregation of the output of each weak learner.

[0158]

[0159] Among them, w i is the weight of the i-th weak learner, and predicted value i is the predicted value of the i-th weak learner.

[0160] After obtaining the final forecast value, the system can make adjustments in advance based on the predicted resource requirements.

[0161] Example 3

[0162] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of a container dynamic allocation method based on machine learning described in Example 1 or 2 are implemented.

[0163] Example 4

[0164] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a container dynamic allocation method based on machine learning described in Example 1 or 2.

[0165] Example 5

[0166] A container dynamic allocation system based on machine learning, comprising:

[0167] The management module is configured to: after learning historical data, understand the previous resource usage of each container, so that resources can be automatically allocated to containers and used reasonably. If historical data is not learned before, resources can be allocated based on the banker's algorithm combined with priority; receive workload requests, and use the banker's algorithm combined with priority to allocate container resources for each workload request;

[0168] The scheduling module is configured to: use BiLSTM to learn historical load data and predict future load conditions; improve container scheduling efficiency. Use the improved particle swarm optimization algorithm to dynamically schedule containers; allocate containers to physical hosts through the scheduling algorithm, and perform dynamic scheduling based on resource constraints and load conditions; a reasonable scheduling strategy can maximize the use of server resources and increase container density;

[0169] Monitoring module: is configured to monitor the resource usage of the container, record CPU usage, memory usage, cache consumption, and network traffic usage indicators; it helps with the subsequent management of the container and optimizes its resource allocation;

[0170] Data analysis module: It is configured to use machine learning technology to extract features and learn the features of historical data; use the BiLSTM-Attention-Adaboost model to predict future resource usage through historical time series data and deploy in advance. Comprehensively analyze the collected monitoring data to evaluate the container status and microservice performance. This analysis checks various indicators such as resource utilization, response time, and throughput, and then analyzes the data and stores the data for further use by other components or units in the system, so as to achieve wise decision-making, optimize resource allocation, and enhance performance. Based on historical data and machine learning algorithms, future resource requirements and load patterns are predicted, and container scheduling and resource configuration are performed in advance to reduce resource waste and performance degradation. Combined with predictive scheduling and automated deployment, intelligent management and optimization of virtualized containers are achieved to improve the efficiency and flexibility of the system.

Claims

1. A container dynamic allocation method based on machine learning, characterized in that: include: Receive workload requests and use a combination of the banker algorithm and priority to allocate container resources to each workload request. Use BiLSTM to learn historical load data and predict future load conditions; Use the improved particle swarm optimization algorithm to dynamically schedule containers; Use machine learning technology to extract features and learn the characteristics of historical data; Use the BiLSTM-Attention-Adaboost model to predict future resource usage based on historical time series data and deploy in advance.

2. According to a method for dynamic container deployment based on machine learning according to claim 1, it is characterized in that: A combination of the banker algorithm and priority is used to allocate container resources to each workload request. include: Step 1: Obtain the CPU and memory resource size required by each workload request in the container. Each workload request clearly specifies the resource requirements, including the maximum and current requirements of each resource. At the same time, each workload request is assigned a priority. Step 2: Create a first table to list all allocated workload requests and their corresponding resource requirements; the first table includes the identifier, maximum required memory, and maximum required CPU fields of each workload request; create a second table to record the quantity of each resource in the current system, including total memory, total CPU, remaining available memory, and remaining available CPU; Step 3: Sort all pending workload requests by priority from high to low. The scheduler selects the highest priority request for resource allocation. If the highest priority request cannot be satisfied immediately due to insufficient resources, the scheduler chooses to wait or lower the priority for processing. Step 4: Use the banker algorithm to predict whether the system is in a safe state after resource allocation; Use the banker algorithm to check whether the system has enough resources to meet the maximum requirements of all other workload requests after satisfying the current workload request; If there are not enough resources to meet the maximum requirements of all other workload requests after allocation, that is, the system will be in an unsafe state, then reject the current request and require the work request to wait or readjust its resource requirements; Step 5: If the banker's algorithm is used to confirm that the system is in a safe state, the system will allocate the requested resources from the available resources to the workload request, and update the resource allocation table, i.e., the first table, and the available resource table, i.e., the second table; record the new number of allocated resources in the resource allocation table, and reduce the number of available resources in the available resource table accordingly; Step 6: The workload requests to start executing its task, using the allocated memory and CPU resources. Step 7: After the task is completed, the system automatically or manually releases the previously allocated resources, clears the resource allocation record of the task in the resource allocation table, and increases the corresponding resource quantity in the available resource table; Step 8: Re-evaluate other workload requests in the waiting queue based on the updated resource allocation table and available resource table; select the next workload request to which resources can be safely allocated based on the current resource status and priority.

3. According to the method for dynamic container deployment based on machine learning in claim 1, it is characterized in that: Use BiLSTM to learn historical load data and predict future load conditions; including: Step 9: Use machine learning to learn historical load data, including average CPU load, CPU usage, memory usage; for Kubernetes environments, collect data about containers, Pods, services, and cluster nodes; Step 10: Extract useful features from the collected data. Useful features include container CPU and memory usage, and CPU and memory usage of each Pod. Step 11: Build a BiLSTM model. The BiLSTM model includes two LSTM layers, one LSTM layer is used to process the forward sequence, and the other LSTM layer is used to process the reverse sequence. Use the extracted useful features and historical load data to train the BiLSTM model. Step 12: Input the current features into the BiLSTM model, which will predict future load changes based on the learned patterns.

4. According to the method for dynamic container deployment based on machine learning in claim 1, it is characterized in that: Use the improved particle swarm optimization algorithm to dynamically schedule containers, including: Step 13: Initialize the particle swarm, each particle represents a possible container scheduling solution; the position of each particle is represented by X i , where i represents the particle index, and the continuous particle position is mapped to the {0,1} interval through the Sigmoid function, indicating whether the container is scheduled on a specific node; Step 14: Design a fitness function to evaluate the performance of the container scheduling solution, including resource utilization, load balancing, service response time, and fault tolerance. Step 15: Update the particle position and velocity using the adaptive inertia weight strategy and T-distribution perturbation strategy; The adaptive inertia weight strategy is: Among them, ω is the inertia weight, t is the current iteration number, and tmax is the maximum iteration number; The T-distribution perturbation strategy is: Among them, Xti is the particle position after disturbance, h(t) is the value of T-distribution with the current iteration number and t as the degree of freedom, and Xi refers to the current scheduling plan of the i-th particle; The particle position and velocity update formula is: v′ i,d =ω×v i,d +c1r1(p i,d -x i,d )+c2r2(g %est,d -x i,d ) x′ i,d =x i,d +v i,d Among them, v i,d ′ is the updated speed, x i,d ′ is the updated position, c1 and c2 are learning factors, r1 and r2 are random numbers between [0,1]; x i,d represents the current position of the ith particle in the dth dimension, pi,d represents the individual optimal position of the ith particle in the dth dimension, and g best,d Indicates the optimal position of the group; Step 16: Evaluate the fitness of all particles after each iteration, and update the global optimal solution and the individual optimal solution; after the iteration, select the particle with the highest fitness as the optimal scheduling solution, and apply the optimal scheduling solution to dynamically schedule the container.

5. According to the method for dynamic container allocation based on machine learning in claim 4, it is characterized in that: In step 14, the fitness function is: fitness = α×error_rate+β×RF / D, where error_rate is the error rate of the scheduling scheme, RF is the resource utilization, D is the total resource demand, and α and β are weight coefficients.

6. According to a method for dynamic container deployment based on machine learning according to claim 1, it is characterized in that: Use the BiLSTM-Attention-Adaboost model to predict future resource usage based on historical time series data; including: Step 17: Data preprocessing: Collect historical resource usage data, clean the historical resource usage data, remove outliers and irrelevant data, and normalize the cleaned historical resource usage data; Step 18: Build the BiLSTM model; Step 19: Build the BiLSTM-Attention model; The BiLSTM-Attention model includes the BiLSTM layer and the attention layer; The input of the BiLSTM layer is the CPU and memory usage at N time points for each sample, and the output is a sequence of hidden states at each time point, where each state is a high-level representation of CPU and memory usage; The input of the attention layer is the hidden state sequence output by the BiLSTM layer, and the output is the attention weight and a context vector for each time step. The context vector is used to predict future resource requirements. Step 20: Input the data preprocessed in step 17 into the BiLSTM-Attention model for training. Through training, the BiLSTM-Attention model learns how to predict future resource requirements based on historical data. Step 21: Integrate the Adaboost algorithm; Use the Adaboost algorithm to integrate multiple BiLSTM-Attention models, each of which may focus on different features or data subsets; train the BiLSTM-Attention-Adaboost model; Step 22: Use the trained BiLSTM-Attention-Adaboost model to predict resource requirements in the future.

7. The method for dynamic container deployment based on machine learning according to claim 6 is characterized in that: The training process of the BiLSTM-Attention-Adaboost model includes: Assign the same weight to each sample in the training data set, i.e., the data preprocessed in step 17; In each iteration, a BiLSTM-Attention model is trained using the current weight distribution; For each trained BiLSTM-Attention model, calculate its weighted error rate ∈ on the training data set, and calculate its weight α according to the error rate of each BiLSTM-Attention model. The weight calculation formula is: α=1 / 2ln((1-∈) / ∈); According to the prediction results of each BiLSTM-Attention model, update the weight of each sample in the training data set; after each round of iteration, normalize the sample weights to ensure that the sum is 1; repeat the above steps until the predetermined number of weak learners is reached or the performance of the BiLSTM-Attention model is no longer improved; all trained BiLSTM-Attention models are weighted and combined according to their respective weights α to form a strong learner, that is, the trained BiLSTM-Attention-Adaboost model is obtained; Further preferably, in step 22, the prediction result is obtained by weighted voting.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of a container dynamic allocation method based on machine learning are implemented as described in any one of claims 1-7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of a container dynamic allocation method based on machine learning are implemented as described in any one of claims 1 to 7.

10. A container dynamic deployment system based on machine learning, characterized in that: include: The management module is configured to: receive workload requests, and allocate container resources to each workload request by using a method combining a banker algorithm and a priority; The scheduling module is configured to: use BiLSTM to learn historical load data and predict future load conditions; use the improved particle swarm optimization algorithm to dynamically schedule containers; Monitoring module: is configured to monitor the resource usage of the container, record CPU usage, memory usage, cache consumption, and network traffic usage indicators; Data analysis module: It is configured to use machine learning technology to extract features and learn the characteristics of historical data; use the BiLSTM-Attention-Adaboost model to predict future resource usage through historical time series data and deploy in advance.

Citation Information

Cited By

  • Industrial equipment intelligent operation optimization method and system

    CN120256138A

  • Cloud mobile phone resource scheduling method and related equipment

    CN121173870A