Task scheduling method and device and storage medium

Based on the resource pool, the scheduling strategy based on business emergency, obtaining and sorting tasks, determining the number of dispatch tasks, solving the problem of high -business priority tasks during resource tension, and realizing the efficient scheduling and operation of the task. Essence

CN119376877APending Publication Date: 2025-01-28CHINA MERCHANTS BANK
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411334745.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

During resource tight periods, the prior art cannot properly schedule and run tasks with high business priorities.

Method used

By obtaining the number of idle resources in the resource pool, when the proportional proportion of the number of free resources is lower than the total number of resources, the average waiting time of the task in the target queue is determined. If the average waiting duration is greater than or equal to the preset duration, obtain the first task arranged in all queues, calculate the scheduling score based on its status information, and sort the task. Finally, determine the number of scheduling tasks according to the number of free resources, and select the target task to perform from the sorted tasks.

Benefits of technology

When the resource pool is insufficient, through the scheduling strategies based on business emergency, ensure that high -business priority tasks can run normally, and avoid emergency business construction tasks overdue.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119376877A_ABST
    Figure CN119376877A_ABST
Patent Text Reader

Abstract

The invention discloses a task scheduling method and device and a storage medium, and relates to the technical field of data processing.The method comprises the steps that the number of idle resources of a resource pool is obtained, and when the number of the idle resources is lower than a preset proportion of the total number of resources, the average waiting duration of construction tasks in a target queue is determined, if the average waiting duration is greater than or equal to a preset duration, obtaining first tasks arranged in all queues, then determining scheduling scores of the first tasks based on state information of the first tasks, and sorting the first tasks according to the scheduling scores, and finally, determining the number of schedulable tasks according to the number of idle resources in the resource pool, selecting target tasks with the number of schedulable tasks from the sorted first tasks in sequence for execution, and when the resource pool is insufficient, scheduling construction tasks through a scheduling strategy based on the business emergency degree. Therefore, the scheduling operation of the construction task with the high business priority is completed.
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 technology, and in particular to a task scheduling method, device and storage medium. Background Art

[0002] Currently, in the continuous delivery pipeline, the solution to implement task scheduling is to adopt a fair strategy to schedule tasks according to the order in which they enter the resource pool. This solution cannot distinguish the priority of tasks based on the stage environment during resource shortages, resulting in the inability to schedule and run high-priority tasks normally.

[0003] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0004] The present application provides a task scheduling method, device and storage medium, aiming to solve the problem that related solutions cannot normally schedule and run tasks with high business priority during periods of resource shortage.

[0005] To achieve the above object, the present application provides a task scheduling method, which includes the following steps:

[0006] Get the number of free resources in the resource pool;

[0007] When the number of idle resources is lower than a preset ratio of the total number of resources, determining an average waiting time for building tasks in the target queue;

[0008] If the average waiting time is greater than or equal to the preset time, the first task arranged in all queues is obtained;

[0009] Determine a scheduling score of the first task based on the status information of the first task, and sort the first tasks according to the scheduling score;

[0010] The number of schedulable tasks is determined according to the number of idle resources in the resource pool, and target tasks of the number of schedulable tasks are selected in sequence from the sorted first tasks for execution.

[0011] In one embodiment, before the step of obtaining the number of idle resources in the resource pool, the method further includes:

[0012] Construct top queue, high priority queue, medium priority queue and low priority queue;

[0013] Define queue tags and associate them with corresponding queues, and queue tasks in the resource pool according to the corresponding queue tags.

[0014] In one embodiment, the method comprises:

[0015] When it is detected that the number of queued tasks in the resource pool is greater than the total number of resources, obtaining the queue weight ratio preset for each queue;

[0016] The task triggering number of each queue is determined according to the queue weight ratio, and the second task is scheduled for execution from the corresponding queue according to the task triggering number.

