Task scheduling methods, apparatus, equipment, storage media and program products
Patent Information
- Application Number
- CN202610874902.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-17
- Publication Date
- 2026-08-18
AI Technical Summary
[0004]一种是仅按照各任务之间的依赖关系调度任务,容易将任务调度到资源紧张的设备端,导致任务执行缓慢甚至失败,进而使后续依赖任务长时间阻塞;
Smart Images

Figure CN122593953A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data, and more specifically to a task scheduling method, apparatus, device, storage medium, and program product. Background Technology
[0002] In batch task scheduling scenarios in financial business, the scheduling end needs to uniformly schedule multiple tasks with dependencies and ensure that the tasks are reasonably allocated to the appropriate devices for execution.
[0003] Currently, there are two main methods for task scheduling at the scheduling end:
[0004] One approach is to schedule tasks solely based on their dependencies, which can easily lead to tasks being scheduled to resource-constrained devices, resulting in slow or even failed task execution and causing subsequent dependent tasks to be blocked for extended periods.
[0005] Another approach is to schedule tasks according to a fixed configuration, which cannot adapt to dynamic changes in the resource status of the devices. When a device fails or resources become scarce, tasks cannot be automatically migrated to other devices, requiring manual intervention to adjust the configuration, resulting in long fault recovery times. Summary of the Invention
[0006] In view of the above problems, embodiments of this application provide a task scheduling method, apparatus, device, storage medium, and program product.
[0007] According to a first aspect of this application, a task scheduling method is provided, applied to a scheduling terminal, which is connected to multiple device terminals. The task scheduling includes: in response to receiving a batch task scheduling request, obtaining multiple tasks to be scheduled and attribute information of each task from the batch task scheduling request, and obtaining the current resource availability of each device terminal from the multiple device terminals; determining the scheduling order of the multiple tasks based on the attribute information; selecting a target task that meets a first preset condition from the multiple tasks based on the scheduling order; selecting a target device terminal that meets a second preset condition from the multiple device terminals based on the order of the target task in the scheduling order and the current resource availability of the multiple device terminals; and scheduling the target task to the target device terminal to instruct the target device terminal to execute the target task.
[0008] According to an embodiment of this application, determining the scheduling order of multiple tasks based on attribute information includes: for any two tasks among the multiple tasks, determining whether there is a dependency relationship between the two tasks based on the attribute information of each task in the two tasks; if so, determining the scheduling order of the two tasks based on the dependency relationship between the two tasks; otherwise, determining the scheduling order of the two tasks based on the attribute information of each task in the two tasks.
[0009] According to an embodiment of this application, selecting a target task that meets a first preset condition from multiple tasks based on the scheduling order includes: traversing multiple tasks according to the scheduling order, and for any current task traversed among the multiple tasks, if it is determined that some of the preceding tasks that have a dependency relationship with at least one of the preceding tasks of the current task have been executed by the corresponding device, then the current task is taken as the target task.
[0010] According to an embodiment of this application, selecting a target device that meets a second preset condition from multiple device terminals based on the order of the target task in the scheduling order and the current resource availability of multiple device terminals includes: when it is determined from the scheduling order that the target task does not have at least one preceding task, selecting the device terminal with the largest current resource availability from multiple device terminals as the target device terminal.
[0011] According to an embodiment of this application, selecting a target device that meets a second preset condition from multiple device terminals based on the order of the target task in the scheduling sequence and the current resource availability of multiple device terminals further includes: determining a candidate device terminal from multiple device terminals to execute at least one prerequisite task when it is determined based on the scheduling sequence that the target task has at least one prerequisite task; obtaining the number of concurrent threads of the candidate device terminal, wherein the number of concurrent threads represents the number of threads when the candidate device terminal executes at least one prerequisite task; updating the number of concurrent threads based on the current resource availability of the candidate device terminal, and if the updated number of concurrent threads is less than a preset thread number threshold, using the candidate device terminal as the target device terminal.
[0012] According to an embodiment of this application, scheduling a target task to a target device includes: when it is determined that a candidate device executing at least one prerequisite task is different from the target device executing the target task, obtaining the execution result of at least one prerequisite task among the candidate device devices; and scheduling the target task to the target device based on the execution result.
[0013] According to an embodiment of this application, after scheduling the target task to the target device, the method further includes: responding to receiving the execution status of the target task from the target device, adjusting the scheduling order based on the execution status of the target task; and for the adjusted scheduling order, returning the step of selecting a target device that meets a second preset condition from multiple devices based on the order of the target task in the scheduling order and the current resource availability of multiple devices.
[0014] According to an embodiment of this application, adjusting the scheduling order based on the execution status of the target task includes: when the execution status is abnormal, sending at least one retry instruction to the target device and recording the number of times the at least one retry instruction is sent; repeatedly executing the operation of sending at least one retry instruction until the execution status of the target task is normal or the number of times the instruction is sent exceeds a preset threshold; when the number of times the instruction is sent exceeds the threshold, determining the subsequent task of the target task in the scheduling order, and rearranging the order of the target task after the order of the subsequent tasks in the scheduling order.
[0015] According to a second aspect of this application, a task scheduling device is provided, applied to a scheduling terminal, the scheduling terminal being connected to multiple device terminals; the task scheduling device includes: an acquisition module, configured to, in response to receiving a batch task scheduling request, acquire multiple tasks to be scheduled and attribute information of each task from the batch task scheduling request, and acquire the current resource availability of each device terminal from the multiple device terminals; a determination module, configured to determine the scheduling order of the multiple tasks based on the attribute information; a selection module, configured to select a target task that meets a first preset condition from the multiple tasks based on the scheduling order, and select a target device terminal that meets a second preset condition from the multiple device terminals based on the order of the target task in the scheduling order and the current resource availability of the multiple device terminals; and a scheduling module, configured to schedule the target task to the target device terminal to instruct the target device terminal to execute the target task.
[0016] According to a third aspect of this application, an electronic device is provided, 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.
[0017] According to a fourth aspect of this application, a computer-readable storage medium is also provided, on which a computer program or instructions are stored, wherein the computer program or instructions, when executed by a processor, implement the steps of the above-described method.
[0018] According to a fifth aspect of this application, a computer program product is also provided, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method. Attached Figure Description
[0019] 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:
[0020] Figure 1 The illustrations depict application scenarios of the task scheduling method, apparatus, device, storage medium, and program product according to embodiments of this application.
[0021] Figure 2 A sequence diagram of a task scheduling method according to an embodiment of this application is illustrated schematically;
[0022] Figure 3 A flowchart illustrating the selection of a target device according to an embodiment of this application is shown schematically.
[0023] Figure 4 This illustration schematically shows a sequence diagram of scheduling a target task to a target device according to an embodiment of this application;
[0024] Figure 5 This schematic diagram illustrates a structural block diagram of a task scheduling apparatus according to an embodiment of the present application;
[0025] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a task scheduling method according to an embodiment of this application. Detailed Implementation
[0026] 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.
[0027] 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 the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0028] 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.
[0029] 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.).
[0030] Figure 1The illustrations depict application scenarios of task scheduling methods, apparatuses, devices, storage media, and program products according to embodiments of this application. For example... Figure 1 As shown, the application scenario 100 according to the embodiments of this application may include a first request terminal 101, a second request terminal 102, a third request terminal 103, a scheduling terminal 104, a first device terminal 105, a second device terminal 106, and a third device terminal 107.
[0031] The first request terminal 101, the second request terminal 102, and the third request terminal 103 are used to initiate batch task scheduling requests to the scheduling terminal 104. The scheduling terminal 104 is used to execute the task scheduling method provided in this application embodiment, and establish a communication connection with the first device terminal 105, the second device terminal 106, and the third device terminal 107, and send the scheduled tasks to the corresponding device terminals for execution.
[0032] For example, the first requesting terminal 101, the second requesting terminal 102, and the third requesting terminal 103 can be electronic devices capable of initiating task requests, such as smartphones, personal computers, servers, vehicle terminals, industrial control terminals, and Internet of Things devices.
[0033] The first device terminal 105, the second device terminal 106, and the third device terminal 107 can be server clusters, edge computing nodes, industrial execution equipment, IoT terminals, or other devices with computing and execution capabilities that can perform business tasks.
[0034] The scheduling terminal 104 can be a server that provides task scheduling services, such as a scheduling server that supports batch task scheduling requests initiated by the first requesting terminal 101, the second requesting terminal 102, and / or the third requesting terminal 103 (this is just an example). The scheduling server can analyze and process the received batch task scheduling requests and other data, and schedule the target tasks that need to be scheduled to the target device. The scheduling terminal can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services such as cloud servers, cloud databases, cloud functions, cloud storage, message queues, network services, cloud communication, middleware services, security services, content delivery networks, and basic cloud computing services such as big data. The scheduling terminal 104 can be used to provide task scheduling services for the first requesting terminal 101, the second requesting terminal 102, and / or the third requesting terminal 103, and to provide task distribution and status management services for the first device 105, the second device 106, and the third device 107.
[0035] It should be noted that the task scheduling method provided in this application embodiment can generally be executed by the scheduling terminal 104. Accordingly, the task scheduling device provided in this application embodiment can generally be set in the scheduling terminal 104.
[0036] It should be understood that Figure 1 The number of requesters, schedulers, and devices shown is merely illustrative. Depending on implementation needs, there can be any number of requesters, schedulers, and devices.
[0037] Figure 2 A sequence diagram illustrating a task scheduling method according to an embodiment of this application is shown schematically. Figure 2 As shown, the task scheduling method 200 according to an embodiment of this application may include steps S210 to S240.
[0038] In step S210, in response to receiving a batch task scheduling request, the system obtains multiple tasks to be scheduled and attribute information of each task from the batch task scheduling request, and obtains the current resource balance of each device from multiple devices.
[0039] The requesting end can be an upper-layer application or a user interface that submits batch task scheduling requests to the scheduling end. The requesting end can be a command-line tool, a graphical interface program, or any business system that needs to execute tasks in batches.
[0040] The scheduler can be a control node responsible for scheduling tasks. It can be located on a server, a personal computer, or a mobile device (such as a mobile phone or tablet). The device can be a device connected to the scheduler to execute tasks. Different devices may use different operating systems and hardware. An adaptation layer can be used to shield the differences between different devices, allowing the scheduler to interact with each device in a unified way.
[0041] For example, when the scheduling terminal is set on a mobile device, the mobile device can both schedule other devices to perform tasks and perform tasks itself.
[0042] A batch task scheduling request can be an instruction sent from the requesting end to the scheduling end to start batch task scheduling. The instruction contains multiple tasks to be scheduled and attribute information of each task.
[0043] For example, a Hypertext Transfer Protocol (HTTP) request can be sent to the scheduler via the Representational State Transfer Application Programming Interface (RESTful API), which is a batch task scheduling request; batch task scheduling instructions can also be entered via the command line, specifying the location of the configuration files for multiple tasks; and the interfaces provided by the scheduler can be called via the Software Development Kit Access Package (SDK).
[0044] A task can be a unit of work that needs to be scheduled and executed. In a computer, a task can be represented as a runnable program, script, or command.
[0045] Attribute information can be data describing the characteristics of each task, including dependencies between different tasks and the importance of each task.
[0046] Current resource availability can be used as an indicator to measure the current available computing power of a device.
[0047] For example, current resource availability can include CPU utilization, remaining memory size, remaining hard disk space, and network bandwidth.
[0048] In step S220, the scheduling order of multiple tasks is determined based on attribute information.
[0049] The scheduling order can be the order in which multiple tasks are scheduled.
[0050] For example, if there are multiple tasks including a first task, a second task, and a third task, the scheduling order is to schedule the first task first, then the third task, and finally the second task.
[0051] In step S230, a target task that meets the first preset condition is selected from multiple tasks based on the scheduling order, and a target device that meets the second preset condition is selected from multiple devices based on the order of the target task in the scheduling order and the current resource availability of multiple devices.
[0052] The target task can be a currently selected task that meets the first preset condition and is ready for scheduling and distribution. The first preset condition can be a pre-defined condition that a task must meet to be selected as the target task.
[0053] The target device can be the device selected by the scheduler for the target task to execute the target task. The second preset condition can be the conditions that a device must meet to be selected as the target device.
[0054] In step S240, the target task is scheduled to the target device to instruct the target device to execute the target task.
[0055] Scheduling can include two actions: one is to transfer the task from the scheduler to the target device, and the other is to send an instruction to the target device to notify it to start executing the target task.
[0056] The task scheduling method based on the embodiments of this application dynamically allocates tasks according to the real-time resource availability of the device, avoiding sending tasks to devices with insufficient memory or overloaded CPUs, thus reducing task execution failures and timeouts. Simultaneously, it schedules tasks sequentially according to the scheduling order, avoiding scheduling chaos caused by task backlog. This can shorten the overall processing time of batch tasks and reduce the workload of manual adjustments.
[0057] In embodiments of this application, determining the scheduling order of multiple tasks based on attribute information includes: for any two tasks among the multiple tasks, determining whether there is a dependency relationship between the two tasks based on the attribute information of each task in the two tasks; if so, determining the scheduling order of the two tasks based on the dependency relationship between the two tasks; otherwise, determining the scheduling order of the two tasks based on the attribute information of each task in the two tasks.
[0058] If there is a dependency between two tasks, the scheduler determines the scheduling order of the two tasks based on the direction of the dependency.
[0059] For example, if two tasks include a first task and a second task, and the dependency direction is that the first task depends on the second task, it can be determined that the second task will be scheduled before the first task; if the dependency direction is that the second task depends on the first task, it can be determined that the first task will be scheduled before the second task.
[0060] If there is no dependency between two tasks, the priority of the two tasks can be determined based on the attribute information of each task; the scheduling order of the two tasks can then be determined based on the priority.
[0061] For example, if the priority of the first task is 3 and the priority of the second task is 2, then the first task will be scheduled before the second task. That is, the scheduling order is positively correlated with the priority, and the higher the priority, the earlier the task will be scheduled.
[0062] For example, if there are no dependencies and the priorities are the same, scheduling can be done according to the task identifier in the attribute information, or the tasks can be randomly ordered.
[0063] The task scheduling method based on the embodiments of this application determines the order of tasks with dependencies according to the direction of dependency, so as to avoid task execution failure due to incorrect order; and determines the order of tasks without dependencies according to priority, so that important tasks are executed first, thereby shortening the waiting time of important tasks.
[0064] In the embodiments of this application, selecting a target task that meets a first preset condition from multiple tasks based on the scheduling order includes: traversing multiple tasks according to the scheduling order, and for any current task traversed among the multiple tasks, if it is determined that some of the preceding tasks that have a dependency relationship with at least one of the preceding tasks of the current task have been executed by the corresponding device, then the current task is taken as the target task.
[0065] Preceding tasks are tasks that precede the current task in the scheduling order. The scheduler can traverse each task from front to back according to the scheduling order. For the current task, the scheduler can determine the execution result on the corresponding device based on the status record table maintained in the scheduler. The status record table records the execution status of each scheduled task. When a task is dispatched to the device, the device will return the execution result to the scheduler upon completion. The scheduler will then update the execution status of the task in the status record table to "execution completed" based on this execution result.
[0066] The task scheduling method based on the embodiments of this application checks each task sequentially according to the scheduling order. Only after all the preceding tasks that the current task depends on have been completed will the current task be designated as the target task. This ensures that dependent tasks are scheduled in the correct order, avoids task execution failure due to incomplete preceding tasks, and improves the success rate of task scheduling.
[0067] In the embodiments of this application, selecting a target device that meets the second preset condition from multiple device terminals based on the order of the target task in the scheduling order and the current resource reserves of multiple device terminals includes: when it is determined from the scheduling order that the target task does not have at least one preceding task, selecting the device terminal with the largest current resource reserves from multiple device terminals as the target device terminal.
[0068] For example, the device with the largest remaining memory can be selected as the target device. If multiple devices have the same remaining memory, CPU utilization can be compared, and the device with the lowest CPU utilization can be selected as the target device.
[0069] The task scheduling method based on the embodiments of this application selects the device with the largest current resource reserve as the target device, which can prioritize the allocation of tasks to the device with the most abundant resources, reduce task execution time, reduce the risk of task failure due to insufficient resources, and balance the load of each device, thereby improving the stability of task scheduling.
[0070] In embodiments of this application, selecting a target device that meets a second preset condition from multiple device terminals based on the order of the target task in the scheduling sequence and the current resource availability of multiple device terminals further includes: if it is determined from the multiple device terminals that the target task has at least one prerequisite task based on the scheduling sequence, determining a candidate device terminal that executes at least one prerequisite task; obtaining the number of concurrent threads of the candidate device terminal, wherein the number of concurrent threads represents the number of threads when the candidate device terminal executes at least one prerequisite task; updating the number of concurrent threads based on the current resource availability of the candidate device terminal, and if the updated number of concurrent threads is less than a preset thread number threshold, using the candidate device terminal as the target device terminal.
[0071] Figure 3 A flowchart illustrating the selection of a target device according to an embodiment of this application is shown schematically. Figure 3 As shown, in some embodiments, selecting the target device includes steps S231 to S2352.
[0072] In step S231, if it is determined that the target task has at least one prerequisite task based on the scheduling order, a candidate device end for executing at least one prerequisite task is determined from multiple device ends.
[0073] Since the target task may depend on multiple preceding tasks, and these preceding tasks may be executed on different devices, there may be one or more candidate devices.
[0074] In step S232, the number of concurrent threads on the candidate device is obtained. The number of concurrent threads represents the number of threads when the candidate device executes at least one pre-task.
[0075] For each candidate device, obtain the number of concurrent threads when the candidate device is executing the pre-task. The number of concurrent threads reflects the current busy level of the candidate device.
[0076] In step S233, the number of concurrent threads is updated based on the current resource availability of the candidate device.
[0077] The number of concurrent threads is updated based on the current resource availability of the candidate devices. The resource availability of the devices is dynamic and needs to be reassessed based on the latest resource availability.
[0078] In step S234, it is determined whether the updated number of concurrent threads is less than the preset thread number threshold.
[0079] When the available resources on a device decrease, its capacity to handle concurrent threads will also decrease accordingly. Therefore, it is necessary to control the device to reduce the number of concurrent threads. Conversely, when the available resources increase, the number of concurrent threads should be increased. The updated number of concurrent threads reflects the actual load on the device under the current resource conditions.
[0080] In step S2351, if yes, the candidate device is selected as the target device.
[0081] If the updated number of concurrent threads is less than the thread count threshold, it means that the candidate device is still capable of executing new tasks, and the scheduler will use the candidate device as the target device.
[0082] In step S2352, otherwise, select the device with the largest current resource reserve as the target device.
[0083] If the updated number of concurrent threads is greater than or equal to the thread count threshold, it means that the current load of the candidate device has exceeded its capacity and it is not suitable to allocate new tasks. The candidate device needs to be replaced by the one with the largest current resource reserve among other non-candidate devices as the target device.
[0084] The task scheduling method based on the embodiments of this application dynamically assesses the load capacity of a device based on its current resource availability. If the updated number of concurrent threads is less than a threshold, it indicates that the device still has idle resources to execute new tasks, and the same device continues to be used, thereby reducing cross-device data transmission and state synchronization overhead. If the updated number of concurrent threads has reached or exceeded the threshold, it indicates that the device is heavily loaded, and other devices with sufficient resources are selected to avoid further burdening it. This achieves dynamic load balancing on the device side and improves the efficiency of task scheduling.
[0085] In embodiments of this application, scheduling a target task to a target device includes: if it is determined that a candidate device executing at least one prerequisite task is different from the target device executing the target task, obtaining the execution result of at least one prerequisite task among the candidate devices; and scheduling the target task to the target device based on the execution result.
[0086] Figure 4 This diagram schematically illustrates a sequence for scheduling a target task to a target device according to an embodiment of this application. For example... Figure 4 As shown, in some embodiments, scheduling the target task to the target device includes steps S241 to S243.
[0087] In step S241, if it is determined that the candidate device end that executes at least one prerequisite task is different from the target device end that executes the target task, the execution result of at least one prerequisite task among the candidate device ends is obtained.
[0088] For example, the execution results include whether the task was executed successfully, the output data generated during the execution process, error messages, execution time, etc.
[0089] If the candidate device for executing at least one prerequisite task is different from the target device for executing the target task, it means that the prerequisite and target tasks have been assigned to different devices for execution. In this case, the target device needs to know the execution results of the prerequisite tasks in order to decide whether the target task can start execution and how to execute it.
[0090] For example, a query request can be sent to the candidate device, which then returns the execution result of the preceding task upon receiving the request; alternatively, the candidate device can proactively push the execution result to the scheduler after the preceding task is completed, and the scheduler stores the result in a local cache. When needed, the scheduler reads the result directly from the local cache.
[0091] In step S242, the execution results are analyzed.
[0092] For example, depending on the analysis results, the following situations can be identified: the first is when multiple prerequisite tasks are executed successfully; the second is when any of the prerequisite tasks fails, but the system configuration or user instructions allow skipping the failed task and continuing to execute subsequent tasks; the third is when any prerequisite task fails and the system configuration or user instructions require the failed task to prevent subsequent tasks; and the fourth is when the execution time of the prerequisite task exceeds the preset timeout threshold.
[0093] In step S243, the target task is scheduled to the target device based on the analysis results.
[0094] For example, in the first case mentioned above, it means that the conditions on which the target task depends have been met, the target task can be executed normally, the target task can be marked as executable, and it is ready to be sent to the target device.
[0095] For example, in the second scenario described above, the preceding task can be marked as skipped, and the target task can be unblocked from blocking the preceding task. The target task can still be scheduled for execution, but it needs to carry the context information of the preceding task's failure during execution so that the target task can handle the situation internally.
[0096] For example, in the third scenario described above, the target task can be marked as paused, and the status of all tasks that depend on the target task can be updated to a degraded state. In this case, the target task will not be scheduled until the scheduler receives a recovery instruction (such as skipping failed tasks or retrying failed tasks) and reassesses the executable conditions of the target task.
[0097] For example, in the fourth case mentioned above, it can be determined that the execution of the pre-task has timed out. At this time, one of the following operations can be selected according to the configuration: terminate the pre-task and mark the target task as paused; ignore the timeout and continue to wait; send an alarm notification.
[0098] For example, the timeout threshold for circuit breaker overdue can be set from 1 hour to 24 hours.
[0099] Based on the task scheduling method of this application embodiment, when a dependent prerequisite task and a target task are assigned to different devices, the scheduler obtains the execution result of the prerequisite task and schedules the target task accordingly, so that the target task is automatically triggered to execute after the prerequisite task is completed, without manual intervention or additional polling, thus achieving seamless connection of cross-device dependent tasks and avoiding execution errors caused by inconsistent states.
[0100] In embodiments of this application, after scheduling the target task to the target device, the method further includes: responding to receiving the execution status of the target task from the target device, adjusting the scheduling order based on the execution status of the target task; and for the adjusted scheduling order, returning the step of selecting a target device from multiple devices that meets the second preset condition based on the order of the target task in the scheduling order and the current resource availability of multiple devices.
[0101] If the execution status is normal, it can be checked whether there are any subsequent tasks that depend on the target task. If there are subsequent tasks, the number of preceding tasks that these subsequent tasks depend on is reduced by one. When all preceding tasks of any subsequent task have been completed, that subsequent task is made schedulable, and its order in the scheduling sequence is moved up.
[0102] If the execution status is abnormal, you can decide whether to remove the subsequent tasks that depend on the target task from the scheduling order or mark them as unschedulable, based on the preset configuration.
[0103] In the embodiments of this application, the scheduling order is adjusted based on the execution status of the target task, including: when the execution status is abnormal, sending at least one retry instruction to the target device and recording the number of times the at least one retry instruction is sent; repeatedly executing the operation of sending at least one retry instruction until the execution status of the target task is normal or the number of times the instruction is sent exceeds a preset number of times the instruction is sent; when the number of times the instruction is sent exceeds the number of times the instruction is sent, determining the subsequent task of the target task in the scheduling order, and rearranging the order of the target task after the order of the subsequent tasks in the scheduling order.
[0104] After receiving feedback that the execution status is abnormal, the scheduler sends a first retry command to the target device, instructing the target device to re-execute the target task, and records the number of times the retry command was sent as one, and waits for the target device to provide feedback on the execution status after this retry.
[0105] For example, the task retry interval can be set to 10s to 1h; the memory of the execution environment on the target device can be limited to 50MB to 2GB.
[0106] If the execution status reported by the target device is normal, the retry was successful. The target task is marked as completed, and it is checked whether there are any subsequent tasks that depend on this target task. If the reported execution status is still abnormal, a retry command is sent to the target device again, and the number of retry commands is increased by one. The above sending, waiting, and receiving operations are repeated to form an iterative loop until one of the following two conditions is met: the execution status of the target task becomes normal, indicating a successful retry; or the number of retry commands sent exceeds a preset threshold.
[0107] When the number of transmissions exceeds a preset threshold, retry commands are stopped, and the target task is deemed to have failed. At this point, at least one subsequent task blocked by the target task is identified. At least one non-dependent subsequent task can be selected, and its order in the scheduling sequence is rearranged after the latter, allowing it to be scheduled before the target task. Even if the target task repeatedly fails, the execution of the latter will not be blocked.
[0108] The task scheduling method based on the embodiments of this application can automatically perform a limited number of retries when a task execution is abnormal, and move the failed task to the back when the retries are ineffective, so as to avoid the entire batch of tasks from being stalled due to the continuous failure of a single task.
[0109] In some embodiments, after the target task is scheduled to the target device, a portion of the storage area of the target device has a built-in isolation environment. The target task is executed in this isolation environment to prevent the target task from affecting the system stability of the device itself or other running tasks due to anomalies (such as infinite loops, memory leaks, or illegal system calls) during its operation.
[0110] For example, an isolated environment can be a virtualized container, a process-level resource-limited sandbox, or a restricted execution space based on operating system permission mechanisms. Regardless of the specific technology used, the goal is to establish an isolation barrier between the target task and the device's operating system, restricting the target task to execution within specific resource limits.
[0111] After actual testing and verification, this application has significantly improved the following key indicators compared with related technologies. Related technologies take timed task management tools and command line scripting languages (shell) as examples, as shown in Table 1.
[0112] Table 1 Comparison of Key Indicators
[0113]
[0114] As shown in the table above, the embodiments of this application achieve automatic connection of cross-device dependent tasks through a state synchronization mechanism, ensure stable operation of the mobile terminal through isolation environment and concurrency control, and reduce access costs through command encapsulation and multi-language script support. Actual testing shows that this application outperforms existing solutions in terms of cross-platform task success rate, anomaly recovery efficiency, mobile terminal resource consumption, and access modification costs, demonstrating good practical value and promising prospects for widespread adoption.
[0115] Based on the above task scheduling method, embodiments of this application also provide a task scheduling apparatus. The following will be combined with... Figure 5 The device is described in detail.
[0116] Figure 5 A schematic block diagram of a task scheduling apparatus according to an embodiment of this application is shown.
[0117] like Figure 5 As shown, the task scheduling device 500 of this embodiment includes an acquisition module 510, a determination module 520, a selection module 530, and a scheduling module 540.
[0118] The acquisition module 510 is used to, in response to receiving a batch task scheduling request, acquire multiple tasks to be scheduled and attribute information of each task from the batch task scheduling request, and acquire the current resource availability of each device from multiple devices. In one embodiment, the acquisition module 510 can be used to execute step S210 described above, which will not be repeated here.
[0119] The determining module 520 is used to determine the scheduling order of multiple tasks based on attribute information. In one embodiment, the determining module 520 can be used to perform step S220 described above, which will not be repeated here.
[0120] The selection module 530 is used to select a target task that meets a first preset condition from multiple tasks based on the scheduling order, and to select a target device that meets a second preset condition from multiple devices based on the order of the target task in the scheduling order and the current resource availability of the multiple devices. In one embodiment, the selection module 530 can be used to execute step S230 described above, which will not be repeated here.
[0121] The scheduling module 540 is used to schedule the target task to the target device to instruct the target device to execute the target task. In one embodiment, the scheduling module 540 can be used to execute step S240 described above, which will not be repeated here.
[0122] According to an embodiment of this application, the determining module 520 includes a judging unit and a determining unit. The judging unit is used to determine, for any two tasks among a plurality of tasks, whether there is a dependency relationship between the two tasks based on the attribute information of each of the two tasks. The determining unit is used to determine the scheduling order of the two tasks based on the dependency relationship if the dependency relationship exists; otherwise, it determines the scheduling order of the two tasks based on the attribute information of each of the two tasks.
[0123] According to an embodiment of this application, the selection module 530 includes a first selection unit. The first selection unit is used to traverse multiple tasks according to the scheduling order, and for any current task traversed among the multiple tasks, if it is determined that some of the preceding tasks that have a dependency relationship with the current task have been executed by the corresponding device, the current task is selected as the target task.
[0124] According to an embodiment of this application, the selection module 530 further includes a second selection unit. The second selection unit is used to select the device with the largest current resource reserve from multiple device devices as the target device device when it is determined from multiple device devices that the target task does not have at least one preceding task based on the scheduling order.
[0125] According to an embodiment of this application, the second selection unit is further configured to determine, from multiple device terminals, a candidate device terminal to execute at least one prerequisite task when it is determined based on the scheduling order that the target task has at least one prerequisite task; obtain the number of concurrent threads of the candidate device terminal, wherein the number of concurrent threads represents the number of threads when the candidate device terminal executes at least one prerequisite task; update the number of concurrent threads based on the current resource availability of the candidate device terminal; and, if the updated number of concurrent threads is less than a preset thread number threshold, use the candidate device terminal as the target device terminal.
[0126] According to an embodiment of this application, the scheduling module 540 includes an acquisition unit and a scheduling unit. The acquisition unit is used to acquire the execution results of at least one of the candidate device terminals executing at least one prerequisite task when it is determined that the candidate device terminal executing at least one prerequisite task is different from the target device terminal executing the target task. The scheduling unit is used to schedule the target task to the target device terminal based on the execution results.
[0127] According to an embodiment of this application, the task scheduling device 500 further includes an adjustment module and a return module. The adjustment module is used to adjust the scheduling order based on the execution status of the target task received from the target device. The return module is used to return, for the adjusted scheduling order, the steps of selecting a target device that meets a second preset condition from among multiple devices based on the order of the target task in the scheduling order and the current resource availability of the multiple devices.
[0128] According to an embodiment of this application, the adjustment module includes a sending unit and a switching unit. The sending unit is used to send at least one retry instruction to the target device when the execution state is abnormal, and to record the number of times the at least one retry instruction is sent; the operation of sending at least one retry instruction is repeated until the execution state of the target task is normal or the number of sends exceeds a preset sending threshold. The switching unit is used to determine at least one subsequent task of the target task in the scheduling order when the number of sends exceeds the sending threshold, and to switch the order of the target task after the order of at least one subsequent task in the scheduling order.
[0129] According to embodiments of this application, any multiple modules among the acquisition module 510, determination module 520, selection module 530, and scheduling module 540 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 510, determination module 520, selection module 530, and scheduling module 540 can be at least partially implemented as hardware circuitry, such as field-programmable gate arrays, programmable logic arrays, systems-on-a-chip, systems-on-a-substrate, systems-on-package, application-specific integrated circuits, or any other reasonable means of integrating or packaging 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 510, determination module 520, selection module 530, and scheduling module 540 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.
[0130] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a task scheduling method according to an embodiment of this application.
[0131] like Figure 6 As shown, an electronic device 600 according to an embodiment of this application includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory 602 or a program loaded from a storage portion 608 into a random access memory 603. The processor 601 may include, for example, a general-purpose microprocessor, an instruction set processor and / or an associated chipset and / or a dedicated microprocessor. The processor 601 may also include onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for executing different steps of the method flow according to an embodiment of this application.
[0132] Random access memory 603 stores various programs and data required for the operation of electronic device 600. Processor 601, read-only memory 602, and random access memory 603 are interconnected via bus 604. Processor 601 executes various steps of the method flow according to embodiments of this application by executing programs in read-only memory 602 and / or random access memory 603. It should be noted that the programs may also be stored in one or more memories other than read-only memory 602 and random access memory 603. Processor 601 may also execute various steps of the method flow according to embodiments of this application by executing programs stored in said one or more memories.
[0133] According to embodiments of this application, the electronic device 600 may further include an input / output interface 605, which is also connected to a bus 604. The electronic device 600 may also include one or more of the following components connected to the input / output interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube, liquid crystal display, etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card, such as a local area network card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 610 as needed so that computer programs read from it can be installed into the storage section 608 as needed.
[0134] Embodiments of this application also provide 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.
[0135] 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, read-only memory, erasable programmable read-only memory, portable compact disk read-only memory, optical storage devices, magnetic storage devices, or any suitable combination thereof. In embodiments of 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 the read-only memory 602 described above, and / or random access memory 603, and / or one or more memories other than read-only memory 602 and random access memory 603.
[0136] 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.
[0137] 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 downloaded and installed via the communication section 609, and / or installed from the removable medium 611. 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.
[0138] In embodiments of this application, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by processor 601, it performs the functions defined in the system of embodiments of this application. According to embodiments of this application, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0139] 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. 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).
[0140] 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.
[0141] 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.
Claims
1. A task scheduling method, applied to a scheduling terminal, wherein the scheduling terminal is connected to multiple device terminals; characterized in that, The method includes: In response to receiving a batch task scheduling request, the system obtains multiple tasks to be scheduled and attribute information of each task from the batch task scheduling request, and obtains the current resource balance of each device from the multiple device terminals. The scheduling order of the multiple tasks is determined based on the attribute information; Based on the scheduling order, a target task that meets the first preset condition is selected from the plurality of tasks; based on the order of the target task in the scheduling order and the current resource availability of the plurality of devices, a target device that meets the second preset condition is selected from the plurality of devices. The target task is scheduled to the target device to instruct the target device to execute the target task.
2. The method according to claim 1, characterized in that, Determining the scheduling order of the multiple tasks based on the attribute information includes: For any two tasks among the plurality of tasks, based on the attribute information of each of the two tasks, determine whether there is a dependency relationship between the two tasks; If so, determine the scheduling order of the two tasks based on their dependency relationship; otherwise, determine the scheduling order of the two tasks based on the attribute information of each of the two tasks.
3. The method according to claim 2, characterized in that, Based on the scheduling order, a target task that meets the first preset condition is selected from the plurality of tasks, including: The multiple tasks are traversed according to the scheduling order. For any current task traversed among the multiple tasks, if it is determined that some of the preceding tasks that have a dependency relationship with at least one of the preceding tasks of the current task have been executed by the corresponding device, the current task is taken as the target task.
4. The method according to claim 1, characterized in that, Based on the order of the target task in the scheduling sequence and the current resource availability of the multiple device terminals, a target device terminal that meets the second preset condition is selected from the multiple device terminals, including: If, based on the scheduling order, it is determined that the target task does not have at least one preceding task, the device with the largest current resource reserve is selected from the plurality of device devices and used as the target device.
5. The method according to claim 4, characterized in that, Based on the order of the target tasks in the scheduling order and the current resource availability of the multiple device terminals, the method further includes selecting a target device terminal that meets the second preset condition from the multiple device terminals, and further includes: If it is determined from the scheduling order that the target task has at least one prerequisite task, a candidate device for executing the at least one prerequisite task is determined from the plurality of device devices. Obtain the number of concurrent threads on the candidate device, wherein the number of concurrent threads represents the number of threads on the candidate device when executing the at least one pre-task; The number of concurrent threads is updated based on the current resource availability of the candidate device. If the updated number of concurrent threads is less than a preset thread count threshold, the candidate device is selected as the target device.
6. The method according to claim 5, characterized in that, Scheduling the target task to the target device includes: If it is determined that the candidate device for executing the at least one pre-task is different from the target device for executing the target task, the execution result of the at least one pre-task in the candidate device is obtained; Based on the execution result, the target task is scheduled to the target device.
7. The method according to claim 1, characterized in that, After scheduling the target task to the target device, the method further includes: In response to receiving the execution status of the target task from the target device, the scheduling order is adjusted based on the execution status of the target task; For the adjusted scheduling order, return to the step of selecting the target device terminal that meets the second preset condition from the multiple device terminals based on the order of the target task in the scheduling order and the current resource availability of the multiple device terminals.
8. The method according to claim 7, characterized in that, Based on the execution status of the target task, the scheduling order is adjusted, including: If the execution status is abnormal, send at least one retry command to the target device and record the number of times the at least one retry command is sent; Repeat the operation of sending the retry instruction at least once until the execution status of the target task is normal or the number of times it is sent exceeds a preset number of times it is sent. If the number of transmissions exceeds the transmission threshold, at least one subsequent task of the target task in the scheduling order is determined, and the order of the target task is rearranged after the order of the at least one subsequent task in the scheduling order.
9. A task scheduling device, applied to a scheduling terminal, the scheduling terminal being connected to multiple device terminals; characterized in that, The device includes: The acquisition module is used to, in response to receiving a batch task scheduling request, acquire multiple tasks to be scheduled and attribute information of each task from the batch task scheduling request, and acquire the current resource balance of each device from the multiple device terminals. A determination module is used to determine the scheduling order of the multiple tasks based on the attribute information; The selection module is configured to select a target task satisfying a first preset condition from the plurality of tasks based on the scheduling order, and to select a target device satisfying a second preset condition from the plurality of device terminals based on the order of the target task in the scheduling order and the current resource availability of the plurality of device terminals; and The scheduling module is used to schedule the target task to the target device to instruct the target device to execute 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.