Task scheduling method and device and computer readable medium
By grouping tasks by type and implementing multi-threaded synchronous scheduling, the problems of resource conflicts and task blocking caused by improper task scheduling are resolved, achieving efficient task processing and improving system performance and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZTE CORP
- Filing Date
- 2024-10-31
- Publication Date
- 2026-05-01
AI Technical Summary
With the development of network technology, the number and types of tasks processed by the system are growing exponentially. Improper task scheduling may lead to resource conflicts, task blocking, or excessively long task processing times, affecting user experience.
By grouping tasks according to their type, assigning task group threads, creating task sub-threads within each task group thread, and synchronously scheduling task groups and sub-threads, we can ensure that each type of task receives the most suitable resources and achieve multi-threaded parallel processing.
It improved overall resource utilization, shortened task scheduling time, avoided task blocking, enhanced task scheduling and execution efficiency, and improved user experience.
Smart Images

Figure CN121957791A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of task scheduling technology, and in particular to a task scheduling method, apparatus and computer-readable medium. Background Technology
[0002] With the continuous development of network technology, the number and types of tasks that systems can handle are growing exponentially. As the number and types of tasks increase, efficiently utilizing resources and scheduling tasks becomes a challenge. The efficiency of task scheduling directly affects system performance and user experience. Improper task scheduling can lead to a series of problems such as resource conflicts, task blocking, or excessively long task processing times, thus impacting user experience. Summary of the Invention
[0003] This disclosure provides a task scheduling method, apparatus, and computer-readable medium.
[0004] In a first aspect, embodiments of this disclosure provide a task scheduling method, the method comprising: responding to multiple tasks from at least one task initiator; grouping the multiple tasks according to multiple task types of the multiple tasks to obtain multiple task groups corresponding to the multiple task types, each task group corresponding to one task type; allocating a task group thread to each task group, and creating multiple task sub-threads in each task group thread for each task group including the multiple tasks; and synchronously scheduling each task group thread and each task sub-thread.
[0005] In a second aspect, embodiments of this disclosure provide a task scheduling apparatus, which includes: a memory and a processor; the memory stores a computer program that can be executed by the processor, and when the computer program is executed by the processor, it implements the first aspect and any possible embodiment of the first aspect.
[0006] Thirdly, embodiments of this disclosure provide a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the first aspect and any possible embodiments thereof.
[0007] In this embodiment, after receiving multiple tasks from at least one task initiator, the tasks can be grouped according to their task types to obtain multiple task groups corresponding to each task type. Each task group corresponds to one task type. A task group thread is then allocated to each task group, and multiple task sub-threads are created within each task group thread for each task included in that task group. The task group threads and task sub-threads are then scheduled synchronously. Since different types of tasks have different resource requirements, differentiated grouping and scheduling of tasks according to task type ensures that each type of task receives the most suitable resources, thereby improving overall resource utilization. By allocating a task group thread to each task group and creating multiple task sub-threads within that task group thread for each task included in that task group, not only can multiple task groups be scheduled synchronously, but also multiple tasks within each task group can be scheduled synchronously. This multi-threaded approach enables dual parallel processing of multiple tasks, shortening the overall task scheduling time, avoiding task blocking, improving task scheduling and execution efficiency, and ultimately enhancing the user experience. Attached Figure Description
[0008] In the accompanying drawings of the embodiments disclosed herein:
[0009] Figure 1 This is a schematic diagram of a task scheduling scenario provided by an embodiment of the present disclosure;
[0010] Figure 2 A flowchart of a task scheduling method provided in this embodiment of the present disclosure;
[0011] Figure 3 This is a schematic diagram of task synchronization scheduling provided in an embodiment of the present disclosure;
[0012] Figure 4 A flowchart of a grouping method provided in an embodiment of this disclosure;
[0013] Figure 5 A schematic diagram of task grouping provided in an embodiment of this disclosure;
[0014] Figure 6 This is a schematic diagram of a task scheduling device provided in an embodiment of the present disclosure. Detailed Implementation
[0015] To enable those skilled in the art to better understand the technical solutions of this disclosure, the embodiments of this disclosure will be described in detail below with reference to the accompanying drawings.
[0016] The present disclosure will be described more fully below with reference to the accompanying drawings; however, the embodiments shown may be embodied in different forms, and the present disclosure should not be construed as limited to the embodiments set forth below. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will enable those skilled in the art to fully understand the scope of the disclosure.
[0017] The accompanying drawings of the embodiments disclosed herein are provided to further illustrate the embodiments of this disclosure and form part of the specification. They are used together with the detailed embodiments to explain this disclosure and do not constitute a limitation thereof. The above and other features and advantages will become more apparent to those skilled in the art from the description of the detailed embodiments with reference to the accompanying drawings.
[0018] Where there is no conflict, the various embodiments of this disclosure and the features thereof in the embodiments may be combined with each other.
[0019] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to limit the disclosure. The term "and / or" as used in this disclosure includes any and all combinations of one or more of the associated enumerated entries. The singular forms "a" and "the" as used in this disclosure are also intended to include the plural forms, unless the context clearly indicates otherwise. The terms "comprising," "made of," etc., as used in this disclosure specify the presence of the stated feature, integral, step, operation, element, and / or component, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof.
[0020] In the description of this disclosure, the words “first”, “second”, etc., are used only for the purpose of distinguishing the description and should not be construed as indicating or implying relative importance or order.
[0021] Unless otherwise specified, all terms used in this disclosure (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined in this disclosure.
[0022] With the continuous development of network technology, the number and types of tasks that systems can handle are growing exponentially. As the number and types of tasks increase, efficiently utilizing resources and scheduling tasks becomes a challenge. The efficiency of task scheduling directly affects system performance and user experience. Improper task scheduling can lead to a series of problems such as resource conflicts, task blocking, or excessively long task processing times, thus impacting user experience.
[0023] In view of this, embodiments of this disclosure provide a task scheduling method, apparatus, and computer-readable medium, which can be applied to, but are not limited to, virtualization scenarios. Before introducing this disclosure, a possible scenario to which the embodiments of this disclosure are applicable will first be described.
[0024] See attached document Figure 1 This is a schematic diagram of a task scheduling scenario provided by an embodiment of the present disclosure. The task scheduling scenario 10 may include a task initiator 11, a task initiating device 12, a distributed task scheduling system 13, and a distributed task management system 14. Figure 1 This is merely an illustrative diagram and does not constitute a limitation on the applicable scenarios of the technical solutions provided in this disclosure. The following sections will describe these scenarios in detail. Figure 1 The composition and function of each part.
[0025] Task initiator 11 refers to the user or device that initiates the task. Task initiator 11 may include user groups, maintenance personnel, and third-party systems.
[0026] Task initiating device 12 refers to a device capable of initiating or requesting the execution of a task. Task initiating device 12 may include a client, an operations and maintenance management system, and external interfaces. The task initiator 11 can initiate or request the execution of a task through its corresponding task initiating device 12. Specifically, users can initiate or request the execution of tasks using a client; for example, they can initiate virtualization tasks using desktop virtualization or application virtualization technologies. Operations and maintenance personnel can initiate or request the execution of tasks through the operations and maintenance management system; for example, they can initiate various types of virtualization tasks through the operations and maintenance management system. Third-party systems can initiate or request the execution of tasks through external interfaces; for example, they can initiate or request the execution of virtualization tasks such as desktop virtualization tasks, data virtualization tasks, application virtualization tasks, or cloud virtualization tasks.
[0027] A distributed task scheduling system 13 can be used for task distribution and scheduling. It includes multiple distributed servers and a message broker, with each distributed server potentially including a task grouper and / or a task scheduler. It can be deployed on a cloud platform distributed architecture system based on an open-source cloud environment architecture. Microservices are used to encapsulate the task grouper and task scheduler in different containers; that is, the task grouper and task scheduler are deployed as microservices, and the task scheduler communicates with the task grouper through a message broker (such as Kafka). The distributed task scheduling system 13 can distribute and schedule tasks to various task management systems within the distributed task management system 14.
[0028] The distributed task management system 14 can be used to manage tasks, such as executing tasks. It can be deployed on various servers and can be understood as a higher-level management system for the servers. It receives tasks from the distributed task scheduling system 13, operates on underlying server resources, interacts and communicates with these resources, and completes task execution. In some embodiments, the tasks are virtualized, and the corresponding task management system can be a virtualized task management system.
[0029] Figure 1 An example scenario to which embodiments of this disclosure apply is illustrated. It should be noted that embodiments of this disclosure are not limited to those described herein. Figure 1 The scenario shown is not merely a theoretical one, but has broader applicability. The technical solution of this embodiment can be applied in a variety of different scenarios, including but not limited to... Figure 1 The example scenarios presented are described below. The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.
[0030] Firstly, refer to the appendix Figure 2 This is a flowchart of a task scheduling method provided in an embodiment of the present disclosure. This method can be applied to, but is not limited to, tasks scheduled in this way. Figure 1 A distributed task scheduling system, the method comprising:
[0031] S21: Responding to multiple tasks from at least one task initiator.
[0032] In this embodiment of the disclosure, the scheduled task may come from at least one task initiator, such as... Figure 1 The user base, operations and maintenance personnel, and third-party systems within it.
[0033] S22: Group multiple tasks according to multiple task types to obtain multiple task groups corresponding to multiple task types, with each task group corresponding to one task type.
[0034] In this embodiment of the disclosure, after receiving multiple tasks from at least one task initiator, the task type of each task can be determined. The multiple tasks are then grouped according to their task types to obtain multiple task groups corresponding to the multiple task types. Each task group corresponds to one task type. This can be understood as all tasks in each task group belonging to the task type corresponding to that task group, or as multiple tasks belonging to the same task type being divided into a task group corresponding to that task type.
[0035] In this embodiment of the disclosure, the number of task groups is not limited. Given that too many task groups may result in low concurrency in a single task group, and low concurrency may cause task execution to be blocked in a single task group, an appropriate number of task groups can be created according to actual application needs.
[0036] S23: Assign a task group thread to each task group, and create multiple task sub-threads for each task group's multiple tasks within each task group thread.
[0037] In this embodiment of the disclosure, a task group thread is assigned to each task group, and each task group is scheduled by its corresponding task group thread. In each task group thread, multiple task sub-threads are created for the multiple tasks included in each task group, and one task in each task group can be scheduled by one task sub-thread.
[0038] S24: Synchronize and schedule the threads of each task group and the sub-threads of each task.
[0039] In this embodiment of the disclosure, by synchronously scheduling each task group thread and each task sub-thread, it is possible to synchronously schedule multiple task groups and multiple tasks in each task group.
[0040] In this embodiment of the disclosure, since different types of tasks have different resource requirements, by grouping and scheduling tasks in a differentiated manner according to task type, it can be ensured that each type of task can obtain the most suitable resources, thereby improving the overall resource utilization. By allocating a task group thread to each task group and creating multiple task sub-threads for each task group's multiple tasks within the task group thread, not only can multiple task groups be scheduled synchronously, but also multiple tasks within each task group can be scheduled synchronously. By achieving dual parallel processing of multiple tasks through multi-threading, the overall task scheduling time can be shortened, task blocking can be avoided, task scheduling and execution efficiency can be improved, thereby enhancing the user experience.
[0041] The following example illustrates an embodiment of this disclosure. Figure 2 Examples are given for S23 to S24.
[0042] In one example, refer to the appendix Figure 3 This is a schematic diagram of task synchronization scheduling provided in an embodiment of this disclosure. Figure 3The method divides multiple tasks into two task groups, Task Group 1 and Task Group 2. Task Group 1 is assigned a task group thread, denoted as Thread 1, and Task Group 2 is assigned a task group thread, denoted as Thread 2. Within Thread 1, a corresponding task sub-thread is created for each of the three tasks (A, B, and C) in Task Group 1: the task sub-thread for Task A is denoted as Thread A, the task sub-thread for Task B is denoted as Thread B, and the task sub-thread for Task C is denoted as Thread C. Similarly, within Thread 2, a corresponding task sub-thread is created for each of the three tasks (D, E, and F) in Task Group 2: the task sub-thread for Task D is denoted as Thread D, the task sub-thread for Task E is denoted as Thread E, and the task sub-thread for Task F is denoted as Thread F. This method allows for the synchronous scheduling of Thread 1, Thread 2, and Threads A through F, enabling the synchronous scheduling of each task group and multiple tasks within each task group. This allows multiple tasks synchronously scheduled to the task management system to be processed simultaneously. Figure 3 Tasks A through F can be processed simultaneously, achieving the effect of concurrent task execution and thus improving the efficiency of multitasking.
[0043] The following example illustrates a possible implementation of grouping multiple tasks according to multiple task types in embodiment S22 of this disclosure. (Refer to the appendix.) Figure 4 This is a flowchart of a grouping method provided in an embodiment of the present disclosure, for grouping... Figure 4 The middle grouping method is applied to Figure 1 Taking a distributed task scheduling system as an example, this method includes:
[0044] S1: Obtain the raw data for the task.
[0045] For example, each task initiator can send raw data of various types of tasks to the task grouper of the distributed task scheduling system.
[0046] S2: Format the raw data of the task based on the task classification model.
[0047] For example, the task grouper can format the raw task data based on the task classification model. The formatted task data includes at least the task type, and may also include task identifier, task name, task description, resource name, resource type, and subtask identifier, in addition to the task type.
[0048] S3: Group tasks based on a task classification model.
[0049] For example, after obtaining the task type of each task based on the task classification model, multiple tasks can be grouped according to the multiple task types of multiple tasks to obtain multiple task groups corresponding to multiple task types.
[0050] In one example, the task is a virtualized task, after... Figure 4 The S2 processing class obtains multiple task types, including: desktop virtualization, application virtualization, network virtualization, data virtualization, storage virtualization, and cloud virtualization. According to... Figure 4 The grouping method shown allows for the grouping of tasks based on task type, resulting in the following six task groups:
[0051] Task Group 1: Desktop Virtualization Task Group;
[0052] Task Group 2: Application Virtualization Task Group;
[0053] Task Group 3: Network Virtualization Task Group;
[0054] Task Group 4: Data Virtualization Task Group;
[0055] Task Group 5: Storage Virtualization Task Group;
[0056] Task Group 6: Cloud Virtualization Task Group.
[0057] In this embodiment, multiple tasks can be grouped not only according to task type, but also according to actual application needs combined with other parameters. For example, tasks of the same type often need to be distinguished by their execution order. For instance, for n boot tasks (desktop virtualization tasks) received simultaneously, the initiators may include users, maintenance personnel, and third-party systems. To improve the user experience, the boot task triggered by the user should respond promptly. Therefore, it should be selected first for execution during task grouping. Thus, to further enhance the user experience, this embodiment can also group tasks according to task priority. The following describes a possible implementation method for grouping multiple tasks according to task type and task priority.
[0058] In some embodiments, grouping multiple tasks according to multiple task types in S22 to obtain multiple task groups corresponding to multiple task types can be implemented in the following way:
[0059] For each task type, multiple tasks are assigned to a task queue based on their priority. Different task queues correspond to different priorities. Tasks with the same priority among the multiple tasks for each task type are stored in the corresponding priority task queue. Based on the flow control value of the task group for each task type, the tasks in each task queue are assigned to the task group for each task type in descending order of priority. This results in multiple task groups for multiple task types, where the number of tasks in each task group is less than or equal to the flow control value for that task group. By setting different flow control values for different task groups, differentiated flow control can be implemented for task groups of different task types. This limits the concurrent execution volume of each task type, preventing task congestion. At the same time, grouping multiple tasks of the same task type according to priority ensures that high-priority tasks are scheduled first, allowing the server to respond to high-priority tasks faster. This ensures that critical or urgent tasks with high priority are processed in a timely manner, thereby improving the user experience. Furthermore, by limiting the number of tasks in each task group, excessive resource consumption by a single task group can be avoided, maintaining stable allocation of system resources and improving system reliability and stability. Through reasonable resource allocation, the overall execution efficiency of the system can be improved.
[0060] Among them, the flow control value represents the maximum number of tasks that the system can schedule simultaneously within a task group per unit time, that is, the maximum number of tasks that a task group can execute concurrently within the same time period.
[0061] In some embodiments, the priority of multiple tasks corresponding to each task type is determined based on the type of task initiator. In this embodiment, there is no limitation on the priority levels; the more priority levels, the more granular the control over the task execution order. For example, in some scenarios, user tasks need to be processed first, followed by maintenance personnel tasks, and finally third-party system tasks. In this case, user tasks can be set as high-priority tasks, maintenance personnel tasks as medium-priority tasks, and third-party system tasks as low-priority tasks. Similarly, in other scenarios, maintenance personnel tasks need to be processed first, followed by user tasks, and finally third-party system tasks. In this case, maintenance personnel tasks can be set as high-priority tasks, user tasks as medium-priority tasks, and third-party system tasks as low-priority tasks. This allows for the simultaneous preset of priorities for tasks of the same type based on the task initiator type. Tasks of different priorities are stored in task queues of different priorities. Under the condition of satisfying resource flow control, high-priority task queues can process tasks promptly upon receiving them, allowing the server to respond to high-priority tasks faster, thereby improving the user experience.
[0062] The following example illustrates a method for grouping multiple tasks according to task type and task priority in some embodiments of this disclosure.
[0063] In one example, refer to the appendix Figure 5 This is a schematic diagram of task grouping provided in an embodiment of the present disclosure. Taking the grouping process of one task group corresponding to one task type as an example, when there are multiple task groups corresponding to multiple task types, each task group can be grouped according to this method. The example includes the following process:
[0064] S1: Determine the priority of multiple tasks corresponding to a task type based on the type of task initiator.
[0065] In this example, the types of task initiators include users, operations and maintenance personnel, and third-party systems. Tasks initiated by users can be identified as high-priority tasks, tasks initiated by third-party systems can be identified as medium-priority tasks, and tasks initiated by operations and maintenance personnel can be identified as low-priority tasks.
[0066] S2: Create task queues according to the priority of multiple tasks corresponding to a task type. Different task queues correspond to different priorities.
[0067] In this example, a queue is used to implement priority task grouping. In a distributed environment, queues have publish-subscribe characteristics; one queue is bound to one topic, and the group processor listens to the corresponding topic. As soon as a task is received in the queue, the group processor can immediately receive and process it. In this example, three priorities can be set up with three topics, and the group processor listens to these three topics respectively. Thus, there are three queues in the grouping logic. The task queue corresponding to high-priority tasks is designated as the high-priority task queue, the task queue corresponding to medium-priority tasks is designated as the medium-priority task queue, and the task queue corresponding to low-priority tasks is designated as the low-priority task queue.
[0068] S3: Store tasks with the same priority among multiple tasks corresponding to a task type into the task queue of the corresponding priority.
[0069] In this example, the five tasks corresponding to the same task type are denoted as R1-R5. Tasks R1-R5 are received in chronological order T1-T5 (with a very small time difference). Among them, tasks R1-R4 are low-priority tasks and are stored in the low-priority task queue, while task R5 is a high-priority task and is stored in the high-priority task queue. There are no medium-priority tasks in this example.
[0070] S4: Based on the flow control value of the task group corresponding to a task type, the tasks in each task queue are assigned to the task group corresponding to that task type in descending order of priority, so that the number of tasks in the task group is less than or equal to the flow control value corresponding to the task group.
[0071] In this example, the flow control value for this task group is configured to 3. The group processor monitors each priority task queue. When selecting tasks from each priority task queue, the group processor prioritizes scheduling tasks from the highest priority task queue until there are no more tasks available for scheduling in the highest priority task queue. Then, it continues to schedule tasks from the medium priority task queue, and so on, until the number of tasks to be executed in the task group reaches the flow control value. Figure 5 In the example, task R5 in the high-priority task queue is first assigned to a task group until there are no more tasks available for scheduling in the high-priority task queue. Then, tasks are scheduled from the medium-priority task queue. Since there are no more tasks available for scheduling in the medium-priority task queue, tasks R1 and R2 in the low-priority task queue are assigned to a task group in sequence. Since the flow control value of this task group is 3, after assigning R2 to the task group, the number of tasks in this task group reaches the flow control value, that is, the maximum value of this task scheduling. Therefore, the tasks that need to be processed are R5, R1, and R2. R5 implements queue jumping, and its processing response time is faster than R3 and R4.
[0072] In practical applications, due to the limited processing capabilities of server underlying resources, the actual number of tasks that can be processed simultaneously is limited. Furthermore, since different task types consume different processing resources, the maximum number of different task types that can be processed simultaneously also varies. Therefore, in order to adapt to server processing capabilities while taking into account task processing efficiency, some embodiments of this disclosure can set flow control strategies for task groups based on server processing capabilities and the processing efficiency of different task types. Some possible implementation methods are described below.
[0073] In some embodiments, in S23, multiple task sub-threads are created in each task group thread for each task group including multiple tasks. This can be achieved as follows: based on the flow control value corresponding to each task group, multiple task sub-threads are created in each task group thread for each task group including multiple tasks, and the number of multiple task sub-threads is less than or equal to the size of the flow control value. In this way, by using different flow control values for different task groups, the number of concurrent tasks for each task type can be limited, and task execution congestion can be avoided.
[0074] In some embodiments, the initial value of the flow control value is a default flow control value, which can be determined based on the task type of the corresponding task group. For example, for task types that require more resource processing but can handle fewer tasks concurrently, a smaller default flow control value can be set; conversely, for task types that require less resource processing but can handle more tasks concurrently, a larger default flow control value can be set. For instance, desktop virtualization tasks require more resource processing, so a smaller default flow control value can be configured for the desktop virtualization task group. Similarly, network virtualization tasks require less resource processing, so a larger default flow control value can be configured for the network virtualization task group. In this way, by setting flow control values according to task type, differentiated flow control scheduling can be performed for different types of tasks. The system can allocate resources more rationally to different types of tasks, ensuring that resources are not over-consumed while meeting the needs of different tasks, thus improving task processing efficiency and overall system performance.
[0075] In this disclosure, since the initial flow control value may no longer be applicable to current flow control requirements as server resources are consumed and network conditions change, some embodiments of this disclosure propose a scheme for dynamically adjusting the flow control value. Some possible implementation methods are described below.
[0076] In some embodiments, after creating multiple task sub-threads for each task group within each task group thread in step S23, the flow control value can be adjusted as follows: Based on preset rules and a preset flow control value adjustment amount, the flow control value corresponding to each task group in the next task scheduling is adjusted. This allows for dynamic adjustment of the flow control value for each task scheduling according to the preset flow control value adjustment amount, ensuring that the flow control value for each scheduling is suitable for the current server and network configuration, thereby ensuring effective resource utilization and stable system operation.
[0077] The preset rules include any of the following:
[0078] Rule 1: The target difference is less than or equal to the first response time threshold, and the maximum task response time is less than or equal to the second response time threshold;
[0079] Rule #2: The target difference is less than or equal to the first response time threshold, and the maximum task response time is greater than the second response time threshold;
[0080] Rule #3: The target difference is greater than the first response time threshold.
[0081] The target difference refers to the difference between the maximum task response time and the minimum task response time. The maximum task response time is the maximum response time for each task in each task group to complete execution, and the minimum task response time is the minimum response time for each task in each task group to complete execution.
[0082] In this embodiment, the first response time threshold represents the maximum value of the difference between the maximum and minimum task response times of each task in the same task group. For ease of understanding, the first response time threshold can also be described as a response time stability threshold. If the difference between the maximum and minimum task response times in the same task scheduling is greater than the first response time threshold, it can be considered that the task execution times in the task group vary significantly, and the task execution in the task group is unstable, which may be caused by unstable system performance. In this case, it is necessary to reduce the flow control value of the task group to adapt to the system performance. By setting the first response time threshold, a quality of service guarantee can be provided for each task in the task group to ensure that no task's response time is delayed to an unacceptable level.
[0083] In this embodiment, the second response time threshold characterizes the maximum tolerable response time for the task execution of the task type corresponding to the task group. It can be used to measure the longest acceptable time for task execution. For ease of understanding, the second response time threshold in this disclosure can also be described as a response time tolerance threshold. For example, the second response time threshold refers to the longest response time required for a task of a certain type to be executed normally on a server. If the maximum task response time in the same task scheduling exceeds the second response time threshold, it can be considered that congestion has occurred during task processing. Congestion usually means that system resources (such as CPU, memory, I / O, etc.) are insufficient to handle the current task load, resulting in task execution delays. In this case, it is necessary to reduce the flow control value of the task group. By setting the second response time threshold, the system can identify potential performance bottlenecks and congestion situations and take corresponding measures (such as adjusting the flow control value) to ensure the efficiency of task execution and the stability of the system.
[0084] In some possible implementations, the first response time threshold can be set to half of the second response time threshold.
[0085] In some embodiments, at least one of the preset flow control value adjustment amount, the first response time threshold, and the second response time threshold is determined according to the task type of the corresponding task group.
[0086] For example, the first response time threshold for each task group can be determined based on the task type of the task group. For instance, a larger first response time threshold can be configured for tasks that take a long time to complete, ensuring that these tasks can be responded to and processed within a reasonable timeframe. Conversely, a smaller first response time threshold can be configured for tasks that take a short time to complete, helping the system respond quickly to these tasks and improving overall efficiency. In this way, by adjusting the first response time threshold, it can be ensured that no task's response time is delayed to an unacceptable level. The system can achieve load balancing when processing different types of tasks, avoiding resource bottlenecks caused by excessively long response times in certain tasks.
[0087] For example, the second response time threshold for each task group can be determined based on the task type of the task group. For instance, a larger second response time threshold can be configured for tasks that take a long time to complete, ensuring that these tasks can be responded to and processed within a reasonable time. Conversely, a smaller second response time threshold can be configured for tasks that take a short time to complete, helping the system respond quickly to these tasks and improving overall work efficiency. In this way, by configuring the second response time threshold, it can be ensured that tasks in the task group will not experience collective congestion due to an excessive number of concurrent tasks, thus avoiding task congestion.
[0088] For example, the preset flow control value adjustment amount for each task group can be determined according to the task type of the task group. For instance, for task types that require high control precision, a smaller flow control value adjustment amount can be configured. The smaller the flow control value adjustment amount, the slower the control speed of task scheduling, but the finer the control precision. Conversely, for task types that require lower control precision, a larger flow control value adjustment amount can be configured. The larger the flow control value adjustment amount, the faster the control speed of task scheduling, but the coarser the control precision. In this way, control precision can be set for different types of tasks to meet differentiated scheduling needs.
[0089] In this embodiment of the disclosure, different methods can be used to adjust the flow control value corresponding to each task group in the next task scheduling according to the preset flow control value adjustment amount for different preset rules. The following description will be based on the preset rules of the above-mentioned rule 1 to rule 3.
[0090] In some embodiments, when the target difference is less than or equal to the first response time threshold and the maximum task response time is less than or equal to the second response time threshold (i.e., the preset rule is the first rule), if the sum of the flow control value corresponding to each task group in the current task scheduling and the preset flow control value adjustment amount is less than or equal to the preset maximum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be increased by the preset flow control value adjustment amount. If the sum of the flow control value corresponding to each task group in the current task scheduling and the preset flow control value adjustment amount is greater than the preset maximum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be set to the preset maximum flow control value. In this way, if the difference between the maximum and minimum task response times in the same task scheduling of a task group is less than or equal to the first response time threshold, and the maximum task response time is less than or equal to the second response time threshold, it can be known that the task execution in the task group is stable and there is no congestion. That is, the task execution in the task group is smooth. To further improve the task scheduling efficiency, the flow control value of the task group in the next task scheduling can be increased according to the flow control value adjustment amount. However, the flow control value cannot be greater than the preset maximum flow control value. The flow control value can be dynamically adjusted according to the needs to make the flow control of task scheduling more precise.
[0091] In some embodiments, the preset maximum flow control value is determined based on the task type of the corresponding task group. For example, for resource-intensive tasks (such as creating virtualized desktops), the number of tasks that can be processed concurrently is relatively small. A smaller preset maximum flow control value can be set for this type of task to avoid system overload while ensuring that these tasks can obtain sufficient resources to complete smoothly. Conversely, for resource-inefficient tasks (such as boot / shutdown tasks), the number of tasks that can be processed concurrently is relatively large. A larger preset maximum flow control value can be set for this type of task to improve system processing capacity, allowing more tasks to execute concurrently, thereby improving overall efficiency. In this way, the preset maximum flow control value can be flexibly set according to different task types, balancing task execution efficiency and resource utilization. By limiting resource usage through setting the maximum flow control value, the risk of system instability or crashes due to resource contention can be reduced.
[0092] In some embodiments, when the target difference is less than or equal to the first response time threshold and the maximum task response time is greater than the second response time threshold (i.e., the preset rule is the second rule), if the difference between the flow control value corresponding to each task group in the current task scheduling and the preset flow control value adjustment amount is greater than or equal to the preset minimum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be reduced by the preset flow control value adjustment amount. If the difference between the flow control value corresponding to each task group in the current task scheduling and the preset flow control value adjustment amount is less than the preset minimum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be set to the preset minimum flow control value. In this way, if the difference between the maximum and minimum task response times in the same task scheduling of a task group is less than or equal to the first response time threshold, and the maximum task response time is greater than the second response time threshold, it can be known that although the tasks in the task group are executing stably, congestion has occurred during the processing of the tasks in the task group. The flow control value of the task group in the next task scheduling can be reduced according to the flow control value adjustment amount, but the flow control value cannot be less than the preset minimum flow control value. The flow control value can be dynamically adjusted according to the needs to make the flow control of task scheduling more precise.
[0093] In this embodiment of the disclosure, the minimum flow control value corresponding to each task group can be set according to actual application requirements. The minimum flow control value must be greater than zero and less than or equal to the default flow control value.
[0094] In some embodiments, the preset minimum flow control value is determined based on the task type of the corresponding task group. For example, for resource-intensive tasks (such as creating virtualized desktops), the number of tasks that can be processed concurrently is relatively small. A smaller preset minimum flow control value can be set for this type of task to avoid system overload. Conversely, for resource-inefficient tasks (such as boot / shutdown tasks), the number of tasks that can be processed concurrently is relatively large. A larger preset minimum flow control value can be set for this type of task to allow more tasks to execute concurrently, thereby improving system efficiency. In this way, the preset minimum flow control value can be flexibly set according to different task types to achieve optimal system performance and resource utilization.
[0095] In some embodiments, when the target difference is greater than the first response time threshold (i.e., the preset rule is rule number 3), if the difference between the flow control value corresponding to each task group in the current task scheduling and the preset flow control value adjustment amount is greater than or equal to the preset minimum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be reduced by the preset flow control value adjustment amount. If the difference between the flow control value corresponding to each task group in the current task scheduling and the preset flow control value adjustment amount is less than the preset minimum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be set to the preset minimum flow control value. Thus, when the difference between the maximum and minimum task response times in the same task scheduling of a task group is greater than the first response time threshold, it can be known that the response times of each task in the task group are significantly different, and the execution of each task in the task group is unstable. The flow control value of this task group in the next task scheduling can be reduced according to the flow control value adjustment amount, but the flow control value cannot be less than the preset minimum flow control value. The flow control value can be dynamically adjusted according to requirements, making the flow control of task scheduling more precise.
[0096] By using the above method, the flow control value for each scheduling can be dynamically adjusted according to the server's processing capacity and task response time. This can balance and alleviate the pressure on the server to process tasks, ensuring that the server always runs efficiently and stably, maximizing the utilization of server resources, guaranteeing the stable execution of tasks, and improving task processing efficiency.
[0097] The following example illustrates a method for dynamically adjusting the flow control value of a task group in some embodiments of this disclosure.
[0098] One example illustrates adjusting the flow control value of a task group. When there are multiple task groups, each task group can adjust its initial flow control value using this method. The example includes the following flow:
[0099] S1: Configure a default flow control value for a task group based on its task type, denoted as x, and configure a preset flow control value adjustment amount for the task group, denoted as p. p represents the amount of change in the flow control value each time it is adjusted. The smaller the p value, the slower the adjustment speed, but the finer the adjustment precision.
[0100] S2: Configure a preset maximum flow control value, denoted as y, for a task group based on its task type, where y >= x; configure a preset minimum flow control value, denoted as n, where n must satisfy 0. <n<=x;
[0101] S3: Configure a second response time threshold for a task group based on the task type of the task group, denoted as m;
[0102] S4: Configure a first response time threshold, denoted as z, for a task group based on its task type. For example, the value of z can be set to half the value of m.
[0103] S5: When initially scheduling the task group, create x task sub-threads for the multiple tasks included in the task group in the task group thread, schedule the tasks to the server for processing, and record the response time of the multiple tasks included in the task group in an array [A1,A2,...,Ax];
[0104] S6: Determine the maximum response time for the completion of each task in this task group, denoted as timeMax = Max([A1,A2,...,Ax]);
[0105] S7: Determine the minimum response time for each task in the task group to complete, denoted as timeMin = Min([A1,A2,...,Ax]);
[0106] S8: Determine the difference between the maximum and minimum response times for each task in the task group, denoted as timeDif = timeMax - timeMin;
[0107] S9: If timeDif <= z and timeMax <= m, then in the next task scheduling, the flow control value corresponding to the task group will be set to x = Min(x+p,y). In this case, it can be known that the tasks in the task group are executing smoothly. The flow control value can be appropriately increased in the next scheduling of the task group, that is, the number of concurrent tasks can be increased. However, the number of concurrent tasks cannot be increased indefinitely, and its maximum value cannot exceed y.
[0108] S10: If timeDif <= z and timeMax > m, then in the next task scheduling, the flow control value corresponding to the task group will be set to x = Max(xp, n). In this case, it can be known that the task in the task group is congested during processing. The flow control value can be appropriately reduced in the next scheduling of the task group, that is, the number of concurrent tasks can be reduced. However, the number of concurrent tasks cannot be reduced indefinitely, and its minimum value cannot be less than n.
[0109] S11: If timeDif > z, then in the next task scheduling, the flow control value corresponding to the task group will be set to x = Max(xp, n). In this case, it can be seen that the response time of each task in the task group is very different and the task execution is unstable. The flow control value can be appropriately reduced in the next scheduling of the task group, that is, the number of concurrent tasks can be reduced. However, the number of concurrent tasks cannot be reduced indefinitely, and its minimum value cannot be less than n.
[0110] By adjusting the flow control value for each scheduling process, the flow control value can be kept within an appropriate range, ensuring stable task execution and improving task processing efficiency while maximizing the use of server resources.
[0111] Secondly, refer to the appendix. Figure 6 This is a schematic diagram of a task scheduling device structure provided in an embodiment of the present disclosure, comprising: at least one processor 601, at least one memory 602, and one or more I / O interfaces 603. The one or more I / O interfaces 603 are connected between the processor 601 and the memory 602. The memory 602 stores one or more computer programs, which are executed by the at least one processor 601 to enable the at least one processor 601 to implement the methods described in the first aspect and any possible embodiments thereof.
[0112] The processor 601 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the memory 602 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), and flash memory (FLASH); the I / O interface 603 (read-write interface) is connected between the processor 601 and the memory 602, enabling information exchange between the processor 601 and the memory 602, including but not limited to a data bus.
[0113] Thirdly, embodiments of this disclosure provide a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the methods of the first aspect and any possible embodiments of the first aspect.
[0114] Those skilled in the art will understand that all or some of the steps, systems, and devices disclosed above, as functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0115] In hardware implementations, the division between functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be executed by several physical components working together.
[0116] Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit (CPU), digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technique for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH) or other disk storage; read-only optical disc (CD-ROM), digital versatile disc (DVD) or other optical disc storage; magnetic cartridges, magnetic tapes, disk storage or other magnetic storage; and any other media that can be used to store desired information and can be accessed by a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0117] This disclosure has disclosed exemplary embodiments, and although specific terminology has been used, it is for general illustrative purposes only and should not be construed as limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in conjunction with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in conjunction with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this disclosure as set forth by the appended claims.
Claims
1. A task scheduling method, characterized in that, The method includes: Responding to multiple tasks from at least one task initiator; The multiple tasks are grouped according to their multiple task types to obtain multiple task groups corresponding to the multiple task types, and each task group corresponds to one task type. Assign a task group thread to each task group, and create multiple task sub-threads for each task group within each task group thread. Synchronize and schedule the threads of each task group and the sub-threads of each task.
2. The method according to claim 1, characterized in that, The step of grouping the multiple tasks according to multiple task types to obtain multiple task groups corresponding to multiple task types includes: For each task type, create task queues according to the priority of the multiple tasks corresponding to each task type, with different task queues corresponding to different priorities; For each task type, tasks with the same priority are stored in the corresponding priority task queue. Based on the flow control value corresponding to the task group for each task type, the tasks in each task queue are divided into task groups corresponding to each task type in descending order of priority of the task queue, resulting in multiple task groups corresponding to multiple task types. The number of tasks in each task group is less than or equal to the flow control value corresponding to each task group.
3. The method according to claim 2, characterized in that, The priority of multiple tasks corresponding to each task type is determined according to the type of the task initiator.
4. The method according to claim 2, characterized in that, The initial value of the flow control value is the default flow control value, which is determined according to the task type of the corresponding task group.
5. The method according to claim 1, characterized in that, After creating multiple task sub-threads for each task group within each task group thread, the method further includes: According to preset rules, the flow control value corresponding to each task group in the next task scheduling is adjusted according to a preset flow control value adjustment amount, wherein the preset rules include any one of the following: The target difference is less than or equal to the first response time threshold, and the maximum task response time is less than or equal to the second response time threshold; The target difference is less than or equal to the first response time threshold, and the maximum task response time is greater than the second response time threshold; The target difference is greater than the first response time threshold; The target difference refers to the difference between the maximum task response time and the minimum task response time. The maximum task response time is the maximum response time for each task in each task group to complete execution, and the minimum task response time is the minimum response time for each task in each task group to complete execution.
6. The method according to claim 5, characterized in that, The step of adjusting the flow control value corresponding to each task group in the next task scheduling according to preset rules and preset flow control value adjustment amounts includes: If the target difference is less than or equal to the first response time threshold, and the maximum task response time is less than or equal to the second response time threshold, and the sum of the flow control value corresponding to each task group in this task scheduling and the preset flow control value adjustment amount is less than or equal to the preset maximum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be increased by the preset flow control value adjustment amount. If the sum of the flow control value corresponding to each task group in this task scheduling and the preset flow control value adjustment amount is greater than the preset maximum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be set to the preset maximum flow control value.
7. The method according to claim 5, characterized in that, The step of adjusting the flow control value corresponding to each task group in the next task scheduling according to preset rules and preset flow control value adjustment amounts includes: If the target difference is less than or equal to the first response time threshold, and the maximum task response time is greater than the second response time threshold, and the difference between the flow control value corresponding to each task group in this task scheduling and the preset flow control value adjustment amount is greater than or equal to the preset minimum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be reduced by the preset flow control value adjustment amount. If the difference between the flow control value corresponding to each task group in this task scheduling and the preset flow control value adjustment amount is less than the preset minimum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be set to the preset minimum flow control value.
8. The method according to claim 5, characterized in that, The step of adjusting the flow control value corresponding to each task group in the next task scheduling according to preset rules and preset flow control value adjustment amounts includes: If the target difference is greater than the first response time threshold, and the difference between the flow control value corresponding to each task group in the current task scheduling and the preset flow control value adjustment amount is greater than or equal to the preset minimum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be reduced by the preset flow control value adjustment amount. If the difference between the flow control value corresponding to each task group in the current task scheduling and the preset flow control value adjustment amount is less than the preset minimum flow control value, then the flow control value corresponding to each task group in the next task scheduling will be set to the preset minimum flow control value.
9. The method according to claim 5, characterized in that, At least one of the preset flow control value adjustment amount, the first response time threshold, and the second response time threshold is determined according to the task type of the corresponding task group.
10. The method according to claim 6, 7, or 8, characterized in that, The preset maximum flow control value or the preset minimum flow control value is determined according to the task type of the corresponding task group.
11. A task scheduling device, characterized in that, include: Memory, processor; The memory stores a computer program that can be executed by the processor, and when the computer program is executed by the processor, it implements the task scheduling method according to any one of claims 1 to 10.
12. A computer-readable medium having a computer program stored thereon, the computer program, when executed by a processor, implementing the task scheduling method according to any one of claims 1 to 10.