[0017] In one embodiment, before the step of determining the number of task triggers of each queue according to the queue weight ratio and scheduling the execution of the corresponding second task from each queue according to the task trigger number, the step further includes:

[0018] When it is detected that the number of queued tasks in the resource pool is less than or equal to the total number of resources, all queued first tasks are scheduled for execution.

[0019] In one embodiment, the step of scheduling the execution of the second task from the corresponding queue according to the task trigger number includes:

[0020] Obtaining the task triggering number of each queue, and determining the scheduling ratio of each queue according to the task triggering number;

[0021] Determine the number of executable tasks of each queue according to the total number of resources and the scheduling ratio;

[0022] Target tasks corresponding to the number of tasks are screened out from each of the queues, and the target tasks are scheduled for execution.

[0023] In one embodiment, the step of determining the scheduling score of the first task based on the status information of the first task, and sorting the first tasks according to the scheduling score includes:

[0024] Determine a benchmark score and a weight coefficient of a priority queue associated with the first task according to the status information, and determine a task queuing time of the first task in the status information;

[0025] Calculate the scheduling score of the first task based on the benchmark score, the weight coefficient and the task queuing time;

[0026] The first tasks are sorted in descending order according to the scheduling scores.

[0027] In one embodiment, after the step of calculating the scheduling score of the first task, the method further includes:

[0028] Get the maximum queue score associated with each queue;

[0029] Determine a first queue corresponding to the first task, and determine a target maximum score corresponding to the first queue;

[0030] If the scheduling score is greater than the target maximum score, the target maximum score is determined as the scheduling score of the first task.

[0031] In one embodiment, before the step of determining the scheduling score of the first task based on the state information of the first task and sorting the first tasks according to the scheduling score, the step further includes:

[0032] Get the number of free resources in the resource pool;

[0033] When the number of idle resources is greater than a preset ratio of the total number of resources, all queued first tasks are scheduled for execution.

[0034] In addition, to achieve the above-mentioned purpose, the present application also provides a task scheduling device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the task scheduling method as described above.

[0035] In addition, to achieve the above-mentioned purpose, the present application also provides a storage medium, which is a computer-readable storage medium, and a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the steps of the task scheduling method described above are implemented.

[0036] The present application provides a task scheduling method, a task scheduling device and a storage medium. By obtaining the number of idle resources in a resource pool, when the number of idle resources is lower than a preset ratio of the total number of resources, the average waiting time of the construction task in the target queue is determined. If the average waiting time is greater than or equal to the preset time, the first task arranged in all queues is obtained, and then the scheduling score of the first task is determined based on the status information of the first task, and the first task is sorted according to the scheduling score. Finally, the number of schedulable tasks is determined according to the number of idle resources in the resource pool, and the target tasks of the number of schedulable tasks are selected in sequence from the sorted first tasks for execution. When the resource pool is insufficient, the present application schedules the construction tasks based on the business urgency scheduling strategy, thereby completing the scheduling and operation of high business priority construction tasks to avoid overdue emergency business construction tasks to be put into production. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0038] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0039] Figure 1 This is a flowchart of the first embodiment of the task scheduling method of the present application;

[0040] Figure 2 A flow chart for constructing a scheduling queue involved in the embodiment of the present application;

[0041] Figure 3 This is a schematic diagram of the strategy switching involved in the embodiment of the present application;

[0042] Figure 4 A queue score table for the application implementation scheme;

[0043] Figure 5 A flow chart of a scheduling strategy based on business urgency involved in an embodiment of the present application;

[0044] Figure 6 This is a flow chart of the second embodiment of the task scheduling method of the present application;

[0045] Figure 7 A flow chart of a scheduling strategy based on a business activity strategy involved in an embodiment of the present application;

[0046] Figure 8 This is a schematic diagram of the architecture of the hardware operating environment of the task scheduling device involved in the embodiment of the present application.

[0047] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0048] 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.

