CN116820769A - Task allocation method, device and system - Google Patents

Task allocation method, device and system Download PDF

Info

Publication number
CN116820769A
CN116820769A CN202310799474.6A CN202310799474A CN116820769A CN 116820769 A CN116820769 A CN 116820769A CN 202310799474 A CN202310799474 A CN 202310799474A CN 116820769 A CN116820769 A CN 116820769A
Authority
CN
China
Prior art keywords
task
waiting queue
target
allocated
waiting
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310799474.6A
Other languages
Chinese (zh)
Inventor
陈杰
谭文明
方家乐
王鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN202310799474.6A priority Critical patent/CN116820769A/en
Publication of CN116820769A publication Critical patent/CN116820769A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Telephonic Communication Services (AREA)

Abstract

The embodiment of the application provides a task allocation method, a device and a system, which allocate target tasks submitted by target clients into a plurality of waiting queues by setting the waiting queues and a preset threshold, so that the number of the tasks submitted by each client in a high-priority waiting queue is limited, each client has the submitted tasks in the high-priority waiting queue, each client submitted task can be responded quickly, the problem that because a certain client submits too many tasks, a server only processes the tasks submitted by the client, and each client has the tasks in the high-priority waiting queue for other clients can be avoided, and the execution efficiency of the server is improved.

Description

