Container instance scheduling method and apparatus, computer device, and storage medium
By predicting container cluster load and automatically scheduling container instances, the problem of eviction caused by insufficient resources in container clusters is solved, timely scheduling of container instances is achieved, failure probability and cost are reduced, and system availability is improved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2025-09-24
- Publication Date
- 2026-05-07
AI Technical Summary
In existing container clusters, the random eviction of container instances leads to decreased throughput, slower response, and system lag. Furthermore, manual monitoring cannot address the issue of timely scheduling, resulting in a high probability of cluster failure, high costs, and low efficiency.
By predicting the load of container instances on host nodes, comparing the total predicted load with the preset load, container instances are automatically scheduled to avoid nodes with insufficient resources evicting container instances and to schedule them to nodes with lighter loads. The target prediction model is used to predict future loads, reducing cluster failures and improving scheduling efficiency.
It enables timely scheduling of container instances, reduces the probability of cluster failure, lowers scheduling costs, improves scheduling efficiency, and enhances system availability.
Smart Images

Figure CN2025123523_07052026_PF_FP_ABST
Abstract
Description
A method, apparatus, computer device, and storage medium for scheduling container instances.
[0001] Cross-references to related applications
[0002] This application claims priority to Chinese Patent Application No. 202411537025.5, filed on October 31, 2024, entitled “A method, apparatus, computer device and storage medium for scheduling container instances”, the entire contents of which are incorporated herein by reference. Technical Field
[0003] This application relates to a method, apparatus, computer device, and storage medium for scheduling container instances. Background Technology
[0004] With the development of distributed storage systems and container technology, the need for container orchestration has become increasingly apparent, leading to the emergence of container orchestration tools. All containers managed by a container orchestration tool are called a container cluster. To ensure the normal operation of each host node in the container cluster, container orchestration tools have developed a mechanism—the pressure eviction mechanism. This mechanism randomly evicts one or more container instances running on a node when its memory, disk, or other resources are insufficient, ensuring that the operation of other container instances and the container orchestration program on that node is not affected. This random behavior may lead to the deletion of some important services, causing a decrease in throughput, slower response times, and system lag. Furthermore, evicted (i.e., deleted) container instances will randomly attempt to restart on other host nodes. If the reassigned host also lacks sufficient resources, they will be evicted repeatedly, potentially leading to containers failing to be scheduled or finding a suitable node only after multiple evictions, resulting in low efficiency.
[0005] To address the issue of container cluster node eviction due to pressure, manual monitoring of container instances running on each node is typically required. When an eviction is detected, it's observed whether the evictioned instance can be successfully restarted, and whether the reassigned host node has sufficient resources to prevent further eviction. If no suitable node is available, the cluster is expanded. However, this approach leads to untimely scheduling of container instances, resulting in a high probability of cluster failure. Furthermore, it lacks proactive early warning, and the need for constant monitoring of cluster eviction status by operations personnel results in high costs and low efficiency in container instance scheduling. Summary of the Invention
[0006] According to an embodiment of this application, in a first aspect, a method for scheduling container instances is provided. The method includes: determining, in at least one host node included in a container cluster, the total predicted load of each host node and the predicted load of each container instance on each host node, wherein at least one container instance can run on each host node, each container instance corresponds to a predicted load during runtime, and the total predicted load is the sum of the predicted loads of all container instances running on each host node; determining, by comparing the total predicted load of each host node with a preset load of each host node, whether there exists a first host node whose total predicted load is greater than the preset load; in response to the existence of such a first host node, determining, based on the total predicted load and the preset load of the first host node, a first container instance to be scheduled on the first host node, wherein the first host node is a host node among at least one host node; evict the first container instance from the first host node and schedule the first container instance to a second host node other than the first host node among at least one host node, wherein the second host node is a host node in the container cluster capable of running the first container instance.
[0007] Secondly, this application provides a container instance scheduling device, which includes: a processing module, configured to determine the total predicted load of each host node and the predicted load of each container instance on each host node in at least one host node included in the container cluster, wherein at least one container instance can run on each host node, each container instance corresponds to a predicted load when it runs, and the total predicted load is the sum of the predicted loads of all container instances running on each host node.
[0008] The processing module is also used to determine whether there is a first host node whose total predicted load is greater than the preset load by comparing the total predicted load of each host node with the preset load of each host node. The total predicted load of the first host node is greater than the preset load.
[0009] The processing module is also configured to respond to the existence of a first host node with a total predicted load greater than a preset load, and determine the first container instance that the first host node needs to be scheduled based on the total predicted load and the preset load of the first host node, wherein the first host node is a host node among at least one host node.
[0010] The scheduling module is also used to evict the first container instance from the first host node and schedule the first container instance to at least one second host node other than the first host node, the second host node being a host node in the container cluster that can run the first container instance.
[0011] Thirdly, this application provides a computer device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the scheduling method of the container instance of the first aspect or any corresponding embodiment described above.
[0012] Fourthly, this application provides a non-transitory computer-readable storage medium storing computer instructions, which are used to cause a computer to execute the scheduling method of the container instance of the first aspect or any corresponding embodiment described above.
[0013] Fifthly, this application provides a computer program product, including computer instructions for causing a computer to execute a scheduling method for a container instance of the first aspect or any corresponding embodiment described above.
[0014] Details of one or more embodiments of this application are set forth in the following drawings and description. Other features and advantages of this application will become apparent from the specification, drawings, and claims. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0016] Figure 1 is a topology diagram of a scheduling system for container instances according to an embodiment of this application;
[0017] Figure 2 is a flowchart of a method for scheduling container instances according to an embodiment of this application;
[0018] Figure 3 is a flowchart of the training method of the target prediction model according to an embodiment of this application;
[0019] Figure 4 is a flowchart illustrating a scheduling method for another container instance according to an embodiment of this application;
[0020] Figure 5 is a structural block diagram of a scheduling device for a container instance according to an embodiment of this application;
[0021] Figure 6 is a schematic diagram of the hardware structure of a computer device according to an embodiment of this application;
[0022] Figure 7 is a schematic diagram of the structure of a non-transitory computer-readable storage medium according to an embodiment of this application;
[0023] Figure 8 is a schematic diagram of the structure of a computer program product according to an embodiment of this application. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0025] The embodiments of this application are applied to container clusters.
[0026] Before the advent of container technology, Virtual Machines (VMs) were the primary virtualization technology. VMs provide hardware-level isolation, with each VM having its own operating system and resources. However, VMs have limitations such as slow startup, high resource consumption, and difficulty in migration. Container technology overcomes these limitations by providing a lightweight, isolated environment at the operating system level. Because containers share the host machine's operating system kernel, they start quickly, consume fewer resources, and are easy to migrate and scale. With the increasing prevalence of cloud computing, the demand for elastic, scalable, and distributed systems has increased. Container technology provides a lightweight, portable execution environment, making it ideal for deploying and scaling applications in cloud environments.
[0027] As described in the background section, in order to deal with the problem of pressure eviction of container cluster nodes, it is usually necessary to manually monitor the container instances running on each node. This method results in the inability to schedule container instances in a timely manner, leading to a high probability of cluster failure. Furthermore, it cannot provide early warnings and the cost and efficiency of scheduling container instances are high because it requires maintenance personnel to constantly monitor the cluster eviction status.
[0028] To address the aforementioned technical issues, this application provides a method for scheduling container instances. By predicting the load of container instances running on host nodes, the method schedules container instances in a timely manner, thereby reducing the probability of cluster failures, lowering scheduling costs, and improving scheduling efficiency.
[0029] The following description uses the scheduling system 100 of the container instance shown in Figure 1 as an example to illustrate the method provided in this application. Figure 1 is only a schematic diagram and does not constitute a limitation on the applicable scenarios of the technical solution provided in this application.
[0030] As shown in Figure 1, Figure 1 is a topology diagram of a container instance scheduling system according to an embodiment of this application. In Figure 1, the container instance scheduling system 100 may include a container instance scheduling device 101, a first host node 102, a second host node 103, and a third host node 104.
[0031] The container instance scheduling device 101 in this embodiment can be a device with communication and computing functions, such as a server, cloud server, or virtual machine. The container instance scheduling device 101 can be used to manage the host nodes included in the container cluster, such as the first host node 102, the second host node 103, and the third host node 104.
[0032] Optionally, the container instance scheduling device 101 includes a monitoring module, a prediction module, a scheduling and early warning module, and an eviction module. The monitoring module monitors each host node in the container cluster. The prediction module predicts the load of each container instance. The scheduling and early warning module schedules container instances and issues an early warning when the load of a host node in the cluster exceeds a preset load. The eviction module evicts container instances from the host nodes.
[0033] In this embodiment, the first host node 102, the second host node 103, or the third host node 104 can be any host node in the container cluster. Each host node runs at least one container instance.
[0034] Each host node is equipped with a NodeExporter component, which can obtain the load of each container instance among all container instances running on each host node.
[0035] Understandably, the container instance scheduler deploys a PrometheusServer component. The PrometheusServer component is used to periodically pull the NodeExporter component's interface and store the load of each container instance.
[0036] The container instance scheduling system 100 shown in Figure 1 is for illustrative purposes only and is not intended to limit the technical solutions of this application. Those skilled in the art should understand that in specific implementations, the container instance scheduling system 100 may also include other host nodes, and the number of host nodes can be determined according to specific needs without limitation.
[0037] According to an embodiment of this application, a method for scheduling container instances is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0038] This embodiment provides a method for scheduling container instances, which can be used in the aforementioned container instance scheduling apparatus. Figure 2 is a flowchart of the container instance scheduling method according to an embodiment of this application. As shown in Figure 2, the process includes the following steps:
[0039] S201: In at least one host node included in the container cluster, determine the total predicted load for each host node and the predicted load for each container instance on each host node.
[0040] The total predicted load is the sum of the predicted loads of all container instances running on each host node.
[0041] Each host node can run at least one container instance, and each container instance corresponds to a predicted load when it runs.
[0042] In some optional implementations, the container instance scheduling device obtains the load of each container instance among all container instances running on each host node in the current period; inputs the load into the target prediction model and outputs the predicted load; calculates the sum of the predicted loads of each container instance to obtain the total predicted load of each host node.
[0043] The load of each container instance refers to the resource usage of each container instance within the current period. For example, the load of each container instance can be the CPU (Central Processing Unit) utilization, memory utilization, disk throughput, or network throughput of each container instance within the current period.
[0044] In this embodiment, the target prediction model is used to predict the predicted load of each container instance in the next cycle. The target prediction model is trained by the container instance scheduling device. As shown in Figure 3, Figure 3 is a flowchart of the training method of the target prediction model in this embodiment; specifically, in Figure 3, the container instance scheduling device further performs the following steps:
[0045] S301: Before inputting the load into the target prediction model, obtain the first historical load of each container instance among all container instances running on at least one host node within the first historical period.
[0046] The first historical load can be multiple historical loads within the first historical period.
[0047] Example 1, taking the first host node as an example, the first historical load can be multiple historical disk throughputs within the first historical period. For example, multiple historical disk throughputs include 100M, 10M, 90M, and 30M.
[0048] S302: Normalize the first historical load to obtain the historical load dataset.
[0049] In one example, the scheduling device of the container instance normalizes the first historical load based on the first formula, and compresses the first historical load to the range of [0,1] through min-max normalization to obtain the historical load dataset.
[0050] The first formula is:
[0051] Where, x i For the i-th historical load; x min The smallest historical load among multiple historical loads; x max This is the largest historical load among multiple historical loads.
[0052] Example 2, taking the first historical load of 100M, 10M, 90M and 30M in Example 1 as an example, the scheduling device of the container instance normalizes 100M, 10M, 90M and 30M based on the first formula, and the historical load dataset includes 1, 0, 8 / 9 and 2 / 9.
[0053] S303: Slide through the historical load dataset using the time pane to obtain the feature dataset.
[0054] In one example, the scheduler of the container instance normalizes the first historical load based on a second formula to obtain a historical load dataset.
[0055] The second formula is:
[0056] Among them, a i It is the i-th time pane, b i It is the next preceding time pane, n is the number of data in the pane, i is the data index in the pane, and y is the new feature data value in the feature dataset.
[0057] S304: Obtain the pre-trained first model and adjust the gradient parameters of the first model to obtain the second model.
[0058] The first model is a prediction model based on Long Short-Term Memory (LSTM) network, and an LSTM-Attention model that incorporates an attention mechanism.
[0059] The first model corresponds to the first gradient parameters.
[0060] In some optional implementations, the scheduling device of the container instance obtains the historical feature dataset of the first model, which includes multiple sample data; calculates the gradient estimate of the second model based on the multiple sample data and the first gradient parameter; determines the cumulative squared gradient value of the second model based on the gradient estimate and the decay coefficient; calculates the parameter update value of the first gradient parameter based on the cumulative squared gradient value and the gradient estimate; calculates the sum of the parameter update value and the first gradient parameter to obtain the second gradient parameter, and configures the second gradient parameter into the first model to obtain the second model.
[0061] In one example, the scheduler of the container instance calculates the gradient estimate of the second model based on multiple sample data and a first gradient parameter, and on a third formula.
[0062] The third formula is
[0063] Where, x i It can be the i-th sample data in a set of multiple sample data, or it can be the i-th historical load.
[0064] f(x i Let x, θ) be the objective function. i The corresponding mapping is y i L is the loss function. θ represents the first gradient parameter.
[0065] In one example, the scheduler of the container instance determines the cumulative squared gradient value of the second model based on the gradient estimate and the decay coefficient, and on the fourth formula.
[0066] The fourth formula is α=βα+(1-β)s.
[0067] Where β is the decay coefficient and α is the cumulative squared gradient value.
[0068] In one example, the scheduler of the container instance calculates the parameter update value of the first gradient parameter based on the cumulative squared gradient value and the gradient estimate, and based on the fifth formula.
[0069] Among them, the fifth formula is
[0070] Where ε represents the global learning rate, δ is a small constant, and e is the natural constant. Δθ represents the parameter update value.
[0071] S305: Train the second model based on the feature dataset to obtain the target prediction model.
[0072] The feature dataset includes a training feature dataset and a test feature dataset. The ratio of the training feature dataset to the test feature dataset can be set according to actual needs; for example, the ratio could be 7:3.
[0073] In one instance, the scheduling device of the container instance inputs the training feature dataset into the second model for model training to obtain the third model; and inputs the test feature dataset into the third model for model validation to obtain the target prediction model.
[0074] Understandably, the target prediction model can assign different weights to different features during the prediction process to improve prediction accuracy. Furthermore, the inclusion of a decay coefficient β when calculating the cumulative squared gradient accelerates the speed at which the target prediction model predicts the load of container instances.
[0075] S202: By comparing the total predicted load of each host node with the preset load of each host node, determine whether there is a host node whose total predicted load is greater than the preset load.
[0076] One possible design is that the preset load can be set according to actual needs without restriction.
[0077] Understandably, at least one host node with a total predicted load greater than the preset load needs to schedule container instances running on that host node.
[0078] S203: If there is a first host node whose total predicted load is greater than the preset load, then determine the first container instance that the first host node needs to schedule based on the total predicted load and the preset load of the first host node.
[0079] The first host node runs N container instances, and its total predicted load is greater than the preset load. The first host node is the host node from which container instances need to be scheduled.
[0080] In some optional implementations, the scheduling device of the container instance calculates the difference between the total predicted load of the first host node and the preset load to obtain a first difference; selects M container instances from N container instances; calculates the difference between the first difference and the predicted load of each container instance in the M container instances to obtain M second differences; and takes the container instance corresponding to the smallest second difference among the N second differences as the first container instance.
[0081] Among them, the predicted load of each of the M container instances is greater than or equal to the first difference, and N≥M.
[0082] S204: Evict the first container instance from the first host node and schedule the first container instance to at least one second host node other than the first host node.
[0083] In one example, the scheduler of the container instance determines the host node with the smallest total predicted load as the second host node based on the total predicted load of the host nodes other than the first host node among at least one host node.
[0084] Understandably, the second host node is the host node with the lowest total predicted load among the other host nodes, which means that the second host node is most likely not to trigger the eviction of the container instance among the other host nodes. Therefore, the first container instance needs to be scheduled to the second host node.
[0085] In some optional implementations, after scheduling the first container instance to the second host node, the scheduling device of the container instance calculates the sum of the total predicted load of the second host node and the predicted load of the first container instance to obtain the total predicted load of the second host node; compares the total predicted load of the second host node with a preset load; if the total predicted load is greater than the preset load, then determines the second container instance that needs to be scheduled by the second host node based on the total predicted load and the preset load; evicts the second container instance from the second host node and schedules the second container instance to other host nodes other than the second host node, until the total predicted load of each host node after scheduling is less than or equal to the preset load.
[0086] The predicted load of the second container instance is less than the predicted load of the first container instance. P container instances are running on the second host node.
[0087] In some optional implementations, the scheduling device of the container instance calculates the difference between the predicted total load and the preset load to obtain a third difference; selects Q container instances from P container instances; calculates the difference between the third difference and the predicted load of each container instance in the Q container instances to obtain Q fourth differences; and takes the container instance corresponding to the smallest fourth difference among the Q fourth differences as the second container instance.
[0088] Among them, the predicted load of each of the Q container instances is greater than or equal to the third difference, and P≥Q.
[0089] Optionally, if the predicted total load is less than or equal to the preset load, the container instance's scheduler will not trigger the second host node to evict the container instance.
[0090] In some alternative implementations, if after traversing and scheduling at least one host node, there is still a third host node whose total predicted load is greater than the preset load, the container instance scheduling device will evict the container instance from the third host node until the total predicted load of the third host node is less than or equal to the preset load.
[0091] In one example, a container instance belongs to a service, and a container instance corresponding to a service can be deployed on multiple host nodes.
[0092] In some optional implementations, the container instance scheduling device obtains the number of container instances, the number of task requests, and the weight ratio of each service in at least one service; determines the importance score of each service based on the number of task requests, the number of container instances, and the weight ratio; and evicts the container instance corresponding to the service with the lowest importance score from the third host node based on the importance score.
[0093] In one example, the container instance scheduling device calculates the importance score of each service according to a preset algorithm based on the number of task requests, the number of container instances, and the weight ratio.
[0094] The preset algorithm is: D = A / B * C.
[0095] Where D represents the importance score, A represents the number of task requests, B represents the number of container instances, and C represents the weight percentage.
[0096] Understandably, when evicting container instances from a third-party host node, the number of container instances corresponding to each service, the number of task requests, and the weight ratio of each service in at least one service can be comprehensively determined to minimize the impact of eviction and avoid eviction of container instances of important services.
[0097] Based on the methods described in S201 to S204, the total predicted load of each host node in the container cluster can be determined. By comparing the total predicted load with the preset load, the first host node that needs to schedule container instances and the first container instance that needs to be scheduled on the first host node can be determined, and then the first container instance can be evicted from the first host node. Since the total predicted load of each host node is determined, and the total predicted load is the total predicted load of each host node at a future time, the first host node and the first container instance that need to be scheduled can be determined in advance based on the predicted total predicted load. This avoids the problem of not being able to schedule container instances in a timely manner when the container cluster nodes are under pressure to evict, thereby reducing the probability of cluster failure, improving the efficiency of container instance scheduling, reducing the cost of container instance scheduling, and improving the availability of the system.
[0098] This embodiment also provides a method for scheduling container instances, as shown in Figure 4, which is an illustration of this embodiment. In Figure 4, the container instance scheduling device further performs the following:
[0099] S401: Determine the total predicted load for each host node in at least one host node included in the container cluster;
[0100] S402: Determine whether the total predicted load of each host node is greater than the preset load of each host node;
[0101] S403: If not, do not trigger the host node to evict the container instance;
[0102] S404: If so, determine the first host node that needs to schedule container instances, and determine the first container instance that needs to be scheduled by the first host node based on the total predicted load and preset load of the first host node.
[0103] S405: Determine if there is an idle load greater than or equal to the target host node of the first container instance;
[0104] S406: If so, the first container instance is scheduled to the target host node, and the sum of the total predicted load of the target host node after scheduling and the predicted load of the first container instance is less than or equal to the preset load.
[0105] S407: If not, then determine the container instances to be scheduled and evict them based on the number of container instances, the number of task requests, and the weight ratio of each service on at least one host node.
[0106] This embodiment also provides a container instance scheduling device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0107] This embodiment provides a container instance scheduling device, as shown in Figure 5. Figure 5 is a structural block diagram of a container instance scheduling device according to an embodiment of this application; the device includes:
[0108] The processing module 501 is used to determine the total predicted load of each host node and the predicted load of each container instance on each host node in the container cluster, wherein at least one container instance can run on each host node, each container instance corresponds to a predicted load when it runs, and the total predicted load is the sum of the predicted loads of all container instances running on each host node.
[0109] The processing module 501 is also used to determine whether there is a host node whose total predicted load is greater than the preset load by comparing the total predicted load of each host node with the preset load of each host node.
[0110] The processing module 501 is further configured to, if there is a first host node whose total predicted load is greater than the preset load, determine the first container instance that the first host node needs to be scheduled based on the total predicted load and the preset load of the first host node, wherein the first host node is a host node among at least one host node.
[0111] The scheduling module 502 is also used to evict the first container instance from the first host node and schedule the first container instance to at least one second host node other than the first host node, wherein the second host node is a host node in the container cluster that can run the first container instance.
[0112] In some optional implementations, the processing module 501 is specifically used to obtain the load of each container instance among all container instances running on each host node in the current period; the processing module 501 is also specifically used to input the load into the target prediction model and output the predicted load, the target prediction model is used to predict the predicted load of each container instance in the next period; the processing module 501 is also specifically used to calculate the sum of the predicted loads of each container instance to obtain the total predicted load of each host node.
[0113] In some optional implementations, N container instances run on the first host node; the processing module 501 is further specifically used to calculate the difference between the total predicted load of the first host node and the preset load to obtain a first difference; the processing module 501 is further specifically used to select M container instances from the N container instances, wherein the predicted load of each of the M container instances is greater than or equal to the first difference, and N≥M; the processing module 501 is further specifically used to calculate the difference between the first difference and the predicted load of each of the M container instances to obtain M second differences; the processing module 501 is further specifically used to take the container instance corresponding to the smallest second difference among the N second differences as the first container instance.
[0114] In some optional implementations, after scheduling the first container instance to the second host node, the processing module 501 is further configured to calculate the sum of the total predicted load of the second host node and the predicted load of the first container instance to obtain the total predicted load of the second host node; the processing module 501 is further configured to compare the total predicted load of the second host node with a preset load; the processing module 501 is further configured to, if the total predicted load is greater than the preset load, determine the second container instance that needs to be scheduled for the second host node based on the total predicted load and the preset load, wherein the predicted load of the second container instance is less than the predicted load of the first container instance; the scheduling module 502 is further configured to evict the second container instance from the second host node and schedule the second container instance to other host nodes other than the second host node, until the total predicted load of each host node after scheduling is less than or equal to the preset load.
[0115] In some optional implementations, P container instances run on the second host node; the processing module 501 is further specifically used to calculate the difference between the sum of predicted loads and the preset load to obtain a third difference; the processing module 501 is further specifically used to select Q container instances from the P container instances, wherein the predicted load of each of the Q container instances is greater than or equal to the third difference, P≥Q; the processing module 501 is further specifically used to calculate the difference between the third difference and the predicted load of each of the Q container instances to obtain Q fourth differences; the processing module 501 is further specifically used to select the container instance corresponding to the smallest fourth difference among the Q fourth differences as the second container instance.
[0116] In some alternative implementations, the scheduling module 502 is further configured to not trigger the second host node to evict the container instance if the predicted total load is less than or equal to the preset load.
[0117] In some optional implementations, the scheduling module 502 is further configured to, if after traversing and scheduling at least one host node, there is still a third host node whose total predicted load is greater than a preset load, evict container instances from the third host node until the total predicted load of the third host node is less than or equal to the preset load.
[0118] In some optional implementations, a container instance belongs to a service, and a container instance corresponding to a service can be deployed on multiple host nodes; a third host node runs container instances of at least one service; the scheduling module 502 is specifically used to obtain the number of container instances, the number of task requests, and the weight ratio of each service in the at least one service; the scheduling module 502 is also specifically used to determine the importance score of each service based on the number of task requests, the number of container instances, and the weight ratio; the scheduling module 502 is also specifically used to evict the container instance corresponding to the service with the lowest importance score from the third host node based on the importance score.
[0119] In some optional implementations, the scheduling module 502 is further configured to calculate the importance score of each service according to a preset algorithm based on the number of task requests, the number of container instances, and the weight ratio. The preset algorithm is: D = A / B * C; where D represents the importance score, A represents the number of task requests, B represents the number of container instances, and C represents the weight ratio.
[0120] In some optional implementations, before inputting the load into the target prediction model, the processing module 501 is further configured to obtain the first historical load of each container instance among all container instances running on at least one host node within a first historical period; the processing module 501 is further configured to normalize the first historical load to obtain a historical load dataset; the processing module 501 is further configured to slide the historical load dataset through a time pane to obtain a feature dataset; the processing module 501 is further configured to obtain a pre-trained first model and adjust the gradient parameters of the first model to obtain a second model; the processing module 501 is further configured to train the second model based on the feature dataset to obtain the target prediction model.
[0121] In some optional implementations, the first model corresponds to the first gradient parameters; the processing module 501 is further specifically used to obtain the historical feature dataset of the first model, which includes multiple sample data; the processing module 501 is further specifically used to calculate the gradient estimate of the second model based on the multiple sample data and the first gradient parameters; the processing module 501 is further specifically used to determine the cumulative squared gradient value of the second model based on the gradient estimate and the decay coefficient; the processing module 501 is further specifically used to calculate the parameter update value of the first gradient parameters based on the cumulative squared gradient value and the gradient estimate; the processing module 501 is further specifically used to calculate the sum of the parameter update value and the first gradient parameters to obtain the second gradient parameters, and configure the second gradient parameters into the first model to obtain the second model.
[0122] In some optional implementations, the processing module 501 is further configured to determine the host node with the smallest total predicted load as the second host node based on the total predicted load of the host nodes other than the first host node among at least one host node.
[0123] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0124] In this embodiment, the scheduling device for the container instance is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0125] This application also provides a computer device having a scheduling device for the container example shown in FIG5 above.
[0126] Please refer to Figure 6, which is a schematic diagram of the structure of a computer device provided in an optional embodiment of this application. As shown in Figure 6, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components communicate with each other using different buses and can be installed on a common motherboard or otherwise as needed. The processor can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 6 uses one processor 10 as an example.
[0127] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GPA), or any combination thereof.
[0128] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0129] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0130] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0131] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.
[0132] Referring to Figure 7, this application embodiment also provides a non-transitory computer-readable storage medium. The methods described above according to this application embodiment can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that a computer, processor, microprocessor controller, or programmable hardware includes storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the methods shown in the above embodiments are implemented.
[0133] Referring to Figure 8, a portion of this application can be applied as a computer program product, such as computer program instructions. When executed by a computer, these instructions, through the operation of the computer, can invoke or provide the methods and / or technical solutions according to this application. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, and installation package files. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions; the computer compiling the instructions and then executing the corresponding compiled program; the computer reading and executing the instructions; or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available non-transitory computer-readable storage medium or communication medium accessible to a computer.
[0134] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and all such modifications and variations fall within the scope defined by the appended claims.
Claims
1. A method for scheduling container instances, characterized in that, The method includes: In at least one host node included in the container cluster, the total predicted load of each host node and the predicted load of each container instance on each host node are determined, wherein at least one container instance can run on each host node, each container instance corresponds to a predicted load when it runs, and the total predicted load is the sum of the predicted loads of all container instances running on each host node. By comparing the total predicted load of each host node with the preset load, it is determined whether there is a first host node whose total predicted load is greater than the preset load; In response to the existence of a first host node whose total predicted load exceeds the preset load, a first container instance to be scheduled for the first host node is determined based on the total predicted load of the first host node and the preset load, wherein the first host node is a host node among the at least one host node; and The first container instance is evicted from the first host node and scheduled to a second host node other than the first host node in the at least one host node, wherein the second host node is a host node in the container cluster capable of running the first container instance.
2. The method according to claim 1, characterized in that, Determining the total predicted load for each host node and the predicted load for each container instance on each host node within the container cluster includes: Get the load of each container instance running on each of the host nodes in the current period; The load is input into the target prediction model, and the predicted load is output. The target prediction model is used to predict the predicted load of each container instance in the next period; and The sum of the predicted loads for each of the container instances is calculated to obtain the total predicted load for each of the host nodes.
3. The method according to claim 2, characterized in that, The first host node runs N container instances; determining the first container instance to be scheduled by the first host node based on the total predicted load of the first host node and the preset load includes: Calculate the difference between the total predicted load of the first host node and the preset load to obtain the first difference; Select M container instances from the N container instances, wherein the predicted load of each of the M container instances is greater than or equal to the first difference, and N≥M; Calculate the difference between the first difference and the predicted load of each of the M container instances to obtain M second differences; and The container instance corresponding to the smallest second difference among the N second differences is taken as the first container instance.
4. The method according to any one of claims 1-3, characterized in that, After scheduling the first container instance to the second host node, the method further includes: The total predicted load of the second host node is calculated by summing the total predicted load of the first container instance to obtain the total predicted load of the second host node. Compare the predicted total load of the second host node with the preset load; In response to the predicted total load being greater than the preset load, based on the predicted total load and the preset load, a second container instance that the second host node needs to schedule is determined, wherein the predicted load of the second container instance is less than the predicted load of the first container instance; and The second container instance is evicted from the second host node and scheduled to other host nodes other than the second host node, until the total predicted load of each of the scheduled host nodes is less than or equal to the preset load.
5. The method according to claim 1, characterized in that, The second host node runs P container instances; determining the second container instance that needs to be scheduled on the second host node based on the predicted total load and the preset load includes: Calculate the difference between the predicted total load and the preset load to obtain a third difference; Select Q container instances from the P container instances, wherein the predicted load of each of the Q container instances is greater than or equal to the third difference, where P ≥ Q; Calculate the difference between the third difference and the predicted load of each of the Q container instances to obtain Q fourth differences; and The container instance corresponding to the smallest fourth difference among the Q fourth differences is used as the second container instance.
6. The method according to claim 5, characterized in that, The method further includes: In response to the predicted total load being less than or equal to the preset load, the second host node is not triggered to evict the container instance.
7. The method according to claim 4, characterized in that, The method further includes: If, after traversing and scheduling all at least one host node, there is still a third host node whose total predicted load is greater than the preset load, container instances are evicted from the third host node until the total predicted load of the third host node is less than or equal to the preset load.
8. The method according to claim 7, characterized in that, A container instance belongs to a service, and a container instance corresponding to a service can be deployed on multiple host nodes; the third host node runs at least one container instance of a service. The process of evictting the container instance from the third host node includes: Obtain the number of container instances, the number of task requests, and the weight percentage of each service in the at least one service; Based on the number of task requests, the number of container instances, and the weight percentage, determine the importance score for each service; and Based on the importance score, the container instance corresponding to the service with the lowest importance score is evicted from the third host node.
9. The method according to claim 8, characterized in that, The step of determining the importance score for each service based on the number of task requests, the number of container instances, and the weight ratio includes: Based on the number of task requests, the number of container instances, and the weight ratio, the importance score for each service is calculated according to a preset algorithm, wherein the preset algorithm is: D = A / B * C; and Wherein, D represents the importance score, A represents the number of task requests, B represents the number of container instances, and C represents the weight percentage.
10. The method according to claim 2, characterized in that, Before inputting the load into the target prediction model, the method further includes: Obtain the first historical load of each container instance running on the at least one host node within the first historical period; The first historical load is normalized to obtain the historical load dataset; The historical load dataset is slid through a time pane to obtain the feature dataset; Obtain a pre-trained first model and adjust its gradient parameters to obtain a second model; and The second model is trained based on the feature dataset to obtain the target prediction model.
11. The method according to claim 10, characterized in that, The first model corresponds to the first gradient parameters; adjusting the gradient parameters of the first model to obtain the second model includes: Obtain the historical feature dataset of the first model, wherein the historical feature dataset includes multiple sample data; Based on the multiple sample data and the first gradient parameter, calculate the gradient estimate of the second model; Based on the gradient estimate and the decay coefficient, determine the cumulative squared gradient value of the second model; Based on the cumulative squared gradient value and the gradient estimate, calculate the parameter update value of the first gradient parameter; and The sum of the parameter update value and the first gradient parameter is calculated to obtain the second gradient parameter, and the second gradient parameter is configured into the first model to obtain the second model.
12. The method according to claim 1, characterized in that, The method further includes: Based on the total predicted load of the host nodes other than the first host node among the at least one host nodes, the host node with the smallest total predicted load is determined as the second host node.
13. The method according to claim 1, characterized in that, The method further includes: In response to the absence of a first host node whose total predicted load is greater than the preset load, the first host node is not triggered to evict the container instance.
14. The method according to claim 10, characterized in that, The normalization process for the first historical load includes: The first historical load is normalized according to the following first formula: Where, x i x represents the i-th first historical load; min This represents the smallest historical load among multiple first historical loads; x max The largest historical load among the multiple first historical loads.
15. The method according to claim 10, characterized in that, The sliding process of the historical load dataset through a time pane includes: The historical load dataset is then subjected to sliding processing according to the following second formula: Among them, a i b represents the i-th time pane. i y represents the previous time pane immediately preceding the time interval window, n represents the number of data in the time pane, i represents the data index in the time pane, and y represents the new feature data value in the feature dataset.
16. The method according to claim 10, characterized in that, The first model includes a predictive model based on long short-term memory networks.
17. The method according to claim 11, characterized in that, The calculation of the gradient estimate of the second model includes: The gradient estimate of the second model is calculated using the following third formula: Where, x i f(x) represents the i-th sample data in a set of multiple sample data. i Let x, θ) represent the objective function, and x i The corresponding mapping is y i L represents the loss function, and θ represents the first gradient parameter.
18. A computer device, characterized in that, include: A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the scheduling method for a container instance according to any one of claims 1 to 17.
19. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions for causing the computer to execute the scheduling method for the container instance according to any one of claims 1 to 17.
20. A computer program product, characterized in that, Includes computer instructions for causing a computer to execute the scheduling method for a container instance according to any one of claims 1 to 17.
Citation Information
Patent Citations
Intelligent resource optimization method of container cloud platform based on load prediction
CN108829494A
Container expelling method, container expelling equipment and readable storage medium
CN117724801A
Service instance scheduling method and device, electronic equipment and storage medium
CN117914948A
Cluster management method and device
CN118260132A
Container instance scheduling method and device, computer equipment and storage medium
CN119065795A