[0049] In order to better understand the above technical solution, exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0050] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0051] The main solution of the present application is: obtain the number of free resources in the resource pool; when the number of free resources is lower than the preset ratio of the total number of resources, determine the average waiting time for building tasks in the target queue; if the average waiting time is greater than or equal to the preset time, obtain the first task arranged in all queues; determine the scheduling score of the first task based on the status information of the first task, and sort the first task according to the scheduling score; determine the number of schedulable tasks according to the number of free resources in the resource pool, and select the target tasks of the number of schedulable tasks in order from the sorted first tasks for execution.

[0052] Currently, in the continuous delivery pipeline, the solution to implement task scheduling is to adopt a fair strategy to schedule tasks according to the order in which they enter the resource pool. This solution cannot distinguish the priority of tasks based on the stage environment during resource shortages, resulting in the inability to schedule and run high-priority tasks normally.

[0053] By obtaining the number of free resources in the resource pool, when the number of free resources is lower than the preset ratio of the total number of resources, the average waiting time of the construction task in the target queue is determined; if the average waiting time is greater than or equal to the preset time, the first task arranged in all queues is obtained, and then the scheduling score of the first task is determined based on the status information of the first task, and the first task is sorted according to the scheduling score; finally, the number of schedulable tasks is determined according to the number of free resources in the resource pool, and the target tasks of the number of schedulable tasks are selected in sequence from the sorted first tasks for execution. When the resource pool is insufficient, the present application schedules the construction tasks based on the business urgency scheduling strategy, thereby completing the scheduling and operation of high business priority construction tasks to avoid overdue urgent business construction tasks to be put into production.

[0054] Embodiment 1

[0055] Please refer to Figure 1 In a first embodiment, the task scheduling method comprises the following steps:

[0056] Step S10: Obtain the number of idle resources in the resource pool.

[0057] In this embodiment, the task scheduling system performs the processing action. In the continuous delivery pipeline, the resource pool refers to the size of the resources that can be allocated by the system. The current resource pool status is obtained through the API (Application Programming Interface) provided by the continuous integration tool, and the API of the continuous integration tool is called to view the interface to obtain the current number of idle nodes, that is, the number of idle resources.

[0058] Specifically, in the continuous delivery pipeline, resource pools are usually used to manage resources such as build servers, test environments, and deployment environments. These resources can include virtual machines, containers, database connections, and so on. Before obtaining the number of free resources in the resource pool, you need to configure the resource pool first. Configure the resource pool in the continuous integration tool, such as setting the maximum number of nodes (maxNodes) and the minimum number of free nodes (minNodes). Then create a resource pool instance and configure the node type (such as Docker container, virtual machine, etc.). Then use the API provided by the continuous integration tool to obtain the current resource pool status. You can also check the status of the resource pool regularly through scheduled tasks, or check it on demand when needed. Finally, call the PI of the continuous integration tool or view the interface to obtain the current number of free nodes. If you are using Jenkins, you can obtain the number of free nodes through plug-ins such as NodeJS Plugin or through the Jenkins API. Jenkins is an open source software project and a continuous integration tool developed based on Java. It is used to monitor continuous and repetitive work and aims to provide an open and easy-to-use software platform so that software projects can be continuously integrated; NodeJS Plugin is a plug-in in Jenkins that allows Jenkins to use Node.js during the build process.

[0059] Optionally, in this embodiment, before step S10, the following steps are further included:

[0060] Construct top queues, high-priority queues, medium-priority queues, and low-priority queues; define queue labels and associate them with corresponding queues, and queue tasks in the resource pool according to the corresponding queue labels.