Task allocation method, device and system
Technical Field
The present application relates to the field of scheduling policies of computing tasks, and in particular, to a task allocation method, device, and system.
Background
In the calculation process, the user side sends a task request to the client side, the server side receives the task request and processes the task request, and the server side receives a large number of task requests submitted by the user side. If a certain user terminal submits a large number of tasks at one time, the server terminal can process the tasks submitted by other user terminals only after the task submitted by the user terminal is processed, so that the tasks of other user terminals cannot be responded quickly, and the execution efficiency of the server terminal is low for other user terminals.
Disclosure of Invention
The embodiment of the application aims to provide a task allocation method and device, which are used for solving the problem that the execution efficiency of a server side is low for other user sides when a user side submits a large number of tasks at one time. The specific technical scheme is as follows:
in a first aspect of the present application, a task allocation method is provided, applied to a server, where a plurality of waiting queues are preset, where the plurality of waiting queues include: a first waiting queue and an alternative waiting queue; the method comprises the following steps:
responding to the received task to be allocated of the target user side, and acquiring a first target task number of target tasks which are allocated to the first waiting queue and do not obtain a task result; the target task is a task submitted by the target user terminal and does not obtain a task result;
if the first target task number does not exceed the first preset threshold, the task to be allocated is allocated to a first waiting queue; the first target task number is the target task number in the first waiting queue;
if the first target task number exceeds the first preset threshold, the task to be allocated is allocated to an alternative waiting queue; wherein the priority of the alternative waiting queue is lower than the priority of the first waiting queue;
Executing tasks in the first waiting queue before executing tasks in the alternative waiting queue.
In one possible implementation, the method further includes:
and responding to a priority instruction aiming at the task to be allocated, and executing the task to be allocated before executing the task of the first waiting queue, wherein the priority instruction is sent to the server under the condition that the management end examines and approves the task to be allocated and the examination and approval result is priority execution.
In one possible implementation, the plurality of waiting queues further includes: a zeroth waiting queue; the method comprises the following steps:
responding to a priority instruction aiming at the task to be allocated, and allocating the task to be allocated to a zeroth waiting queue; and before executing the tasks of the first waiting queue, executing the tasks of the zeroth waiting queue sequentially according to the order from early to late of the commit time.
In one possible implementation, the tasks in each waiting queue are arranged in order of early to late commit time, the method further comprising:
and transferring the first target task in the alternative waiting queue to the tail of the first waiting queue in response to ending of running of the target task or execution of the target task in the first waiting queue.
In one possible implementation, the alternative waiting queue includes a plurality of waiting queues, and the transferring the first target task in the alternative waiting queue to the tail of the first waiting queue in response to the end of running of the target task or the execution of the target task in the first waiting queue includes:
responsive to an end of execution of a target task or execution of a target task in the first waiting queue, transferring a first target task in the alternative waiting queue to a tail of the first waiting queue;
and sequentially transferring the first target task in each waiting queue in the alternative waiting queues to the tail of the waiting queue of the previous priority according to the order of the priority from high to low until all waiting queues comprising the target tasks are traversed.
In one possible implementation, the method further includes:
and exchanging the order of the two target tasks for which the exchange instruction is aimed in the waiting queue in response to the exchange instruction sent for the two target tasks.
In one possible implementation manner, the candidate waiting queues include a plurality of waiting queues, and if the first target task number exceeds the first preset threshold, the task to be allocated is allocated to the candidate waiting queues, including:
Determining whether the target task number of a current waiting queue exceeds a preset threshold, wherein the current waiting queue is initially a waiting queue with the highest priority in the alternative waiting queues;
if not, the task to be allocated is allocated to the current waiting queue;
and if so, taking the waiting queue of the next priority of the current waiting queue as the current waiting queue, and returning to execute the step of determining whether the target task number of the current waiting queue exceeds a preset threshold.
In a second aspect of the present application, there is provided a task allocation system, the system comprising: a server side, a user side, wherein,
the user side is used for submitting a task to the server side and receiving a task result sent by the server side;
the server side is used for distributing a waiting queue for the task submitted by the user side based on the method in any one of the first aspect, executing the task according to the priority of the waiting queue to obtain a task result, and sending the task result to the user side.
In a third aspect of the present application, a task allocation device is provided and applied to a server, where the plurality of waiting queues include: a first waiting queue and an alternative waiting queue; a plurality of waiting queues are preset; the device comprises:
The acquisition module is used for responding to the task to be allocated of the receiving target user side and acquiring a first target task number of the target tasks which are allocated to the first waiting queue and do not obtain the task result; the target task is a task submitted by the target user terminal and does not obtain a task result;
the first allocation module is used for allocating the tasks to be allocated to a first waiting queue if the first target task number does not exceed a first preset threshold; the first target task number is the target task number in the first waiting queue;
the alternative allocation module is used for allocating the tasks to be allocated to an alternative waiting queue if the first target task number exceeds the first preset threshold; wherein the priority of the alternative waiting queue is lower than the priority of the first waiting queue;
and the execution module is used for executing the tasks in the first waiting queue before executing the tasks of the alternative waiting queue.
In a fourth aspect of the present application, there is provided a server, including:
a memory for storing a computer program;
a processor configured to implement the method according to any one of the preceding first aspects when executing a program stored on a memory.
In a fifth aspect of the application, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of any of the preceding aspects.
The embodiment of the application has the beneficial effects that:
according to the task allocation method, device and system provided by the embodiment of the application, the first target task number of the target tasks in the first waiting queue can be obtained through the preset waiting queues in response to receiving the tasks to be allocated of the target user side, if the first target task number does not exceed the first preset threshold value, the tasks to be allocated are allocated to the first waiting queue, if the first target task number exceeds the first preset threshold value, the tasks to be allocated are allocated to the waiting queue, and the tasks to be executed in the first waiting queue are executed before the waiting queue is executed. In the embodiment of the application, the target tasks submitted by the target user side are distributed to the waiting queues by setting the waiting queues and the preset threshold, so that the task number of each user side in the high-priority waiting queue is limited, each user side has the submitted task in the high-priority waiting queue, the task submitted by each user side can be responded quickly, the problem that the service side only processes the task submitted by the user side because one user side submits too many tasks can be avoided, and each user side has the task in the high-priority waiting queue for other user sides, thereby improving the execution efficiency of the service side.
Of course, it is not necessary for any one product or method of practicing the application to achieve all of the advantages set forth above at the same time.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the application, and other embodiments may be obtained according to these drawings to those skilled in the art.
Fig. 1 is a schematic flow chart of a user allocation method according to an embodiment of the present application;
fig. 2a is a schematic diagram of a first user allocation method according to an embodiment of the present application;
fig. 2b is a schematic diagram of a second user allocation method according to an embodiment of the present application;
fig. 2c is a schematic diagram of a third user allocation method according to an embodiment of the present application;
fig. 2d is a schematic diagram of a fourth user allocation method according to an embodiment of the present application;
fig. 2e is a schematic diagram of a fifth user allocation method according to an embodiment of the present application;
fig. 2f is a schematic flow chart of a user allocation method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a user distribution system according to an embodiment of the present application;
Fig. 4 is a schematic diagram of a user allocation apparatus according to an embodiment of the present application;
fig. 5 is a schematic diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. Based on the embodiments of the present application, all other embodiments obtained by the person skilled in the art based on the present application are included in the scope of protection of the present application.
In the prior art, in an application scenario requiring a large amount of computation, if a user side submits a large amount of tasks at a time, when a server side processes according to the time of submission, there is a problem that the server side only processes the tasks submitted by the same user side within a period of time, so that for other users, the submitted tasks cannot be responded within the period of time, for example, user side a submits 100 tasks at 7:00, user side B submits 1 task at 7:01, and when the server side executes the tasks, the server side processes according to the time of submission, so that the 1 task submitted by the user side can be processed only after 100 tasks of user side a are processed, and further user experience of user side B is affected, that is, when the current server side distributes the tasks, the problem that when one user submits a large amount of tasks, execution efficiency of the server side is not high for other user sides is not considered.
The application aims to reduce the possibility that tasks of other user sides are delayed and quick response cannot be obtained due to the fact that the user side submits a plurality of tasks at one time, and solve the problem that the execution efficiency of a server side is low for other user sides.
The embodiment of the application provides a task allocation method which is applied to a server, and the server in the embodiment of the application can be a cloud server or any server responding to a request of a user. The server is preset with a plurality of waiting queues, wherein the waiting queues comprise: a first waiting queue and an alternative waiting queue. The waiting queues are arranged in order of priority from high to low, the priority and the execution sequence of tasks in the waiting queues are positively correlated, each waiting queue is provided with a preset threshold, as shown in fig. 1, and the method comprises the following steps:
s101, responding to a receiving task to be allocated of a target user side, and acquiring a first target task number of target tasks which are allocated to a first waiting queue and do not obtain a task result; the target task is a task submitted by the target user terminal and does not obtain a task result.
S102, if the first target task number does not exceed a first preset threshold, distributing the tasks to be distributed to a first waiting queue; the first target task number is the target task number in the first waiting queue.
S103, if the first target task number exceeds a first preset threshold, distributing the task to be distributed to an alternative waiting queue; wherein the priority of the alternative waiting queue is lower than the priority of the first waiting queue.
S104, executing the tasks in the first waiting queue before executing the tasks in the alternative waiting queue.
In the embodiment of the application, the plurality of waiting queues and the preset threshold value are set through the waiting queues, and the target tasks submitted by the target user end are distributed to the plurality of waiting queues, so that the number of the tasks submitted by each user end in the high-priority waiting queue is limited, the tasks submitted by each user end in the high-priority waiting queue are all submitted by each user end, the tasks submitted by each user end can be responded quickly, the problem that the tasks submitted by a certain user end are too many and only the tasks submitted by the user end are processed by the service end can be avoided, the tasks of each user end in the high-priority waiting queue are all in the other user ends, and the execution efficiency of the service end is improved.
The embodiment of the application can also be applied to the situation that a large number of tasks are submitted for one user at a time and no other user submits the tasks. For example, user a submits 100 tasks at a time, 10 tasks of user a are allocated to the first waiting queue, other 90 tasks are allocated to the waiting queue, and in the execution process, 10 tasks of user a in the first waiting queue are executed first, and then 90 tasks in the waiting queue are executed. That is, even one user may have distributed allocation of his submitted tasks to different waiting queues. The above is only one embodiment of the present application, and for convenience of description, the following description of the present application refers to the case where a plurality of users submit tasks, and the case where one user submits tasks is the same as the case where a plurality of users submit tasks, which is not described in detail herein.
The above-described S101 to S104 are described in detail below.
In step S101, the task may be a task requested by the user side to the server side in different application scenarios. For example, the request task submitted in the vehicle identification may be a search task submitted at the time of target search. The server receives tasks to be distributed sent by a plurality of user terminals. The method comprises the steps that a user side sends a task request to a server side, the server side sends a task result to the user side after processing the task, when the server side receives a large number of task requests sent by different user sides, but due to limited resources of the server side, tasks submitted by a plurality of user sides cannot be processed at the same time, when the task requests of the user sides are responded in real time, the server side distributes the tasks sent by the plurality of user sides into a waiting queue according to sending time, and then processes the tasks in the waiting queue according to the sequence in the waiting queue.
The first target task number is the number of target tasks allocated to the first waiting queue and not obtaining task results. The first target task number may be, for example, a sum of a target task number being executed by the server and a target task number in the first waiting queue. When the server side does not have the target task being executed, the first target task number may be the target task number in the first waiting queue; when there is no target task in the first waiting queue, the first target task number may be a target task number being executed by the server. In the embodiment of the application, the first target task number can be determined according to the actual application scene.
And responding to the receiving of the task to be allocated of the target user side, namely, aiming at the task sent by the target user side, the server side needs to allocate the task to the waiting queue, wherein the task to be allocated is the task which is sent by the target client side and is not allocated to the waiting queue.
The target task is a task submitted by a target user side, namely a task submitted by the target user and not yet obtaining a task result.
In step S102, the first preset threshold is the maximum number of tasks that the target user of those skilled in the art can allocate to the first waiting queue. A preset threshold is set in each waiting queue, so as to limit the maximum target task number that the user terminal can allocate in the waiting queues. If the first target task number does not exceed the first preset threshold, it is indicated that the target task number waiting in the first waiting queue does not reach the maximum task number, and at this time, for the target user end, the submitted task to be allocated may also be allocated to the first waiting queue.
Illustratively, as shown in fig. 2a, assuming that the task to be allocated is dm, the first target task number in the first waiting queue is 3, and the first preset threshold is 3, it is determined that the first target task number does not exceed the first preset threshold, and dm is allocated to the first waiting queue.
In step S103, if the first target task number exceeds the first preset threshold, it is indicated that the target task number in the first waiting queue can be the maximum target task number allocated in the first waiting queue, and the server cannot allocate the task to be allocated to the first waiting queue when the subsequent target ue resubmits the task. At this time, the task to be allocated needs to be allocated to an alternative waiting queue one step lower than the level of priority of the first waiting queue.
For convenience of description, only the allocation of the target user in the waiting queue will be described in the following embodiments, where d1 is the first task of the target user in the first waiting queue, but is not the first task in the first waiting queue, and d1 may also have tasks of other users before. The position of d1 in the first waiting queue is not limited in the embodiment of the present application, and is specifically limited according to the actual application scenario. And if the task to be allocated is dm, the first target task number in the first waiting queue is 4, the first preset threshold is 3, and 4 is more than 3, allocating dm to the waiting queue.
In step S104, tasks in the waiting queue having a high priority level are preferentially executed. The first waiting queue has a higher priority than the alternative waiting queue, so tasks in the first waiting queue are preferentially executed. When executing the tasks in the waiting queue, the tasks can be executed according to the order of the target tasks in the waiting queue, and the target tasks can also be executed randomly. The order of executing the tasks in the waiting queue is not limited in the embodiment of the present application.
For example, assume that the target task of the target client 1 in the first waiting queue 1 is: task 1, task 2, task 3, task 4, the tasks are executed in the order of task 1→task 2→task 3→task 4 when executing the tasks.
In one possible embodiment, in order to further ensure that the task allocation method in the present application may perform urgent processing on some urgent tasks and preferentially process some important tasks according to an actual application scenario, the method in the embodiment of the present application further includes:
s105, responding to a priority instruction aiming at the task to be allocated, and executing the task to be allocated before executing the task of the first waiting queue, wherein the priority instruction is sent to the server under the condition that the management end examines and approves the task to be allocated and the examination and approval result is priority execution.
In this step, the preset information is used to characterize that the task to be allocated needs to be executed preferentially, where the preset information is preconfigured by the management end of the user end, and the priority instruction is an instruction sent by the target user end and used to instruct the server end to process the task to be allocated preferentially. The management terminal is a virtual user terminal with authority higher than that of a general user in the user terminal. In one possible implementation manner, when the target user end needs to perform urgent processing on the task, a preset request is submitted to the management end, after the management end receives the preset request and approves the request, preset information is configured on the task to be allocated, a priority instruction is sent to the service end, and after the service end receives the priority instruction, the task to be allocated is executed before the task in the first waiting queue according to the preset information.
In this embodiment, if the approval of the priority processing of the task to be allocated passes, after the preset information is configured for the task to be allocated, a priority instruction is sent to the server, if the server receives the priority instruction for the task to be allocated, the priority processing is indicated to be required for the task to be allocated, the approval is performed for the task to be allocated which is processed in priority by the management end, the preset information is configured, and then the priority instruction is sent to process the task to be allocated in advance, so that the applicability of task allocation is improved, the execution efficiency of the task executed by the server is further improved, and the user experience is improved.
In one possible embodiment, the plurality of waiting queues further includes: zero wait queue. In the above S105, the specific steps may be:
s1051, responding to a priority instruction for a task to be allocated, and allocating the task to be allocated to a zeroth waiting queue; and executing tasks of the zeroth waiting queue sequentially according to the order from the early to the late of the commit time before executing tasks of the first waiting queue.
In this step, the priority of the zeroth waiting queue is higher than the priority of the first waiting queue. If a priority instruction aiming at the task to be allocated is received, the task to be allocated is allocated to a zeroth waiting queue, so that the task in the zeroth waiting queue can be executed in advance before the task of the first waiting queue is executed, and the task to be allocated is executed preferentially.
The number of tasks in the zeroth wait queue is not limited, and when the tasks in the zeroth wait queue are executed, the tasks are executed strictly according to the sequence of the commit time.
In this embodiment, by setting a zeroth waiting queue with a higher priority than the first waiting queue, when a task to be allocated is allocated, once the task to be allocated is configured with preset information, the task to be allocated is allocated to the zeroth waiting queue, so that the task to be allocated can be preferentially processed, and the applicability of task allocation is improved.
In a possible embodiment, the executing the task to be allocated in S105 before the execution of the first waiting queue may specifically be:
s1052, distributing the task to be distributed to the head of the first waiting queue.
In this way, the task to be allocated may be allowed to execute preferentially before executing the task in the first waiting queue.
In a possible embodiment, the tasks in each waiting queue are arranged in order of early to late commit time, and the method further includes:
s106, in response to the end of running of one target task or the execution of one target task in the first waiting queue, transferring the first target task in the alternative waiting queue to the tail of the first waiting queue.
In this step, it is assumed that the target client 1 submits the target task from early to late: task 1, task 2, task 3, task 4, the ordering in the first waiting queue is: task 1→task 2→task 3→task 4.
The end of the running of a target task or the execution of a target task in the first waiting queue indicates that there is one less task being executed or one less task waiting in the first waiting queue at the target user side, i.e. a position is left in the first waiting queue to be allocated with the task to be allocated, but if the task to be allocated is directly allocated to the first waiting queue, the task to be allocated is executed after the task to be allocated is executed, which affects the user experience. In order to avoid directly distributing the task to be distributed to the position which is emptied in the first waiting queue in the situation when the task is distributed, once one task in the target task is finished in operation or one task in the target task is executed, the first task in the target user side in the waiting queue is transferred to the tail of the first waiting queue, so that the task to be distributed can be distributed according to the submitting time as much as possible when the task to be distributed to the waiting queue, the situation that the submitting is executed later but earlier is avoided, and the user experience is improved.
For example, as shown in fig. 2b, where the target tasks of the target users 1 are denoted by d, where d1, d2, d3 and … … are target tasks, assuming that the task to be allocated is dm, the preset threshold of the target users 1 in the first waiting queue is 3, that is, only the target tasks of 4 target users 1 can be allocated in the first waiting queue. When the task 1 is reassigned, the tasks of the target clients 1 in the first waiting queue are already full, and the tasks of the 4 target clients 1 in the waiting queue are replaced. In response to ending of one target task or execution of one target task in the first waiting queue, at this time, if d1 is executed, the number of first target tasks is 3, and does not exceed the first preset threshold, in order to avoid allocation of task 1 to the first waiting queue, the first task of the target user side with the candidate priority is transferred to the tail of the queue in the first waiting queue.
In this embodiment, in order to avoid that when a task to be allocated is allocated, the task to be allocated is allocated to the first priority level due to the end of one task operation of the target user or the execution of one task of the target task in the first waiting queue, the execution efficiency is reduced, and the first task of the target user side in the waiting queue is transferred to the tail of the first waiting queue, so that when the task to be allocated is allocated, the task to be allocated is allocated to the last task of the target user side in the waiting queue, that is, the task to be allocated is implemented, and the execution efficiency is improved and the user experience is also improved.
In one possible embodiment, the method further comprises:
s107, exchanging the order of the two target tasks in the waiting queue, which are aimed at by the exchange instruction, in response to the exchange instruction sent for the two target tasks.
In this step, the target ue may adjust the execution sequence of the target tasks, select two tasks that need to be adjusted in the execution sequence at the target ue, then send an exchange instruction to the server, and after the server receives the exchange instruction, exchange the two tasks targeted by the exchange instruction in the order of the waiting queue, as shown in fig. 2c, assuming that the two target tasks are d3 and d7 respectively. For the zeroth waiting queue, the zeroth waiting queue is a special waiting queue, so that two target tasks in the switch instruction cannot be selected from the zeroth waiting queue, that is, the switch instruction is not suitable for the tasks in the zeroth waiting queue.
In this embodiment, through the exchange instruction for two target tasks sent by the target user end, the target user end can freely adjust the execution sequence of the tasks of the target user end, and the task ordering of other user ends is not affected, so that the flexibility of the task allocation method is improved, and the user experience is improved.
In one possible embodiment, the alternative wait queue includes a plurality of wait queues. The step S103 may include:
s1031, determining whether the target task number of the current waiting queue exceeds a preset threshold, wherein the current waiting queue is initially the waiting queue with the highest priority in the alternative waiting queues.
S1032, if not, the task to be allocated is allocated to the current waiting queue.
S1033, if so, taking the waiting queue of the next priority of the current waiting queue as the current waiting queue, and returning to execute the step of determining whether the target task number of the current waiting queue exceeds a preset threshold.
For example, as shown in fig. 2d, the task to be allocated is dm, and the dummy device selects the waiting queues to include 3 waiting queues, which are respectively: the second waiting queue, the third waiting queue and the fourth waiting queue, wherein the priority of the second waiting queue is higher than that of the third waiting queue, and the priority of the third waiting queue is higher than that of the fourth waiting queue. The second preset threshold of the second waiting queue is 3, the third preset threshold of the third waiting queue is 3, and the fourth preset threshold of the fourth waiting queue is 100.
And determining the second waiting queue as a current waiting queue, and distributing the task dm to the second waiting queue if the target task number in the second waiting queue is 2 and 2 is less than 3.
Assuming that the target task number in the second waiting queue is 4,
and 4 > 3, determining the third waiting queue as the current waiting queue, and if the target task number in the third waiting queue is 2, 2 < 3, distributing the task dm to the third waiting queue.
Assuming that the target task number in the third waiting queue is 4,
and 4 > 3, determining the waiting queue as the current waiting queue, and if the target task number in the fourth waiting queue is 2, 2 < 100, and distributing the task dm to the fourth waiting queue.
The target number of tasks in the lowest waiting queue is generally unconstrained.
In this embodiment, the candidate waiting queues include a plurality of waiting queues, and priorities in the waiting queues are different and arranged in order from high to low. By arranging a plurality of waiting queues, tasks to be distributed submitted by the target user side are distributed to different waiting queues according to the priority order, so that each target user has tasks in different waiting queues as much as possible, and further, when executing the tasks, the tasks of each user can be executed as fast as possible, and the user experience is improved.
In one possible embodiment, the step S106 may specifically be:
S1061, in response to ending of one target task or execution of one target task in the first waiting queue, transferring the first target task in the alternative waiting queue to the tail of the first waiting queue.
S1062, sequentially transferring the first target task in each waiting queue in the candidate waiting queues to the tail of the waiting queue of the previous priority according to the order of the priorities from high to low until all waiting queues comprising the target tasks are traversed.
For example, as shown in fig. 2e, the foregoing alternative waiting queue includes 3 waiting queues, where the task to be allocated of the target user 1 is the task dm, if d1 is executed when the waiting queue is allocated for the task, the first waiting queue is set at a position, the first target task number is 3, the first preset threshold 3 is exceeded, the target task in the second waiting queue is 4, the target task number in the third waiting queue is 4, the target task number in the fourth waiting queue is 2,2 < 100, where, to avoid allocating the task dm to the first waiting queue, the first target task in the second waiting queue is transferred to the tail of the first waiting queue, the first target task in the fourth waiting queue is transferred to the tail of the third waiting queue, and at this time, the target tasks in the first waiting queue, the second waiting queue and the third waiting queue exceed the preset threshold, and the target task number in the fourth waiting queue exceeds the preset threshold, the first waiting queue, and the first target task in the second waiting queue is transferred to the tail of the second waiting queue, and the target task in the fourth waiting queue is 3 is allocated to the tail of the target task in the fourth waiting queue, and d is as shown in fig. 2.
In this embodiment, in order to avoid that when a task to be allocated is allocated, the task to be allocated is allocated to the first priority due to the end of one task operation of the target user or the execution of one task of the target task in the first waiting queue, the execution efficiency is reduced, and the first task of the target user side in the waiting queue is transferred to the tail of the first waiting queue, so that when the task to be allocated is allocated, the task to be allocated is allocated to the last task of the target user side in the waiting queue, thereby improving the execution efficiency and improving the user experience.
As shown in fig. 2f, in an embodiment of the present application, a target ue sends a task request of a task to be allocated to a server, and when the server allocates the task to be allocated, the target ue determines whether the number of waiting tasks in a first waiting queue is less than a first preset threshold; if yes, the task to be allocated is allocated to a first waiting queue; if not, judging whether the number of the waiting tasks in the ith waiting queue is smaller than a preset threshold value; if yes, the task to be allocated is allocated to an ith waiting queue; if not, judging whether the ith waiting queue is the waiting queue with the lowest priority; if yes, the task to be allocated is allocated to an ith waiting queue; if not, the waiting queue of the next priority is entered for judgment.
The embodiment of the application provides a task distribution system, as shown in fig. 3, a plurality of user terminals, where the system includes: a server side, a user side, wherein,
the user end is used for submitting the task to the server end and receiving the task result sent by the server end.
The server side is used for distributing a waiting queue for the task submitted by the user side based on any task distribution method, executing the task according to the priority of the waiting queue to obtain a task result, and sending the task result to the user side.
The method specifically comprises the following steps:
responding to the task to be allocated of the receiving target user side, and acquiring a first target task number; the target task is a task submitted by the target user terminal and does not obtain a task result;
if the first target task number does not exceed the first preset threshold, the task to be allocated is allocated to a first waiting queue; the first target task number is the target task number in the first waiting queue;
if the first target task number exceeds the first preset threshold, the task to be allocated is allocated to an alternative waiting queue; wherein the priority of the alternative waiting queue is lower than the priority of the first waiting queue;
Executing tasks in the first waiting queue before executing tasks in the alternative waiting queue.
And executing the task according to the priority of the waiting queue to obtain a task result, and sending the task result to the target user side.
In the embodiment of the application, the target tasks submitted by the target user terminals are distributed and distributed into the waiting queues by setting the waiting queues and the preset threshold value, so that the task number of each user terminal in the high waiting queue is limited, each user terminal has the submitted task in the high waiting queue, the task submitted by each user terminal can be responded quickly, the problem that the service terminal only processes the task submitted by the user terminal because one user terminal submits too many tasks can be avoided, and each user terminal has the task in the high waiting queue for other user terminals, thereby improving the execution efficiency of the service terminal.
The embodiment of the application provides a task allocation device, which is applied to a server and is provided with a plurality of waiting queues in advance, wherein each waiting queue is arranged in sequence, and the waiting queues at least comprise two waiting queues; as shown in fig. 4, the apparatus includes:
an obtaining module 401, configured to obtain a target task number in response to receiving a task to be allocated of a target user terminal; the target task is a task submitted by a target user side;
A first allocation module 402, configured to allocate the task to be allocated to a first waiting queue if the first target task number does not exceed a first preset threshold; wherein the first target task number includes: the sum of the number of tasks being executed and the number of tasks in the first waiting queue;
an alternative allocation module 403, configured to allocate the task to be allocated to an alternative waiting queue if the first target task number exceeds the first preset threshold; wherein the priority of the alternative waiting queue is lower than the priority of the first waiting queue;
an executing module 404, configured to execute a task to be executed in the first waiting queue before the execution of the candidate waiting queue.
The embodiment of the application also provides a server, as shown in fig. 5, including:
a memory 501 for storing a computer program;
the processor 502 is configured to execute the program stored in the memory 501, and implement the following steps:
responding to the task to be allocated of the receiving target user side, and acquiring a first target task number; the target task is a task submitted by the target user terminal and does not obtain a task result;
if the first target task number does not exceed the first preset threshold, the task to be allocated is allocated to a first waiting queue; the first target task number is the target task number in the first waiting queue;
If the first target task number exceeds the first preset threshold, the task to be allocated is allocated to an alternative waiting queue; wherein the priority of the alternative waiting queue is lower than the priority of the first waiting queue;
executing tasks in the first waiting queue before executing tasks in the alternative waiting queue.
And the electronic device may further comprise a communication bus and/or a communication interface, through which the processor 502, the communication interface, and the memory 501 communicate with each other.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present application, there is also provided a computer readable storage medium having stored therein a computer program which, when executed by a processor, implements the steps of any of the task allocation methods described above.
In yet another embodiment of the present application, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform any of the task allocation methods of the above embodiments.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, tape), an optical medium (e.g., DVD), or other medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims (10)

