Task scheduling method, task scheduling device, electronic device, medium and product
By acquiring task parameters and server resource status, calculating evaluation values, and selecting target servers, the problem of low task scheduling accuracy is solved, and balanced resource utilization and stable business execution are achieved.
Patent Information
- Application Number
- CN202611486354.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-23
- Publication Date
- 2026-11-10
AI Technical Summary
Existing technologies suffer from low accuracy in task scheduling and cannot dynamically adjust task execution arrangements, leading to uneven resource consumption and potentially causing business delays or crashes.
By acquiring task parameters and server resource status, the evaluation values of tasks and servers are calculated, a target server with lower load is selected to execute the task, and dynamic adjustments are made in the task dependency and retry mechanism to ensure reasonable task scheduling.
It improved the accuracy of task scheduling, achieved balanced resource utilization, avoided business delays and crashes, and improved overall execution efficiency.
Smart Images

Figure CN123068045A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing, specifically to a task scheduling method, task scheduling device, electronic device, medium, and product. Background Technology
[0002] Task scheduling is the core mechanism for coordinating and managing the orderly execution of multiple tasks, and reasonable task scheduling can improve business processing efficiency. In scenarios such as data backup, log cleanup, and report generation, related technologies often use timed scheduling to automatically execute tasks according to preset times or cycles.
[0003] However, the relevant technologies suffer from low task scheduling accuracy. Summary of the Invention
[0004] In view of the above problems, this application provides a task scheduling method, task scheduling device, electronic device, medium and product for improving task scheduling accuracy.
[0005] According to a first aspect of this application, a task scheduling method is provided, comprising: obtaining task parameters of a plurality of tasks to be executed and the current resource status of a plurality of servers in a cluster; determining the current load level of the cluster based on the current usage of cluster resources by the servers indicated by the resource status; determining a first evaluation value for each of the plurality of tasks based on the task parameters and the current load level, the first evaluation value indicating the necessity of using available cluster resources to execute the task; and selecting at least one target task from the plurality of tasks based on the first evaluation value, and sending the target task to a target server in the cluster that meets preset conditions, so that the target server executes the target task.
[0006] According to embodiments of this application, the resource status includes a first utilization rate of the server's processor, a second utilization rate of the server's storage space, and the number of network links of the server; determining the current load level of the cluster based on the current utilization of cluster resources by the servers indicated by the resource status includes: determining a second evaluation value for each of the multiple servers using the first utilization rate, the second utilization rate, and the number of network links, the second evaluation value being used to reflect the current utilization of cluster resources by the server; determining the current load level of each of the multiple servers based on the second evaluation value using a preset mapping relationship, the preset mapping relationship representing the relationship between the server's evaluation value and the load level; and determining the current load level of the cluster based on the current load level of each of the multiple servers.
[0007] According to an embodiment of this application, the task parameters include a preset task weight, a task urgency level, and a task historical success rate; based on the task parameters and the current load level, a first evaluation value is determined for each of the multiple tasks, including: obtaining configuration information for the current task scheduling cycle, the configuration information including at least one preset coefficient of each of the preset task weight, task urgency level, and task historical success rate, and a preset coefficient of the load level; for each task, a first evaluation value is determined using the load level and at least one of the preset task weight, task urgency level, and task historical success rate, as well as the preset coefficient.
[0008] According to an embodiment of this application, the preset conditions include that the current load level of the server is less than or equal to a first load threshold; based on a first evaluation value, selecting at least one target task from multiple tasks and sending the target task to a target server in the cluster that meets the preset conditions includes: based on the first evaluation value, selecting at least one target task from multiple tasks and adding the target task to a queue of tasks to be processed; based on the current load level of each of the multiple servers, selecting a server in the cluster that meets the preset conditions as the target server; and sequentially sending the target tasks in the queue of tasks to be processed to the target server.
[0009] According to an embodiment of this application, the task scheduling method further includes: if a first task and a second task with a dependency relationship exist in the task queue to be processed, and no response information for the first task is received from the target server within a predetermined time period, then the order of the second task in the task queue to be processed is adjusted to the later stage.
[0010] According to an embodiment of this application, the task scheduling method further includes: when receiving a response message from the target server for the target task and the response message indicating that the target server has not successfully executed the target task, resending the target task to the target server; when the number of resends is greater than or equal to a predetermined retry threshold, determining the waiting time of the target task based on the number of resends and stopping sending the target task; and when the time for stopping sending reaches the waiting time, resending the target task to the target server.
[0011] According to an embodiment of this application, the task scheduling method further includes: when the stop sending time reaches the waiting time and the target server is executing a task, determining a backup server that meets preset conditions among the multiple other servers in the cluster based on the resource status of each of the multiple other servers besides the target server, and sending the target task to the backup server.
[0012] According to an embodiment of this application, the task scheduling method further includes: extending the waiting time when the stop sending time reaches the waiting time and the current load level of the cluster is greater than or equal to a second load threshold, and resending the target task to the target server when the stop sending time reaches the extended waiting time.
[0013] A second aspect of this application provides a task scheduling apparatus, comprising: an acquisition module for acquiring task parameters of multiple tasks to be executed and the current resource status of multiple servers in a cluster; a load level determination module for determining the current load level of the cluster based on the current usage of cluster resources by the servers indicated by the resource status; a task evaluation module for determining a first evaluation value for each of the multiple tasks based on the task parameters and the current load level, the first evaluation value indicating the necessity of using available cluster resources to execute the task; and a target task selection module for selecting at least one target task from the multiple tasks based on the first evaluation value, and sending the target task to a target server in the cluster that meets preset conditions, so that the target server executes the target task.
[0014] A third aspect of this application provides an electronic device comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.
[0015] A fourth aspect of this application also provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, implement the steps of the above-described method.
[0016] The fifth aspect of this application also provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method. Attached Figure Description
[0017] The above-mentioned contents, other objects, features and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0018] Figure 1 The illustrations depict application scenarios of task scheduling methods, apparatuses, devices, media, and program products according to embodiments of this application.
[0019] Figure 2 A flowchart illustrating a task scheduling method according to an embodiment of this application is shown schematically;
[0020] Figure 3 A flowchart illustrating a task scheduling method according to another embodiment of this application is shown schematically;
[0021] Figure 4 This schematic diagram illustrates a structural block diagram of a task scheduling apparatus according to an embodiment of the present application;
[0022] Figure 5 A block diagram schematically illustrates an electronic device suitable for implementing a task scheduling method according to an embodiment of this application. Detailed Implementation
[0023] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of this application for ease of explanation. However, it will be apparent that one or more embodiments may be implemented without these specific details. Furthermore, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this application.
[0024] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The terms “comprising,” “including,” etc., as used herein indicate the presence of features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0025] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0026] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0027] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, they do not mean that the applicant has used or necessarily used the solution.
[0028] When scheduling tasks, a common approach is to time them automatically according to preset times or cycles. However, pre-configuring task execution schedules makes it impossible to dynamically adjust execution arrangements based on real-time changes in workload or task urgency. Furthermore, multiple tasks may trigger simultaneously at preset times, causing a surge in resource consumption, leading to business delays or even crashes, while resources may remain idle at other times. Additionally, the inability to differentiate between the execution priorities of core and non-core tasks can disrupt critical business operations during resource-constrained periods. Therefore, this technology suffers from low task scheduling accuracy.
[0029] Embodiments of this application provide a task scheduling method, a task scheduling device, an electronic device, a medium, and a product.
[0030] Figure 1 The illustration shows an application scenario diagram of a task scheduling method, apparatus, device, medium, and program product according to embodiments of this application.
[0031] like Figure 1 As shown, the application scenario according to this embodiment may include a business system module 110, a scheduling module 120, a cluster module 130, and a storage module 140.
[0032] The business system module 110 is used to register, update, delete, or pause tasks to be executed with the scheduling module 120, define task parameters and send them to the scheduling module 120, and receive notifications of task execution results returned by the scheduling module 120. For example, the business system module 110 is an e-commerce platform or a data analysis platform. The task parameters defined by the business system module 110 are stored in the storage module 140.
[0033] The scheduling module 120 is used to execute the task scheduling method of the embodiments of this application. The scheduling module 120 includes an interface, a scheduler, and a queue of tasks to be processed.
[0034] The interface is used to receive task management requests from business system module 110. The task management requests include the setting of task scheduling cycle and configuration information.
[0035] The scheduler is used to determine the target task and the target server. The scheduler also periodically retrieves task parameters for each of the multiple tasks to be executed from the storage module 140, i.e., it retrieves task parameters from the storage module 140 in each task scheduling cycle. The scheduler also retrieves the current resource status of multiple servers in the cluster from the storage module 140. The scheduler also sends the target task to the target server in the cluster module 130 that meets preset conditions and retrieves the task execution result from the target server in the cluster module 130. The scheduler can also write task execution records, including the task execution result, into the storage module 140.
[0036] The task queue is used to store target tasks determined by the scheduler. The task queue can be in memory or cache.
[0037] Cluster module 130 includes multiple servers. Cluster module 130 sends the resource status of the multiple servers in the cluster to the scheduler of scheduling module 120 and stores the resource status in storage module 140. The target server in cluster module 130 executes the received target task. When executing the target task, the server in cluster module 130 can call the interface of business system module 110 and perform data processing to implement the business logic corresponding to the target task. Cluster module 130 sends the task execution result to the scheduler of scheduling module 120.
[0038] The storage module 140 is used to store task parameters, dynamically store the resource status of each server, and record the execution of each task.
[0039] The following will be based on Figure 1 The described scene, through Figures 2-3 The task scheduling method of the disclosed embodiments will be described in detail.
[0040] Figure 2 A flowchart illustrating a task scheduling method according to an embodiment of this application is shown.
[0041] like Figure 2 As shown, the task scheduling method in this embodiment includes operations S210 to S240.
[0042] In operation S210, the task parameters of each of the multiple tasks to be executed and the current resource status of each of the multiple servers in the cluster are obtained.
[0043] The task parameters include preset task weight, task urgency, and historical task success rate. The preset task weight indicates the pre-set importance of the task, the task urgency indicates how close the current time is to the latest possible execution time of the task, and the historical task success rate indicates the success rate of the task in a historical period.
[0044] The cluster consists of multiple servers, which are used to perform tasks.
[0045] Resource status includes the server's primary utilization of the processor, secondary utilization of the storage space, and the number of network links to the server. In practical use, primary utilization can be represented by CPU utilization.
[0046] In some embodiments, in response to the start of each task scheduling cycle, the task parameters of each of the multiple tasks to be executed and the current resource status of each of the multiple servers in the cluster are obtained. This allows for task evaluation at the beginning of each task scheduling cycle, preventing cluster crashes caused by a concentrated triggering of tasks.
[0047] In operation S220, the current load level of the cluster is determined based on the current usage of cluster resources by the server according to the resource status indication.
[0048] The current load level of the cluster represents the overall utilization of cluster resources, that is, the combined utilization of cluster resources by multiple servers in the cluster.
[0049] In some embodiments, the current usage of multiple servers is used as the average of the current usage of all servers to represent the current load level of the cluster. Alternatively, a preset weight can be assigned to each server, and the current usage of each server can be averaged to obtain the current load level of the cluster.
[0050] In operation S230, based on task parameters and current load levels, the first evaluation value for each of the multiple tasks is determined.
[0051] The first evaluation value indicates the necessity of utilizing available cluster resources to execute the task. It should be understood that even when multiple servers in the cluster consume a certain amount of cluster resources, there are still available cluster resources to execute the task. Combining this with the task parameters determines the necessity of utilizing available cluster resources to execute the task.
[0052] In operation S240, based on the first evaluation value, at least one target task is selected from multiple tasks, and the target task is sent to a target server in the cluster that meets the preset conditions, so that the target server executes the target task.
[0053] Here, the target task represents a task that requires a high degree of necessity to be executed using available cluster resources. The degree of necessity can be determined based on a preset necessity level; if the necessity level is higher than the preset necessity level, then the necessity level is higher.
[0054] The default condition is the condition for selecting the target server. For example, the default condition is that the server's current load level is low.
[0055] According to embodiments of this application, task parameters and server resource status are obtained for the task to be executed, thereby clarifying the task characteristics and cluster resource situation. The current load level of the cluster is determined based on resource usage, thus understanding the current resource status of the cluster. Furthermore, a first evaluation value is calculated for each task by combining the task parameters and the current load level, taking into account both the task itself and the load situation, making the determined first evaluation value more reflective of the necessity of utilizing available cluster resources to execute the task. Finally, target tasks are selected based on the first evaluation values and assigned to target servers, achieving reasonable task scheduling and execution.
[0056] In some exemplary embodiments, determining the current load level of the cluster based on the current usage of cluster resources by the servers indicated by the resource status includes: determining a second evaluation value for each of the multiple servers using a first utilization rate, a second utilization rate, and the number of network links; determining the current load level of each of the multiple servers based on the second evaluation value using a preset mapping relationship; and determining the current load level of the cluster based on the current load level of each of the multiple servers.
[0057] The second evaluation value is used to reflect the current usage of cluster resources by the server.
[0058] The higher the current load level, the more cluster resources are currently in use, and the fewer cluster resources are available.
[0059] In some embodiments, the first utilization rate, the second utilization rate, and the number of network links are input into the trained evaluation model to obtain a second evaluation value for each server.
[0060] A preset mapping relationship represents the relationship between a server's rating and its load level. For example, a preset mapping relationship includes at least one range of rating values, with each range corresponding to a different load level. For instance, a rating value between 0 and 20 indicates a low load level; a rating value between 20 and 50 indicates a medium load level; and a rating value between 50 and 100 indicates a high load level.
[0061] According to embodiments of this application, a first utilization rate, a second utilization rate, and the number of network links are used to comprehensively characterize the server's occupation of cluster resources. These three indicators are then used to calculate a second evaluation value for each server, thereby quantifying the current utilization of cluster resources by each server. The second evaluation value is then converted into the current load level of each server through a preset mapping relationship. The overall current load level of the cluster is determined by combining the current load levels of each server, thus providing a basis for subsequent task scheduling at the cluster resource level.
[0062] In some exemplary embodiments, a first evaluation value for each of multiple tasks is determined based on task parameters and the current load level, including: obtaining configuration information of the current task scheduling cycle; and for each task, determining the first evaluation value of the task by using at least one of the load level, preset task weight, task urgency, and historical task success rate, as well as a preset coefficient.
[0063] The configuration information includes at least one preset coefficient for each of the following: preset task weight, task urgency, and historical task success rate, as well as a preset coefficient for load level. It should be understood that different preset coefficients can be set for each task scheduling cycle to adjust the weights of the preset task weight, task urgency, and historical task success rate, thereby determining a more accurate primary evaluation value.
[0064] For example, using formula Determine the first evaluation value. Among them, As the first evaluation value, To preset task weights, Depending on the urgency of the task, For the historical success rate of the mission, For load level, All are preset coefficients.
[0065] According to embodiments of this application, preset task weights, task urgency, and historical task success rates are used to characterize the multi-dimensional characteristics of tasks. Configuration information for the current task scheduling cycle is obtained, including preset coefficients for preset task weights, task urgency, and historical task success rates, as well as preset coefficients for load levels. This provides a weighting basis for calculating the first evaluation value, thereby quantifying the scheduling priority of each task under the current load level.
[0066] In some exemplary embodiments, selecting at least one target task from multiple tasks based on a first evaluation value and sending the target task to a target server in the cluster that meets preset conditions includes: selecting at least one target task from multiple tasks based on the first evaluation value and adding the target task to a queue of tasks to be processed; selecting a server from the cluster that meets preset conditions based on the current load level of each of the multiple servers and using it as the target server; and sending the target tasks in the queue of tasks to be processed to the target server in sequence.
[0067] The pending task queue is used to store tasks that need to be processed.
[0068] The preset criteria include that the server's current load level is less than or equal to a first load threshold. It should be understood that the preset criteria are intended to select servers with lower load levels, thereby achieving load balancing.
[0069] The first load threshold refers to the server's load threshold. When the server's current load exceeds the first load threshold, it means that the server is temporarily unable to support the execution of the task.
[0070] According to an embodiment of this application, a preset condition requires that the current load level of the server does not exceed a first load threshold, thereby ensuring that the target server has sufficient resources. Target tasks are selected based on a first evaluation value and added to a task queue, thus filtering out tasks with higher scheduling priority. Servers that meet the preset conditions are selected as target servers based on the load level of each server, thereby locking in servers with execution capabilities. The target tasks in the queue are sent sequentially to the target servers, achieving precise matching of tasks and resources.
[0071] In some exemplary embodiments, the task scheduling method further includes: if a first task and a second task with a dependency relationship exist in the task queue to be processed, and no response information for the first task is received from the target server within a predetermined time period, then the order of the second task in the task queue to be processed is adjusted to the later stage.
[0072] In this context, both the first and second tasks are in the task queue, and the second task must be executed after the first task is successfully completed. Therefore, the successful execution information of the first task is used as a prerequisite for the subsequent tasks.
[0073] According to an embodiment of this application, for a first task and a second task that have a dependency relationship, it is monitored whether a response message for the first task is received from the target server within a predetermined time period, thereby determining the execution status of the predecessor task of the second task. If no response is received within the predetermined time period, the order of the second task in the queue is postponed, thereby avoiding abnormal execution of dependent tasks due to the incomplete completion of the predecessor task.
[0074] Figure 3 A flowchart illustrating a task scheduling method according to another embodiment of this application is shown.
[0075] like Figure 3 As shown, the task scheduling method in this embodiment includes operations S310 to S370. It should be understood that the business system module, scheduling module, cluster module, and storage module in this embodiment correspond to... Figure 1 The embodiment includes a business system module 110, a scheduling module 120, a cluster module 130, and a storage module 140.
[0076] When operating S310, the business system module sends a task registration request to the scheduling module.
[0077] In this embodiment of the application, the task registration request carries the task parameters of the task.
[0078] When operating S320, the scheduling module responds to the received task registration request by storing the task parameters in the storage module.
[0079] In practical applications, the scheduling module receives a task registration request, verifies the validity of the request parameters, and persistently stores the task parameters in the task configuration table of the storage module. The scheduling module then enters a monitoring state, waiting for the task's preset trigger time to arrive, and then treats the task as a task to be executed.
[0080] When operating the S330, the scheduling module responds at the beginning of each task scheduling cycle by obtaining the task parameters and the current resource status of each server in the cluster.
[0081] In practical applications, the scheduling module reads all tasks to be executed from the storage module and simultaneously obtains the current resource status of each server.
[0082] When operating S340, the scheduling module determines the current load level of the cluster based on the server's current usage of cluster resources indicated by the resource status, and determines the first evaluation value of the task based on the task parameters and the current load level.
[0083] When operating S350, the scheduling module selects at least one target task from multiple tasks based on the first evaluation value and adds the target task to the queue of tasks to be processed.
[0084] In practical applications, target tasks can be added to the task queue in descending order of their first evaluation value.
[0085] When operating the S360, the scheduling module sends the target tasks in the task queue to the target server in the cluster module that meets the preset conditions.
[0086] In practical applications, the target task with the highest evaluation value in the pending task queue should be sent first. Furthermore, if the target server's status indicates that it is not functioning properly, a backup server should be selected.
[0087] When operating S370, the target server in the cluster module executes the target task. If the execution is successful, it sends a response message to the scheduling module indicating that the target server has successfully executed the target task. If the execution fails, it sends a response message to the scheduling module indicating that the target server has not successfully executed the target task, and obtains the waiting time of the target task from the scheduling module.
[0088] In practical applications, the target server, based on the target task, calls the business interface corresponding to the target task of the business system module or executes the preset business code corresponding to the target task.
[0089] When the scheduling module receives a response from the target server indicating that the target task has been successfully executed, it processes the next target task in the pending task queue and restarts execution from operation S360.
[0090] In some exemplary embodiments, the task scheduling method further includes: when receiving a response from the target server for the target task and the response indicates that the target server has not successfully executed the target task, resending the target task to the target server; when the number of resends is greater than or equal to a predetermined retry threshold, determining the waiting time of the target task based on the number of resends and stopping sending the target task; and when the time after stopping sending reaches the waiting time, resending the target task to the target server.
[0091] The resend count refers to the number of times the target task is resent to the target server. In some embodiments, the resend count can be replaced by the number of times the target server re-executes the target task.
[0092] Waiting time refers to the time that the target task must wait before it is successfully executed by the target server.
[0093] For example, using formula Calculate the waiting time. Among them, Waiting time; To preset a basic interval, for example, it can be set to 1 hour; Preset retreat coefficient; This represents the number of resends.
[0094] In practical applications, when the target task needs to wait, the target task's status is set to "waiting for retry" and a future retry timestamp is set. The retry timestamp is determined using the current time and the waiting time.
[0095] According to an embodiment of this application, when a response indicating that the target server has failed to execute the target task is received, the target task is resent, thereby giving the target server another opportunity to execute the target task. When the number of resentments reaches a predetermined retry threshold, a waiting period is determined based on the number of resentments, and sending is paused, thereby avoiding resource waste caused by unlimited retries. After the waiting period expires, the target task is resent, achieving continuous scheduling of the task until successful execution.
[0096] In some embodiments, when a response message is received from the target server for the target task, and the response message indicates that the execution time of the target server for the target task is greater than or equal to a preset execution threshold, a backup server that meets the preset conditions is determined based on the resource status of multiple other servers in the cluster other than the target server, and the target task is sent to the backup server.
[0097] In some exemplary embodiments, the task scheduling method further includes: when the stop sending time reaches the waiting time and the target server is executing a task, determining a backup server that meets preset conditions among the multiple other servers in the cluster based on the resource status of each of the multiple other servers besides the target server, and sending the target task to the backup server.
[0098] The other servers are those in the cluster other than the target server. It should be understood that when the target server is executing a task, using a backup server ensures that the task is executed immediately and that resources are used efficiently.
[0099] In some embodiments, determining a backup server that meets preset conditions from among the multiple other servers in the cluster based on their respective resource statuses (excluding the target server) includes: determining a second evaluation value for each of the multiple other servers based on their respective resource statuses; determining the current load level of each of the multiple other servers based on their second evaluation values using a preset mapping relationship; and selecting a server that meets preset conditions from among the multiple other servers as a backup server based on its current load level.
[0100] According to an embodiment of this application, when the pause period expires and the target server is busy, a backup server that meets preset conditions is selected based on the resource status of other servers, thereby preventing the task from being continuously blocked due to the target server being busy. The target task is then sent to the backup server, thereby achieving rapid task transfer and scheduling, and improving the overall execution efficiency of the cluster.
[0101] In some exemplary embodiments, the task scheduling method further includes: extending the waiting time when the stop sending time reaches the waiting time and the current load level of the cluster is greater than or equal to a second load threshold, and resending the target task to the target server when the stop sending time reaches the extended waiting time.
[0102] The second load threshold refers to the cluster's load threshold. When the cluster's current load exceeds the second load threshold, it means that the cluster's available resources are temporarily insufficient to support task execution, so the waiting time is extended.
[0103] According to an embodiment of this application, when the pause period reaches the waiting period and the current load of the cluster exceeds a second load threshold, the waiting period is extended to avoid frequent scheduling exacerbating resource stress when the cluster is under high load. The target task is resent when the extended waiting period expires, thereby resuming task scheduling and execution once the cluster load eases.
[0104] Based on the above task scheduling method, this application also provides a task scheduling apparatus. The following will be combined with... Figure 4 The device is described in detail.
[0105] Figure 4 A schematic block diagram of a task scheduling apparatus according to an embodiment of this application is shown.
[0106] like Figure 4 As shown, the task scheduling device 400 in this embodiment includes an acquisition module 410, a load level determination module 420, a task evaluation module 430, and a target task selection module 440.
[0107] The acquisition module 410 is used to acquire the task parameters of each of the multiple tasks to be executed and the current resource status of each of the multiple servers in the cluster. In one embodiment, the acquisition module 410 can be used to perform the operation S210 described above, which will not be repeated here.
[0108] The load level determination module 420 is used to determine the current load level of the cluster based on the server's current usage of cluster resources according to the resource status indication. In one embodiment, the load level determination module 420 can be used to perform the operation S220 described above, which will not be repeated here.
[0109] The task evaluation module 430 is used to determine a first evaluation value for each of multiple tasks based on task parameters and the current load level. The first evaluation value indicates the necessity of utilizing available cluster resources to execute the task. In one embodiment, the task evaluation module 430 can be used to perform the operation S230 described above, which will not be repeated here.
[0110] The target task selection module 440 is used to select at least one target task from multiple tasks based on a first evaluation value, and send the target task to a target server in the cluster that meets preset conditions, so that the target server executes the target task. In one embodiment, the target task selection module 440 can be used to perform the operation S240 described above, which will not be repeated here.
[0111] According to an embodiment of this application, the load level determination module 420 includes a second evaluation value determination submodule, a server load level determination submodule, and a cluster load level determination submodule. The second evaluation value determination submodule is used to determine a second evaluation value for each of the multiple servers using a first utilization rate, a second utilization rate, and the number of network links. The second evaluation value reflects the current usage of cluster resources by the server. The server load level determination submodule is used to determine the current load level of each of the multiple servers based on the second evaluation value using a preset mapping relationship, where the preset mapping relationship represents the relationship between the server's evaluation value and its load level. The cluster load level determination submodule is used to determine the current load level of the cluster based on the current load levels of the multiple servers.
[0112] According to an embodiment of this application, the task evaluation module 430 includes a configuration information acquisition submodule and a first evaluation value determination submodule. The configuration information acquisition submodule acquires configuration information for the current task scheduling cycle, including at least one preset coefficient for each of the following: preset task weight, task urgency, and historical task success rate, as well as a preset coefficient for load level. The first evaluation value determination submodule determines a first evaluation value for each task using the load level, at least one of the preset task weight, task urgency, and historical task success rate, and the preset coefficient.
[0113] According to an embodiment of this application, the target task selection module 440 includes a task adding submodule, a target server determining submodule, and a sending submodule. The task adding submodule is used to select at least one target task from multiple tasks based on a first evaluation value and add the target task to the task queue to be processed; the target server determining submodule is used to select a server that meets preset conditions from the cluster based on the current load level of each of the multiple servers and use it as the target server; the sending submodule is used to send the target tasks in the task queue to the target server in sequence.
[0114] According to an embodiment of this application, the task scheduling device 400 further includes a first processing submodule. The first processing submodule is used to adjust the order of the second task in the task queue if no response information for the first task is received from the target server within a predetermined time period when there are a first task and a second task with a dependency relationship in the task queue to be processed.
[0115] According to an embodiment of this application, the task scheduling device 400 further includes a first retry submodule, a waiting duration determination submodule, and a second retry submodule. The first retry submodule is used to resend the target task to the target server when it receives a response from the target server indicating that the target server has not successfully executed the target task. The waiting duration determination submodule is used to determine the waiting duration of the target task based on the number of retryes, and stop sending the target task, if the number of retryes is greater than or equal to a predetermined retry threshold. The second retry submodule is used to resend the target task to the target server when the stopped sending time reaches the waiting duration.
[0116] According to an embodiment of this application, the task scheduling device 400 further includes a second processing submodule. The second processing submodule is used to determine a backup server that meets preset conditions among the multiple other servers in the cluster based on the resource status of each of the multiple other servers besides the target server when the stop sending time reaches the waiting time and the target server is executing a task, and then send the target task to the backup server.
[0117] According to an embodiment of this application, the task scheduling device 400 further includes a third processing submodule, which is used to extend the waiting time when the stop sending time reaches the waiting time and the current load level of the cluster is greater than or equal to the second load threshold, and to resend the target task to the target server when the stop sending time reaches the extended waiting time.
[0118] According to embodiments of this application, any multiple modules among the acquisition module 410, load level determination module 420, task evaluation module 430, and target task selection module 440 can be combined into one module, or any one of these modules can be split into multiple modules. Alternatively, at least some of the functions of one or more of these modules can be combined with at least some of the functions of other modules and implemented in one module. According to embodiments of this application, at least one of the acquisition module 410, load level determination module 420, task evaluation module 430, and target task selection module 440 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in software, hardware, or firmware, or in any appropriate combination of any of these three implementation methods. Alternatively, at least one of the acquisition module 410, the load level determination module 420, the task evaluation module 430, and the target task selection module 440 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.
[0119] Figure 5 A block diagram schematically illustrates an electronic device suitable for implementing a task scheduling method according to an embodiment of this application.
[0120] like Figure 5 As shown, an electronic device 500 according to an embodiment of this application includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage portion 508 into a random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this application.
[0121] RAM 503 stores various programs and data required for the operation of electronic device 500. Processor 501, ROM 502, and RAM 503 are interconnected via bus 504. Processor 501 executes various operations of the method flow according to embodiments of this application by executing programs in ROM 502 and / or RAM 503. It should be noted that programs may also be stored in one or more memories other than ROM 502 and RAM 503. Processor 501 may also execute various operations of the method flow according to embodiments of this application by executing programs stored in one or more memories.
[0122] According to embodiments of this application, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to a bus 504. The electronic device 500 may also include one or more of the following components connected to the input / output (I / O) interface 505: an input section 506 including a keyboard, mouse, etc.; an output section 507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the input / output (I / O) interface 505 as needed. A removable medium 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 510 as needed so that computer programs read from it can be installed into the storage section 508 as needed.
[0123] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of this application.
[0124] According to embodiments of this application, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this application, the computer-readable storage medium may include ROM 502 and / or RAM 503 and / or one or more memories other than ROM 502 and RAM 503 described above.
[0125] Embodiments of this application also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to cause the computer system to implement the methods provided in the embodiments of this application.
[0126] When the computer program is executed by the processor 501, it performs the functions defined in the system / apparatus of this application embodiment. According to the embodiments of this application, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0127] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via the communication section 509, and / or installed from a removable medium 511. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0128] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by processor 501, it performs the functions defined in the system of this application embodiment. According to embodiments of this application, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0129] According to embodiments of this application, program code for executing the computer programs provided in the embodiments of this application can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0130] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0131] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.
[0132] The embodiments of this application have been described above. However, these embodiments are merely illustrative and not intended to limit the scope of this application. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Without departing from the scope of this application, those skilled in the art can make various substitutions and modifications, all of which should fall within the scope of this application.
Claims
1. A task scheduling method, characterized in that, The method includes: Obtain the task parameters of each of the multiple tasks to be executed, as well as the current resource status of each of the multiple servers in the cluster; Based on the resource status indication of the server's current usage of cluster resources, the current load level of the cluster is determined; Based on the task parameters and the current load level, a first evaluation value is determined for each of the plurality of tasks, the first evaluation value indicating the necessity of executing the task using available cluster resources; and Based on the first evaluation value, at least one target task is selected from the plurality of tasks, and the target task is sent to a target server in the cluster that meets preset conditions, so that the target server executes the target task.
2. The method according to claim 1, characterized in that, The resource status includes the server's first utilization rate of the processor, the server's second utilization rate of the storage space, and the number of network links of the server. Based on the server's current usage of cluster resources indicated by the resource status, the current load level of the cluster is determined, including: Using the first utilization rate, the second utilization rate, and the number of network links, a second evaluation value is determined for each of the plurality of servers. The second evaluation value is used to reflect the current utilization of the cluster resources by the server. Using a preset mapping relationship, based on the second evaluation value, the current load level of each of the plurality of servers is determined, wherein the preset mapping relationship represents the relationship between the server's evaluation value and its load level; The current load level of the cluster is determined based on the current load level of each of the multiple servers.
3. The method according to claim 1 or 2, characterized in that, The task parameters include preset task weights, task urgency, and historical task success rates; based on the task parameters and the current load level, a first evaluation value is determined for each of the multiple tasks, including: Obtain the configuration information for the current task scheduling cycle. The configuration information includes at least one of the preset coefficients for the preset task weight, the task urgency, and the historical success rate of the task, as well as the preset coefficient for the load level. For each task, a first evaluation value for the task is determined by using at least one of the load level, the preset task weight, the task urgency, the task historical success rate, and the preset coefficient.
4. The method according to claim 2, characterized in that, The preset conditions include the server's current load level being less than or equal to a first load threshold; based on the first evaluation value, selecting at least one target task from the plurality of tasks, and sending the target task to a target server in the cluster that meets the preset conditions, including: Based on the first evaluation value, at least one target task is selected from the plurality of tasks, and the target task is added to the task queue to be processed; Based on the current load level of each of the multiple servers, a server that meets the preset conditions is selected from the cluster and used as the target server; The target tasks in the queue of tasks to be processed are sent to the target server in sequence.
5. The method according to claim 4, characterized in that, The method further includes: If a first task and a second task with a dependency relationship exist in the queue of tasks to be processed, and no response information for the first task is received from the target server within a predetermined time period, then the order of the second task in the queue of tasks to be processed will be adjusted to the next lower level.
6. The method according to claim 1, characterized in that, The method further includes: If a response is received from the target server for the target task and the response indicates that the target server has failed to execute the target task, the target task is resent to the target server. If the number of retransmissions is greater than or equal to a predetermined retry threshold, the waiting time for the target task is determined based on the number of retransmissions, and the transmission of the target task is stopped; and If the waiting time for the stopped sending period expires, the target task is resent to the target server.
7. The method according to claim 6, characterized in that, The method further includes: If the waiting period for stopping transmission reaches the specified duration and the target server is executing a task, based on the resource status of multiple other servers in the cluster besides the target server, a backup server that meets preset conditions is determined among the multiple other servers, and the target task is sent to the backup server.
8. The method according to claim 6, characterized in that, The method further includes: If the paused sending time reaches the waiting time and the current load of the cluster is greater than or equal to the second load threshold, the waiting time is extended, and if the paused sending time reaches the extended waiting time, the target task is resent to the target server.
9. A task scheduling device, characterized in that, The device includes: The acquisition module is used to acquire the task parameters of each of the multiple tasks to be executed, as well as the current resource status of each of the multiple servers in the cluster. The load level determination module is used to determine the current load level of the cluster based on the current usage of cluster resources by the server indicated by the resource status. A task evaluation module is used to determine a first evaluation value for each of the plurality of tasks based on the task parameters and the current load level. The first evaluation value indicates the necessity of executing the task using available cluster resources. The target task selection module is used to select at least one target task from the plurality of tasks based on the first evaluation value, and send the target task to a target server in the cluster that meets preset conditions, so that the target server executes the target task.
10. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 8.
12. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 8.