[0061] Specifically, Figure 2 As shown, Figure 2A flowchart for scheduling queue construction involved in the embodiment of the present application is provided. A multi-level queue model is split based on a single queue model, including a top queue, a high priority queue, a medium priority queue, and a low priority queue. When a pipeline construction task is triggered to join the queue, a queue record will be initialized in the task queue table. Construction tasks in different stage environments will be marked with different queue tags, and the corresponding priority queues will be associated with the queue tags. And the construction tasks queued by the resource pool are queued in the corresponding queue according to the queue tags. Among them, the top S queue is responsible for receiving queue-jumping tasks, quick release and urgent release process construction tasks, the high priority I queue is responsible for receiving UAT stage pipeline construction tasks, the medium priority II queue is responsible for receiving ST stage pipeline construction tasks, and the low priority III queue is responsible for receiving DEV stage pipeline and agent construction construction tasks. For agent construction tasks, most of them are background asynchronous scanning tasks, which are not sensitive to queuing delays and are managed by low priority III queues. For pipeline construction tasks, the business priorities from high to low are UAT pipeline, ST pipeline and DEV pipeline, which are managed separately by the top S queue.

[0062] It can be understood that the UAT phase means that the software has completed internal testing and will be tested by end users or roles on behalf of users to confirm whether the software meets business requirements. The ST phase is a comprehensive testing phase that aims to verify the functional and non-functional requirements of the entire system. The DEV phase is the initial stage of software development, where developers write code.

[0063] Step S20: When the number of idle resources is lower than a preset ratio of the total number of resources, the average waiting time of the construction tasks in the target queue is determined.

[0064] In this embodiment, when the number of free resources in the resource pool is obtained, it is also necessary to obtain the total number of resources that can be currently allocated in the resource pool, and determine whether the number of free resources is less than a preset ratio of the total number of resources. If it is less than, the waiting time of all build tasks in the target queue is obtained. If it is not less than, there is no need to obtain the waiting time of the build task. Among them, the target queue is the top queue and the high priority queue. Before determining whether the number of free resources is lower than the preset ratio of the total number of resources, it is necessary to determine whether the size of the resource pool reaches a threshold, that is, whether the size of the resource pool reaches the size of the total resources. Optionally, the preset ratio can be 1 / 5, and the specific value can be customized by the system according to needs.

[0065] Step S30: If the average waiting time is greater than or equal to the preset time, the first task arranged in all queues is obtained.

[0066] In this embodiment, if the calculated average waiting time is greater than or equal to the preset time, which may be 2 minutes, it indicates that traffic congestion or cluster failure has occurred, and the scheduling strategy is automatically switched to the business urgency strategy. The first task currently arranged in all queues is obtained according to the business urgency strategy.

[0067] Specifically, the business urgency strategy is that when build resources are tight, the build task automatically switches to the business urgency scheduling strategy. This strategy scores the queued tasks of each queue based on the priority of each level of queue, sorts the tasks from high to low according to the score, and selects the build tasks with the largest number of resources for scheduling, ensuring that build tasks with high business levels are always triggered first during business peak periods and platform failures.

[0068] Optionally, the scheduling strategy includes a service urgency strategy and a service activity strategy, which are triggered by different trigger conditions and can automatically switch between the service urgency strategy and the service activity strategy.

[0069] Specifically, Figure 3 As shown, Figure 3 This is a schematic diagram of the policy switching involved in the embodiment of the present application. First, the resource pool information is obtained, and the total resource size is determined based on the size of the resource pool. If not, the scheduling policy is switched to a scheduling policy based on business activity. If so, it is further determined whether the number of idle resources is less than 1 / 5 of the total number of resources. When the number of idle resources is less than 1 / 5 of the total number of resources, the task waiting time of the S queue and the I queue is queried, and the average waiting time of the task is calculated to determine whether it is greater than 2 minutes. If it is greater, the scheduling policy is switched to a policy based on business urgency. Otherwise, the scheduling policy is switched to a scheduling policy based on business activity.

[0070] Step S40: determining a scheduling score of the first task based on the status information of the first task, and sorting the first tasks according to the scheduling score.

