CN111309467B - Task distribution method and device, electronic equipment and storage medium - Google Patents

Task distribution method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111309467B
CN111309467B CN202010110981.0A CN202010110981A CN111309467B CN 111309467 B CN111309467 B CN 111309467B CN 202010110981 A CN202010110981 A CN 202010110981A CN 111309467 B CN111309467 B CN 111309467B
Authority
CN
China
Prior art keywords
task
message queue
scheduling
module
processing module
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.)
Active
Application number
CN202010110981.0A
Other languages
Chinese (zh)
Other versions
CN111309467A (en
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.)
Rajax Network Technology Co Ltd
Original Assignee
Rajax Network 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 Rajax Network Technology Co Ltd filed Critical Rajax Network Technology Co Ltd
Priority to CN202010110981.0A priority Critical patent/CN111309467B/en
Publication of CN111309467A publication Critical patent/CN111309467A/en
Application granted granted Critical
Publication of CN111309467B publication Critical patent/CN111309467B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue
    • 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

Abstract

The embodiment of the invention relates to the technical field of information processing, and discloses a task distribution method and device, electronic equipment and a storage medium. Acquiring a scheduling task from a preset first message queue by responding to a task request; adding the scheduling task into a preset second message queue; processing the scheduling task; if the scheduled tasks in the first message queue are detected to be taken out, the first message queue is exchanged with the second message queue, so that resource waste can be reduced, and task distribution efficiency is improved.

Description

