Task queuing method, device, computer equipment and storage medium

By summarizing tasks from different sources into the same task group and taking turns to put tasks in the task control queue, combining monitoring and target task group management, the problem of excessive system load caused by independent task queues is solved, and efficient utilization of system resources and stability guarantee is achieved.

CN113806049BActive Publication Date: 2025-03-14KINGDEE SOFTWARE(CHINA) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111092187.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-17
Publication Date
2025-03-14
Estimated Expiration
2041-09-17

AI Technical Summary

Technical Problem

In a multi-module environment, independent task queues cause system load to increase instantly, and their resources occupying more than the upper limit of system capacity, seriously affecting system performance and stability, and may even lead to system crashes.

Method used

By receiving tasks from different sources, summarizing tasks from the same source into the same task group, and taking turns to put tasks from different task groups into the task control queue. Monitor the output tasks, obtain the number of tasks in the same task group in a preset state, determine the target task group based on the number of tasks, and stop the tasks and put them into the task control queue.

Benefits of technology

Effectively control the total number of tasks' execution threads, avoid excessive resource usage, ensure that the task control queue can output multiple tasks, improve system efficiency and stability, and prevent system crashes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113806049B_ABST
    Figure CN113806049B_ABST
Patent Text Reader

Abstract

The present application relates to a task queuing method, device, computer equipment and storage medium. The method includes: after receiving tasks from different sources, tasks from the same source are grouped into the same task group; tasks from different task groups are placed in a task control queue in turn, and tasks of multiple task groups are output through the task control queue; the output tasks are monitored to obtain the number of tasks in a preset state of the same task group, and based on the task number range in which the task number is located, the corresponding task group is determined to be the target task group, and the tasks of the target task group are stopped from being placed in the task control queue. After adopting this method, no matter how many task sources there are, too many computing resources will not be occupied, and the task control queue can output multiple queues, which can ensure efficiency and will not exceed the system's capacity limit, and the system has high performance and stability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a task queuing method, device, computer equipment and storage medium. Background Art

[0002] With the development of data processing technology, multiple modules may share unified computing resources to achieve full utilization of computing resources. In order to make fuller use of computing resources, independent task queue technology has emerged. In each independent task queue, the task scheduling is independent and independent of each other. There is no need to wait for other queue tasks to finish before execution.

[0003] When using independent task queue technology, each task queue and execution thread are independent of each other. After the user submits a task, it can be executed promptly without being forced to wait for other tenants' tasks. Even if there are too many tasks that need to be queued, the user can see that some tasks are being executed in the task list, which significantly improves the user experience.

[0004] However, its defect is that when many modules are deployed in the environment, a large number of queues and execution threads are required. When multiple modules submit a large number of tasks at the same time, the system load will increase instantly, and the occupied resources may exceed the system's capacity limit, seriously affecting the system's performance and stability, and may even cause the system to crash. Summary of the invention

[0005] Based on this, it is necessary to provide a task queuing method, device, computer equipment and storage medium that take into account both computing resource utilization efficiency and system stability in order to address the above technical problems.

[0006] A task queuing method, the method comprising:

[0007] After receiving tasks from different sources, tasks from the same source are grouped into the same task group;

[0008] Putting tasks of different task groups into a task control queue in turn, and outputting tasks of multiple task groups through the task control queue;

[0009] Monitor the tasks after output, obtain the number of tasks in the same task group in a preset state, determine the corresponding task group as the target task group based on the task number range in which the task number is located, and stop putting the tasks of the target task group into the task control queue.

[0010] In one embodiment, the monitoring output tasks, obtaining the number of tasks in a preset state of the same task group, determining the corresponding task group as the target task group based on the task number range in which the task number is located, and stopping the tasks of the target task group from being put into the task control queue, include:

[0011] Monitoring the tasks being executed, determining the task group to which the tasks being executed belong, and determining the number of tasks being executed by at least one task group;

[0012] Obtaining a threshold value of the number of tasks being executed by the task group;

[0013] The number of tasks being executed by the task group is compared with the task number threshold. If the number of tasks being executed by the task group is greater than the task number threshold, the corresponding task group is determined to be the target task group, and the tasks of the target task group are stopped from being put into the task control queue.

[0014] In one embodiment, obtaining the threshold value of the number of tasks being executed by the target task group includes:

[0015] The number of the task groups is obtained, and a threshold value of the number of tasks being executed by the target task group is generated according to the number of the task groups.

[0016] In one embodiment, after the tasks of the target task group are stopped and placed in the task control queue, the process includes:

[0017] In the task regulation queue, a suspended execution task is determined, the suspended execution task is a task output by the target task group and not executed, and the suspended execution task is not output through the task regulation queue.

[0018] In one embodiment, after determining to suspend execution of the task, the method further includes:

[0019] The number of tasks being executed by the target task group is determined. If the number of tasks being executed by the target task group is less than the task number threshold, the suspended task participates in the task arrangement of the task control queue.