[0071] In this embodiment, the status information of the first task is obtained, wherein the status information includes the task queuing time of the first task and the information of the priority queue in which the first task is located. The scheduling score of each of the first tasks is calculated according to the status information and based on a preset formula, and the first tasks are sorted according to the size of the scheduling score, wherein the sorting method can be to re-create a sorting queue, and according to the size of the scheduling score, the first tasks are placed in the sorting queue in ascending order.

[0072] Optionally, in this embodiment, step S40 includes:

[0073] Obtain a baseline score and a weight coefficient of the priority queue associated with the first task; determine the task queuing duration of the first task according to the status information, and calculate the scheduling score of the first task based on the baseline score, the weight coefficient and the task queuing duration; sort the first tasks in descending order according to the size of the scheduling score.

[0074] Specifically, read the number of idle Jenkins resources in the current resource pool and calculate the maximum number of queued tasks N that can be scheduled. Obtain all queued build tasks in the queue table and group the queued tasks according to priority queues. Calculate the scheduling score of each task based on the benchmark score, weight coefficient and task queueing time of each priority queue. Sort the first task in reverse order according to the scheduling score of the task.

[0075] In addition, under the business urgency scheduling strategy, each queue will be assigned a fixed task baseline score and a task maximum score, such as Figure 4 As shown, Figure 4 This is the queue score table involved in the application implementation scheme. Through the queue score table, the benchmark score can be determined, and then the task scheduling score of each queue can be calculated, where the task scheduling score = MIN (current queue benchmark score + task waiting time, current queue maximum score), the queue benchmark score is the starting score after the task enters the current queue, the queue maximum score is the maximum score after the task enters the current queue, to avoid the score of the queue task out of bounds, and the task waiting time is the cumulative time from the task entering the queue to the emergency scheduling of the current business.

[0076] Furthermore, in this embodiment, after the step of calculating the scheduling score of the first task, the step further includes:

[0077] Obtain the maximum queue score associated with each queue; determine the first queue corresponding to the first task, and determine the target maximum score corresponding to the first queue; if the scheduling score is greater than the target maximum score, determine the target maximum score as the scheduling score of the first task.

[0078] Specifically, first determine the first queue corresponding to the first task, then determine the queue tag of the queue, and then determine the target maximum score associated with the queue tag according to the queue score table. Then obtain the scheduling score determined in the above steps, compare the scheduling score with the target maximum score, and when the scheduling score is greater than the target maximum score, use the target maximum score as the scheduling score of the first task to avoid the score of the queue task exceeding the threshold.

[0079] Optionally, in this embodiment, before step S40, the following steps are further included:

[0080] The number of idle resources in the resource pool is obtained; when the number of idle resources is greater than a preset ratio of the total number of resources, all queued first tasks are scheduled for execution.

[0081] Specifically, by obtaining the number of idle resources in the resource pool, when the number of idle resources is greater than a preset ratio of the total number of resources, the scheduling strategy can be automatically switched to a strategy based on business activity, and then all queued first tasks are scheduled for execution according to the business activity strategy.

[0082] Step S50: determining the number of schedulable tasks according to the number of idle resources in the resource pool, and selecting target tasks of the number of schedulable tasks in order from the sorted first tasks for execution.

[0083] In this embodiment, after determining the number of idle resources in the resource pool, the number of currently schedulable tasks is determined based on the number of idle resources, and then the target tasks of the number of schedulable tasks are selected in sequence from the sorted first tasks for execution, wherein the target tasks are to filter out the first N tasks with the largest scores.

[0084] In addition, the queued tasks in the queue table are triggered periodically by the scheduled tasks. The scheduled tasks will batch extract build tasks from the priority queues in the queue table, allocate resources, and trigger the build according to the size of the build resource pool and the scheduling strategy.