1. The task allocation method is characterized in that the task allocation method is applied to a server side, a plurality of waiting queues are preset, and the waiting queues comprise: a first waiting queue and an alternative waiting queue; the method comprises the following steps:
responding to the received task to be allocated of the target user side, and acquiring a first target task number of target tasks which are allocated to the first waiting queue and do not obtain a task result; the target task is a task submitted by the target user terminal and does not obtain a task result;
if the first target task number does not exceed the first preset threshold, the task to be allocated is allocated to a first waiting queue; the first target task number is the target task number in the first waiting queue;
if the first target task number exceeds the first preset threshold, the task to be allocated is allocated to an alternative waiting queue; wherein the priority of the alternative waiting queue is lower than the priority of the first waiting queue;
Executing tasks in the first waiting queue before executing tasks in the alternative waiting queue.
2. The method according to claim 1, wherein the method further comprises:
and responding to a priority instruction aiming at the task to be allocated, and executing the task to be allocated before executing the task of the first waiting queue, wherein the priority instruction is sent to the server under the condition that the management end examines and approves the task to be allocated and the examination and approval result is priority execution.
3. The method of claim 2, wherein the plurality of wait queues further comprises: a zeroth waiting queue; the method comprises the following steps:
responding to a priority instruction aiming at the task to be allocated, and allocating the task to be allocated to a zeroth waiting queue; and before executing the tasks of the first waiting queue, executing the tasks of the zeroth waiting queue sequentially according to the order from early to late of the commit time.
4. The method of claim 1, wherein the tasks in each waiting queue are ordered in an early-to-late order of commit time, the method further comprising:
and transferring the first target task in the alternative waiting queue to the tail of the first waiting queue in response to ending of running of the target task or execution of the target task in the first waiting queue.
5. The method of claim 4, wherein the alternative wait queue includes a plurality of wait queues, and wherein the transferring the first target task in the alternative wait queue to the tail of the first wait queue in response to one target task ending or being executed in the first wait queue comprises:
responsive to an end of execution of a target task or execution of a target task in the first waiting queue, transferring a first target task in the alternative waiting queue to a tail of the first waiting queue;
and sequentially transferring the first target task in each waiting queue in the alternative waiting queues to the tail of the waiting queue of the previous priority according to the order of the priority from high to low until all waiting queues comprising the target tasks are traversed.
6. The method according to claim 1, wherein the method further comprises:
and exchanging the order of the two target tasks for which the exchange instruction is aimed in the waiting queue in response to the exchange instruction sent for the two target tasks.
7. The method of claim 1, wherein the candidate waiting queue includes a plurality of waiting queues, and wherein the allocating the task to be allocated to the candidate waiting queue if the first target task number exceeds the first preset threshold includes:
Determining whether the target task number of a current waiting queue exceeds a preset threshold, wherein the current waiting queue is initially a waiting queue with the highest priority in the alternative waiting queues;
if not, the task to be allocated is allocated to the current waiting queue;
and if so, taking the waiting queue of the next priority of the current waiting queue as the current waiting queue, and returning to execute the step of determining whether the target task number of the current waiting queue exceeds a preset threshold.
8. A task distribution system, the system comprising: a server side, a user side, wherein,
the user side is used for submitting a task to the server side and receiving a task result sent by the server side;
the server is configured to allocate a waiting queue for a task submitted by the user based on the method of any one of claims 1 to 7, execute the task according to the priority of the waiting queue to obtain a task result, and send the task result to the user.
9. The task allocation device is characterized by being applied to a server side and being provided with a plurality of waiting queues in advance, wherein the waiting queues comprise: a first waiting queue and an alternative waiting queue; the device comprises:
The acquisition module is used for responding to the task to be allocated of the receiving target user side and acquiring a first target task number of the target tasks which are allocated to the first waiting queue and do not obtain the task result; the target task is a task submitted by the target user terminal and does not obtain a task result;
the first allocation module is used for allocating the tasks to be allocated to a first waiting queue if the first target task number does not exceed a first preset threshold; the first target task number is the target task number in the first waiting queue;
the alternative allocation module is used for allocating the tasks to be allocated to an alternative waiting queue if the first target task number exceeds the first preset threshold; wherein the priority of the alternative waiting queue is lower than the priority of the first waiting queue;
and the execution module is used for executing the tasks in the first waiting queue before executing the tasks of the alternative waiting queue.
10. A server, comprising:
a memory for storing a computer program;
a processor for implementing the method of any of claims 1-7 when executing a program stored on a memory.
CN202310799474.6A 2023-06-30 2023-06-30 Task allocation method, device and system Pending CN116820769A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310799474.6A CN116820769A (en) 2023-06-30 2023-06-30 Task allocation method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310799474.6A CN116820769A (en) 2023-06-30 2023-06-30 Task allocation method, device and system