[0020] In one embodiment, grouping tasks from the same source into the same task group includes:

[0021] Group tasks from the same source into the same task group queue;

[0022] After the tasks of the target task group are stopped and put into the task control queue, the process includes:

[0023] The target task group queue is moved into the queue pool, and the target task group queue interrupts outputting tasks to the task regulation queue.

[0024] In one embodiment, placing the tasks of the task group into the task control queue in turn includes:

[0025] Obtain a circular queue, obtain the tasks output by the task group through the circular queue, and fill the storage space of the circular queue;

[0026] When the tasks output by the task group fill up the storage space of the circular queue, the task control queue is obtained.

[0027] A task queuing device, comprising:

[0028] A task group generation module is used to group tasks from the same source into the same task group after receiving tasks from different sources;

[0029] A control queue construction module, used to put tasks of different task groups into the task control queue in turn, and output the tasks of multiple task groups through the task control queue;

[0030] The control queue monitoring module is used to obtain the number of tasks in the same task group in a preset state, and based on the task number range in which the task number is located, determine that the corresponding task group is the target task group, and stop putting the tasks of the target task group into the task control queue.

[0031] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0032] After receiving tasks from different sources, tasks from the same source are grouped into the same task group;

[0033] Putting tasks of different task groups into a task control queue in turn, and outputting tasks of multiple task groups through the task control queue;

[0034] Monitor the tasks after output, obtain the number of tasks in the same task group in a preset state, determine the corresponding task group as the target task group based on the task number range in which the task number is located, and stop putting the tasks of the target task group into the task control queue.

[0035] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0036] After receiving tasks from different sources, tasks from the same source are grouped into the same task group;

[0037] Putting tasks of different task groups into a task control queue in turn, and outputting tasks of multiple task groups through the task control queue;

[0038] Monitor the outputted tasks, obtain the number of tasks in the same task group in a preset state, determine the corresponding task group as the target task group based on the task number range in which the task number is located, and stop putting the tasks of the target task group into the task control queue

[0039] The above-mentioned task queuing method, device, computer equipment and storage medium, after receiving tasks from different sources, summarize the tasks from the same source into the same task group; put the tasks of the task group into the task control queue in turn, and output the tasks of the task group through the task control queue; obtain the number of tasks in the same task group in a preset state, and determine the corresponding task group as the target task group based on the task number range in which the task number is located, and stop putting the tasks of the target task group into the task control queue. Thus, the task group is formed with the tasks from the same source, and the tasks output by the task group are arranged into a task control queue. It only needs to set the task number threshold for the task execution state of the task group and control the tasks in the task control queue to control the total number of execution threads of the task. Under this condition, no matter how many modules submit tasks, they will not occupy too many computing resources, and the task control queue can output multiple tasks, which can ensure efficiency and will not exceed the capacity limit of the system. The system has high performance and stability. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 An application environment diagram of a task queuing method in one embodiment;

[0041] Figure 2 A flowchart of a task queuing method in one embodiment;

[0042] Figure 3 A schematic diagram of a process for determining a target task group in one embodiment;

[0043] Figure 4 A flowchart of a task queuing method in another embodiment;

[0044] Figure 5 It is a structural block diagram of a task queuing device in one embodiment;

[0045] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0046] In traditional technology, at least two common technical solutions are used to queue tasks, namely global shared task queues and tenant independent task queues. In a global shared task queue, all tenants share a task queue, and all tasks are queued in the same queue; when the server is busy, it may often be necessary to wait for other tenants' tasks to finish before executing them in the background. In an independent task queue, each tenant or module uses at least one independent task queue, and their task scheduling is independent and independent of each other. There is no need to wait for other tenants' or modules' tasks to finish before executing.

[0047] In the global shared task queue, all submitted tasks are added to a global shared queue. The background task scheduling engine uses a group of threads to process according to the queue's queuing strategy. The queuing strategy can be based on the order of task submission time. When there are too many tasks, exceeding the upper limit of the number of execution threads, and the task scheduling engine has no time to execute them simultaneously, the unexecuted tasks are queued in the queue. In this way, the server controls the maximum number of tasks that can be executed simultaneously to effectively reduce the server load during peak periods and improve system stability and performance.

[0048] The advantage of the global shared task queue is that the maximum number of tasks that can be executed concurrently by the server is limited, which makes it easy to control the maximum resource requirements of the server and has good stability. However, in a multi-tenant environment, when individual tenants suddenly submit a large number of background tasks and the execution time is long, the tasks submitted by other tenants will be forced to queue up, and may need to wait for a long time to be executed. If you encounter extreme situations such as an infinite loop caused by a program error, they may never be executed unless human intervention occurs. Therefore, if the background task engine of the global shared task queue is used, the response speed of task execution may be very slow. For example, when the server processes tasks of multiple tenants, because the background task engine is executing tasks submitted by other tenants at full capacity, users of some tenants can only see that they have submitted many tasks, but all tasks are waiting. From the perspective of tenants, this global shared task queue is very unfair. When all tenants are equal, the execution of tasks needs to wait for the execution of tasks of other tenants, which may take a long time, which makes people mistakenly think that the system has failed.