[0085] For example, Figure 5 As shown, Figure 5 This is a flowchart of the scheduling strategy based on business urgency involved in the implementation scheme of the present application. When the task trigger starts, here it means starting a build or deployment task, obtaining resource pool information and obtaining the benchmark score of each queue. Then query the queued tasks of all queues, and determine whether the resources are sufficient, that is, determine whether the number of idle resources is lower than the total number of resources, and whether the waiting time is greater than or equal to the preset time. When resources are sufficient, all queued tasks are dequeued for execution. When resources are insufficient, the tasks in the queue are queried in turn according to the priority of the queue, and the scheduling score of each task is calculated according to the formula. The tasks in each queue are merged and sorted according to the scheduling score.

[0086] In the technical solution provided in this embodiment, by obtaining the number of free resources in the resource pool, when the number of free resources is lower than the preset proportion of the total number of resources, the average waiting time of the construction task in the target queue is determined, if the average waiting time is greater than or equal to the preset time, the first task arranged in all queues is obtained, and then the scheduling score of the first task is determined based on the status information of the first task, and the first task is sorted according to the scheduling score, and finally the number of schedulable tasks is determined according to the number of free resources in the resource pool, and the target tasks of the number of schedulable tasks are selected in sequence from the sorted first tasks for execution. When the resource pool is insufficient, the present application schedules the construction tasks based on the business urgency scheduling strategy, thereby completing the scheduling and operation of high business priority construction tasks to avoid overdue emergency business construction tasks to be put into production.

[0087] Embodiment 2

[0088] Please refer to Figure 6 In a second embodiment, the method further comprises the following steps:

[0089] Step S60: when it is detected that the number of queued tasks in the resource pool is greater than the total number of resources, the preset queue weight ratios of the queues are obtained.

[0090] Step S70: determining the task triggering number of each queue according to the queue weight ratio, and scheduling the second task to be executed from the corresponding queue according to the task triggering number.

[0091] In this embodiment, when the construction resources are sufficient, the construction task automatically switches to the business activity scheduling strategy. Based on the business activity scheduling strategy, the information of the current resource pool is obtained, including the current total capacity, maximum capacity, current idle number and reserved idle number, and then the total number of queued tasks currently in queues at all levels is queried, and the queue weight ratio pre-set for queues at all levels is queried. If the resources are sufficient, that is, the number of queued tasks in the resource pool is less than the total number of resources, all queued tasks are dequeued and triggered for execution. If the resources are insufficient, the target number of tasks is preferentially screened out from the top S queue, where the target number here is less than the total number of queued tasks. Finally, the task trigger number of each queue is calculated according to the queue weight ratio, and the corresponding tasks are screened out from the high priority I queue, the medium priority II queue and the low priority III queue respectively. And merge the tasks of the top S queue, the high priority I queue, the medium priority II queue and the low priority III queue, and dequeue and trigger the operation.

[0092] Optionally, in this embodiment, before the step of determining the number of task triggers of each queue according to the queue weight ratio and scheduling the execution of the corresponding second task from each queue according to the task trigger number, the method further includes:

[0093] When it is detected that the number of queued tasks in the resource pool is less than or equal to the total number of resources, all queued first tasks are scheduled for execution.

[0094] Specifically, the first task is the build task queued in all queues. When resources are sufficient, all queued tasks are dequeued and triggered for execution.

[0095] Further, in this embodiment, the step of scheduling the execution of the second task from the corresponding queue according to the task trigger number includes:

[0096] Obtain the task trigger number of each queue, and determine the scheduling ratio of each queue according to the task trigger number; determine the number of executable tasks of each queue according to the total number of resources and the scheduling ratio; filter out the target tasks corresponding to the number of tasks in each queue, and schedule the target tasks for execution.

[0097] Specifically, the task triggering number of each queue is calculated according to the queue weight ratio, and the corresponding tasks are screened out from the high priority I queue, the medium priority II queue, and the low priority III queue, and the screened tasks are executed.

