Cloud resource load scheduling method based on Q-learning
The cloud resource load scheduling model is constructed through the Q-learning algorithm, which solves the scalability and accuracy problems of the resource scheduling algorithm in the cloud computing platform, achieves efficient resource allocation and load balancing, and improves system performance and resource utilization.
Patent Information
- Application Number
- CN202410840166.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-09-13
AI Technical Summary
Resource scheduling algorithms in existing cloud computing platforms lack scalability and are difficult to handle heterogeneous resources in complex and dynamic cloud environments, resulting in unbalanced resource allocation and poor load scheduling accuracy.
The Q-learning algorithm is used to achieve adaptive resource scheduling by collecting historical load data, predicting future load conditions, building a load scheduling model, and using Q-value tables to optimize resource allocation strategies.
It improves resource utilization and system performance, reduces response time and resource waste, and achieves efficient resource scheduling in a dynamic load environment.
Smart Images

Figure CN118642855A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of cloud computing and big data, and in particular relates to a cloud resource load scheduling method based on Q-learning. Background Art
[0002] With the rapid development of information technology, cloud computing has gradually become the mainstream way for enterprises and individuals to store and process data. In order to use cloud computing resources more efficiently, we need to reasonably allocate and balance cloud computing resources for storage, applications and other related services. One of the most important tasks in cloud computing platforms is task allocation, and task scheduling is the most complex and challenging part of it. The core concept of scheduling is to minimize time loss, reduce workload, and maximize processing capabilities. Resource allocation algorithms are usually implemented using dynamic adjustment strategies or fixed parameter adjustment mechanisms. The core goal of balance is to improve resource utilization efficiency and avoid insufficient or excessive resource use. Therefore, in cloud computing, how to achieve efficient, reasonable and accurate resource allocation and load balancing has become one of the hot issues in current research. In the current complex and ever-changing cloud computing environment, researchers at home and abroad have conducted in-depth discussions on resource allocation and load balancing issues, but the actual results have not met expectations and there are some obvious shortcomings: (1) Resource data and loads in actual cloud environments change frequently and complexly; (2) Due to the large scale of cloud computing environments, existing load scheduling algorithms lack excellent scalability; (3) Resources in cloud environments may be heterogeneous (different types of virtual machines, storage, and network resources), and scheduling algorithms cannot handle these heterogeneous resources, etc.
[0003] Q-learning represents an enhanced learning strategy specifically designed to handle model-based Markov decision-making process problems. This method takes advantage of human cognitive ability to understand the laws of development of things and introduces it into the field of artificial intelligence. This method uses a value iteration-based strategy to guide the agent to make decisions in the environment by learning a table called Q value.
[0004] The present invention adopts Q-learning algorithm to solve the complexity in cloud environment and dynamically schedule resources. The uniqueness of Q-learning lies in its adaptive learning, model-free and long-term optimization capabilities, which enables it to continuously learn and optimize resource allocation and task scheduling strategies in complex and dynamic cloud environments, thereby improving system performance and resource utilization, which makes it have significant advantages in cloud resource load scheduling. Summary of the invention
[0005] The present invention proposes a cloud resource load scheduling method based on Q-learning to solve the problems in the prior art of poor relevance of resource scheduling decisions and poor accuracy of load scheduling in a cloud environment.
[0006] In order to achieve the above purpose, the technical solution adopted by the present invention includes the following steps:
[0007] Step S1: Collect historical cloud resource load data;
[0008] Step S2: predicting the expected load usage of cloud resources within a predetermined time period based on historical cloud resource load data;
[0009] Step S3: Using the Q-learning algorithm, a load scheduling model is constructed based on the collected cloud resource load data;
[0010] Step S4: Apply the constructed load scheduling model to the actual cloud environment and run it.
[0011] The step S1 is specifically as follows:
[0012] First, obtain the CPU usage, memory usage, and storage utilization of the virtual machine, as well as the usage, request volume, response time, etc. of these three resources; secondly, preprocess various data and convert the data into data suitable for the scheduling model; then use the Prometheus monitoring tool to collect these cloud resource load data, record these data, and finally store them in a database or time series database.
[0013] The step S2 is specifically as follows:
[0014] The data obtained and preprocessed in step S1 are modeled and trained using the time series analysis model ARIMA to capture the trend and periodic changes in resource usage. The trained model is used to predict the usage rates of various cloud resources of the target virtual machine in a specific time period in the future, and the prediction results are obtained. The prediction results provide environmental information for the Q-learning algorithm to ensure that accurate and efficient resource scheduling decisions are made under dynamically changing load conditions.
[0015] The step S3 is specifically as follows:
[0016] The load information is input as the state into the Q-learning algorithm. The algorithm selects actions and updates the Q-value table based on actual feedback. The Q-value table records the expected reward values for performing various actions under different states. As learning progresses, the Q-value table is continuously optimized. The process is as follows:
[0017] S31: Create a Q matrix, where rows represent states and columns represent actions;
[0018] S32: Use historical cloud resource load data to train the Q matrix, clarify the main goals of load scheduling: reduce resource usage costs, improve service quality, and set the current state as the initial state;
[0019] S33: Select the decision action using the ε-greedy strategy based on the current state and Q matrix;
[0020] S34: Execute the decision action, obtain a new state, observe the new state and the immediate reward, update the new Q value into the Q matrix, and set the new state as the current state;
[0021] S35: If the predetermined number of training steps is reached or the end point is reached, then the next step is entered, otherwise it returns to step S33;
[0022] S36: If the predetermined number of training times is reached and the training is completed, then return to step S32;
[0023] Finally, the scheduling model can quickly select the optimal scheduling strategy under dynamic load conditions, improve resource utilization and system performance, and reduce response time and resource waste.
[0024] The step S4 is specifically as follows:
[0025] Acquire real-time load operation data in the cloud environment, obtain expected load operation data corresponding to the real-time data and input it into the scheduling model established in S3, output the scheduling decision, perform actual scheduling according to the scheduling decision, and perform performance evaluation on the scheduling model. When the performance evaluation result is lower than the preset expectation, return to step S1 and loop until the performance evaluation result of the established model reaches the preset expectation. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 This is a step diagram of a cloud resource load scheduling method based on Q-learning of the present invention.
[0027] Figure 2 A flow chart is established for a scheduling model of a cloud resource load scheduling method based on Q-learning in the present invention. DETAILED DESCRIPTION
[0028] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0029] like Figure 1 As shown, the cloud resource load scheduling method based on Q-learning described in the present invention mainly includes the following steps:
[0030] Step S1: Collect historical cloud resource load data. The present invention selects the CPU usage, memory usage and storage utilization of the virtual machine as load data, and selects the past three months as the time range for data collection. The Prometheus monitoring tool is used to ensure that the required data can be collected. The monitoring tool is configured to collect data at a time interval of every 2 minutes, and the collected data is stored in the time series library Prometheus TSDB. After successfully collecting the data, the data is cleaned to eliminate the noise and error information therein, and processed according to the following formula:
[0031] (1)
[0032] (2)
[0033] (3)
[0034] in, is the original data, is the standardized data, is the mean of the data, is the standard deviation of the data, is the CPU usage, is the CPU time used, is the total CPU time, is the memory usage, is the used memory, is the total memory;
[0035] At the same time, the collected load data is standardized and the Min-Max method is used to standardize the data and map it to the range of [0,1]. The calculation formula is:
[0036] (4)
[0037] in, and are the maximum and minimum values in the data, respectively. is the final normalized data;
[0038] After preprocessing the load data, useful features are extracted. For load scheduling, a three-hour time period is selected to capture the short-term trend of the load data. At the same time, the data is divided into training and test sets using time series segmentation to evaluate the performance of the model.
[0039] Step S2: Based on the historical cloud resource load data, the time series analysis model ARIMA is used to predict the expected load usage of cloud resources within a predetermined time period, and the sliding average error correction mechanism is used to reduce the impact of the prediction error on the actual scheduling. The formula is shown in (5):
[0040] (5)
[0041] in, represents the sliding average at time t, i.e. the predicted load; represents the load value actually observed at time t; represents the sliding average at time t-1, that is, the predicted load at the previous time point, is the smoothing factor;
[0042] The trained model is then used to predict the cloud resource load within a predetermined time period, generate load forecast values and load upper and lower bound forecasts, provide interval estimates of load changes, and finally organize the forecast results into a report, including the predicted load value, forecast interval and confidence level, for use by the scheduling system.
[0043] Step S3: Q-learning Assume that the actions of the agent and the environment will affect the next state, and the taking of different actions is affected by the strategy and the accumulated reward value, where the action set is represented by A={a1,a2,…,an}, the environment state set is represented by S={s1,s2,…,sn}, the reward is denoted by r, and the strategy is denoted by ε; in each round of iteration, the agent obtains information by perceiving the current environment state s∈S, and specifies an action a∈A based on the current strategy ε to affect the environment, thereby causing the environment state to enter the next state s'∈S. At the same time, the agent receives a reinforcement signal (reward) r(s,a) as feedback. Based on this reward, the agent adjusts its strategy and then proceeds to the next iteration; the Q function is optimized through continuous feedback learning. The process of optimizing the Q function enables the agent to train the best strategy ε(s)∈A under each state, thereby approaching the goal of maximizing the long-term cumulative reward value, as shown in formula (6):
[0044] (6)
[0045] in, It represents the cumulative reward value that state s can get when using strategy ε, which is called the state value function; represents the state at time t; represents the strategy adopted at time t; represents the relative importance between future cumulative rewards and current rewards. This is called the time discount factor constant, and its value range is (0, 1). According to the Bellman optimal criterion, the maximum value of formula (6) can be calculated, as shown in formula (7):
[0046] V * (s)=max V ε (s)=max[R(s,a)+γ ∑ s ' ∈ S P s, s ' (a) × V * ( s ' )] (7)
[0047] in, For different time states Next Action The mathematical expectation of Indicate action Time Status Change to status The transition probability of Q-learning is: in the control strategy, each pair They are all related to a Q value, that is, in state s, the reward of action a is combined with the Q value, so as to achieve efficient Q value iteration to satisfy formula (8):
[0048] (8)
[0049] Then we can get:
[0050] (9)
[0051] (10)
[0052] in, is the learning rate, the range is (0,1], and the calculation method is The inverse of the total number of visits + 1; as t increases, each pair The Q value will undergo multiple updates, and the learning rate Will gradually decrease when the learning rate When it decreases to 0, Converges to the optimal value; at this time, the strategy derived from formula (9) is the optimal strategy;
[0053] In the process of using the Q-learning algorithm to build a model, the most important thing is the design of the reward function. The reward function directly affects how to learn and optimize resource management strategies. In cloud resource load management, the reward function needs to consider: resource utilization, service quality and resource allocation cost. Based on the above three points, the reward function is established as shown in formula (11):
[0054] (11)
[0055] in, is the reward for performing action a in state s, and They are the CPU and memory utilization, is the service response time, is the resource allocation cost, , , is the weight coefficient, which is used to balance the importance of different factors; Indicates the average value of CPU and memory utilization. High utilization corresponds to high rewards. represents the negative contribution of response time to reward, the longer the response time, the greater the penalty; It represents the negative contribution of resource allocation cost to the reward. The higher the cost, the greater the penalty.
[0056] After the established scheduling model is obtained, the scheduling model is tested using cloud resource load data. The specific test steps include:
[0057] S31: Create a Q matrix, where rows represent states and columns represent actions;
[0058] S32: Use historical cloud resource load data to train the Q matrix, clarify the main goals of load scheduling: reduce resource usage costs, improve service quality, and set the current state as the initial state;
[0059] S33: Based on the current state and Q matrix, the ε-greedy strategy is used to select those behaviors with the largest Q value as decision behaviors;
[0060] S34: Execute the decision action, obtain a new state, observe the new state and the immediate reward, update the new Q value into the Q matrix, and set the new state as the current state;
[0061] S35: If the predetermined number of training steps is reached or the end point is reached, then the next step is entered, otherwise it returns to step S33;
[0062] S36: If the predetermined number of training times is reached and the training is completed, then return to step S32.
[0063] Step S4: Integrate the trained Q-Learning model into Kubernetes, use the Kubernetes API to implement automated resource management, obtain real-time load operation data in the cloud resource environment, obtain expected load operation data corresponding to the real-time load operation data and input it into the scheduling model, and output a scheduling decision; use the expected load data corresponding to the real-time operation data as the current state of the scheduling model, select the action with the maximum Q value as the decision action, that is, the scheduling decision, and then generate the load utilization rate and planning plan according to the scheduling decision.
[0064] like Figure 2 As shown, the establishment process of the Q-learning scheduling model in the present invention is:
[0065] (1) Initialize key parameters such as the Q table, learning rate, discount factor, and exploration rate, and set the current load of each virtual machine (including the number of tasks running and the amount of resources occupied) as the initial environment state;
[0066] (2) Use the monitoring tool Prometheus to obtain real-time cloud resource usage data and determine the current status of the system. Process the collected information to obtain the current user behavior pattern;
[0067] (3) Adopt the ε-greedy strategy and select an action based on the current state and the established Q table;
[0068] (4) Execution action, that is, when the target virtual machine performs a large amount of calculation, more computing resources are allocated to the current task; when the target virtual machine performs a small amount of calculation, the computing resources allocated to the current task are reduced;
[0069] (5) Using dynamic programming algorithms for optimization, in the Kubernetes environment, the selected operation is executed and resources are adjusted. At the same time, the action is sent as a task scheduling instruction to the target virtual machine for resource allocation. The system performance after execution is evaluated and real-time rewards are calculated to improve the efficiency of resource utilization. At the same time, this behavior can be used as the target for the next execution of the action.
[0070] (6) Based on the real-time reward and the maximum Q value of the next state, update the corresponding Q value of the current state, and based on the feedback after executing the action, update the system state;
[0071] (7) Continue to execute the above steps and continuously optimize the resource scheduling strategy based on the target virtual machine load scheduling;
[0072] (8) Determine whether the scheduling strategy is optimal. That is, when the performance evaluation result is lower than the preset expectation, return to step 1 and loop again. Otherwise, end the loop. The resulting model is the optimal scheduling model.
[0073] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A cloud resource load scheduling method based on Q-learning, characterized in that: The following steps are involved: Step S1: Collect historical cloud resource load data; Step S2: predicting the expected load usage of cloud resources within a predetermined time period based on historical cloud resource load data; Step S3: Using the Q-learning algorithm, a load scheduling model is constructed based on the collected cloud resource load data; Step S4: Apply the constructed load scheduling model to the actual cloud environment and run it.
2. According to claim 1, a Q-learning-based cloud resource load scheduling method is characterized in that: First, obtain the CPU usage, memory usage, and storage utilization of the virtual machine, as well as the usage, request volume, response time, etc. of these three resources; secondly, preprocess various data and convert the data into data suitable for the scheduling model; then use the Prometheus monitoring tool to collect these cloud resource load data, record these data, and finally store them in a database or time series database.
3. According to the Q-learning-based cloud resource load scheduling method of claim 1, it is characterized in that: The data obtained and preprocessed in step S1 are modeled and trained using the time series analysis model ARIMA to capture the trend and periodic changes in resource usage. The trained model is used to predict the usage rates of various cloud resources of the target virtual machine in a specific time period in the future, and the prediction results are obtained. The prediction results provide environmental information for the Q-learning algorithm to ensure that accurate and efficient resource scheduling decisions are made under dynamically changing load conditions.
4. According to claim 1, a Q-learning-based cloud resource load scheduling method is characterized in that: The load information is input as the state into the Q-learning algorithm. The algorithm selects actions and updates the Q-value table based on actual feedback. The Q-value table records the expected reward values for performing various actions under different states. As learning progresses, the Q-value table is continuously optimized. The process is as follows: S31: Create a Q matrix, where rows represent states and columns represent actions; S32: Use historical cloud resource load data to train the Q matrix, clarify the main goals of load scheduling: reduce resource usage costs, improve service quality, and set the current state as the initial state; S33: Select the decision action using the ε-greedy strategy based on the current state and Q matrix; S34: Execute the decision action, obtain a new state, observe the new state and the immediate reward, update the new Q value into the Q matrix, and set the new state as the current state; S35: If the predetermined number of training steps is reached or the end point is reached, then the next step is entered, otherwise it returns to step S33; S36: If the predetermined number of training times is reached and the training is completed, then return to step S32; Finally, the scheduling model can quickly select the optimal scheduling strategy under dynamic load conditions, improve resource utilization and system performance, and reduce response time and resource waste.
5. The cloud resource load scheduling method based on Q-learning according to claim 1, characterized in that: Acquire real-time load operation data in the cloud environment, obtain expected load operation data corresponding to the real-time data and input it into the scheduling model established in S3, output the scheduling decision, perform actual scheduling according to the scheduling decision, and perform performance evaluation on the scheduling model. When the performance evaluation result is lower than the preset expectation, return to step S1 and loop until the performance evaluation result of the established model reaches the preset expectation.
Citation Information
Cited By
Intelligent scheduling method and system for heterogeneous equipment system
CN118939438A
Decision-making large model-oriented multi-level heterogeneous memory collaborative scheduling method
CN119576555A
Dynamic resource allocation and load balancing method in cloud computing environment
CN119883663A