[0049] In an independent task queue, each tenant or module uses its own dedicated task queue, and the submitted tasks enter the corresponding task queue; the background task scheduling engine assigns a corresponding execution thread group to each queue, and the tasks in each queue are executed by their own dedicated thread group. The response speed of task execution is significantly improved. When task queuing occurs, users can also easily understand the reason for the queuing from the task queue monitoring data.

[0050] The advantage of independent task queues is that they can solve the problem of globally shared task queues. Because each task queue and execution thread are independent of each other, submitted tasks can be executed in a timely manner without being forced to wait for tasks in other queues; even if there are too many tasks to queue, feedback can be provided in a timely manner, and users can also see the execution process of some tasks in the task list, which significantly improves the user experience. However, its drawback is that when many tenants or modules are deployed in the environment, a large number of queues and execution threads are required. When multiple tenants or modules submit a large number of tasks at the same time, the system load will increase instantly, and the resources occupied may exceed the system capacity limit, seriously affecting the system's performance and stability, and may even cause the system to crash.

[0051] Based on this, how to strike a balance between computing resource utilization efficiency and system stability is an issue that needs to be studied in depth.

[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0053] The task queuing method provided in this application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0054] In one embodiment, Figure 2 As shown, a task queuing method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0055] Step 202, after receiving tasks from different sources, tasks from the same source are grouped into the same task group.

[0056] A task is a schedulable entity used by a hypervisor. In a multiprogrammed or multiprocess environment, a task is the basic unit of work performed by a computer. It is a sequence of one or more instructions processed by a control program. A sequence of instructions includes at least one instruction. A task can be a simple task such as calculating a single data, or a complex task such as displaying a certain data or rendering a certain data.

[0057] Tasks from different sources can be divided according to the objects that issue the tasks. They can be tasks issued by different tenants of the server, tasks issued by different computer devices, tasks issued by different computer modules, tasks issued by different program locks, or tasks generated under different circumstances. Tasks from different sources can be divided according to the time when the tasks are issued. It can be a specific time, a specific time interval, or some time identifiers. Tasks from different sources can have different source identifiers.

[0058] A task group may include a task set. A task group may include one or more task sets. A task group may include tasks. A task group may include one or more tasks, or may not include any tasks. When a task group includes one or more tasks, the tasks within it are tasks waiting to be scheduled, and the task group may be dynamically converted between a target task group and a non-target task group, or may remain in the state of a target task group or a non-target task group for a long time. When a task group does not include any tasks, the task group may also be considered a target task group. Different task groups may have different task group identifiers, and the task group identifier may be the same as the source identifier or may be different from the source identifier. In a task group, after each task is executed, the next task is executed sequentially or according to the dependency relationship between tasks.

[0059] It is important to understand that grouping tasks from the same source into the same task group can avoid interference between tasks from different sources, and can also control tasks according to task groups, so as to execute the overall tasks more efficiently. A task group can be a task group, which can be a collection of user accounts, computer accounts or other domain objects with the same management tasks. Domain objects can be one or N of the following: organizational units of tasks, task groups, users, computers, contacts, printers, security policies, etc., where N is an arbitrary integer.

[0060] Specifically, the source of the task can be determined by the source identifier in the task, and the data structure is relatively clear; the source of the task can also be determined directly according to the result generated by the task, and the data is relatively concise; the source of the task can also be determined according to the dependency relationship within the task group, and the task data relationship is clear, and the data structure is relatively simple. For example, some tasks have specific strings, and these specific strings are used to characterize the source of the task, so the task group to which these tasks should belong can be determined based on these specific strings; some tasks will generate strings with dependencies, and the task groups to which these tasks belong can also be determined through the strings with dependencies; when a task is obtained, the task has a dependency relationship with a task in a task group, and the task group to which the task belongs can be determined through this dependency relationship.

[0061] Step 204 , tasks of different task groups are put into the task control queue in turn, and tasks of multiple task groups are output through the task control queue.

[0062] The task control queue is mainly used to arrange the tasks of each task group. Its storage space can be a fixed value or a dynamic value. It can be a queue that only allows insertion at one end and output at the other end. Therefore, only the elements that enter the queue first can be output from the queue first, so the queue is also called a first-in-first-out linear list. The process of inserting a task into the task control queue can be called putting it into the task control queue; after outputting a task from the task control queue, the task control queue will delete the output task. The task control queue can also be other data sets with the same or similar functions, or any data structure that can control tasks.

