CN111309467A - Task distribution method and device, electronic equipment and storage medium - Google Patents
Task distribution method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN111309467A CN111309467A CN202010110981.0A CN202010110981A CN111309467A CN 111309467 A CN111309467 A CN 111309467A CN 202010110981 A CN202010110981 A CN 202010110981A CN 111309467 A CN111309467 A CN 111309467A
- Authority
- CN
- China
- Prior art keywords
- task
- message queue
- scheduling
- processing module
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/548—Queue
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE 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/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
- Multi Processors (AREA)
Abstract
本发明实施例涉及信息处理技术领域,公开了一种任务分发方法及装置、电子设备及存储介质。通过响应于任务请求,从预设的第一消息队列中获取一个调度任务;将所述调度任务添加到预设的第二消息队列中;处理所述调度任务;若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列交换,可以减少资源浪费,提高任务分发的效率。
Embodiments of the present invention relate to the technical field of information processing, and disclose a task distribution method and device, an electronic device, and a storage medium. Obtain a scheduling task from the preset first message queue in response to the task request; add the scheduling task to the preset second message queue; process the scheduling task; All scheduled tasks are taken out, and the first message queue is exchanged with the second message queue, which can reduce waste of resources and improve the efficiency of task distribution.
Description
技术领域technical field
本发明涉及信息处理技术领域,特别涉及一种任务分发方法及装置、电子设备及存储介质。The present invention relates to the technical field of information processing, and in particular, to a task distribution method and device, an electronic device and a storage medium.
背景技术Background technique
在服务架构中,为了高可用性、高吞吐量等目标,常做集群化部署。在一个进程集群内,往往包括多个相同的服务进程,每个服务进程都可独立对外提供服务。各个服务进程在处理进程任务的过程中,若有多个服务进程同时命中同一个任务,往往会通过抢锁的方式来获取处理任务。In the service architecture, cluster deployment is often done for the goals of high availability and high throughput. In a process cluster, multiple identical service processes are often included, and each service process can independently provide external services. In the process of processing the task of each service process, if multiple service processes hit the same task at the same time, the processing task is often obtained by grabbing the lock.
抢锁式任务处理是指集群内所有服务进程均得到了所有的调度任务,每个服务进程进行调度任务之前,先获取一个针对该任务的分布式任务锁,若得到了锁,则对该任务进行调度,若未得到锁,说明该任务已经被其他进程处理,本进程不处理该任务。Lock-grabbing task processing means that all service processes in the cluster have obtained all scheduling tasks. Before each service process schedules tasks, it first obtains a distributed task lock for the task. If the lock is obtained, the task is locked. Scheduling, if the lock is not obtained, it means that the task has been processed by other processes, and this process does not process the task.
发明人发现相关技术中至少存在如下问题:各个进程服务之间为了抢任务造成了很大的资源浪费,而且任务分发的效率也不高。The inventor finds that the related art has at least the following problems: a large amount of resources are wasted in order to grab tasks among various process services, and the efficiency of task distribution is not high.
发明内容SUMMARY OF THE INVENTION
本发明实施方式的目的在于提供一种任务分发方法,可以减少资源浪费,提高任务分发的效率。The purpose of the embodiments of the present invention is to provide a task distribution method, which can reduce waste of resources and improve the efficiency of task distribution.
为解决上述技术问题,本发明的实施方式提供了一种任务分发方法,包括:响应于任务请求,从预设的第一消息队列中获取一个调度任务;将所述调度任务添加到预设的第二消息队列中;处理所述调度任务;若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列交换。In order to solve the above technical problems, embodiments of the present invention provide a task distribution method, including: in response to a task request, acquiring a scheduling task from a preset first message queue; adding the scheduling task to a preset first message queue In the second message queue; process the scheduling task; if it is detected that all the scheduling tasks in the first message queue are taken out, exchange the first message queue with the second message queue.
本发明的实施方式还提供了一种任务分发系统,任务分发系统包括任务分发模块、任务处理模块以及队列处理模块;所述任务分发模块用于响应于所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务;所述队列处理模块用于将所述调度任务添加到预设的第二消息队列中;所述任务处理模块用于处理所述调度任务;所述队列处理模块还用于若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列互换。Embodiments of the present invention also provide a task distribution system, the task distribution system includes a task distribution module, a task processing module and a queue processing module; the task distribution module is configured to respond to a task request sent by the task processing module, by The queue processing module acquires a scheduling task from the preset first message queue; the queue processing module is used to add the scheduling task to the preset second message queue; the task processing module is used to process 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 the scheduling tasks in the first message queue are taken out.
本发明的实施方式还提供了一种电子设备,包括存储器和处理器,存储器存储计算机程序,处理器运行程序时执行:响应于任务请求,从预设的第一消息队列中获取一个调度任务;将所述调度任务添加到预设的第二消息队列中;处理所述调度任务;若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列交换。An embodiment of the present invention also provides an electronic device, including a memory and a processor, the memory stores a computer program, and when the processor runs the program, the processor executes: in response to a task request, acquires a scheduling task from a preset first message queue; Add the scheduling task to the preset second message queue; process the scheduling task; if it is detected that the scheduling tasks in the first message queue are all taken out, combine the first message queue with the second message Queue exchange.
本发明的实施方式还提供了一种非易失性存储介质,用于存储计算机可读程序,计算机可读程序用于供计算机执行如上的任务分发方法。Embodiments of the present invention also provide a non-volatile storage medium for storing a computer-readable program, where the computer-readable program is used for a computer to execute the above task distribution method.
本发明实施方式相对于现有技术而言,响应于任务请求,从预设的第一消息队列中获取一个调度任务,并将所述调度任务添加到预设的第二消息队列中,使用消息队列来实现任务的分发,可避免各个进程为获取处理任务而消耗原本可用于对调度任务进行处理的资源,提高任务分发的效率;设计一个第二消息队列来存放在一轮调度任务中已经被调取了的任务,可保证在一个调度周期内,每个网格的调度任务只有一次,避免在一个调度周期内反复调度各个网格的调度任造成的资源浪费,在第一消息队列中的任务都比取出之后,将第一消息队列与第二消息队列互换,能够保证下一轮任务调度的顺利进行。Compared with the prior art, the embodiment of the present invention acquires a scheduling task from a preset first message queue in response to a task request, adds the scheduling task to a preset second message queue, and uses the message Queue to realize task distribution can avoid each process consuming resources that can be used to process scheduling tasks in order to obtain processing tasks, and improve the efficiency of task distribution; design a second message queue to store in a round of scheduling tasks that have been The fetched task can ensure that each grid has only one scheduling task in a scheduling cycle, avoiding the waste of resources caused by repeatedly scheduling the scheduling tasks of each grid in a scheduling cycle. After the tasks are all taken out, the first message queue is exchanged with the second message queue, which can ensure the smooth progress of the next round of task scheduling.
另外,上述任务分发方法应用于包含任务分发模块、任务处理模块以及队列处理模块的任务分发系统;响应于任务请求,从预设的第一消息队列中获取一个调度任务,具体为:任务分发模块响应于任务处理模块发送的任务请求,通过队列处理模块从预设的第一消息队列中获取一个调度任务;将调度任务添加到预设的第二消息队列中,具体为:队列处理模块将调度任务添加到预设的第二消息队列中;处理调度任务具体为,任务处理模块处理调度任务;若检测到第一消息队列中的调度任务都被取出,将第一消息队列与第二消息队列的身份互换,具体为,队列处理模块若检测到第一消息队列中的调度任务都被取出,将第一消息队列与第二消息队列的身份互换。提供任务分发模块来完成进程任务的分发,由任务分发模块接收任务处理模块发的任务请求,并将获取到的调度任务发送给任务处理模块,避免各个任务处理模块为获取处理任务而消耗原本可用于对调度任务进行处理的资源。In addition, the above task distribution method is applied to a task distribution system including a task distribution module, a task processing module and a queue processing module; in response to a task request, acquiring a scheduling task from a preset first message queue, specifically: a task distribution module In response to the task request sent by the task processing module, obtain a scheduling task from the preset first message queue through the queue processing module; add the scheduling task to the preset second message queue, specifically: the queue processing module will schedule The task is added to the preset second message queue; the processing of the scheduling task is specifically, the task processing module processes the scheduling task; if it is detected that the scheduling tasks in the first message queue are all taken out, the first message queue and the second message queue are Specifically, if the queue processing module detects that all the scheduling tasks in the first message queue are taken out, the identities of the first message queue and the second message queue are exchanged. Provide a task distribution module to complete the distribution of process tasks. The task distribution module receives the task request sent by the task processing module, and sends the obtained scheduling task to the task processing module, so as to avoid each task processing module consuming the original available processing tasks for obtaining processing tasks. Resources for processing scheduled tasks.
另外,所述任务分发模块的数量为多个且形成任务分发模块集群;响应于所述任务请求的所述任务分发模块为所述任务分发模块集群中的一个;所述任务分发系统还包括选择模块,在所述任务分发模块响应于所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中调取的调度任务之前,还包括:所述选择模块基于预设的分配原则将所述任务请求分配给所述任务分发模块。多个任务分发模块形成任务分发模块集群,由选择模块来选择一个进行任务分发的任务分发模块,直接通过任务分发模块来将任务分发给任务获取模块,将多个任务分发模块集中起来,形成任务分发模块集群,方便对任务分发模块的统一管理,且更容易对任务分发模块进行软硬件的更新。In addition, the number of the task distribution modules is multiple 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 includes a selection module, before the task distribution module responds to the task request sent by the task processing module, and before the scheduling task fetched from the preset first message queue by the queue processing module, further comprising: the selection module is based on A preset assignment principle assigns the task request to the task distribution module. Multiple task distribution modules form a task distribution module cluster. The selection module selects a task distribution module for task distribution, directly distributes tasks to the task acquisition module through the task distribution module, and gathers multiple task distribution modules to form tasks. The distribution module cluster facilitates the unified management of the task distribution module, and makes it easier to update the software and hardware of the task distribution module.
另外,上述分配原则为负载均衡原则。依据负载均衡原则,来选择任务分发模块进行当前的任务分发工作,使得各个任务分发模块的负载相对均衡,任务分发模块集群中的资源被利用的更重复。In addition, the above allocation principle is a load balancing principle. According to the load balancing principle, the task distribution module is selected to perform the current task distribution work, 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, a plurality of task distribution modules in the above-mentioned task distribution module cluster are selected in turn. The target task distribution module is selected by the task processing module, and each task processing module is selected in turn, which can achieve load balance as much as possible from the perspective of the task processing module.
另外,上述所述任务分发模块与所述任务处理模块的数量相等且一一对应;所述任务分发模块响应于所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务,具体为,所述任务分发模块响应于对应的所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务。为每个任务处理模块设置对应的任务分发模块,使得任务分发更具针对性。In addition, the number of the above-mentioned task distribution modules and the task processing modules are equal and in one-to-one correspondence; the task distribution module responds to the task request sent by the task processing module, through the queue processing module, from a preset number of Acquiring a scheduling task from a message queue, specifically, the task distribution module acquires a scheduling task from a preset first message queue through the queue processing module in response to a task request sent by the corresponding task processing module . A corresponding task distribution module is set for each task processing module to make task distribution more targeted.
附图说明Description of drawings
图1是根据本发明第一实施方式中的任务分发方法流程图;1 is a flowchart of a task distribution method according to a first embodiment of the present invention;
图2是根据本发明第一实施方式中的各个模块间的连接关系结构示意图;FIG. 2 is a schematic structural diagram of the connection relationship between the modules according to the first embodiment of the present invention;
图3是根据本发明第二实施方式中的任务分发方法流程图;3 is a flowchart of a task distribution method according to a second embodiment of the present invention;
图4是根据本发明第二实施方式中的各个模块间的连接关系结构示意图;4 is a schematic structural diagram of a connection relationship between modules according to a second embodiment of the present invention;
图5是根据本发明第三实施方式中的任务分发系统结构示意图;5 is a schematic structural diagram of a task distribution system according to a third embodiment of the present invention;
图6是根据本发明第四实施方式中的电子设备结构示意图。FIG. 6 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合附图对本发明的各实施方式进行详细的阐述。然而,本领域的普通技术人员可以理解,在本发明各实施方式中,为了使读者更好地理解本申请而提出了许多技术细节。但是,即使没有这些技术细节和基于以下各实施方式的种种变化和修改,也可以实现本申请所要求保护的技术方案。以下各个实施例的划分是为了描述方便,不应对本发明的具体实现方式构成任何限定,各个实施例在不矛盾的前提下可以相互结合相互引用。In order to make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the various embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, those of ordinary skill in the art can appreciate that, in the various embodiments of the present invention, many technical details are set forth in order for the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in the present application can be realized. The following divisions of the various embodiments are for the convenience of description, and should not constitute any limitation on the specific implementation of the present invention, and the various embodiments may be combined with each other and referred to each other on the premise of not contradicting each other.
在外卖领域中,可以将各个配送区域划分为一个个的网格,在每个网格内存在多个订单任务,在实际实施中,会设计多个任务处理模块来处理每个网格中的订单任务,将每个网格看成一项调度任务,任务处理模块在一个处理周期内可处理一项网格调度任务。In the field of food delivery, each delivery area can be divided into grids, and there are multiple order tasks in each grid. In actual implementation, multiple task processing modules will be designed to process the For order tasks, each grid is regarded as a scheduling task, and the task processing module can process a grid scheduling task in one processing cycle.
本发明的第一实施方式涉及一种任务分发方法,如图1所示,该方法包括:The first embodiment of the present invention relates to a task distribution method, as shown in FIG. 1 , the method includes:
步骤S101,响应于任务请求,从预设的第一消息队列中获取一个调度任务。Step S101, in response to the task request, acquire a scheduling task from a preset first message queue.
具体地说,本方案应用于包含任务分发模块、任务处理模块以及队列处理模块的任务分发系统。在该任务分发系统中,可预先设一个第一消息队列来存放网格的调度任务,第一消息队列模块中存放的各项调度任务及其排列顺序,由第一个启动的任务处理模块对消息队列模块进行初始化得到。当任务分发系统中的任务处理模块检测到自身的待处理任务不够时,可向任务分发模块发送任务请求,任务分发模块响应于这个请求,通过一个数据接口来接收任务处理模块发送的任务请求,并通过队列处理模块从初始化完成后的第一消息队列中获取调度任务。需要说明的是,这个调度任务是从第一消息队列的头部取出的调度任务。在本实施方式中,提供任务分发模块来完成进程任务的分发,由任务分发模块接收任务处理模块发送的任务请求,并将获取到的调度任务发送给任务处理模块,避免各个任务处理模块为获取处理任务而消耗原本可用于对调度任务进行处理的资源,同时,将调度任务的分配工作集中在任务分发模块进行,可提高任务分发的效率。Specifically, this solution is applied to a task distribution system including 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 the scheduling tasks of the grid. The scheduling tasks and their arrangement order stored in the first message queue module are processed by the first activated task processing module. The message queue module is initialized. When the task processing module in the task distribution system detects that its own tasks to be processed are not enough, it can send a task request to the task distribution module. The task distribution module responds to this request and receives the task request sent by the task processing module through a data interface. The scheduling task is obtained from the first message queue after the initialization is completed through the queue processing module. It should be noted that this scheduling task is a scheduling task taken from the head of the first message queue. In this embodiment, a task distribution module is provided to complete the distribution of process tasks, the task distribution module receives the task request sent by the task processing module, and sends the obtained scheduling task to the task processing module, so as to prevent each task processing module from obtaining Processing tasks consumes resources that can be used to process scheduling tasks, and at the same time, the assignment of scheduling tasks is concentrated in the task distribution module, which can improve the efficiency of task distribution.
步骤S102,将调度任务添加到预设的第二消息队列中。Step S102, adding the scheduling task to the preset second message queue.
具体地说,在从第一消息队列中获取到调度任务时,队列处理模块会将这个从第一调度任务队列中获取的调度任务添加到第二消息队列中,在实际实施中,会将从第一消息队列的头部取出的调度任务放到第二消息队列的尾部,这样可以保证第二消息队列中消息的存放顺序与第一消息队列一致。Specifically, when the scheduling task is obtained from the first message queue, the queue processing module will add the scheduling task obtained from the first scheduling task queue to the second message queue. The scheduling task fetched from the head of the first message queue is placed at the tail of the second message queue, so that the storage order of messages in the second message queue can be guaranteed to be consistent with the first message queue.
在一个具体的例子中,第一消息队列为消息队列A,第二消息队列为消息队列B。在任务分发模块获取调度任务的过程中,消息队列模块中的处理中心会从消息队列A的头部取出一个调度任务,将这个调度任务发送给任务分发模块,并将这个调度任务放到消息队列B的尾部,在一轮调度完成后,消息队列A中已经没有调度任务了,处理中心再控制将队列A和队列B进行交换,这样,在下一轮调度中,就会从消息队列B的头部获取调度任务并放到消息队列A的尾部。In a specific example, the first message queue is message queue A, and the second message queue is message queue B. In the process of obtaining the scheduling task by the task distribution module, the processing center in the message queue module will take out a scheduling task from the head of the message queue A, send the scheduling task to the task distribution module, and put the scheduling task in the message queue At the end of B, after one round of scheduling is completed, there is no scheduling task in message queue A, and the processing center controls the exchange of queue A and queue B. In this way, in the next round of scheduling, the message queue B will be sent from the head of the message queue B. The department obtains the scheduled task and puts it at the tail of the message queue A.
步骤S103,处理调度任务。Step S103, processing the scheduling task.
具体地说,任务处理模块在从消息队列模块获中取到调度任务后,可通过数据接口将这个调度任务发送给发送任务请求的任务请求模块,再由任务请求模块去。Specifically, after obtaining the scheduling task from the message queue module, the task processing module can send the scheduling task to the task requesting module that sends the task request through the data interface, and then the task requesting module sends the scheduling task.
在一个具体的例子中,消息队列中存储的调度任务,可以是各个网格的编号,任务处理模块在处理任务的过程中,可根据这个编号找到对应的网格,并在存储订单任务的数据库找出这个网格中的订单任务并进行处理。仅以网格编号来代表调度任务,使得消息队列不用对网格中具体的订单任务进行管理。In a specific example, the scheduling task stored in the message queue can be the number of each grid. During the process of processing the task, the task processing module can find the corresponding grid according to this number, and store the order task in the database of the order task. Find order tasks in this grid and process them. Only the grid number is used to represent the scheduling task, so that the message queue does not need to manage the specific order tasks in the grid.
步骤S104:若检测到第一消息队列中的调度任务都被取出,将第一消息队列与第二消息队列交换。Step S104: If it is detected that all the scheduling tasks in the first message queue are taken out, the first message queue is exchanged with the second message queue.
具体地说,队列处理模块会对第一消息队列和第二消息队列进行监控,在检测到第一消息队列中的调度任务都被取出后,将第一消息队列与第二消息队列交换,也就是将第一消息队列的首地址与第二消息队列的首地址交换,使得下次任务分发模块能够从第一消息队列中获取到任务(因为该第一消息队列是原来的第二消息队列,其中包含了所有的调度任务)。本实施方式中,设计第二消息队列来存放在一轮调度中已经被获取了的任务,可保证在一个调度周期内,每个网格的调度任务只被调度一次,避免在一个调度周期内反复调度各个网格的调度任务造成的资源浪费。Specifically, the queue processing module will monitor the first message queue and the second message queue, and after detecting that the scheduling tasks in the first message queue have been taken out, exchange the first message queue with the second message queue, and also exchange the first message queue with the second message queue. It is to exchange the first address of the first message queue with the first address of the second message queue, so that the next task distribution module can obtain tasks from the first message queue (because the first message queue is the original second message queue, which contains all scheduled tasks). In this implementation manner, the second message queue is designed to store the tasks that have been acquired in one round of scheduling, which can ensure that the scheduling tasks of each grid are only scheduled once in one scheduling period, avoiding the need for scheduling tasks in one scheduling period. The waste of resources caused by the repeated scheduling of the scheduling tasks of each grid.
在本实施方式中,任务处理模块与任务分发模块的数量相等且一一对应,每个任务分发模块与其对应的任务处理模块集成在一起,形成一个处理调度任务的集群进程;每个任务分发模块接收其对应的任务处理模块发送的任务请求;通过队列处理模块从预设的第一消息队列中获取一个调度任务,并且,在获取到调度任务后,任务分发模块也只会将获取到的调度任务发送给对应的任务处理模块。本实施方式为每个任务处理模块设置对应的任务分发模块,使得任务分发更具针对性。In this embodiment, the number of task processing modules and task distribution modules are equal and in one-to-one correspondence, and each task distribution module is integrated with its corresponding task processing module to form a cluster process for processing scheduling tasks; each task distribution module Receive the task request sent by its corresponding task processing module; obtain a scheduling task from the preset first message queue through the queue processing module, and after obtaining the scheduling task, the task distribution module will only dispatch the obtained scheduling task. The task is sent to the corresponding task processing module. In this embodiment, a corresponding task distribution module is set for each task processing module, so that the task distribution is more targeted.
下面对本实施方式的订单调度方法的实现细节进行具体的说明,以下内容仅为方便理解提供的实现细节,并非实施本方案的必须。The implementation details of the order scheduling method in this embodiment will be specifically described below. The following content is only provided for the convenience of understanding, and is not necessary for implementing this solution.
以每个任务处理模块对应一个任务分发模块为例,各个模块之间的连接关系如图2所示,每个任务分发模块与其对应的任务处理模块集成在一起,形成一个处理调度任务的集群进程.消息队列模块的消息队列A中,存储有3个网格的调度任务,从队列头部开始,存放的分别是网格3、网格1、网格2对应的编号。当任务处理模块1检测到自身的待处理任务队列没有被填满,向对应的任务分发模块1发送任务请求,任务分发模块1从消息队列模块中获取调度任务,这个调度任务是由消息队列模块中的处理中心从消息队列A头部取出的网格3的调度任务;任务分发模块1获取到这个调度任务后,将这个调度任务发送给任务处理模块1;任务处理模块1在对网格3的调度任务进行任务处理时,在存储订单任务的数据库找出网格3中的订单任务并进行处理。Taking each task processing module corresponding to a task distribution module as an example, the connection relationship between the modules is shown in Figure 2. Each task distribution module is integrated with its corresponding task processing module to form a cluster process that processes scheduling tasks. .In the message queue A of the message queue module, the scheduling tasks of three grids are stored. Starting from the head of the queue, the numbers corresponding to grid 3, grid 1, and grid 2 are stored respectively. When the task processing module 1 detects that its pending task queue is not full, it sends a task request to the corresponding task distribution module 1, and the task distribution module 1 obtains the scheduling task from the message queue module. This scheduling task is created by the message queue module. The processing center in the message queue A takes out the scheduling task of grid 3 from the head of the message queue A; after the task distribution module 1 obtains the scheduling task, it sends the scheduling task to the task processing module 1; the task processing module 1 is on the grid 3 When the scheduling task of the Grid 3 performs task processing, find out the order task in grid 3 in the database storing the order task and process it.
本实施方式相对现有技术而言,响应于任务请求,从预设的第一消息队列中获取一个调度任务,并将调度任务添加到预设的第二消息队列中,使用消息队列来实现任务的分发,可避免各个进程为获取处理任务而消耗原本可用于对调度任务进行处理的资源,提高任务分发的效率;设计一个第二消息队列来存放在一轮调度任务中已经被调取了的任务,可保证在一个调度周期内,每个网格的调度任务只有一次,避免在一个调度周期内反复调度各个网格的调度任造成的资源浪费,在第一消息队列中的任务都比取出之后,将第一消息队列与第二消息队列互换,能够保证下一轮任务调度的顺利进行。Compared with the prior art, this embodiment obtains a scheduling task from a preset first message queue in response to a task request, adds the scheduling task to a preset second message queue, and uses the message queue to implement the task It can prevent each process from consuming resources that can be used to process scheduling tasks in order to obtain processing tasks, and improve the efficiency of task distribution; design a second message queue to store the messages that have been called in a round of scheduling tasks. It can ensure that in a scheduling cycle, each grid has only one scheduling task, avoiding the waste of resources caused by repeatedly scheduling the scheduling tasks of each grid in a scheduling cycle, and the tasks in the first message queue are less After that, the first message queue is exchanged with the second message queue, which can ensure the smooth progress of the next round of task scheduling.
本发明的第二实施方式涉及一种任务分发方法,本实施方式中与第一实施方式大致相同,主要区别在于,在本实施方式中,任务分发模块与任务处理模块不再是一一对应,多个任务分发模块形成一个任务分发模块集群,本实施方式的流程图如图3所示,下面进行具体说明。The second embodiment of the present invention relates to a task distribution method. This embodiment is substantially the same as the first embodiment. The main difference is that, in this embodiment, the task distribution module and the task processing module are no longer in a one-to-one correspondence. A plurality of task distribution modules form a task distribution module cluster. The flowchart of this embodiment is shown in FIG. 3 , which will be described in detail below.
在本实施方式中,任务分发系统中还包括一个选择模块,在第一实施方式中提到的任务分发模块响应于任务处理模块发送的任务请求,通过队列处理模块从预设的第一消息队列中调取的调度任务之前,还包括下面的步骤S301。In this embodiment, the task distribution system further includes a selection module. The task distribution module mentioned in the first embodiment responds to the task request sent by the task processing module, and sends the message from the preset first message queue through the queue processing module. The following step S301 is also included before the scheduling task retrieved from the .
步骤S301,选择模块基于预设的分配原则将任务请求分配给任务分发模块。Step S301, the selection module allocates the task request to the task distribution module based on a preset allocation principle.
具体地说,当有任务处理模块检测到自身的待处理任务队列没有被填满时,可向任务分发模块集群发送任务请求,任务分发模块集群将接收到的任务请求发送给一个目标任务分发模块,由目标任务分发模块接收这个任务请求并进行下一步的处理。目标任务分发模块可由任务分发模块集群中的选择模块选择,选择模块依据负载均衡的原则,从多个任务分发模块中选择一个任务分发模块,作为接收任务请求的目标任务分发单元。由任务分发模块集群中的选择模块依据负载均衡原则,来选择任务分发模块进行当前的任务分发工作,使得各个任务分发模块的负载相对均衡,任务分发模块集群中的资源被利用的更重复。Specifically, when a task processing module detects that its pending task queue is not full, it can send a task request to the task distribution module cluster, and the task distribution module cluster sends the received task request to a target task distribution module , the target task distribution module receives the task request and performs the next step of processing. The target task distribution module can be selected by the selection module in the task distribution module cluster. The selection module selects a task distribution module from multiple task distribution modules according to the principle of load balancing as the target task distribution unit for receiving the task request. 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 also be selected by the task processing module, and each task distribution module in the task distribution module cluster can be selected by the task processing module in turn as the task distribution module that receives the task request. The target task distribution module is selected by the task processing module, and each task processing module is selected in turn, which can realize load balancing from the perspective of the task processing module.
需要说明的是,任务处理模块可预先获取任务分发模块集群中各个任务分发模块分别对应的标识信息,在选择目标任务分发模块时,从获取的这些标识信息中,选择一个目标标识信息,并将目标标识信息对应的任务分发模块作为目标任务分发模块。而且,在具体实施中,各个任务分发模块可运行在同一服务器上,也可分别运行在不同的任务分发服务器上;当各个任务分发模块分别运行在不同的服务器上时,每个任务分发模块的标识信息,可以是其对应的任务分发服务器的IP地址。It should be noted that the task processing module can obtain the identification information corresponding to each task distribution module in the task distribution module cluster in advance, and when selecting the target task distribution module, select a target identification information from the obtained identification information, The task distribution module corresponding to the target identification information is used as the target task distribution module. Moreover, in the specific implementation, each task distribution module can run on the same server, and can also run on different task distribution servers; when each task distribution module runs on different servers, the The identification information may be the IP address of the corresponding task distribution server.
步骤S302,响应于任务请求,从预设的第一消息队列中获取一个调度任务。Step S302, in response to the task request, obtain a scheduling task from a preset first message queue.
步骤S303,将调度任务添加到预设的第二消息队列中。Step S303, adding the scheduling task to the preset second message queue.
步骤S304,处理调度任务。Step S304, processing the scheduling task.
步骤S305,若检测到第一消息队列中的调度任务都被取出,将第一消息队列与第二消息队列交换。Step S305, if it is detected that all the scheduling tasks in the first message queue are taken out, the first message queue is exchanged with the second message queue.
步骤S302至步骤S305与本发明第一实施方式中的步骤S101至步骤S104大致相同,为避免重复,这里不再一一赘述。Steps S302 to S305 are substantially the same as steps S101 to S104 in the first embodiment of the present invention, and to avoid repetition, they will not be repeated here.
在一个例子中,本实施方式中的各个模块之间的连接关系如图4所示,各个任务分发模块(图中仅画出了三个,实际上可以是多个)形成一个任务分发模块集群,各个任务处理模块(图中仅画出了三个,实际上可以是多个)形成一个任务处理模块集群。当任务处理模块集群中的某个任务处理模块检测到自身的待处理任务队列没有被填满时,向任务分发模块集群发送任务请求,任务分发模块集群接收到的任务请求后,由其中的目标任务分发模块从消息队列模块中获取调度任务,并将获取到的调度任务发送给任务处理模块。In an example, the connection relationship between the various modules in this implementation manner is shown in FIG. 4 , and each task distribution module (only three are shown in the figure, but may actually be multiple) form a task distribution module cluster , and each task processing module (only three are drawn in the figure, in fact there may be more than one) form a task processing module cluster. When a task processing module in the task processing module cluster detects that its pending task queue is not full, it sends a task request to the task distribution module cluster. After the task distribution module cluster receives the task request, the target The task distribution module obtains the scheduling task from the message queue module, and sends the obtained scheduling task to the task processing module.
本实施方式相对第一代实施方式而言,将多个任务分发模块集中起来,形成任务分发模块集群,方便对任务分发模块的统一管理,且更容易对任务分发模块进行软硬件的更新。Compared with the first-generation embodiment, this embodiment integrates multiple task distribution modules to form a task distribution module cluster, which facilitates unified management of the task distribution modules and makes it easier to update the software and hardware of the task distribution modules.
本发明的第三实施方式涉及一种任务分发系统,如图5所示,该任务分发系统包括:任务分发模块501、任务处理模块502以及队列处理模块503;任务分发模块501用于响应于任务处理模块502发送的任务请求,通过队列处理模块503从预设的第一消息队列中获取一个调度任务;队列处理模块503用于将调度任务添加到预设的第二消息队列中;任务处理模块502用于处理调度任务;队列处理模块503还用于若检测到第一消息队列中的调度任务都被取出,将第一消息队列与第二消息队列的身份互换。The third embodiment of the present invention relates to a task distribution system. As shown in FIG. 5 , the task distribution system includes: a
在一个例子中,上述任务分发模块501的数量为多个且形成任务分发模块501集群;响应于任务请求的任务分发模块501为任务分发模块501集群中的一个;任务分发系统还包括选择模块,在任务分发模块501响应于任务处理模块502发送的任务请求,通过队列处理模块503从预设的第一消息队列中调取的调度任务之前,还包括:选择模块基于预设的分配原则将任务请求分配给任务分发模块501。In one example, the number of the above-mentioned
在一个例子中,上述分配原则为负载均衡原则。In one example, the above allocation principle is a load balancing principle.
在一个例子中,上述任务分发模块501集群中的多个任务分发模块501被轮流选择。In one example, multiple
在一个例子中,任务分发模块501与任务处理模块502的数量相等且一一对应;任务分发模块501响应于任务处理模块502发送的任务请求,通过队列处理模块503从预设的第一消息队列中获取一个调度任务,具体为,任务分发模块501响应于对应的任务处理模块502发送的任务请求,通过队列处理模块503从预设的第一消息队列中获取一个调度任务。In one example, the number of
不难发现,本实施方式为与第一至第二实施方式中任一实施方式相对应的系统实施例,本实施方式可与第一至第二实施方式中任一实施方式互相配合实施。第一至第二实施方式中提到的相关技术细节在本实施方式中依然有效,为了减少重复,这里不再赘述。相应的,本实施方式中提到的相关技术细节也可应用在第一实施方式至第二实施方式中。It is not difficult to find that this embodiment is a system example corresponding to any of the first to second embodiments, and this embodiment can be implemented in cooperation with any of the first to second embodiments. The related technical details mentioned in the first to second embodiments are still valid in this embodiment, and are not repeated here in order to reduce repetition. Correspondingly, the relevant technical details mentioned in this embodiment can also be applied to the first embodiment to the second embodiment.
值得一提的是,本实施方式中所涉及到的各单元均为逻辑单元,在实际应用中,一个逻辑单元可以是一个物理单元,也可以是一个物理单元的一部分,还可以以多个物理单元的组合实现。此外,为了突出本发明的创新部分,本实施方式中并没有将与解决本发明所提出的技术问题关系不太密切的单元引入,但这并不表明本实施方式中不存在其它的单元。It is worth mentioning that each unit involved in this embodiment is a logical unit. In practical applications, a logical unit may be a physical unit, a part of a physical unit, or multiple physical units. A composite implementation of the unit. In addition, in order to highlight the innovative part of the present invention, this embodiment does not introduce units that are not closely related to solving the technical problem proposed by the present invention, but this does not mean that there are no other units in this embodiment.
本发明的第四实施方式涉及一种电子设备,如图6所示,该电子设备600包括:至少一个处理器601;以及,与至少一个处理器601通信连接的存储器602;以及,与扫描装置通信连接的通信组件603,通信组件603在处理器601的控制下接收和发送数据;其中,存储器602存储有可被至少一个处理器601执行的指令,指令被至少一个处理器601执行以实现:接收任务处理模块发送的任务请求;从预设的消息队列模块中获取调度任务;将获取到的调度任务发送给任务处理模块。The fourth embodiment of the present invention relates to an electronic device. As shown in FIG. 6 , the
具体地,该终端设备600包括:一个或多个处理器601以及存储器602,图6中以一个处理器601为例。处理器601、存储器602可以通过总线或者其他方式连接,图6中以通过总线连接为例。存储器602作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块。处理器601通过运行存储在存储器602中的非易失性软件程序、指令以及模块,从而执行设备的各种功能应用以及数据处理,即实现上述任务分发方法。Specifically, the
存储器602可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储选项列表等。此外,存储器602可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。在一些实施方式中,存储器602可选包括相对于处理器601远程设置的存储器602,这些远程存储器602可以通过网络连接至外接设备。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The
一个或者多个模块存储在存储器602中,当被一个或者多个处理器601执行时,执行上述第一实施方式或第二实施方式中的任务分发方法。One or more modules are stored in the
值得一提的是,本实施方式中所涉及到的各单元均为逻辑单元,在实际应用中,一个逻辑单元可以是一个物理单元,也可以是一个物理单元的一部分,还可以以多个物理单元的组合实现。此外,为了突出本发明的创新部分,本实施方式中并没有将与解决本发明所提出的技术问题关系不太密切的单元引入,但这并不表明本实施方式中不存在其它的单元。It is worth mentioning that each unit involved in this embodiment is a logical unit. In practical applications, a logical unit may be a physical unit, a part of a physical unit, or multiple physical units. A composite implementation of the unit. In addition, in order to highlight the innovative part of the present invention, this embodiment does not introduce units that are not closely related to solving the technical problem proposed by the present invention, but this does not mean that there are no other units in this embodiment.
本发明的第五实施方式涉及一种非易失性存储介质,用于存储计算机可读程序,计算机可读程序用于供计算机执行上述部分或全部的方法实施例。The fifth embodiment of the present invention relates to a non-volatile storage medium for storing a computer-readable program, and the computer-readable program is used for a computer to execute some or all of the above method embodiments.
即,本领域技术人员可以理解,实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-OnlyMemory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。That is, those skilled in the art can understand that all or part of the steps in the method for implementing the above embodiments can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium and includes several instructions to make a device ( It may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods of the various embodiments of the present application. The aforementioned storage medium includes: U disk, removable hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes.
本领域的普通技术人员可以理解,上述各实施方式是实现本发明的具体实施例,而在实际应用中,可以在形式上和细节上对其作各种改变,而不偏离本发明的精神和范围。Those skilled in the art can understand that the above-mentioned embodiments are specific examples for realizing the present invention, and in practical applications, various changes in form and details can be made without departing from the spirit and the spirit of the present invention. scope.
本申请实施例公开了A1.一种任务分发方法,包括:The embodiment of the present application discloses A1. A task distribution method, comprising:
响应于任务请求,从预设的第一消息队列中获取一个调度任务;In response to the task request, obtain a scheduling task from the preset first message queue;
将所述调度任务添加到预设的第二消息队列中;adding the scheduling task to a preset second message queue;
处理所述调度任务;processing the scheduled task;
若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列交换。If it is detected that all the scheduling tasks in the first message queue are taken out, the first message queue is exchanged with the second message queue.
A2.如A1所述的任务分发方法,所述任务分发方法应用于包含任务分发模块、任务处理模块以及队列处理模块的任务分发系统;A2. The task distribution method as described in A1, 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;
所述响应于任务请求,从预设的第一消息队列中获取一个调度任务,具体为:所述任务分发模块响应于所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务;The obtaining a scheduling task from the preset first message queue in response to the task request is specifically: the task distribution module responds to the task request sent by the task processing module, and sends the scheduled task from the preset first message queue through the queue processing module. Obtain a scheduling task from the first message queue of ;
所述将所述调度任务添加到预设的第二消息队列中,具体为:所述队列处理模块将所述调度任务添加到预设的第二消息队列中;The adding the scheduling task to the preset second message queue is specifically: the queue processing module adds the scheduling task to the preset second message queue;
所述处理所述调度任务具体为,所述任务处理模块处理所述调度任务;The processing of the scheduling task is specifically: the task processing module processes the scheduling task;
所述若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列交换,具体为,所述队列处理模块若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列交换。If it is detected that all the scheduling tasks in the first message queue are taken out, the first message queue is exchanged with the second message queue, specifically, if the queue processing module detects that the scheduling tasks in the first message queue are All scheduled tasks are taken out, and the first message queue is exchanged with the second message queue.
A3.如A2所述的任务分发方法,所述任务分发模块的数量为多个且形成任务分发模块集群;响应于所述任务请求的所述任务分发模块为所述任务分发模块集群中的一个;A3. The task distribution method according to A2, wherein the number of the task distribution modules is multiple 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 includes a selection module, before the task distribution module responds to the task request sent by the task processing module, and before the scheduling task fetched from the preset first message queue by the queue processing module, Also includes:
所述选择模块基于预设的分配原则将所述任务请求分配给所述任务分发模块。The selection module allocates the task request to the task distribution module based on a preset allocation principle.
A4.如A3所述的任务分发方法,所述分配原则为负载均衡原则。A4. The task distribution method according to A3, wherein the distribution principle is a load balancing principle.
A5.如A3所述的任务分发方法,A5. The task distribution method as described in A3,
所述任务分发模块集群中的多个任务分发模块被轮流选择。A plurality of task distribution modules in the task distribution module cluster are selected in turn.
A6.如A2所述的任务分发方法,所述任务分发模块与所述任务处理模块的数量相等且一一对应;A6. The task distribution method according to A2, wherein the task distribution modules and the task processing modules are equal in number and correspond one-to-one;
所述任务分发模块响应于所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务,具体为,所述任务分发模块响应于对应的所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务。The task distribution module obtains a scheduling task from the preset first message queue through the queue processing module in response to the task request sent by the task processing module, specifically, the task distribution module responds to the corresponding The task request sent by the task processing module is used to obtain a scheduling task from the preset first message queue through the queue processing module.
本申请实施例公开了B1.一种任务分发系统,所述任务分发系统包括任务分发模块、任务处理模块以及队列处理模块;The embodiment of the present application discloses B1. A task distribution system, the task distribution system includes a task distribution module, a task processing module and a queue processing module;
所述任务分发模块用于响应于所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务;The task distribution module is configured to acquire a scheduling task from a preset first message queue through the queue processing module in response to a task request sent by the task processing module;
所述队列处理模块用于将所述调度任务添加到预设的第二消息队列中;The queue processing module is configured to add the scheduling task to a preset second message queue;
所述任务处理模块用于处理所述调度任务;The task processing module is used to process the scheduling task;
所述队列处理模块还用于若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列的身份互换。The queue processing module is further configured to exchange the identities of the first message queue and the second message queue if it is detected that all the scheduling tasks in the first message queue have been taken out.
本申请实施例公开了C1.一种电子设备,包括存储器和处理器,存储器存储计算机程序,处理器运行程序时执行:The embodiment of the present application discloses C1. An electronic device, comprising a memory and a processor, the memory stores a computer program, and the processor executes the program when running the program:
响应于任务请求,从预设的第一消息队列中获取一个调度任务;In response to the task request, obtain a scheduling task from the preset first message queue;
将所述调度任务添加到预设的第二消息队列中;adding the scheduling task to a preset second message queue;
处理所述调度任务;processing the scheduled task;
若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列交换。If it is detected that all the scheduling tasks in the first message queue are taken out, the first message queue is exchanged with the second message queue.
C2.如C1所述的电子设备,所述电子设备包含任务分发模块、任务处理模块以及队列处理模块;C2. The electronic device as described in C1, the electronic device comprises a task distribution module, a task processing module and a queue processing module;
所述响应于任务请求,从预设的第一消息队列中获取一个调度任务,具体为:所述任务分发模块响应于所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务;The obtaining a scheduling task from the preset first message queue in response to the task request is specifically: the task distribution module responds to the task request sent by the task processing module, and sends the scheduled task from the preset first message queue through the queue processing module. Obtain a scheduling task from the first message queue of ;
所述将所述调度任务添加到预设的第二消息队列中,具体为:所述队列处理模块将所述调度任务添加到预设的第二消息队列中;The adding the scheduling task to the preset second message queue is specifically: the queue processing module adds the scheduling task to the preset second message queue;
所述处理所述调度任务具体为,所述任务处理模块处理所述调度任务;The processing of the scheduling task is specifically: the task processing module processes the scheduling task;
所述若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列的身份互换,具体为,所述队列处理模块若检测到第一消息队列中的调度任务都被取出,将所述第一消息队列与所述第二消息队列的身份互换。If it is detected that the scheduling 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 the first message All scheduling tasks in the queue are taken out, and the identities of the first message queue and the second message queue are exchanged.
C3.如C2所述的电子设备,所述任务分发模块的数量为多个且形成任务分发模块集群;响应于所述任务请求的所述任务分发模块为所述任务分发模块集群中的一个;C3. The electronic device according to C2, wherein the number of the task distribution modules is multiple 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 includes a selection module, before the task distribution module responds to the task request sent by the task processing module, and before the scheduling task fetched from the preset first message queue by the queue processing module, Also includes:
所述选择模块基于预设的分配原则将所述任务请求分配给所述任务分发模块。The selection module allocates the task request to the task distribution module based on a preset allocation principle.
C4.如C3所述的电子设备,所述分配原则为负载均衡原则。C4. The electronic device according to C3, wherein the distribution principle is a load balancing principle.
C5.如C3所述的电子设备,所述任务分发模块集群中的多个任务分发模块被轮流选择。C5. The electronic device according to C3, wherein a plurality of task distribution modules in the task distribution module cluster are selected in turn.
C6.如C2所述的电子设备,所述任务分发模块与所述任务处理模块的数量相等且一一对应;C6. The electronic device according to C2, wherein the task distribution module and the task processing module are equal in number and in one-to-one correspondence;
所述任务分发模块响应于所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务,具体为,所述任务分发模块响应于对应的所述任务处理模块发送的任务请求,通过所述队列处理模块从预设的第一消息队列中获取一个调度任务。The task distribution module obtains a scheduling task from the preset first message queue through the queue processing module in response to the task request sent by the task processing module, specifically, the task distribution module responds to the corresponding The task request sent by the task processing module is used to obtain a scheduling task from the preset first message queue through the queue processing module.
本申请实施例公开了D1.一种非易失性存储介质,用于存储计算机可读程序,所述计算机可读程序用于供计算机执行如A1至A6任一项所述的任务分发方法。The embodiments of the present application disclose D1. A non-volatile storage medium for storing a computer-readable program, where the computer-readable program is used for a computer to execute the task distribution method described in any one of A1 to A6.
Claims (10)
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 device 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 device and storage medium |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN111309467A true CN111309467A (en) | 2020-06-19 |
| CN111309467B 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 device and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111309467B (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113065084A (en) * | 2021-03-08 | 2021-07-02 | 南京苏宁软件技术有限公司 | Data loading method and device, computer equipment and storage medium |
Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20050193269A1 (en) * | 2000-03-27 | 2005-09-01 | Accenture Llp | System, method, and article of manufacture for synchronization in an automated scripting framework |
| 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 |
| US20190095510A1 (en) * | 2017-09-25 | 2019-03-28 | Splunk Inc. | Low-latency streaming analytics |
| 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 |
-
2020
- 2020-02-24 CN CN202010110981.0A patent/CN111309467B/en active Active
Patent Citations (8)
| 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 |
| US20050193269A1 (en) * | 2000-03-27 | 2005-09-01 | Accenture Llp | System, method, and article of manufacture for synchronization in an automated scripting framework |
| 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 |
| US20190095510A1 (en) * | 2017-09-25 | 2019-03-28 | Splunk Inc. | Low-latency streaming analytics |
| 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 |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113065084A (en) * | 2021-03-08 | 2021-07-02 | 南京苏宁软件技术有限公司 | Data loading method and device, computer equipment and storage medium |
| CN113065084B (en) * | 2021-03-08 | 2022-12-23 | 南京苏宁软件技术有限公司 | Data loading method and device, computer equipment and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111309467B (en) | 2023-07-14 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN109564528B (en) | System and method for computing resource allocation in distributed computing | |
| CN105183564B (en) | Equipment scheduling method, apparatus and system based on cloud test platform | |
| CN103150213B (en) | Balancing method of loads and device | |
| US8903981B2 (en) | Method and system for achieving better efficiency in a client grid using node resource usage and tracking | |
| CN101951411A (en) | Cloud scheduling system and method and multistage cloud scheduling system | |
| CN102916953A (en) | Method and device for realizing concurrent service on basis of TCP (transmission control protocol) connection | |
| CN111092921B (en) | Data acquisition method, device and storage medium | |
| CN111880936A (en) | Resource scheduling method and device, container cluster, computer equipment and storage medium | |
| CN111831408A (en) | Asynchronous task processing method and device, electronic equipment and medium | |
| CN106462593B (en) | System and method for massively parallel processing of databases | |
| CN111913784B (en) | Task scheduling method and device, network element and storage medium | |
| CN111355751A (en) | Task scheduling method and device | |
| US20110131288A1 (en) | Load-Balancing In Replication Engine of Directory Server | |
| CN111147603A (en) | Method and device for networking reasoning service | |
| US20200310828A1 (en) | Method, function manager and arrangement for handling function calls | |
| CN111163140A (en) | Method, apparatus and computer readable storage medium for resource acquisition and allocation | |
| CN109388501B (en) | Communication matching method, device, equipment and medium based on face recognition request | |
| CN117453357A (en) | Node task scheduling method, device, computer equipment and storage medium | |
| US7424712B1 (en) | System and method for controlling co-scheduling of processes of parallel program | |
| CN106775975B (en) | Process scheduling method and device | |
| CN111309467B (en) | Task distribution method and device, electronic device and storage medium | |
| CN114265676A (en) | Cluster resource scheduling method, device, device and medium | |
| US10877800B2 (en) | Method, apparatus and computer-readable medium for application scheduling | |
| CN112348196A (en) | Distributed machine learning system and method of self-adaptive RDMA (remote direct memory Access) network | |
| US20240069970A1 (en) | System and method for sharing vitals among service replicas to enable processing of long running automation workflows in a container orchestration 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 |