Task distribution method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of information processing technologies, and in particular, to a task distribution method and apparatus, an electronic device, and a storage medium.
Background
In service architecture, clustered deployment is often done for the purpose of high availability, high throughput, etc. Within a process cluster, a plurality of identical service processes are often included, and each service process can independently provide services to the outside. In the process of processing the process task, if a plurality of service processes hit the same task at the same time, the processing task is often acquired in a lock-robbing manner.
The lock-robbed task processing means that all service processes in the cluster obtain all scheduling tasks, before each service process performs scheduling task, a distributed task lock aiming at the task is obtained, if the lock is obtained, the task is scheduled, if the lock is not obtained, the task is indicated to be processed by other processes, and the process does not process the task.
The inventors found that there are at least the following problems in the related art: the task is allocated to each process service by the aid of the system, so that great resource waste is caused, and the task allocation efficiency is low.
Disclosure of Invention
The embodiment of the invention aims to provide a task distribution method which can reduce resource waste and improve task distribution efficiency.
In order to solve the above technical problems, an embodiment of the present invention provides a task distribution method, including: responding to a task request, and acquiring a scheduling task from a preset first message queue; adding the scheduling task into a preset second message queue; processing the scheduling task; and if the scheduled tasks in the first message queue are all detected to be fetched, exchanging the first message queue with the second message queue.
The embodiment of the invention also provides a task distribution system, which comprises a task distribution module, a task processing module and a queue processing module; the task distribution module is used for responding to the task request sent by the task processing module and acquiring a scheduling task from a preset first message queue through the queue processing module; the queue processing module is used for adding the scheduling task into a preset second message queue; the task processing module is used for processing the scheduling task; the queue processing module is further configured to exchange the first message queue with the second message queue if it is detected that all scheduling tasks in the first message queue are fetched.
The embodiment of the invention also provides an electronic device, which comprises a memory and a processor, wherein the memory stores a computer program, and the processor executes when running the program: responding to a task request, and acquiring a scheduling task from a preset first message queue; adding the scheduling task into a preset second message queue; processing the scheduling task; and if the scheduled tasks in the first message queue are all detected to be fetched, exchanging the first message queue with the second message queue.
Embodiments of the present invention also provide a non-volatile storage medium storing a computer-readable program for causing a computer to execute the task distribution method as above.
Compared with the prior art, the method and the device for dispatching the tasks in the embodiment of the invention have the advantages that a dispatching task is obtained from the preset first message queue in response to the task request, and is added into the preset second message queue, so that the dispatching of the tasks is realized by using the message queue, the consumption of resources which can be used for processing the dispatching tasks originally for obtaining the processing tasks by each process can be avoided, and the efficiency of dispatching the tasks is improved; the second message queue is designed to store the tasks which are already called in one round of dispatching tasks, so that the dispatching tasks of each grid can be guaranteed to be only once in one dispatching period, resource waste caused by repeated dispatching of dispatching any grid in one dispatching period is avoided, and after the tasks in the first message queue are taken out, the first message queue and the second message queue are interchanged, so that the next round of task dispatching can be guaranteed to be smoothly carried out.
In addition, the task distribution method is applied to a task distribution system comprising a task distribution module, a task processing module and a queue processing module; responding to the task request, and acquiring a scheduling task from a preset first message queue, wherein the scheduling task comprises the following specific steps of: the task distributing module responds to the task request sent by the task processing module, and a scheduling task is obtained from a preset first message queue through the queue processing module; the scheduling task is added into a preset second message queue, specifically: the queue processing module adds the scheduling task into a preset second message queue; the task processing module processes the scheduling task; if the scheduled tasks in the first message queue are all taken out, the identities of the first message queue and the second message queue are exchanged, specifically, if the queue processing module detects that the scheduled tasks in the first message queue are all taken out, the identities of the first message queue and the second message queue are exchanged. The task distribution module is provided for completing the distribution of the process tasks, the task distribution module receives the task requests sent by the task processing modules and sends the obtained scheduling tasks to the task processing modules, so that the task processing modules are prevented from consuming resources which can be used for processing the scheduling tasks for obtaining the processing tasks.
In addition, the number of the task distribution modules is a plurality of task distribution module clusters; the task distribution module responding to the task request is one of the task distribution module clusters; the task distribution system further comprises a selection module, and before the task distribution module responds to the task request sent by the task processing module and the scheduling task is called from a preset first message queue through the queue processing module, the task distribution system further comprises: the selection module distributes the task request to the task distribution module based on a preset distribution principle. The task distribution modules form a task distribution module cluster, the task distribution module for task distribution is selected by the selection module, tasks are distributed to the task acquisition module directly through the task distribution module, the task distribution modules are concentrated to form the task distribution module cluster, unified management of the task distribution modules is facilitated, and software and hardware of the task distribution modules are updated more easily.
In addition, the allocation principle is a load balancing principle. According to the load balancing principle, the task distribution module is selected to perform current task distribution work, so that the load of each task distribution module is relatively balanced, and resources in the task distribution module cluster are utilized more repeatedly.
In addition, a plurality of task distribution modules in the task distribution module cluster are selected in turn. The task processing modules select the target task distribution module, and the task processing modules are selected in turn, so that load balancing can be realized as much as possible from the perspective of the task processing modules.
In addition, the task distribution modules and the task processing modules are equal in number and in one-to-one correspondence; the task distribution module responds to the task request sent by the task processing module, and obtains a scheduling task from a preset first message queue through the queue processing module. And setting a corresponding task distribution module for each task processing module, so that the task distribution is more targeted.
Drawings
FIG. 1 is a flow chart of a task distribution method in a first embodiment according to the present invention;
fig. 2 is a schematic diagram showing the connection relationship among the respective modules in the first embodiment of the present invention;
FIG. 3 is a flow chart of a task distribution method in a second embodiment according to the present invention;
fig. 4 is a schematic diagram showing the connection relationship among the respective modules in the second embodiment of the present invention;
FIG. 5 is a schematic diagram of a task distribution system according to a third embodiment of the present invention;
fig. 6 is a schematic view of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the following detailed description of the embodiments of the present invention will be given with reference to the accompanying drawings. However, those of ordinary skill in the art will understand that in various embodiments of the present invention, numerous technical details have been set forth in order to provide a better understanding of the present application. However, the technical solutions claimed in the present application can be implemented without these technical details and with various changes and modifications based on the following embodiments. The following embodiments are divided for convenience of description, and should not be construed as limiting the specific implementation of the present invention, and the embodiments can be mutually combined and referred to without contradiction.
In the takeaway field, each distribution area can be divided into grids, a plurality of order tasks exist in each grid, in practical implementation, a plurality of task processing modules are designed to process the order tasks in each grid, each grid is regarded as a scheduling task, and the task processing modules can process one grid scheduling task in one processing period.
A first embodiment of the present invention relates to a task distribution method, as shown in fig. 1, including:
step S101, a scheduling task is obtained from a preset first message queue in response to a task request.
Specifically, the scheme is applied to a task distribution system comprising a task distribution module, a task processing module and a queue processing module. In the task distribution system, a first message queue can be preset to store scheduling tasks of the grid, each scheduling task stored in the first message queue module and the arrangement sequence thereof are obtained by initializing the message queue module by a first started task processing module. When a task processing module in the task distribution system detects that the task to be processed is insufficient, a task request can be sent to the task distribution module, the task distribution module responds to the task request, the task request sent by the task processing module is received through a data interface, and a scheduling task is acquired from a first message queue after the initialization is completed through the queue processing module. This scheduling task is a scheduling task fetched from the head of the first message queue. In this embodiment, a task distribution module is provided to complete the distribution of a process task, the task distribution module receives a task request sent by a task processing module, and sends an acquired scheduling task to the task processing module, so that each task processing module is prevented from consuming resources that are originally available for processing the scheduling task for acquiring the processing task, and meanwhile, the task distribution work of the scheduling task is concentrated in the task distribution module to be performed, so that the task distribution efficiency can be improved.
Step S102, adding the scheduling task into a preset second message queue.
Specifically, when a scheduling task is obtained from the first message queue, the queue processing module adds the scheduling task obtained from the first scheduling task queue to the second message queue, and in actual implementation, places the scheduling task taken out from the head of the first message queue at the tail of the second message queue, so that the storage sequence of the messages in the second message queue is ensured to be consistent with that of the first message queue.
In a specific example, the first message queue is message queue a and the second message queue is message queue B. In the process that the task distribution module acquires the scheduling task, a processing center in the message queue module takes out a scheduling task from the head of the message queue A, sends the scheduling task to the task distribution module, places the scheduling task at the tail of the message queue B, after one round of scheduling is completed, the message queue A has no scheduling task, and the processing center controls the queue A and the queue B to exchange, so that in the next round of scheduling, the scheduling task is acquired from the head of the message queue B and placed at the tail of the message queue A.
Step S103, processing the scheduling task.
Specifically, the task processing module may send the scheduled task to the task request module that sends the task request through the data interface after the scheduled task is obtained from the message queue module, and then the task request module goes to the task request module.
In a specific example, the scheduling task stored in the message queue may be a number of each grid, and the task processing module may find a corresponding grid according to the number in the process of processing the task, and find an order task in the grid and process the order task in the database of the order task. The scheduling tasks are represented only by grid numbers so that the message queues do not manage specific order tasks in the grid.
Step S104: and if the dispatch tasks in the first message queue are detected to be fetched, exchanging the first message queue with the second message queue.
Specifically, the queue processing module monitors the first message queue and the second message queue, and exchanges the first message queue with the second message queue after detecting that the scheduled tasks in the first message queue are all fetched, that is, exchanges the first address of the first message queue with the first address of the second message queue, so that the task distribution module can acquire the tasks from the first message queue next time (because the first message queue is the original second message queue, and all the scheduled tasks are included therein). In this embodiment, the second message queue is designed to store the acquired tasks in one round of scheduling, so that it can be ensured that the scheduled tasks of each grid are scheduled only once in one scheduling period, and resource waste caused by repeatedly scheduling the scheduled tasks of each grid in one scheduling period is avoided.
In this embodiment, the number of task processing modules is equal to and corresponds to the number of task distribution modules, and each task distribution module is integrated with the corresponding task processing module to form a cluster process for processing and scheduling tasks; each task distribution module receives a task request sent by a corresponding task processing module; and the task distribution module only sends the acquired scheduling task to the corresponding task processing module after acquiring the scheduling task. In the embodiment, a corresponding task distribution module is arranged for each task processing module, so that task distribution is more targeted.
The implementation details of the order scheduling method of the present embodiment are specifically described below, and the following is merely provided for understanding the implementation details, and is not necessary to implement the present embodiment.
Taking a task distribution module corresponding to each task processing module as an example, the connection relation among the modules is shown in fig. 2, and each task distribution module and the corresponding task processing module are integrated together to form a cluster process for processing the scheduled task. When the task processing module 1 detects that a self task queue to be processed is not filled, a task request is sent to a corresponding task distribution module 1, the task distribution module 1 acquires a scheduling task from a message queue module, and the scheduling task is a scheduling task of a grid 3 taken out from the head of a message queue A by a processing center in the message queue module; after the task distribution module 1 acquires the scheduling task, the scheduling task is sent to the task processing module 1; when performing task processing on the scheduled task of the grid 3, the task processing module 1 finds out and processes the order task in the grid 3 in the database storing the order task.
Compared with the prior art, the method and the device for dispatching the tasks in the embodiment are used for responding to the task request, acquiring one dispatching task from the preset first message queue, adding the dispatching task into the preset second message queue, and using the message queue to realize the dispatching of the tasks, so that the consumption of resources which can be used for processing the dispatching task originally for acquiring and processing the task by each process can be avoided, and the efficiency of dispatching the tasks is improved; the second message queue is designed to store the tasks which are already called in one round of dispatching tasks, so that the dispatching tasks of each grid can be guaranteed to be only once in one dispatching period, resource waste caused by repeated dispatching of dispatching any grid in one dispatching period is avoided, and after the tasks in the first message queue are taken out, the first message queue and the second message queue are interchanged, so that the next round of task dispatching can be guaranteed to be smoothly carried out.
A second embodiment of the present invention relates to a task distribution method, which is substantially the same as the first embodiment, and is mainly different from the first embodiment in that in the present embodiment, task distribution modules and task processing modules are not in one-to-one correspondence, and a plurality of task distribution modules form a task distribution module cluster, and a flowchart of the present embodiment is shown in fig. 3, and is specifically described below.
In this embodiment, the task distribution system further includes a selection module, and before the task distribution module mentioned in the first embodiment responds to the task request sent by the task processing module and the task is scheduled and fetched from the preset first message queue by the queue processing module, the following step S301 is further included.
In step S301, the selection module distributes the task request to the task distribution module based on a preset distribution principle.
Specifically, when the task processing module detects that the task queue to be processed is not filled, the task processing module can send a task request to the task distribution module cluster, the task distribution module cluster sends the received task request to a target task distribution module, and the target task distribution module receives the task request and performs the next processing. The target task distribution module can be selected by a selection module in the task distribution module cluster, and the selection module selects one task distribution module from a plurality of task distribution modules according to the principle of load balancing to serve as a target task distribution unit for receiving task requests. The selection module in the task distribution module cluster selects the task distribution module to perform the current task distribution work according to the load balancing principle, so that the load of each task distribution module is relatively balanced, and the resources in the task distribution module cluster are utilized more repeatedly.
In addition, the target task distribution module can be selected by the task processing module, and each task distribution module in the task distribution module cluster can be alternately selected by the task processing module as the task distribution module for receiving the task request. The task processing modules select the target task distribution module, and the task processing modules are selected in turn, so that load balancing can be realized from the perspective of the task processing modules.
The task processing module may obtain, in advance, identification information corresponding to each task distribution module in the task distribution module cluster, and when selecting a target task distribution module, select one target identification information from the obtained identification information, and use the task distribution module corresponding to the target identification information as the target task distribution module. In particular implementation, each task distribution module may run on the same server, or may run on different task distribution servers, respectively; when each task distribution module runs on different servers, the identification information of each task distribution module can be the IP address of the corresponding task distribution server.
Step S302, a scheduling task is obtained from a preset first message queue in response to a task request.
Step S303, adding the scheduling task to a preset second message queue.
Step S304, processing the scheduling task.
In step S305, if it is detected that all the scheduling tasks in the first message queue are fetched, the first message queue is exchanged with the second message queue.
Steps S302 to S305 are substantially the same as steps S101 to S104 in the first embodiment of the present invention, and are not repeated here.
In one example, as shown in fig. 4, each task distribution module (only three are shown in the figure, and may actually be plural) forms a task distribution module cluster, and each task processing module (only three are shown in the figure, and may actually be plural) forms a task processing module cluster. When a certain task processing module in the task processing module cluster detects that a task queue to be processed of the task processing module cluster is not filled, a task request is sent to the task distribution module cluster, after the task request is received by the task distribution module cluster, a target task distribution module in the task request is used for acquiring a scheduling task from the message queue module, and the acquired scheduling task is sent to the task processing module.
Compared with the first generation of the embodiment, the task distribution module cluster is formed by integrating a plurality of task distribution modules, so that unified management of the task distribution modules is facilitated, and software and hardware of the task distribution modules are easier to update.
A third embodiment of the present invention relates to a task distribution system, as shown in fig. 5, including: a task distribution module 501, a task processing module 502, and a queue processing module 503; the task distributing module 501 is configured to obtain a scheduled task from a preset first message queue through the queue processing module 503 in response to a task request sent by the task processing module 502; the queue processing module 503 is configured to add a scheduling task to a preset second message queue; the task processing module 502 is used for processing scheduling tasks; the queue processing module 503 is further configured to exchange identities of the first message queue and the second message queue if it is detected that all scheduling tasks in the first message queue are fetched.
In one example, the task distribution modules 501 are multiple in number and form a cluster of task distribution modules 501; the task distribution module 501 responsive to the task request is one of a cluster of task distribution modules 501; the task distribution system further includes a selection module, before the task distribution module 501 responds to the task request sent by the task processing module 502 and the scheduled task is fetched from the preset first message queue by the queue processing module 503, the task distribution system further includes: the selection module distributes task requests to the task distribution module 501 based on preset distribution principles.
In one example, the allocation principle is a load balancing principle.
In one example, a plurality of task distribution modules 501 in the cluster of task distribution modules 501 are selected in turn.
In one example, the number of task distribution modules 501 and task processing modules 502 is equal and in one-to-one correspondence; the task distribution module 501 responds to the task request sent by the task processing module 502, and obtains a scheduled task from a preset first message queue through the queue processing module 503, specifically, the task distribution module 501 responds to the task request sent by the corresponding task processing module 502, and obtains a scheduled task from the preset first message queue through the queue processing module 503.
It is to be noted that this embodiment is a system example corresponding to any one of the first to second embodiments, and can be implemented in cooperation with any one of the first to second embodiments. The related technical details mentioned in the first to second embodiments are still valid in the present embodiment, and are not repeated here for the sake of reducing repetition. Accordingly, the related technical details mentioned in the present embodiment can also be applied to the first embodiment to the second embodiment.
It should be noted that each unit referred to in this embodiment is a logic unit, and in practical application, one logic unit may be one physical unit, or may be a part of one physical unit, or may be implemented by a combination of multiple physical units. In addition, in order to highlight the innovative part of the present invention, units that are not so close to solving the technical problem presented by the present invention are not introduced in the present embodiment, but this does not indicate that other units are not present in the present embodiment.
A fourth embodiment of the present invention relates to an electronic device, as shown in fig. 6, the electronic device 600 including: at least one processor 601; and a memory 602 communicatively coupled to the at least one processor 601; and a communication component 603 communicatively coupled to the scanning device, the communication component 603 receiving and transmitting data under control of the processor 601; wherein the memory 602 stores instructions executable by the at least one processor 601, the instructions being executable by the at least one processor 601 to implement: receiving a task request sent by a task processing module; acquiring a scheduling task from a preset message queue module; and sending the obtained scheduling task to a task processing module.
Specifically, the terminal device 600 includes: one or more processors 601 and a memory 602, one processor 601 being illustrated in fig. 6. The processor 601, the memory 602 may be connected by a bus or otherwise, for example in fig. 6. The memory 602 is a non-volatile computer readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs, and modules. The processor 601 executes various functional applications of the device and data processing, i.e., implements the task distribution method described above, by running nonvolatile software programs, instructions, and modules stored in the memory 602.
The memory 602 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for a function; the storage data area may store a list of options, etc. In addition, the memory 602 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some implementations, the memory 602 optionally includes memory 602 located remotely from the processor 601, the remote memory 602 being connectable to an external device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
One or more modules are stored in the memory 602 that, when executed by the one or more processors 601, perform the task distribution method of the first or second embodiment described above.
It should be noted that each unit referred to in this embodiment is a logic unit, and in practical application, one logic unit may be one physical unit, or may be a part of one physical unit, or may be implemented by a combination of multiple physical units. In addition, in order to highlight the innovative part of the present invention, units that are not so close to solving the technical problem presented by the present invention are not introduced in the present embodiment, but this does not indicate that other units are not present in the present embodiment.
A fifth embodiment of the present invention relates to a nonvolatile storage medium storing a computer-readable program for causing a computer to execute some or all of the above-described method embodiments.
That is, it will be understood by those skilled in the art that all or part of the steps in implementing the methods of the embodiments described above may be implemented by a program stored in a storage medium, where the program includes several instructions for causing a device (which may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps in the methods of the embodiments described herein. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It will be understood by those of ordinary skill in the art that the foregoing embodiments are specific examples of carrying out the invention and that various changes in form and details may be made therein without departing from the spirit and scope of the invention.
The embodiment of the application discloses a1. A task distribution method, comprising the following steps:
responding to a task request, and acquiring a scheduling task from a preset first message queue;
adding the scheduling task into a preset second message queue;
processing the scheduling task;
and if the scheduled tasks in the first message queue are all detected to be fetched, exchanging the first message queue with the second message queue.
A2. The task distribution method according to A1, which is applied to a task distribution system including a task distribution module, a task processing module, and a queue processing module;
the response to the task request obtains a scheduling task from a preset first message queue, specifically: the task distributing module responds to the task request sent by the task processing module, and a scheduling task is obtained from a preset first message queue through the queue processing module;
the step of adding the scheduling task to a preset second message queue specifically comprises the following steps: the queue processing module adds the scheduling task into a preset second message queue;
the task processing module processes the scheduling task;
and if the scheduling tasks in the first message queue are all detected to be taken out, exchanging the first message queue with the second message queue, specifically, if the queue processing module detects that the scheduling tasks in the first message queue are all taken out, exchanging the first message queue with the second message queue.
A3. The task distribution method according to A2, wherein the number of task distribution modules is a plurality of task distribution modules and a task distribution module cluster is formed; the task distribution module responding to the task request is one of the task distribution module clusters;
the task distribution system further comprises a selection module, and before the task distribution module responds to the task request sent by the task processing module and the scheduling task is called from a preset first message queue through the queue processing module, the task distribution system further comprises:
the selection module distributes the task request to the task distribution module based on a preset distribution principle.
A4. The task distribution method according to A3, wherein the distribution principle is a load balancing principle.
A5. The task distribution method according to A3,
a plurality of task distribution modules in the task distribution module cluster are selected in turn.
A6. The task distribution method according to A2, wherein the number of the task distribution modules is equal to that of the task processing modules and the task distribution modules are in one-to-one correspondence;
the task distribution module responds to the task request sent by the task processing module, and obtains a scheduling task from a preset first message queue through the queue processing module.
The embodiment of the application discloses a task distribution system which comprises a task distribution module, a task processing module and a queue processing module;
the task distribution module is used for responding to the task request sent by the task processing module and acquiring a scheduling task from a preset first message queue through the queue processing module;
the queue processing module is used for adding the scheduling task into a preset second message queue;
the task processing module is used for processing the scheduling task;
the queue processing module is further configured to exchange identities of the first message queue and the second message queue if it is detected that all scheduling tasks in the first message queue are fetched.
The embodiment of the application discloses C1. An electronic device, including a memory and a processor, the memory stores a computer program, the processor executes when running the program:
responding to a task request, and acquiring a scheduling task from a preset first message queue;
adding the scheduling task into a preset second message queue;
processing the scheduling task;
and if the scheduled tasks in the first message queue are all detected to be fetched, exchanging the first message queue with the second message queue.
C2. The electronic device of C1, which includes a task distribution module, a task processing module, and a queue processing module;
the response to the task request obtains a scheduling task from a preset first message queue, specifically: the task distributing module responds to the task request sent by the task processing module, and a scheduling task is obtained from a preset first message queue through the queue processing module;
the step of adding the scheduling task to a preset second message queue specifically comprises the following steps: the queue processing module adds the scheduling task into a preset second message queue;
the task processing module processes the scheduling task;
and if the scheduled tasks in the first message queue are all taken out, exchanging the identities of the first message queue and the second message queue, specifically, if the queue processing module detects that the scheduled tasks in the first message queue are all taken out, exchanging the identities of the first message queue and the second message queue.
C3. The electronic device of C2, wherein the number of task distribution modules is a plurality and forms a task distribution module cluster; the task distribution module responding to the task request is one of the task distribution module clusters;
the task distribution system further comprises a selection module, and before the task distribution module responds to the task request sent by the task processing module and the scheduling task is called from a preset first message queue through the queue processing module, the task distribution system further comprises:
the selection module distributes the task request to the task distribution module based on a preset distribution principle.
C4. The electronic device of C3, wherein the allocation rule is a load balancing rule.
C5. The electronic device of C3, the plurality of task distribution modules in the task distribution module cluster being selected in turn.
C6. The electronic device of C2, wherein the task distribution modules are equal in number and in one-to-one correspondence with the task processing modules;
the task distribution module responds to the task request sent by the task processing module, and obtains a scheduling task from a preset first message queue through the queue processing module.
The embodiment of the application discloses d1. A nonvolatile storage medium for storing a computer-readable program for causing a computer to execute the task distribution method according to any one of A1 to A6.

Claims (14)

1. A method of task distribution, comprising:
responding to a task request, and acquiring a scheduling task from a preset first message queue;
adding the scheduling tasks into a preset second message queue, wherein the second message queue is used for storing the scheduling tasks which are acquired in one round of scheduling, and each scheduling task is scheduled only once in one scheduling period;
processing the scheduling task;
and if the scheduled tasks in the first message queue are all detected to be fetched, exchanging the first message queue with the second message queue.
2. The task distribution method according to claim 1, wherein the task distribution method is applied to a task distribution system including a task distribution module, a task processing module, and a queue processing module;
the response to the task request obtains a scheduling task from a preset first message queue, specifically: the task distributing module responds to the task request sent by the task processing module, and a scheduling task is obtained from a preset first message queue through the queue processing module;
the step of adding the scheduling task to a preset second message queue specifically comprises the following steps: the queue processing module adds the scheduling task into a preset second message queue;
the task processing module processes the scheduling task;
and if the scheduling tasks in the first message queue are all detected to be taken out, exchanging the first message queue with the second message queue, specifically, if the queue processing module detects that the scheduling tasks in the first message queue are all taken out, exchanging the first message queue with the second message queue.
3. The task distribution method according to claim 2, wherein the number of task distribution modules is plural and a task distribution module cluster is formed; the task distribution module responding to the task request is one of the task distribution module clusters;
the task distribution system further comprises a selection module, and before the task distribution module responds to the task request sent by the task processing module and the scheduling task is called from a preset first message queue through the queue processing module, the task distribution system further comprises:
the selection module distributes the task request to the task distribution module based on a preset distribution principle.
4. A task distribution method according to claim 3, characterized in that the allocation principle is a load balancing principle.
5. The task distribution method according to claim 3, characterized in that,
a plurality of task distribution modules in the task distribution module cluster are selected in turn.
6. The task distribution method according to claim 2, wherein the number of the task distribution modules is equal to the number of the task processing modules and corresponds to one;
the task distribution module responds to the task request sent by the task processing module, and obtains a scheduling task from a preset first message queue through the queue processing module.
7. The task distribution system is characterized by comprising a task distribution module, a task processing module and a queue processing module;
the task distribution module is used for responding to the task request sent by the task processing module and acquiring a scheduling task from a preset first message queue through the queue processing module;
the queue processing module is used for adding the scheduling tasks into a preset second message queue, the second message queue is used for storing the scheduling tasks which are acquired in one round of scheduling, and each scheduling task is scheduled only once in one scheduling period;
the task processing module is used for processing the scheduling task;
the queue processing module is further configured to exchange identities of the first message queue and the second message queue if it is detected that all scheduling tasks in the first message queue are fetched.
8. An electronic device comprising a memory storing a computer program and a processor that executes when the program:
responding to a task request, and acquiring a scheduling task from a preset first message queue;
adding the scheduling tasks into a preset second message queue, wherein the second message queue is used for storing the scheduling tasks which are acquired in one round of scheduling, and each scheduling task is scheduled only once in one scheduling period;
processing the scheduling task;
and if the scheduled tasks in the first message queue are all detected to be fetched, exchanging the first message queue with the second message queue.
9. The electronic device of claim 8, wherein the electronic device comprises a task distribution module, a task processing module, and a queue processing module;
the response to the task request obtains a scheduling task from a preset first message queue, specifically: the task distributing module responds to the task request sent by the task processing module, and a scheduling task is obtained from a preset first message queue through the queue processing module;
the step of adding the scheduling task to a preset second message queue specifically comprises the following steps: the queue processing module adds the scheduling task into a preset second message queue;
the task processing module processes the scheduling task;
and if the scheduled tasks in the first message queue are all taken out, exchanging the identities of the first message queue and the second message queue, specifically, if the queue processing module detects that the scheduled tasks in the first message queue are all taken out, exchanging the identities of the first message queue and the second message queue.
10. The electronic device of claim 9, wherein the number of task distribution modules is a plurality and forms a task distribution module cluster; the task distribution module responding to the task request is one of the task distribution module clusters;
the task distribution system further comprises a selection module, and before the task distribution module responds to the task request sent by the task processing module and the scheduling task is called from a preset first message queue through the queue processing module, the task distribution system further comprises:
the selection module distributes the task request to the task distribution module based on a preset distribution principle.
11. The electronic device of claim 10, wherein the allocation principle is a load balancing principle.
12. The electronic device of claim 10, wherein a plurality of task distribution modules in the task distribution module cluster are selected in turn.
13. The electronic device of claim 9, wherein the task distribution modules are equal in number and in one-to-one correspondence with the task processing modules;
the task distribution module responds to the task request sent by the task processing module, and obtains a scheduling task from a preset first message queue through the queue processing module.
14. A non-volatile storage medium storing a computer readable program for causing a computer to execute the task distribution method according to any one of claims 1 to 6.
CN202010110981.0A 2020-02-24 2020-02-24 Task distribution method and device, electronic equipment and storage medium Active CN111309467B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010110981.0A CN111309467B (en) 2020-02-24 2020-02-24 Task distribution method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010110981.0A CN111309467B (en) 2020-02-24 2020-02-24 Task distribution method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111309467A CN111309467A (en) 2020-06-19
CN111309467B true CN111309467B (en) 2023-07-14

Family

ID=71149110

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010110981.0A Active CN111309467B (en) 2020-02-24 2020-02-24 Task distribution method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111309467B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113065084B (en) * 2021-03-08 2022-12-23 南京苏宁软件技术有限公司 Data loading method and device, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7069333B1 (en) * 1999-08-13 2006-06-27 Fieldcentrix, Inc. Method and systems for wireless communication for a field service system
CN102023974A (en) * 2009-09-14 2011-04-20 中国移动通信集团公司 Method, device and system for processing message by message queue
CN102426539A (en) * 2011-11-01 2012-04-25 深圳市航天泰瑞捷电子有限公司 Timer task automatic processing method and system
CN103092682A (en) * 2011-10-28 2013-05-08 浙江大华技术股份有限公司 Asynchronous network application program processing method
CN110502322A (en) * 2019-07-12 2019-11-26 苏宁云计算有限公司 The triggering method and device of timer-triggered scheduler
CN110633126A (en) * 2019-09-27 2019-12-31 北京字节跳动网络技术有限公司 Information display method and device and electronic equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6907546B1 (en) * 2000-03-27 2005-06-14 Accenture Llp Language-driven interface for an automated testing framework
US10860618B2 (en) * 2017-09-25 2020-12-08 Splunk Inc. Low-latency streaming analytics

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7069333B1 (en) * 1999-08-13 2006-06-27 Fieldcentrix, Inc. Method and systems for wireless communication for a field service system
CN102023974A (en) * 2009-09-14 2011-04-20 中国移动通信集团公司 Method, device and system for processing message by message queue
CN103092682A (en) * 2011-10-28 2013-05-08 浙江大华技术股份有限公司 Asynchronous network application program processing method
CN102426539A (en) * 2011-11-01 2012-04-25 深圳市航天泰瑞捷电子有限公司 Timer task automatic processing method and system
CN110502322A (en) * 2019-07-12 2019-11-26 苏宁云计算有限公司 The triggering method and device of timer-triggered scheduler
CN110633126A (en) * 2019-09-27 2019-12-31 北京字节跳动网络技术有限公司 Information display method and device and electronic equipment

Also Published As

Publication number Publication date
CN111309467A (en) 2020-06-19

Similar Documents

Publication Publication Date Title
CN102377686B (en) Message subscription system, method and device
CN105791254B (en) Network request processing method and device and terminal
CN110336848B (en) Scheduling method, scheduling system and scheduling equipment for access request
US8606908B2 (en) Wake-up server
CN108141707A (en) A kind of method, relevant device and trunked communication system for obtaining location information
CN116566984B (en) Routing information creation method and device of k8s container cluster and electronic equipment
CN111447143A (en) Business service data transmission method and device, computer equipment and storage medium
CN111163140A (en) Method, apparatus and computer readable storage medium for resource acquisition and allocation
CN111309467B (en) Task distribution method and device, electronic equipment and storage medium
CN111491017A (en) Data distribution system, method and device for CORS reference station
EP3672203A1 (en) Distribution method for distributed data computing, device, server and storage medium
CN103299298B (en) The method and system of process business
CN108259605B (en) Data calling system and method based on multiple data centers
CN112261125B (en) Centralized unit cloud deployment method, device and system
CN106790354B (en) Communication method and device for preventing data congestion
CN110839061B (en) Data distribution method, device and storage medium
CN115102610B (en) Sharing method and device of Beidou RDSS equipment
CN108781215B (en) Network service implementation method, service controller and communication system
CN114598662A (en) Message queue cluster federal management system and method
CN110611589B (en) Control method and device of regional control system and air conditioning system
US10877800B2 (en) Method, apparatus and computer-readable medium for application scheduling
CN113535402A (en) Load balancing processing method and device based on 5G MEC and electronic equipment
CN113032188A (en) Method, device, server and storage medium for determining main server
CN113645478B (en) Live broadcast push address allocation method and system
CN114003364B (en) Data acquisition scheduling method, server, mobile device and system

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
GR01 Patent grant
GR01 Patent grant