[0063] Specifically, the tasks of different task groups are output in turn, which can be implemented using a loop, and the data structure is relatively simple; pointers or priorities can also be set to implement this process, which is convenient for controlling and adjusting the output strategy. For example, after a task group outputs a rendering task, it will output the next rendering task after other task groups have output a task in turn; after a task group outputs a rendering task, it will output tasks through a specific task group according to the pointer or priority, and then any task group will output the next rendering task.

[0064] Specifically, after outputting tasks of multiple task groups, the multiple tasks can be executed in a multi-threaded parallel manner.

[0065] Step 206, monitor the outputted tasks, obtain the number of tasks in the same task group in a preset state, determine the corresponding task group as the target task group based on the task number range in which the task number is located, and stop putting the tasks of the target task group into the task control queue.

[0066] The output task refers to the task output by the task control queue, which belongs to a specific task group.

[0067] The number of tasks in the same task group that are in the preset state is obtained through the task statistics in a certain task group, which is mainly a statistics of the state of one or more tasks. The preset state is for a single task, which can also be called the task state, which includes three basic states: waiting to be scheduled, executing, and completed, as well as further subdivision or integration of the basic states. When a task is in a task group or a task control queue, it is a task to be scheduled; when a task is output by the task control queue and is being executed, it is an executing task; when an executing task is completed by a thread, it is a completed task.

[0068] The task quantity range can also be called the task execution state of the task group, which is mainly the overall execution state of multiple tasks belonging to a task group. In a task group, the task execution state of the task group can be generated by the number of task states in each state of the task group, or by the relationship function between the number of task states in each state. The task quantity range can also be limited by the task quantity threshold.

[0069] The task quantity threshold may be the number of tasks being executed by the task group, the number of tasks that have been completed by the task group, or may be positively or negatively correlated with the number of tasks being executed. In short, the task quantity threshold may be related to the execution status of a single task or multiple tasks.

[0070] The target task group can be any number of task groups, mainly referring to the regulated task group, which can come from a tenant or any computer module.

[0071] Optionally, in this step, only the tasks being executed may be monitored, and by judging the number of tasks being executed by each task group, it is determined whether the task execution status of the task group is greater than the task number threshold. For example, when the number of tasks being executed by a task group reaches a certain value, the task number threshold of the task group is used to make a judgment to estimate the status of the task group.

[0072] It should be understood that in the target task group of the embodiment, there may be certain problems with the data structure of the task group. If the tasks of the task group participate in queuing, on the one hand, it will take up too many computing resources and affect the execution of tasks of other task groups, resulting in a decrease in overall efficiency; on the other hand, it will not be able to generate problem feedback.

[0073] Specifically, when the computing resources required by the target task group's tasks are too large, there may be a bug, or it may be a normal program, so the target task group's tasks are suspended and placed in the task control queue, but the execution of the corresponding tasks is not suspended, so as to take into account the task execution efficiency of the target task group and other task groups. It should be noted that after the target task group stops being placed in the task control queue, the tasks being executed by the target task group do not necessarily have to be suspended, because the tasks of the target task group may not be unsolvable problems such as dead loops, but require a large amount of resources for calculation to complete, and they may be completed.

[0074] Optionally, if the number of tasks is greater than a task number threshold, the tasks of the task group are put into the task control queue in turn.

[0075] The above-mentioned task queuing method, device, computer equipment and storage medium, after receiving tasks from different sources, summarize the tasks from the same source into the same task group; put the tasks of the task group into the task control queue in turn, and output the tasks of the task group through the task control queue; obtain the number of tasks in the same task group in a preset state, and determine the corresponding task group as the target task group based on the task number range in which the task number is located, and stop putting the tasks of the target task group into the task control queue. Thus, the task group is formed with the tasks from the same source, and the tasks output by the task group are arranged into a task control queue. It only needs to set the task number threshold for the task execution state of the task group and control the tasks in the task control queue to control the total number of execution threads of the task. Under this condition, no matter how many modules submit tasks, they will not occupy too many computing resources, and the task control queue can output multiple tasks, which can ensure efficiency and will not exceed the capacity limit of the system. The system has high performance and stability.

[0076] It should be understood that the tasks output from the task control queue include at least tasks in progress and completed tasks. Tasks in progress may refer to tasks that are being executed by the task engine calling thread, and completed tasks may refer to tasks that have been completed by the task engine calling thread.

[0077] In one embodiment, Figure 3 As shown, monitoring the tasks after output, obtaining the number of tasks in the same task group in a preset state, determining the corresponding task group as the target task group based on the task number range in which the task number is located, and stopping the tasks of the target task group from being put into the task control queue includes:

[0078] Step 302 , monitoring the tasks being executed, determining the task group to which the tasks being executed belong, and determining the number of tasks being executed in at least one task group.

[0079] Specifically, the task group to which the executing task belongs can be determined by the task group identifier of the executing task, by extracting information of the executing task, by a mapping relationship of the executing task, and so on.

[0080] Step 304: Obtain a threshold value of the number of tasks being executed by the task group.