Publications (1)

Publication Number Publication Date
CN116820769A true CN116820769A (en) 2023-09-29

Family

ID=88120017

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310799474.6A Pending CN116820769A (en) 2023-06-30 2023-06-30 Task allocation method, device and system

Country Status (1)

Country Link
CN (1) CN116820769A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117032993A (en) * 2023-10-08 2023-11-10 麒麟软件有限公司 Task scheduling method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117032993A (en) * 2023-10-08 2023-11-10 麒麟软件有限公司 Task scheduling method
CN117032993B (en) * 2023-10-08 2024-04-05 麒麟软件有限公司 Task scheduling method

Similar Documents

Publication Publication Date Title
CN107423120B (en) Task scheduling method and device
CN110837410B (en) Task scheduling method and device, electronic equipment and computer readable storage medium
CN109697122B (en) Task processing method, device and computer storage medium
WO2022068697A1 (en) Task scheduling method and apparatus
CN111258745B (en) Task processing method and device
US11093352B2 (en) Fault management in NVMe systems
CN116820769A (en) Task allocation method, device and system
WO2017096842A1 (en) Content delivery task submission method and system
US11936568B2 (en) Stream allocation using stream credits
CN105022668B (en) Job scheduling method and system
US9665409B2 (en) Methods and apparatus facilitating access to storage among multiple computers
US20170344266A1 (en) Methods for dynamic resource reservation based on classified i/o requests and devices thereof
CN113327053A (en) Task processing method and device
CN111831408A (en) Asynchronous task processing method and device, electronic equipment and medium
CN111930485A (en) Job scheduling method based on performance expression
CN116664377A (en) Data transmission method and related device
CN112805684A (en) Resource allocation using recovery borrowing
CN113127179A (en) Resource scheduling method and device, electronic equipment and computer readable medium
CN109062707B (en) Electronic device, method for limiting inter-process communication thereof and storage medium
CN109062706B (en) Electronic device, method for limiting inter-process communication thereof and storage medium
US10853138B2 (en) Scheduling resource usage
CN114035930A (en) Method and device for task scheduling, electronic equipment and readable storage medium
CN114546279B (en) IO request prediction method and device, storage node and readable storage medium
CN116431327B (en) Task current limiting processing method and fort machine
JP7384214B2 (en) Analysis processing device, system, method and program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination