A task scheduling method and system based on resource demand prediction
Through the task scheduling method based on resource demand prediction, combined with prediction and scheduling models, the problems of low resource utilization and long task waiting time in the task scheduling system are solved, and efficient resource utilization and rapid response to task execution are achieved.
Patent Information
- Application Number
- CN202210172467.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-24
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2042-02-24
AI Technical Summary
While ensuring service quality, existing task scheduling systems are difficult to maximize the use of cloud, network and end resources, resulting in resource fragmentation and long task waiting time.
Using a task scheduling method based on resource demand prediction, the resource requirements and time required for tasks to be executed are obtained through the prediction model, and combined with the working status of the executor, the task scheduling is used to ensure the reasonable allocation of resources and the rapid task. implement. The specific steps include building a prediction model to obtain resource requirements for historical tasks, building a scheduling model to assign tasks to be executed, and monitoring and adjusting task execution in real time.
It effectively shortens the waiting time of tasks, improves resource utilization efficiency, and ensures the response speed of the task scheduling system and the maximum utilization of resources.
Smart Images

Figure CN114579270B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of system engineering, and in particular to a task scheduling method and system based on resource demand prediction. Background Art
[0002] With the development and maturity of cloud computing, blockchain, edge computing and other industries, the use of cloud computing, blockchain and edge computing technologies for cloud-network-end data resource sharing and computing power integration has become an important trend in the industry. The timely transmission of cloud, network and end data, the normal operation of business, and the efficient use of resources all rely on the distribution and coordination of business by the scheduling system.
[0003] Currently, frameworks such as Hadoop, Spark, and Kubernetes include task scheduling functions to achieve task and resource scheduling. Distributed task scheduling platforms such as Azkaban and XXL-JOB are also widely used in cloud computing, data middleware, etc. to achieve task distribution and scheduling. The core of task scheduling is the task scheduling algorithm. At present, the research focus of task scheduling systems is to maximize resource utilization while ensuring service quality. Common scheduling algorithms include first-come-first-served, round-robin scheduling, shortest job first, simulated annealing, ant colony optimization, particle swarm optimization, etc.
[0004] Taking Azkaban as an example, its typical scheduling strategy adopts a first-in-first-out scheduling algorithm, that is, first obtain the tasks in the task queue to be executed, then make judgments based on the current status of all executors, and finally distribute the tasks to be executed to the executors to complete the execution of the tasks. In the above scheduling methods, on the one hand, the algorithm for fair task scheduling has serious resource fragmentation and cannot maximize the use of cloud, network, and terminal computing and network resources; on the other hand, the algorithm for efficient task scheduling also has the problem that task scheduling targets high resources, the waiting time of some tasks is too long, and the overall service capability of the system is low.
[0005] Therefore, how to reasonably schedule the tasks submitted by users, maximize the use of cloud, network, and terminal resources, shorten the overall execution time of tasks as much as possible, and improve the response speed of the task scheduling system has become a key issue in current research. Summary of the invention
[0006] In view of the above problems, the present invention provides a task scheduling method and system based on resource demand prediction that solves at least some of the above technical problems. Through this method, tasks submitted by users can be reasonably scheduled, thereby maximizing the use of cloud, network, and terminal resources, and shortening the overall execution time of tasks as much as possible, thereby improving the response speed of the task scheduling system.
[0007] In a first aspect, an embodiment of the present invention provides a task scheduling method based on resource demand prediction, comprising:
[0008] S1. Obtaining a task to be executed; predicting the task to be executed by using a prediction model to obtain the resource demand of the task to be executed and the time required to execute the task to be executed;
[0009] S2. According to the resource demand of the task to be executed predicted in S1 and the time required to execute the task to be executed, and in combination with the working status of all executors, the task to be executed is scheduled through a scheduling model.
[0010] Furthermore, the prediction model described in S1 is constructed by:
[0011] S11, obtaining historically executed tasks, resource requirements of the historically executed tasks, and time required to execute the historically executed tasks;
[0012] S12. Based on the historically executed tasks obtained in S11, the resource requirements of the historically executed tasks, and the time required to execute the historically executed tasks, a prediction model is constructed using an SVR algorithm.
[0013] Furthermore, the S2 specifically includes:
[0014] S21, constructing a to-be-executed task scheduling queue TaskList; the to-be-executed task includes a plurality of to-be-executed subtasks;
[0015] S22, inputting task information into the TaskList; the task information includes the task to be executed, the weight information of the task to be executed, the resource requirement of the task to be executed, and the time required to execute the task to be executed;
[0016] S23. In combination with the working status of all executors, the plurality of subtasks to be executed are allocated to corresponding executors through a scheduling model.
[0017] Further, the S23 includes:
[0018] S231, receiving the heartbeat packet of the executor: when the heartbeat packet of the executor j is received, the record array is initialized, and the task information in the TaskList is traversed to obtain a subtask i to be executed among the multiple subtasks to be executed;
[0019] S232. According to the heartbeat packet of the executor j, the available resources of the executor j are judged: if the available resources of the executor j are greater than the resource requirement of the subtask i to be executed, then the formula Calculate the subtask i to be executed, and put the calculation result into the record array, continue to traverse the task information in the TaskList, at this time i=i+1, and execute S233 after the traversal is completed; wherein TaskInfo i represents the subtask i to be executed; weight represents the weight information of the subtask i to be executed; TotalD(i,j) represents the maximum resource requirement of the subtask i to be executed on executor j;
[0020] S233, traverse the record array to find the subtask i to be executed with the smallest calculation result value, the scheduler assigns the subtask i to be executed with the smallest calculation result value to the executor j, and removes the information about the subtask i to be executed from the TaskList; continue to execute S231, at this time j=j+1, and stop the loop until all the multiple subtasks to be executed in the TaskList are assigned to the corresponding executors.
[0021] Furthermore, the scheduling model is expressed as:
[0022]
[0023] in, It represents the average remaining amount of resource k in executor j during the period from t0 to t; represents the average remaining amount of resource k of executor j from t0 to t; represents the total amount of resource k of executor j from t0 to t.
[0024] Furthermore, after each subtask to be executed is scheduled, the weight information of the remaining tasks to be executed in the TaskList is changed to N times of the previous weight information, where N>1.
[0025] Furthermore, the S2 further includes:
[0026] When the executor j is executing the subtask i to be executed, the subtask i to be executed is scheduled by using the scheduling model; the specific steps are as follows:
[0027] When the executor j is executing the subtask i to be executed, the subtask i to be executed is scheduled by using the scheduling model; the specific steps are as follows:
[0028] S234, monitoring in real time the actual execution time of the executor j on the subtask i to be executed;
[0029] S235. If the actual execution time monitored in S234 is longer than the preset time, stop sending new tasks to the executor j, and return all tasks waiting to be executed by the executor j to the TaskList;
[0030] S236, allocating all resources of the executor j to the subtask i to be executed;
[0031] S237. Reallocate the tasks returned to the TaskList in S235.
[0032] In a second aspect, an embodiment of the present invention provides a task scheduling system based on resource demand prediction, including a prediction module and a scheduling module;
[0033] The prediction module is used to predict the task to be executed, obtain the resource demand of the task to be executed, and the time required to execute the task to be executed;
[0034] The scheduling module is used to schedule the tasks to be executed through a scheduling model according to the predicted resource requirements of the tasks to be executed and the time required to execute the tasks to be executed, and in combination with the working status of all executors.
[0035] Compared with the prior art, the task scheduling method based on resource demand prediction recorded in the present invention has the following beneficial effects:
[0036] It can effectively shorten the waiting time for task execution;
[0037] It can further improve the utilization efficiency of the physical resources of the equipment;
[0038] Real-time adjustments can be made to prevent large deviations between prediction and reality, which may cause system problems.
[0039] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0040] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0042] Figure 1A flow chart of a task scheduling method based on resource demand prediction provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0044] See also Figure 1 As shown, an embodiment of the present invention provides a task scheduling method based on resource demand prediction, which specifically includes the following steps:
[0045] S1. Obtaining a task to be executed; predicting the task to be executed by using a prediction model to obtain the resource demand of the task to be executed and the time required to execute the task to be executed;
[0046] S2. According to the resource demand of the task to be executed predicted in S1 and the time required to execute the task to be executed, and in combination with the working status of all executors, the task to be executed is scheduled through a scheduling model.
[0047] Through this method, tasks submitted by users can be reasonably scheduled, thereby maximizing the use of cloud, network, and terminal resources, shortening the overall execution time of tasks as much as possible, and improving the response speed of the task scheduling system.
[0048] The following is a detailed description of each of the above steps.
[0049] In the above step S1, in order to improve resource utilization and reduce resource waste during task scheduling, a prediction module is added in the embodiment of the present invention to predict the resources required for the task to be executed (including CPU, memory, network, etc.); in order to improve the accuracy of the prediction of the task to be executed, the embodiment of the present invention also constructs a prediction model in the prediction module, and the specific construction steps are:
[0050] S11, obtaining historically executed tasks, resource requirements of historically executed tasks, and time required to execute historically executed tasks;
[0051] S12. Based on the historically executed tasks, the resource requirements of the historically executed tasks, and the time required to execute the historically executed tasks obtained in S11, a prediction model is constructed using the SVR algorithm and deep learning. The SVR algorithm is a support vector regression algorithm, which mainly realizes linear regression by constructing a linear decision function in a high-dimensional space after dimensionality increase.
[0052] After the prediction model is built, the prediction is performed according to the type of the task to be executed to obtain the resource demand of the task to be executed and the time required to execute the task to be executed; since the task to be executed includes multiple subtasks to be executed, after the prediction, the resource k of one subtask i for an executor j in the multiple subtasks to be executed can be obtained, and the scheduling demand for the reduction from t0 to t can be expressed as
[0053] In the above step S2, the present invention also constructs a scheduling model in the scheduling module based on the resource demand prediction module, which is used to define the remaining situation of the average resources of the executor, which is specifically expressed as:
[0054]
[0055] in, It represents the average remaining amount of resource k in executor j during the period from t0 to t; represents the average remaining amount of resource k of executor j from t0 to t; represents the total amount of resource k of executor j from t0 to t;
[0056] Assume that after subtask i to be executed is assigned to executor j, formula (1) changes to:
[0057]
[0058] in, represents the total resource requirement of resource k for subtask i to be executed on executor j; represents the average remaining amount of resource k of executor j from t0 to t; represents the average demand for resource k of subtask i to be executed from time t0 to t; represents the total amount of resource k of executor j from t0 to t;
[0059] In the embodiment of the present invention, the maximum resource requirement of the subtask i to be executed on the executor j is taken as its total resource requirement, which is specifically expressed as:
[0060]
[0061] According to the above definition, the specific steps of step S2 are:
[0062] S21, constructing a to-be-executed task scheduling queue TaskList in the scheduling module; wherein the to-be-executed task includes a plurality of to-be-executed subtasks;
[0063] S22, inputting the task information (TaskInfo) into TaskList; the task information includes the task information to be executed (RunInfo), the weight information of the task to be executed (Weight, the initial value is 1), the resource demand of the task to be executed (ResDemandInfo), and the time required to execute the task to be executed;
[0064] S23. In combination with the working status of all executors, multiple subtasks to be executed are allocated to corresponding executors through a scheduling model; the working status of the executor here includes the execution status and idle status of the executor.
[0065] Wherein, step S23 is specifically as follows:
[0066] S231, receiving the heartbeat packet of the executor: when the heartbeat packet of the executor j is received, initializing the record array (Record), and traversing the task information in the TaskList to obtain a subtask i to be executed among the multiple subtasks to be executed;
[0067] S232: According to the heartbeat packet of the executor j, the available resources of the executor j are j ) to judge: If the available resources of the executor j are greater than the resource requirements of the subtask i to be executed, then the formula Calculate the subtask i to be executed, and put the calculation result into the record array, continue to traverse the task information in the TaskList, at this time i=i+1, and execute S233 after the traversal is completed; wherein TaskInfo i represents the subtask i to be executed; weight represents the weight information of the subtask i to be executed; TotalD(i,j) represents the maximum resource requirement of the subtask i to be executed on executor j; in this step, the formula After calculating the subtask i to be executed, the calculated result is a priority weight value, and the larger the value, the priority should be executed;
[0068] S233, traverse the record array to find the subtask i to be executed with the smallest calculation result value, the scheduler assigns the subtask i to be executed with the smallest calculation result value to the executor j, and removes the information about the subtask i to be executed from the TaskList; continue to execute S231, at this time j=j+1, and stop the loop until all the multiple subtasks to be executed in the TaskList are assigned to the corresponding executors.
[0069] When the scheduler assigns the pending subtask i to executor j, the available resources of executor j change to Availablej -max(TaskInfo i ·ResDemandInfo); the weight information Weight of the remaining tasks to be executed in TaskList is changed to N times of the previous value, where N>1; in this embodiment, the weight information Weight of the remaining tasks to be executed in TaskList is changed to twice of the previous value, that is, 2Weight.
[0070] When executor j is executing subtask i, due to the limitations of physical hardware, software, data, network and other conditions, the actual execution time may deviate from the preset time. When the estimated execution time is too low and a task is not completed, in order to avoid the task causing other tasks of the executor to wait, other tasks to be executed are abandoned and all resources are given to the task being executed, so that the task can be completed quickly. At the same time, other tasks to be executed are queued up again to be assigned to the executor. The specific steps are as follows:
[0071] In the embodiment of the present invention, when the executor j is executing the subtask i to be executed, the subtask i to be executed is scheduled by using the scheduling model:
[0072] S234, real-time monitoring of the actual execution time of the executor j to execute the subtask i;
[0073] S235. If the actual execution time monitored in S234 is longer than the preset time, stop issuing new tasks to executor j, and return all tasks waiting for executor j to be executed to TaskList; it should be noted here that when the executor is in the execution state, the waiting queue should also be evaluated; that is, when the executor is in the execution state, the execution state is actually executing + waiting queue, and it cannot be simply understood that the execution state is executing;
[0074] S236, allocating all resources of executor j to subtask i to be executed;
[0075] S237. Reallocate the tasks returned to TaskList in S235.
[0076] The embodiment of the present invention also provides a task scheduling system based on resource demand prediction, including a prediction module and a scheduling module;
[0077] The prediction module is used to predict the tasks to be executed, obtain the resource requirements of the tasks to be executed, and the time required to execute the tasks to be executed;
[0078] The scheduling module is used to schedule the tasks to be executed through the scheduling model based on the predicted resource requirements of the tasks to be executed and the time required to execute the tasks to be executed, while combining the working status of all executors.
[0079] The embodiment of the present invention provides a task scheduling method and system based on resource demand prediction. In view of the situation that task scheduling leads to low resource utilization and resource waste, historical task operation conditions are used to build a model to obtain the estimated scheduling time of the task. It is necessary to estimate the usage of task resources according to the type of task, and match tasks with resources as soon as possible according to the remaining resources in the future, so as to improve the efficiency of cloud network resource utilization after the task is issued as much as possible. In view of the problem that the task waiting time is too long and affects the user experience, it is necessary to increase the time waiting factor in the priority calculation process of the overall task scheduling to ensure that when the task execution resources are the same or the task waiting time is too long, the task can obtain the running resources and be executed first. The present invention improves the task scheduling system in terms of process, algorithm, etc., so as to achieve the purpose of improving the efficiency of cloud network resource utilization while ensuring the quality of service.
[0080] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A task scheduling method based on resource demand prediction, characterized in that: include: S1. Obtaining a task to be executed; predicting the task to be executed by using a prediction model to obtain the resource demand of the task to be executed and the time required to execute the task to be executed; S2, according to the resource demand of the task to be executed predicted in S1, and the time required to execute the task to be executed, and in combination with the working status of all executors, the task to be executed is scheduled through the scheduling model; The S2 specifically includes: S21, constructing a to-be-executed task scheduling queue TaskList; the to-be-executed task includes a plurality of to-be-executed subtasks; S22, inputting task information into the TaskList; the task information includes the task to be executed, the weight information of the task to be executed, the resource requirement of the task to be executed, and the time required to execute the task to be executed; S23, combining the working status of all executors, and assigning the plurality of to-be-executed subtasks to corresponding executors through a scheduling model; The S23 includes: S231, receiving the heartbeat packet of the executor: when the heartbeat packet of the executor j is received, the record array is initialized, and the task information in the TaskList is traversed to obtain a subtask i to be executed among the multiple subtasks to be executed; S232. According to the heartbeat packet of the executor j, the available resources of the executor j are judged: if the available resources of the executor j are greater than the resource requirement of the subtask i to be executed, then the formula TotalD(i,j) Calculate the subtask i to be executed and put the calculation result into the TaskInfo i ·weight In the record array, continue to traverse the task information in the TaskList, at this time i=i+1, until the traversal is completed and execute S233; wherein TaskInfo i represents the subtask i to be executed; weight represents the weight information of the subtask i to be executed; TotalD(i,j) represents the maximum resource requirement of the subtask i to be executed on executor j; S233, traverse the record array, find the to-be-executed subtask i with the smallest calculation result value, assign the to-be-executed subtask i with the smallest calculation result value to the executor j through the scheduler, and remove the information about the to-be-executed subtask i from the TaskList; continue to execute S231, at this time j=j+1, and stop the loop until all the multiple to-be-executed subtasks in the TaskList are assigned to the corresponding executors; The scheduling model is expressed as: in, It represents the average remaining amount of resource k in executor j during the period from t0 to t; represents the average remaining amount of resource k of executor j from t0 to t; represents the total amount of resource k of executor j from t0 to t.
2. A task scheduling method based on resource demand prediction as claimed in claim 1, characterized in that: The construction method of the prediction model described in S1 is: S11, obtaining historically executed tasks, resource requirements of the historically executed tasks, and time required to execute the historically executed tasks; S12. Based on the historically executed tasks obtained in S11, the resource requirements of the historically executed tasks, and the time required to execute the historically executed tasks, a prediction model is constructed using an SVR algorithm.
3. A task scheduling method based on resource demand prediction as claimed in claim 1, characterized in that: After each subtask to be executed is scheduled, the weight information of the remaining tasks to be executed in the TaskList is changed to N times the previous one, where N>1.
4. The task scheduling method based on resource demand prediction according to claim 1, characterized in that: The S2 further includes: When the executor j is executing the subtask i to be executed, the subtask i to be executed is scheduled by using the scheduling model; the specific steps are as follows: S234, monitoring in real time the actual execution time of the executor j on the to-be-executed subtask i; S235. If the actual execution time monitored in S234 is longer than the preset time, stop sending new tasks to the executor j, and return all tasks waiting to be executed by the executor j to the TaskList; S236, allocating all resources of the executor j to the subtask i to be executed; S237. Reallocate the tasks returned to the TaskList in S235.
5. A task scheduling system based on resource demand prediction, characterized in that: Includes prediction module and scheduling module; The prediction module is used to predict the task to be executed, obtain the resource demand of the task to be executed, and the time required to execute the task to be executed; The scheduling module is used to schedule the tasks to be executed through a scheduling model according to the predicted resource requirements of the tasks to be executed and the time required to execute the tasks to be executed, and in combination with the working status of all executors; The scheduling module specifically includes: A construction submodule is used to construct a to-be-executed task scheduling queue TaskList; the to-be-executed task includes a plurality of to-be-executed subtasks; An input submodule, used to input task information into the TaskList; the task information includes the task to be executed, the weight information of the task to be executed, the resource requirement of the task to be executed, and the time required to execute the task to be executed; An allocation submodule, used to allocate the plurality of to-be-executed subtasks to corresponding executors through a scheduling model in combination with the working status of all executors; The allocation submodule comprises: A receiving unit, configured to receive a heartbeat packet of the executor: when receiving a heartbeat packet of the executor j, initializing a record array, and traversing the task information in the TaskList to obtain a subtask i to be executed among the multiple subtasks to be executed; A judgment unit is used to judge the available resources of the executor j according to the heartbeat packet of the executor j: if the available resources of the executor j are greater than the resource requirement of the subtask i to be executed, then the formula Calculate the subtask i to be executed, and put the calculation result into the record array, continue to traverse the task information in the TaskList, at this time i=i+1, until the traversal is completed and the allocation unit is executed; wherein TaskInfo i represents the subtask i to be executed; weight represents the weight information of the subtask i to be executed; TotalD(i,j) represents the maximum resource requirement of the subtask i to be executed on executor j; an allocating unit, configured to traverse the record array, find the to-be-executed subtask i with the smallest calculation result value, allocate the to-be-executed subtask i with the smallest calculation result value to the executor j through the scheduler, and remove the information about the to-be-executed subtask i from the TaskList; continue to execute the receiving unit, at this time j=j+1, and stop the loop until all the multiple to-be-executed subtasks in the TaskList are allocated to the corresponding executors; The scheduling model is expressed as: in, It represents the average remaining amount of resource k in executor j during the period from t0 to t; represents the average remaining amount of resource k of executor j from t0 to t; represents the total amount of resource k of executor j from t0 to t.
Citation Information
Cited By
Resource prediction and scheduling system in large model training
CN119356831A
A resource prediction and scheduling system for large model training
CN119356831B