[0081] The task quantity threshold can be a preset static value or a dynamic value. The dynamic value can be set based on factors such as the memory of the terminal and / or server to improve the overall efficiency of the execution of tasks in each task group. Different task groups can have the same task quantity threshold, or different task quantity thresholds can be set for different task groups, so that high-level task groups have higher task quantity thresholds to ensure execution efficiency.

[0082] Step 306, compare the number of tasks being executed by the task group with the task number threshold. If the number of tasks being executed by the task group is greater than the task number threshold, determine that the corresponding task group is the target task group, and stop putting the tasks of the target task group into the task control queue.

[0083] In this embodiment, the task execution status of a task group is judged by the number of tasks being executed by the task group. Even if a small number of tasks in a task group are problematic, most of the tasks in the task group can be executed, while taking into account the execution of tasks in other task groups. Thus, the execution efficiency and stability of the system are improved.

[0084] In order to further improve the performance of this system, a dynamic task quantity threshold can be set using specific parameters. The above threshold for obtaining the number of tasks being executed by the task group includes:

[0085] The number of task groups is obtained, and according to the number of task groups, a threshold value of the number of tasks being executed by the task groups is generated.

[0086] The number of task groups may be related to the number of tenants who rent related resources, or the number of modules in a terminal or server that require resources. The number of task groups may also be the number of target task groups.

[0087] Specifically, if a task is a task that needs to be completed as a priority, the total number of task groups can be positively correlated with the quantity threshold of a task, so as to achieve priority processing of core tasks, enhance execution efficiency, and not affect the overall stability; if a task is a routine task, the total number of task groups can be negatively correlated with the quantity threshold of a task, so as to achieve priority processing of core tasks, enhance execution efficiency, and not affect the overall stability; if each task does not involve priority, the priority of each task can be positively correlated with the quantity threshold, so as to enhance the stability of the overall operation.

[0088] In this embodiment, the number of tasks in the task group execution is dynamically adjusted by adjusting the number of task groups to change the conditions for generating the target task group, so as to better control the overall operating efficiency and stability.

[0089] In order to further improve the operating efficiency and stability of the system, the tasks in the task control queue should also be regulated. Therefore, after the tasks of the target task group are stopped and put into the task control queue, the following steps are included:

[0090] In the task control queue, a suspended task is determined. The suspended task is a task that is put into the task control queue by the target task group and has not been executed. The suspended task is not output through the task control queue.

[0091] Specifically, the step of determining the suspended task can be obtained through the task group identifier carried by the task, or through the information extraction of the task being executed, or through the mapping relationship of the task being executed, etc. If the suspended task is output according to the storage space output order of the task control queue, this task will be directly skipped and the tasks output by other task groups will be executed.

[0092] It should be understood that when a task group is a target task group, the number of tasks being executed by the task group needs to be compared with the task number threshold to determine whether the number of tasks being executed by the task group is greater than the task number threshold. Under this premise, not only the input of each task group to the task control queue should be considered, but also the execution of tasks in the task control queue should be considered.

[0093] In this embodiment, by determining to suspend the execution of the task but not removing the suspended execution task from the task control queue, bugs generated in the data scheduling process can be avoided and the overall stability can be improved.

[0094] Furthermore, after determining to suspend the execution of the task, the method further includes:

[0095] The number of tasks being executed by the target task group is determined. If the number of tasks being executed by the target task group is less than the task number threshold, the execution of the tasks participating in the task control queue is suspended.

[0096] Specifically, this embodiment includes at least two types of threads, one is a monitored thread and the other is a monitoring thread. The status message of the monitored thread includes the task status in the execution of the target task group, and the monitoring thread needs to contact the monitored thread at a preset interval to obtain and listen to the status of all monitored threads. Generally, the main control thread is used as the monitoring thread, and a thread can also be used as a monitoring thread or any other thread in the task can be used as the monitoring thread.

[0097] In this embodiment, the tasks being executed by the target task group are monitored, so that when the tasks being executed by the task group are completed, the suspended tasks are output to the task processing engine in a timely manner to further improve the execution efficiency.

[0098] In addition to improving efficiency and stability, the convenience of calling the queue should also be considered. Therefore, this embodiment introduces the queue pool technology and focuses on the use of the queue pool.

[0099] It is important to understand that when a large number of task groups access the application server concurrently, creating and destroying new service objects will inevitably cause huge overhead on system resources, resulting in a decrease in system performance. To this end, we use the queue pool approach. A queue pool is equivalent to a container that stores the objects we need for reuse, and we assign the tasks we need to do to it, thereby improving system performance.

[0100] Based on this, tasks with the same source are grouped into the same task group, including:

[0101] Group tasks from the same source into the same task group queue;

[0102] Correspondingly, after the tasks of the target task group are stopped and put into the task control queue, the following steps are performed:

[0103] Move the target task group queue into the queue pool, and the target task group queue interrupts the output task to the task control queue.