[0098] For example, Figure 7 As shown, Figure 7 This is a flow chart of the scheduling strategy based on the business activity strategy involved in the implementation scheme of the present application. When switching to the business activity scheduling strategy, first obtain the resource pool information, including the current total capacity, maximum capacity, current idle number and reserved idle number, as well as the weight ratio of each queue, and then query the total number of queued tasks N currently in queues at all levels. Then judge whether the resources are sufficient, that is, judge whether the number of queued tasks in the resource pool is greater than the total number of resources. When the resources are sufficient, all tasks are dequeued for execution. When resources are insufficient, according to the weight ratio of each queue, the number of tasks with corresponding weight ratio is obtained from each queue, and these tasks are merged, and the tasks in the merged queue are scheduled to be dequeued for execution.

[0099] In addition, the present application provides a combination strategy for adaptive queuing scheduling based on a business activity scheduling strategy and a business urgency (Urgent) scheduling strategy. When construction resources are sufficient, based on the historical construction activity of each business type pipeline, the business activity strategy is used to ensure that the number of various types of business pipelines runs relatively balanced. When construction resources are tight, based on the business priority of each business type pipeline, the business urgency strategy is used to ensure that high-priority pipelines run first. It also provides the function of manually adding pipelines of specified systems, release units, and pipeline numbers to the top queue to achieve queue jumping, thereby improving the flexibility of the scheduling strategy. The scheduling strategy performs adaptive strategy switching based on the total size of the resource pool, the number of idle resources, and the average waiting time of queued tasks.

[0100] In the technical solution provided in this embodiment, when it is detected that the number of queued tasks in the resource pool is greater than the total number of resources, the queue weight ratio preset for each queue is obtained, and then the task trigger number of each queue is determined according to the queue weight ratio, and according to the task trigger number, the second task is scheduled for execution from the corresponding queue, thereby scheduling task execution according to business activity and improving task scheduling efficiency.

[0101] Since the system introduced in the embodiment of the present application is a system used to implement the method of the embodiment of the present application, based on the method introduced in the embodiment of the present application, the person skilled in the art can understand the specific structure and deformation of the system, so it is not repeated here. All systems used in the method of the embodiment of the present application belong to the scope of protection of this application.

[0102] The present application provides a task scheduling device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the task scheduling method in the above-mentioned embodiment 1.

[0103] Reference below Figure 8 , which shows a schematic diagram of the structure of a task scheduling device suitable for implementing the embodiment of the present application. The task scheduling device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The task scheduling device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0104] like Figure 8As shown, the task scheduling device may include a processing device 1001 (e.g., a core processor, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the task scheduling device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the task scheduling device to communicate with other devices wirelessly or by wire to exchange data. Although the task scheduling device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0105] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0106] The task scheduling device provided by the present application adopts the task scheduling method in the above embodiment, which can solve the technical problem that high business priority tasks cannot be scheduled normally during resource shortage. Compared with the prior art, the beneficial effects of the task scheduling device provided by the present application are the same as the beneficial effects of the task scheduling method provided by the above embodiment, and the other technical features in the task scheduling device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0107] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0108] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0109] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the task scheduling method in the above-mentioned embodiment.

[0110] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0111] The computer-readable storage medium may be included in the task scheduling device; or may exist independently without being assembled into the task scheduling device.

[0112] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the task scheduling device, the task scheduling device: obtains the number of free resources in the resource pool; when the number of free resources is lower than the preset proportion of the total number of resources, determines the average waiting time for building tasks in the target queue; if the average waiting time is greater than or equal to the preset time, obtains the first task arranged in all queues; determines the scheduling score of the first task based on the status information of the first task, and sorts the first task according to the scheduling score; determines the number of schedulable tasks according to the number of free resources in the resource pool, and selects the target tasks of the number of schedulable tasks in order from the sorted first tasks for execution.