[0104] Specifically, after the concept of queue pool is introduced, when some task groups do not have tasks, these task groups can be stored in the queue pool; when the number of tasks being executed in some task groups reaches the quantity threshold, these task groups can be stored in the queue pool; when the number of tasks being executed in some task groups is less than the quantity threshold, these task group queues can be transferred out of the queue pool and re-participate in task queuing.

[0105] In this embodiment, the calling efficiency of the queue is improved by using a queue pool, the convenience of calling the queue is increased, and the overall execution time is reduced.

[0106] Optionally, to further increase stability, the tasks of the task group are put into the task control queue in turn, including:

[0107] Get the circular queue, get the tasks output by the task group through the circular queue, and fill the storage space of the circular queue.

[0108] A circular queue is a queue that moves the last position of the queue storage space around to the first position, forming a logical ring space for the queue to use in a circular manner. In a circular queue structure, when the last position of the storage space has been used and the queue operation is to be entered again, only the first position of the storage space needs to be free to add elements to the first position, that is, the first position of the storage space is used as the tail of the queue. A circular queue can more easily prevent pseudo overflows, but the queue size is fixed.

[0109] When the tasks output by the task group fill up the storage space of the circular queue, a task control queue is obtained. In the circular queue, one or more storage locations can be set to store identifiers to determine when the queue is empty or the queue space is fully occupied. In this embodiment, through the circular queue, the priority can be set without setting the priority, and the false full phenomenon of the linear queue will not occur.

[0110] Each of the above embodiments has its corresponding focus. This embodiment introduces the overall solution of this technology. For better understanding, this embodiment is described through tenants. Tenants can be one or more accounts that rent computing resources. Tenants can also be considered as modules related to any electronic device, such as processor modules and display modules. Tenants can also be any virtual modules divided by people.

[0111] Overall, if Figure 4 As shown, each tenant is assigned at least one independent task subqueue, and these subqueues are arranged in a ring to form a wheel-shaped global shared queue, which the present invention refers to as a "round-robin queue". Among them, the task subqueue is a form of the above-mentioned task group, and the "round-robin queue" is a general term for the above-mentioned task group and task control queue. In the "round-robin queue", each task subqueue outputs tasks in turn through a loop or the like. In this embodiment, tenant B, tenant C, and tenant E all belong to the target task group queue, and will not put tasks into the round-robin queue, and will not output tasks to the round-robin queue; tenant A, tenant D, and tenant F take turns putting tasks into the round-robin queue.

[0112] When a tenant's task is queued, the tenant's subqueue is found, the task is added to the end of the queue, and the queue operation is completed;

[0113] When a tenant's task is dequeued, the task is obtained from the first subqueue on the ring, and the ring is rotated by 1 grid, so that the next subqueue becomes the first subqueue on the ring; thus achieving the effect of dequeuing tasks according to tenants in turn.

[0114] After the above processing, when multiple tenants submit tasks at the same time, tasks can be executed in turns by tenants. To a certain extent, it can avoid the situation where a tenant monopolizes too many resources and other users mistakenly believe that the system is faulty, and realize fair task scheduling service for tenants. However, when a single tenant submits a large number of tasks suddenly, the tenant may still occupy all the resources of the server. If the execution time of these tasks is very long, then other tenants' submitted tasks will need to wait for a long time before they can be executed.

[0115] After the above processing, when multiple tenants submit tasks at the same time, tasks can be executed in turns by tenants, achieving fair task scheduling services for tenants and preventing a certain task from occupying too many computing resources. However, when a single tenant submits a large number of tasks suddenly, the tenant may still occupy all the resources of the server. If the execution time of these tasks is very long, then other tenants who submit tasks during this period will need to wait for a long time before they can be executed; therefore, the scheme of the present invention introduces a queue pool to control the maximum number of threads that a single tenant can occupy. When the number of tasks in a queue is greater than the task number threshold, the queue is moved into the queue pool so that the task subqueue is not output through the queue pool. At the same time, as long as a task subqueue exists in the task pool, the tasks of the task subqueue will not be executed in subsequent cycles.

[0116] Optionally, the task quantity threshold is specifically: setting an upper limit on the number of tasks that a single tenant can execute concurrently, which can be static or dynamic, but is less than the maximum number of tasks that the background task engine can execute concurrently. When the number of tasks being executed by a tenant reaches the upper limit, the tenant's task subqueue is moved from the round-robin queue to the queue pool; while the subqueue is in the queue pool, the background task engine does not execute the tenant's background tasks to prevent them from occupying too many server resources.

[0117] It should be noted that as long as a task sub-queue exists in the task pool, in subsequent cycles, even if the server has idle threads and the task sub-queue is about to be output through the task scheduling queue, the tasks of the task sub-queue will not be executed to prevent a single tenant from occupying too many server resources; because once a task starts executing, it is impossible to predict when it will end, and its end time is unknown, and there is no way to stop it in the middle to make way for other tasks.

[0118] When a task subqueue is less than the task number threshold, the task subqueue will be removed from the queue pool. For example, when a task of the tenant is completed, the number of tasks in execution of the tenant is checked. If the value is less than the upper limit and the task subqueue is currently in the "queue pool", the subqueue is returned to the "rotating queue" and the task engine is allowed to execute the tasks in it. If the number of tasks in execution of the tenant is still greater than the upper limit, it means that the number of tasks in execution of the tenant is too large and should be in the queue pool and not participate in the task dequeue, that is, even if the background task engine has idle threads at this time, the tenant's tasks cannot be executed. Adding a "subqueue pool" is to simplify the task dequeue of the "rotating queue". If a "subqueue" with too many tasks in execution is moved into the "queue pool", it will not participate in the dequeue of the "rotating queue", thereby preventing the tasks in it from being executed; on the contrary, a "subqueue" with fewer tasks in execution remains in the "rotating queue" and participates in the task dequeue, so that it has the opportunity to be executed.

[0119] In order to better introduce the technical solution of this embodiment, the key points of this embodiment include at least one or any combination of the following technical features: each tenant uses its own dedicated subqueue to queue tasks; the task subqueues of all tenants form a ring to form a globally shared round-robin queue; the background task engine takes turns to obtain tasks from the task subqueues on the ring for execution. Control the upper limit of the number of concurrently executed tasks of a single tenant; increase the queue pool, and the task subqueue of the tenant whose concurrently executed tasks reach the upper limit is moved into the queue pool to wait; after the task is completed, check the number of concurrently executed tasks of the tenant to which it belongs, and if it is less than the upper limit, return the corresponding task subqueue to the round-robin queue.

[0120] Based on these key technologies, the effects in this embodiment include: first, the maximum number of tasks that can be executed concurrently by the background task engine must be controlled so as not to endanger the stability of the system; second, the background task engine must provide relatively fair task scheduling services for each tenant, reduce the adverse effects of a single tenant's tasks on the execution of other tenants' tasks, and cannot monopolize too many system resources due to dead loops caused by individual program bugs; third, when multiple tenants submit tasks at the same time, the maximum number of tasks that can be executed concurrently can be effectively controlled to maximize the number of tenants that can be served simultaneously.

[0121] In order to further clarify the technical solution of this embodiment and simplify the technical solution and technical effects of this embodiment, the data structure of this embodiment is: ring + queue + pool;

[0122] The effects of this embodiment are:

[0123] Tenant fairness: The background task engine executes tasks in turns among tenants, achieving fair task scheduling for tenants to the greatest extent possible.

[0124] Resource usage is controllable: The maximum number of concurrently executed tasks of the background task engine is easy to control, avoiding the problem of out-of-control server resource usage.

[0125] The impact of failures is limited: a single tenant cannot monopolize all threads of the background task engine. Even if the tasks of individual tenants run for too long due to program bugs or environmental factors, the tasks of other tenants can still be executed normally.

[0126] It should be understood that although Figure 2-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-3At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0127] In one embodiment, Figure 5 As shown, a task queuing device is provided, including: a task group generating module 502, a control queue building module 504, and a control queue monitoring module 506, wherein:

[0128] A task group generating module 502 is used to group tasks from different sources into the same task group after receiving the tasks from different sources;

[0129] A control queue construction module 504 is used to put tasks of different task groups into a task control queue in turn, and output tasks of multiple task groups through the task control queue;

[0130] The control queue monitoring module 506 is used to obtain the number of tasks in the same task group in a preset state, and based on the task number range in which the task number is located, determine that the corresponding task group is the target task group, and stop putting the tasks of the target task group into the task control queue.

[0131] In one embodiment, the queue arrangement module 506 includes:

[0132] A task monitoring unit, used to monitor the tasks being executed, determine the task group to which the tasks being executed belong, and determine the number of tasks being executed in at least one target task group;

[0133] A threshold value obtaining unit, used to obtain a threshold value of the number of tasks being executed by the target task group;

[0134] A judgment unit is used to compare the number of tasks being executed by the task group with the task number threshold. If the number of tasks being executed by the task group is greater than the task number threshold, the corresponding task group is determined to be the target task group, and the tasks of the target task group are stopped from being put into the task control queue.

[0135] In one embodiment, the threshold value acquisition unit is specifically configured to acquire the number of the task groups, and generate a threshold value of the number of tasks being executed by the target task group according to the number of the task groups.

[0136] In one embodiment, the judgment unit is specifically used to, when the tasks of the target task group stop being placed in the task control queue, determine a suspended task in the task control queue, the suspended task being a task output by the target task group and not executed, and the suspended task is not output through the task control queue.

[0137] In one embodiment, the judgment unit is further used to judge the number of tasks being executed in the target task group. If the number of tasks being executed in the target task group is less than the task number threshold, the suspended task participates in the task arrangement of the task control queue.