[0113] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0114] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0115] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0116] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned task scheduling method, and can solve the technical problem that tasks with high business priority cannot be scheduled normally during resource shortages. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the task scheduling method provided by the above-mentioned embodiment, and will not be repeated here.

[0117] An embodiment of the present application provides a computer program product, including a computer program, which implements the steps of the task scheduling method as described above when executed by a processor.

[0118] The computer program product provided by the present application can solve the technical problem that tasks with high business priority cannot be scheduled normally during resource shortage. Compared with the prior art, the beneficial effects of the computer program product provided by the embodiment of the present application are the same as the beneficial effects of the task scheduling method provided by the above embodiment, which will not be repeated here.

[0119] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.

Claims

1. A task scheduling method, characterized in that: The method comprises the following steps: Get the number of free resources in the resource pool; When the number of idle resources is lower than a preset ratio of the total number of resources, determining an average waiting time for building tasks in the target queue; If the average waiting time is greater than or equal to the preset time, the first task arranged in all queues is obtained; Determine a scheduling score of the first task based on the status information of the first task, and sort the first tasks according to the scheduling score; The number of schedulable tasks is determined according to the number of idle resources in the resource pool, and target tasks of the number of schedulable tasks are selected in sequence from the sorted first tasks for execution.

2. The method according to claim 1, characterized in that Before the step of obtaining the number of idle resources in the resource pool, the method further includes: Construct top queue, high priority queue, medium priority queue and low priority queue; Define queue tags and associate them with corresponding queues, and queue tasks in the resource pool according to the corresponding queue tags.

3. The method according to claim 1, characterized in that The method comprises: When it is detected that the number of queued tasks in the resource pool is greater than the total number of resources, obtaining the queue weight ratio preset for each queue; The task triggering number of each queue is determined according to the queue weight ratio, and the second task is scheduled for execution from the corresponding queue according to the task triggering number.

4. The method according to claim 3, characterized in that Before the step of determining the number of task triggers of each queue according to the queue weight ratio and scheduling the execution of the corresponding second task from each queue according to the number of task triggers, the method further includes: When it is detected that the number of queued tasks in the resource pool is less than or equal to the total number of resources, all queued first tasks are scheduled for execution.

5. The method according to claim 3, characterized in that The step of scheduling the execution of the second task from the corresponding queue according to the task trigger number includes: Obtaining the task triggering number of each queue, and determining the scheduling ratio of each queue according to the task triggering number; Determine the number of executable tasks of each queue according to the total number of resources and the scheduling ratio; Target tasks corresponding to the number of tasks are screened out from each of the queues, and the target tasks are scheduled for execution.

6. The method according to claim 1, characterized in that The step of determining the scheduling score of the first task based on the status information of the first task, and sorting the first tasks according to the scheduling score includes: Determine a benchmark score and a weight coefficient of a priority queue associated with the first task according to the status information, and determine a task queuing time of the first task in the status information; Calculate the scheduling score of the first task based on the benchmark score, the weight coefficient and the task queuing time; The first tasks are sorted in descending order according to the scheduling scores.

7. The method according to claim 6, characterized in that After the step of calculating the scheduling score of the first task, the method further includes: Get the maximum queue score associated with each queue; Determine a first queue corresponding to the first task, and determine a target maximum score corresponding to the first queue; If the scheduling score is greater than the target maximum score, the target maximum score is determined as the scheduling score of the first task.

8. The method according to claim 1, characterized in that Before the step of determining the scheduling score of the first task based on the state information of the first task and sorting the first tasks according to the scheduling score, the method further includes: Get the number of free resources in the resource pool; When the number of idle resources is greater than a preset ratio of the total number of resources, all queued first tasks are scheduled for execution.

9. A task scheduling device, characterized in that: The task scheduling device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the task scheduling method according to any one of claims 1 to 8.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the task scheduling method according to any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Data processing method, electronic equipment and storage medium

    CN120179372A