[0138] In one embodiment, the task group generation module 502 is also used to group tasks from the same source into the same task group queue and call the task group queue out of the queue pool; correspondingly, the regulation queue construction module 504 is also used to move the target task group queue into the queue pool, and the target task group queue interrupts the output task to the task regulation queue.

[0139] In one embodiment, the task group generation module 502 is specifically used to: obtain a circular queue, obtain the tasks output by the task group through the circular queue, and fill the storage space of the circular queue;

[0140] When the tasks output by the task group fill up the storage space of the circular queue, the task control queue is obtained.

[0141] The specific definition of the task queuing device can be found in the definition of the task queuing method above, which will not be repeated here. Each module in the above-mentioned task queuing device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0142] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store task queuing data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a task queuing method is implemented.

[0143] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0144] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0145] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0146] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0147] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0148] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A task queuing method, characterized in that: The method comprises: After receiving tasks from different sources, tasks from the same source are grouped into the same task group; the tasks from different sources are divided according to the objects that issue the tasks; Putting tasks of different task groups into the task control queue in turn, and outputting tasks of multiple task groups through the task control queue; wherein the task control queue obtains the tasks of the task group in a circular queue, and the tasks of the task group are output by the task group in turn, and the circular queue is to move the last position of the queue storage space around to the first position to form a logical ring space for the queue to use cyclically; Monitor the tasks after output, obtain the number of tasks in the same task group in a preset state, and determine the corresponding task group as the target task group based on the task number range in which the task number is located; the task number range represents the overall execution status of multiple tasks of the same task group; the tasks of the target task group are stopped and placed in the task control queue, and the tasks of the target task group are not terminated.

2. The method according to claim 1, characterized in that The tasks after the monitoring output are obtained, the number of tasks in the same task group in a preset state is obtained, and based on the task number range in which the task number is located, the corresponding task group is determined to be the target task group, and the tasks of the target task group are stopped and put into the task control queue, including: Monitoring the tasks being executed, determining the task group to which the tasks being executed belong, and determining the number of tasks being executed by at least one task group; Obtaining a threshold value of the number of tasks being executed by the task group; The number of tasks being executed by the task group is compared with the task number threshold. If the number of tasks being executed by the task group is greater than the task number threshold, the corresponding task group is determined to be the target task group, and the tasks of the target task group are stopped from being put into the task control queue.

3. The method according to claim 2, characterized in that The step of obtaining the threshold value of the number of tasks being executed by the task group includes: The number of the task groups is obtained, and according to the number of the task groups, a threshold value of the number of tasks being executed by the task groups is generated.

4. The method according to claim 2, characterized in that: After the tasks of the target task group are stopped and put into the task control queue, the process includes: In the task regulation queue, a suspended execution task is determined, the suspended execution task is a task output by the target task group and not executed, and the suspended execution task is not output through the task regulation queue.

5. The method according to claim 4, characterized in that After determining to suspend the execution of the task, the method further includes: The number of tasks being executed by the target task group is determined. If the number of tasks being executed by the target task group is less than the task number threshold, the suspended task participates in the task arrangement of the task control queue.

6. The method according to claim 1, characterized in that The tasks with the same source are grouped into the same task group, including: Group tasks from the same source into the same task group queue; After the tasks of the target task group are stopped and put into the task control queue, the process includes: The target task group queue is moved into the queue pool, and the target task group queue interrupts outputting tasks to the task regulation queue.

7. The method according to any one of claims 1 to 6, characterized in that: The step of placing the tasks of the task group into the task control queue in turn includes: Obtain a circular queue, obtain the tasks output by the task group through the circular queue, and fill the storage space of the circular queue; When the tasks output by the task group fill up the storage space of the circular queue, the task control queue is obtained.

8. A task queuing device, characterized in that: The device comprises: A task group generation module is used to group tasks from the same source into the same task group after receiving tasks from different sources; the tasks from different sources are divided according to the objects that issue the tasks; A control queue construction module is used to put tasks of different task groups into the task control queue in turn, and output multiple tasks of the task groups through the task control queue; wherein the task control queue obtains the tasks of the task group in a circular queue, and the tasks of the task group are output by the task group in turn, and the circular queue is to move the last position of the queue storage space around to the first position to form a logical ring space for the queue to use cyclically; A control queue monitoring module is used to obtain the number of tasks in a preset state of the same task group, and determine that the corresponding task group is a target task group based on the task number range in which the task number is located; the task number range represents the overall execution status of multiple tasks of the same task group; the tasks of the target task group are stopped and placed in the task control queue, and the tasks of the target task group are not terminated.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Task processing method and device

    CN110928655A

  • Workflow processing method and device, intelligent workstation and electronic equipment

    CN112202899A

  • Distributed task scheduling method and device

    CN112231073A

  • Task scheduling method and system

    CN113360254A