WO2021190088A1 - Task distribution method and apparatus, and task execution system and server - Google Patents

Task distribution method and apparatus, and task execution system and server Download PDF

Info

Publication number
WO2021190088A1
WO2021190088A1 PCT/CN2021/071014 CN2021071014W WO2021190088A1 WO 2021190088 A1 WO2021190088 A1 WO 2021190088A1 CN 2021071014 W CN2021071014 W CN 2021071014W WO 2021190088 A1 WO2021190088 A1 WO 2021190088A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
dispatched
dispatch
node
tenant
Prior art date
Application number
PCT/CN2021/071014
Other languages
French (fr)
Chinese (zh)
Inventor
刘向东
Original Assignee
北京金山云网络技术有限公司
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 北京金山云网络技术有限公司 filed Critical 北京金山云网络技术有限公司
Publication of WO2021190088A1 publication Critical patent/WO2021190088A1/en

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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0631Resource planning, allocation, distributing or scheduling for enterprises or organisations
    • G06Q10/06316Sequencing of tasks or work

Definitions

  • the present disclosure relates to the technical field of task scheduling, in particular to a task dispatch method, device, task execution system and server.
  • the task scheduling system usually dispatches tasks to execution nodes through dispatching nodes, and only one dispatching node can dispatch tasks at the same time.
  • This method can avoid task dispatch conflicts among multiple dispatching nodes, and the operation is simple.
  • the pressure of the dispatch node at a certain point in time suddenly increases, and it is easy to reach the performance bottleneck of the dispatch node, resulting in the failure of the entire task scheduling system, thereby affecting the efficiency of task dispatch.
  • the purpose of the embodiments of the present disclosure is to provide a task dispatching method, device, task execution system and server, so as to improve the efficiency of task dispatching.
  • the embodiments of the present disclosure provide a task dispatching method, which is applied to a first dispatching node; the method includes: obtaining tasks to be dispatched by a target tenant; wherein the target tenant corresponds to the first dispatching node; The task to be dispatched is placed in a preset queue to be dispatched for the first dispatching node or dispatching nodes other than the first dispatching node to dispatch the task to be dispatched to the task executor.
  • the method before the step of obtaining the task to be dispatched by the target tenant, the method further includes: obtaining the target tenant from a preset tenant pool; wherein the tenant pool includes at least one tenant, and each tenant is Obtained by the first dispatching node or a dispatching node other than the first dispatching node.
  • the method further includes: putting the target tenant into the tenant pool for the first dispatching node or other than the first dispatching node Dispatching nodes other than those obtain the target tenant from the tenant pool.
  • the target tenant is preset with a job ready queue; the job ready queue is used to store the tasks to be dispatched by the target tenant; the above step of obtaining the tasks to be dispatched by the target tenant includes: obtaining the target from the job ready queue Tenant's tasks to be dispatched.
  • the tasks to be dispatched stored in the job ready queue carry the priority of the tasks to be dispatched; wherein, the priority is set by a priority configuration instruction in the Redis service.
  • the above-mentioned priority configuration command includes a zset command or a list command setting.
  • the method further includes: judging whether the task to be dispatched meets the preset dispatch conditions; if the dispatch conditions are not met, it will be dispatched The task is returned to the target tenant.
  • the above-mentioned preset dispatch conditions include: the resource occupation of the tasks to be dispatched is less than or equal to the remaining available resources of the system, and the number of tasks to be dispatched currently being dispatched is less than or equal to the remaining resources that can be dispatched at the same time in the system. The number of tasks to be dispatched.
  • the target tenant is preset with a dispatch record queue; the dispatch record queue is used to store the dispatched tasks of the target tenant and the resource occupancy of the dispatched tasks; the above method further includes: if the dispatch conditions are met, Put the task to be dispatched into the dispatch record queue of the target tenant.
  • the above method further includes: if a task is obtained from the queue to be dispatched, putting the obtained task into a preset dispatched queue, so that the task executor obtains the task from the dispatched queue, and Perform the acquired task.
  • embodiments of the present disclosure provide a task dispatching device, which is set as a first dispatching node; the device includes: a task acquisition module, which is set to acquire tasks to be dispatched by a target tenant; wherein, the target tenant and the first dispatch node Corresponding to the dispatch node; the task dispatch module is set to place the task to be dispatched into the preset queue for dispatch, so that the first dispatch node or dispatch nodes other than the first dispatch node can dispatch the task to be dispatched to the task executor .
  • the above-mentioned device further includes a target tenant determination module, which is configured to: obtain target tenants from a preset tenant pool; wherein, the tenant pool includes at least one tenant, and each tenant is assigned by the first dispatch node or the second tenant. Obtained by a dispatching node other than a dispatching node.
  • the above-mentioned apparatus further includes a tenant playback module, configured to put the target tenant into the tenant pool, so that the first dispatch node or dispatch nodes other than the first dispatch node can obtain the target tenant from the tenant pool.
  • the target tenant is preset with a job ready queue; the job ready queue is set to store the tasks to be dispatched by the target tenant; the task acquisition module is set to: acquire the tasks to be dispatched by the target tenant from the job ready queue .
  • the tasks to be dispatched stored in the job ready queue carry the priority of the tasks to be dispatched; wherein, the priority is set by a priority configuration instruction in the Redis service.
  • the above-mentioned priority configuration command includes a zset command or a list command.
  • the above-mentioned device further includes a dispatch judging module configured to judge whether the task to be dispatched meets the preset dispatch conditions; if the dispatch conditions are not met, the task to be dispatched is returned to the target tenant.
  • the above-mentioned preset dispatch conditions include: the resource occupation of the tasks to be dispatched is less than or equal to the remaining available resources of the system, and the number of tasks to be dispatched currently being dispatched is less than or equal to the remaining of the system that can be dispatched at the same time The number of tasks to be dispatched.
  • the target tenant has a preset dispatch record queue; the dispatch record queue is set to store the dispatched tasks of the target tenant and the resource occupancy of dispatched tasks; the dispatch judgment module is also set as follows: Dispatch condition, put the task to be dispatched into the dispatch record queue of the target tenant.
  • the above-mentioned device further includes a dispatched task obtaining module, which is configured to: if a task is obtained from the queue to be dispatched, the obtained task is put into a preset dispatched queue, so that the task executor can be removed from the dispatched queue. Obtain tasks in the dispatch queue and execute the obtained tasks.
  • a dispatched task obtaining module which is configured to: if a task is obtained from the queue to be dispatched, the obtained task is put into a preset dispatched queue, so that the task executor can be removed from the dispatched queue. Obtain tasks in the dispatch queue and execute the obtained tasks.
  • embodiments of the present disclosure provide a task execution system, which includes multiple task executors and multiple dispatch nodes; each dispatch node is in communication connection with multiple task executors; and the dispatch node is set to: obtain a target Tasks to be dispatched by the tenant; among them, the target tenant corresponds to the dispatch node; put the tasks to be dispatched into the preset queue for dispatch, so that the dispatch node or dispatch nodes other than the dispatch node among multiple dispatch nodes will be dispatched
  • the task is dispatched to the task executor; the task executor is set to execute the task to be dispatched.
  • embodiments of the present disclosure provide a server including a processor and a memory, the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above task dispatch method.
  • embodiments of the present disclosure provide a machine-readable storage medium that stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine can The execution of the instructions prompts the processor to implement the above-mentioned task dispatch method.
  • the embodiments of the present disclosure provide a task dispatch method, device, task execution system, and server.
  • First obtain the task to be dispatched by the target tenant; wherein the target tenant corresponds to the first dispatch node; and then put the task to be dispatched into the pre-dispatch node
  • the first dispatching node or dispatching nodes other than the first dispatching node may dispatch the task to be dispatched to the task executor.
  • each dispatch node separately manages the corresponding target tenants, and can put the tasks to be dispatched of the corresponding target tenants into the dispatch queue. All dispatch nodes can dispatch all the tasks to be dispatched in the dispatch queue.
  • the tasks to be dispatched by multiple tenants are distributed to each dispatching node to manage separately. Compared with the way that one dispatching node dispatches the tasks of all tenants, this method can spread the pressure of dispatching tasks to each dispatching node, even when the overall task volume is large , The pressure distributed to each dispatch node is also small, so as to ensure the smooth operation of the task scheduling system and improve the efficiency of task dispatch.
  • FIG. 1 is a schematic structural diagram of a task dispatch scenario in related technologies provided by the present disclosure
  • Figure 2 is a flowchart of a task dispatch method provided by the present disclosure
  • FIG. 3 is a flowchart of another task dispatching method provided by the present disclosure.
  • FIG. 4 is a flowchart of another task dispatching method provided by the present disclosure.
  • FIG. 5 is a schematic structural diagram of a task dispatching device provided by the present disclosure.
  • FIG. 6 is a schematic structural diagram of a task execution system provided by the present disclosure.
  • FIG. 7 is a schematic structural diagram of a server provided by the present disclosure.
  • Task dispatch is a very important function. Task dispatch is to select a suitable execution node to execute the task according to a certain strategy from a plurality of task execution nodes to be selected.
  • task dispatch in a task scheduling system usually dispatches tasks to execution nodes through dispatch nodes, and only one master dispatch node can dispatch tasks at the same time.
  • Figure 1 shows a task dispatch scenario in related technologies.
  • common task scheduling systems such as elastic-job and xxl-job implement dynamic master selection through distributed coordination components such as ZooKeeper, and select the master dispatch node that dispatches tasks at a certain time, and the master dispatch node performs Task dispatch.
  • This method can avoid task dispatch conflicts among multiple dispatching nodes, and the operation is simple.
  • the pressure of the dispatching node at a certain point in time increases suddenly, which easily reaches the performance bottleneck of the dispatching node, resulting in the entire
  • the task scheduling system fails, which affects the efficiency of task dispatch.
  • the embodiments of the present disclosure provide a task dispatch method, device, task execution system, and server.
  • the technology can be applied to a task dispatch scenario in a private cloud or a public cloud with a relatively large business scale.
  • a task dispatch method disclosed in the embodiments of the present disclosure is first introduced in detail. As shown in FIG. 2, the method is applied to the first dispatch node, and the method includes the following steps:
  • Step S202 Obtain the tasks to be dispatched by the target tenant; wherein, the target tenant corresponds to the first dispatch node.
  • the above-mentioned first dispatch node is usually any one of a plurality of dispatch nodes in the task scheduling system.
  • the first dispatch node is usually a server, and may also be a service process on the server.
  • Each dispatch node has its corresponding target tenant, where each dispatch node can correspond to one or more target tenants, each dispatch node corresponds to a different target tenant, and the same target tenant can only correspond to one dispatch node.
  • the aforementioned target tenant usually refers to a customer who uses a company's cloud environment, and the customer can be a project team, work group, company, etc.
  • the above-mentioned first dispatching node may obtain the task to be dispatched of its corresponding target tenant, and the task to be dispatched may be tasks such as calculation and storage sent by the tenant through the terminal device.
  • the first dispatch node may obtain the task to be dispatched from the terminal device corresponding to the target tenant, and may also receive the task to be dispatched from the target tenant. Since each dispatch node is in charge of different target tenants, when multiple dispatch nodes obtain tasks to be dispatched at the same time, conflicts when different dispatch nodes obtain tasks to be dispatched from the same tenant at the same time can be avoided.
  • Step S204 Put the above-mentioned task to be dispatched into a preset queue for dispatch, so that the first dispatch node or a dispatch node other than the first dispatch node dispatches the task to be dispatched to the task executor.
  • the above-mentioned queue to be dispatched usually adopts a data structure corresponding to MQ (Message Queue) to store the tasks to be dispatched.
  • MQ message queue can be regarded as a container for storing transmission data, and the transmission data is also the task to be dispatched.
  • the MQ message queue is usually an asynchronous inter-service communication method, and it is also an important component in a distributed system. It can solve the problems of application coupling, asynchronous messaging, traffic cutting, etc.; it also achieves high performance, high availability, scalability and Eventually consistent architecture, MQ message queue usually has RocketMQ, RabbitMQ, Kafka and other forms.
  • all dispatch nodes subscribe to the dispatch queue, so that each dispatch node can dispatch any task to be dispatched in the dispatch queue. It can also be understood that the first dispatch node can not only dispatch the dispatch queue The tasks to be dispatched by the target tenants corresponding to the tasks in the dispatch queue can also be dispatched to the tasks to be dispatched by the target tenants corresponding to the dispatch nodes other than the first dispatch node.
  • subscribing to topics under MQ can be used to make all the dispatching nodes subscribe to the dispatch queue.
  • the above-mentioned way of subscribing to the topic under MQ is usually that each dispatch node puts the obtained task to be dispatched into the message queue under the topic, and all the dispatch nodes subscribed to the topic can obtain any one from the message queue under the topic. Tasks to be dispatched.
  • all the dispatch nodes can subscribe to the same topic, so that all the dispatch nodes can dispatch all the tasks to be dispatched in the dispatch queue.
  • the dispatched task can be marked as "dispatched" in the dispatch queue to prevent the task to be dispatched from being dispatched repeatedly, and this method can be used Realize multiple dispatch nodes to dispatch at the same time, thereby improving the dispatch efficiency of task dispatch.
  • the embodiment of the present disclosure provides a task dispatch method. Firstly, the target tenant's task to be dispatched is obtained; wherein the target tenant corresponds to the first dispatch node; and then the task to be dispatched is placed in a preset queue to be dispatched. For the first dispatching node or dispatching nodes other than the first dispatching node to dispatch the task to be dispatched to the task executor.
  • each dispatch node manages the corresponding target tenants, and can put the tasks to be dispatched of the corresponding target tenants into the dispatch queue, and all dispatch nodes can dispatch all the tasks to be dispatched in the dispatch queue. This way The tasks to be dispatched by multiple tenants can be distributed to each dispatching node for management separately.
  • this method can spread the pressure of dispatching tasks to each dispatching node, even when the overall task volume is relatively high. When it is large, the pressure distributed to each dispatch node is also small, so as to ensure the smooth operation of the task scheduling system and improve the efficiency of task dispatch.
  • the embodiment of the present disclosure also provides another task dispatch method, which is implemented on the basis of the method in the above embodiment; the method focuses on the specific process of obtaining the task to be dispatched by the target tenant (implemented through the following step S304); As shown in Figure 3, the method includes the following steps:
  • Step S302 Obtain a target tenant from a preset tenant pool; wherein the target tenant has a preset job ready queue, and the job ready queue is used to store tasks to be dispatched by the target tenant; the tenant pool includes at least one tenant, each Ten tenants are acquired by the first dispatching node or a dispatching node other than the first dispatching node.
  • the above-mentioned preset tenant pool usually pools tenants through Redis (Remote Dictionary Server) to obtain the tenant pool.
  • the Redis mentioned above is usually a key-value storage system, and Redis also supports sorting in different ways. All tenants are stored in the above tenant pool, and all dispatch nodes compete for tenant resources from the tenant pool, that is, each dispatch node obtains the corresponding target tenant from the tenant pool, and each dispatch node can obtain one or more Tenants, and each tenant can only be obtained by one dispatch node.
  • there are 6 tenants in the tenant pool represented by T1, T2, T3, T4, T5, T6, and there are 3 dispatching nodes in the task scheduling system
  • the target tenants corresponding to the first dispatching node can be T1 and T3.
  • the target tenant corresponding to the second dispatching node may be T6, and the tenants corresponding to the third dispatching node are T2, T4, and T5.
  • the aforementioned target tenant is preset with a job ready queue, and the job ready queue is used to store tasks to be dispatched by the target tenant.
  • each tenant has a corresponding job ready queue.
  • the job ready queue can use the data structure corresponding to Redis to save the tasks to be dispatched corresponding to the target tenant.
  • This data structure relies on the advantages of operating data in Redis memory and provides a series of practicalities.
  • the unique interface controls data, is easy to use, fast, and can realize unique data feature sorting and reading.
  • the tasks to be dispatched stored in the job ready queue carry the priority of the tasks to be dispatched; wherein, the priority is set by a priority configuration instruction in the Redis service.
  • the priority configuration command can be a zset command or a list command.
  • the priority of the tasks to be dispatched above may characterize the order in which the tasks to be dispatched are dispatched, and the tasks to be dispatched with higher priority are usually given priority.
  • the priority of the task to be dispatched can be set in the job ready queue according to the zset instruction or the list instruction in the Redis service.
  • the job ready queue can adopt the zset data structure, which is similar to the set, and adds the sequence attribute on the basis of the set.
  • the order attribute can specify the priority when adding the queue to be dispatched. After each priority is specified, zset will automatically re-adjust the order of the tasks in the queue. It can also be understood that there are two lists in the job ready queue, one for the tasks to be dispatched , A column stores the priority corresponding to the task to be dispatched.
  • the job ready queue can adopt a list data structure.
  • the list data structure is usually a linked list structure.
  • the job ready queue can include multiple lists of list data structures, and each list corresponds to a priority, for example, The priority of the task to be dispatched is divided into 5 levels. There are five lists of list data structure in the job ready queue, and the tasks to be dispatched of different priority are stored respectively.
  • Step S304 Obtain the tasks to be dispatched by the target tenant from the above-mentioned job ready queue.
  • the dispatch node When the dispatch node obtains the task to be dispatched from the job ready queue, it usually first obtains the task to be dispatched with high priority, so that the dispatch node can first dispatch the task to be dispatched with high priority, so that the task to be dispatched can be executed first. Enhance the experience of tenants.
  • Step S306 Put the above-mentioned task to be dispatched into a preset queue to be dispatched, so that the first dispatching node or dispatching nodes other than the first dispatching node can dispatch the task to be dispatched to the task executor.
  • the method further includes: putting the target tenant into the tenant pool for the first dispatching node or other than the first dispatching node.
  • the dispatch node other than the node obtains the target tenant from the tenant pool.
  • the target tenant acquired by each dispatch node changes dynamically, that is, when the dispatch node puts the target tenant's to-be-dispatched tasks into the dispatch queue, the dispatch node will put the target tenant back into the tenant pool.
  • the dispatching node dispatches tasks next time, it can obtain tenants from the tenant pool again.
  • the obtained tenants may be the target tenants mentioned above, or they may be other tenants besides the target tenants, so that each tenant can be dispatched reasonably and efficiently. Tenant's tasks to be dispatched.
  • the above task dispatch method firstly obtains the target tenant from the preset tenant pool; then obtains the task to be dispatched by the target tenant from the job ready queue corresponding to the target tenant; then puts the task to be dispatched into the preset queue to be dispatched , For the first dispatching node or dispatching nodes other than the first dispatching node to dispatch the task to be dispatched to the task executor.
  • each dispatch node manages the corresponding target tenant separately, which avoids the conflict phenomenon when multiple dispatch nodes dispatch the tasks to be dispatched by one tenant at the same time.
  • all dispatch nodes can dispatch the tasks to be dispatched in the dispatch queue at the same time. Therefore, there is no sudden increase in the pressure of a single dispatch node in this method, which ensures the normal operation of the task scheduling system, thereby improving the efficiency of task dispatch.
  • the embodiment of the present disclosure also provides another task dispatching method, which is implemented on the basis of the method in the above-mentioned embodiment; the method focuses on describing the specific dispatching process after placing the above-mentioned task to be dispatched into the preset waiting queue; As shown in Figure 4, the method includes the following steps:
  • Step S402 Obtain the tasks to be dispatched by the target tenant; wherein, the target tenant corresponds to the first dispatch node.
  • Step S404 Put the above-mentioned task to be dispatched into a preset queue for dispatch.
  • step S406 it is judged whether the above task to be dispatched meets the preset dispatch conditions; if the dispatch conditions are not met, step S408 is executed; if the dispatch conditions are met, step S410 is executed.
  • business logic is used to determine whether the task to be dispatched meets the preset dispatch conditions.
  • the business logic defines the conditions that must be met to complete an action, that is, defines the dispatch conditions that need to be met when the task is dispatched.
  • the above business logic is usually stored in a preset database.
  • the database can use the string data type in the Redis database to store the business logic.
  • string is usually a string, which is the simplest data type.
  • the above-mentioned business logic may include the remaining available resources of the system, the remaining number of tasks to be dispatched that can be dispatched at the same time, etc.; the remaining available resources of the system may also be referred to as a logical resource group, which may include multiple types of remaining available resources, for example , The remaining amount of the Oracle connection, the remaining amount of memory, etc.; the remaining number of tasks to be dispatched in the system that can be dispatched at the same time can refer to the number of tasks to be dispatched that the system allows multiple dispatching nodes to dispatch at the same time.
  • the business logic required for different tasks to be dispatched may be the same or different.
  • the number of Oracle connections required for task 1 to be dispatched is 10, and the number of Oracle connections required for task 2 to be dispatched is 20.
  • the aforementioned preset dispatch conditions include: the resource occupation of the tasks to be dispatched is less than or equal to the remaining available resources of the system, and the number of tasks to be dispatched currently being dispatched is less than or equal to the number of remaining tasks to be dispatched in the system that can be dispatched at the same time. number.
  • the task to be dispatched Only when the task to be dispatched meets the above dispatch conditions, can the task in the dispatch queue be dispatched. After the dispatch of the task to be dispatched is completed, it is necessary to update the business logic in the preset database according to the resource occupation of the task to be dispatched. For example, assuming that the remaining available resources of the system is 100, the remaining number of tasks to be dispatched in the system that can be dispatched at the same time is 20, and the resource occupancy of tasks to be dispatched is 40, the number of tasks being dispatched by the dispatching node at this time is 10. Then the dispatch node can dispatch the task to be dispatched. After the dispatch of the task to be dispatched is completed, the remaining available resource amount in the preset database is updated to 60.
  • Step S408 Return the task to be dispatched to the target tenant.
  • the task to be dispatched if the task to be dispatched does not meet the dispatch conditions, the task to be dispatched is returned to the job ready queue corresponding to the target tenant, so as to wait for the dispatch node to take the task to be dispatched from the job ready queue and put it in In the queue to be dispatched.
  • Step S410 Put the aforementioned tasks to be dispatched into the dispatch record queue of the target tenant; the target tenant presets a dispatch record queue, and the dispatch record queue is used to store the dispatched tasks of the target tenant and the resource occupation of the dispatched tasks quantity.
  • the above-mentioned dispatch record queue usually adopts the Redis list data structure.
  • each tenant has a dispatch record queue.
  • the dispatch record queue can record the dispatched tasks of the target tenant and the resource occupation of the dispatched tasks.
  • the total resource occupancy of dispatch tasks can also be compared with the remaining available resources in the business logic in the database to ensure the accuracy of the remaining available resources recorded in the data.
  • Step S412 Put the tasks to be dispatched in the aforementioned dispatch record queue into the dispatched queue, so that the first dispatch node or dispatch nodes other than the first dispatch node can dispatch the tasks to be dispatched to the task executor.
  • the dispatching node dispatches the recorded tasks to be dispatched to the dispatched queue so that all dispatching nodes can dispatch the dispatched tasks in the dispatched queue to the task executor.
  • the above-mentioned dispatched queue may use the data structure corresponding to MQ to store the tasks to be dispatched.
  • the obtained task is put into the preset dispatched queue, so that the task executor obtains the task from the dispatched queue and executes the obtained task .
  • the task executor can subscribe to tasks in the dispatched queue, so that the task executor can actively obtain the task to be executed from the dispatched queue and execute the acquired task to be executed.
  • the above task dispatch method first obtains the tasks to be dispatched by the target tenant; then puts the tasks to be dispatched into the preset dispatch queue, and then determines whether the dispatch tasks meet the preset dispatch conditions; if the dispatch conditions are not met , Return the task to be dispatched to the target tenant; if the dispatch conditions are met, put the task to be dispatched into the dispatch record queue of the target tenant, and then put the dispatched task in the dispatch record queue into the dispatched queue for The first dispatch node or dispatch nodes other than the first dispatch node dispatch the task to be dispatched to the task executor. In this way, multiple dispatch nodes can dispatch tasks in parallel, and in the case of a large amount of tasks, higher dispatch efficiency can still be achieved.
  • the embodiment of the present disclosure also provides a task dispatching device, which is set as the first dispatching node; as shown in FIG. 5, the device includes:
  • the task acquisition module 50 is configured to acquire the tasks to be dispatched by the target tenant; wherein, the target tenant corresponds to the first dispatch node.
  • the task dispatch module 51 is configured to put the tasks to be dispatched into a preset queue for dispatch, so that the first dispatch node or dispatch nodes other than the first dispatch node dispatch the tasks to be dispatched to the task executor.
  • the above task dispatching device first obtains the tasks to be dispatched by the target tenant; among them, the target tenant corresponds to the first dispatch node; and then puts the tasks to be dispatched into the preset waiting queue for the first dispatch node or other
  • the dispatch node other than the first dispatch node dispatches the task to be dispatched to the task executor.
  • each dispatch node manages the corresponding target tenants, and can put the tasks to be dispatched of the corresponding target tenants into the dispatch queue. All dispatch nodes can dispatch all the tasks to be dispatched in the dispatch queue.
  • the tasks to be dispatched by multiple tenants are distributed to each dispatching node to manage separately.
  • this method can spread the pressure of dispatching tasks to each dispatching node, even when the overall task volume is large , The pressure distributed to each dispatch node is also less, so as to ensure the smooth operation of the task scheduling system and improve the efficiency of task dispatch.
  • the above-mentioned device further includes a target tenant determination module, which is configured to obtain target tenants from a preset tenant pool; wherein the tenant pool includes at least one tenant, and each tenant is removed by the first dispatch node or Obtained by a dispatch node other than the first dispatch node.
  • a target tenant determination module configured to obtain target tenants from a preset tenant pool; wherein the tenant pool includes at least one tenant, and each tenant is removed by the first dispatch node or Obtained by a dispatch node other than the first dispatch node.
  • the above-mentioned apparatus further includes a tenant playback module, configured to put the target tenant into the tenant pool, so that the first dispatching node or dispatching nodes other than the first dispatching node can obtain the target tenant from the tenant pool.
  • a tenant playback module configured to put the target tenant into the tenant pool, so that the first dispatching node or dispatching nodes other than the first dispatching node can obtain the target tenant from the tenant pool.
  • the target tenant is preset with a job ready queue; the job ready queue is set to store the tasks to be dispatched by the target tenant; the task acquisition module 50 is set to: obtain the job ready queues to be dispatched from the target tenant Task.
  • the task to be dispatched stored in the above job ready queue carries the priority of the task to be dispatched; wherein, the priority is set by a priority configuration instruction in the Redis service.
  • the above-mentioned priority configuration command includes a zset command or a list command.
  • the above-mentioned device also includes a dispatch judging module, which is configured to judge whether the task to be dispatched meets the preset dispatch conditions; if the dispatch condition is not met, the task to be dispatched is returned to the target tenant.
  • a dispatch judging module which is configured to judge whether the task to be dispatched meets the preset dispatch conditions; if the dispatch condition is not met, the task to be dispatched is returned to the target tenant.
  • the aforementioned preset dispatch conditions include: the resource occupation of the tasks to be dispatched is less than or equal to the remaining available resources of the system, and the number of tasks to be dispatched currently being dispatched is less than or equal to the number of remaining tasks to be dispatched in the system that can be dispatched at the same time. number.
  • the target tenant is preset with a dispatch record queue; the dispatch record queue is set to store the dispatched tasks of the target tenant and the resource occupancy of dispatched tasks; the dispatch judgment module is also set as follows: Dispatch condition, put the task to be dispatched into the dispatch record queue of the target tenant.
  • the above-mentioned device further includes a dispatched task obtaining module, which is configured to: if a task is obtained from the queue to be dispatched, the obtained task is put into a preset dispatched queue, so that the task executor can be removed from the dispatched queue. Obtain tasks in the dispatch queue and execute the obtained tasks.
  • a dispatched task obtaining module which is configured to: if a task is obtained from the queue to be dispatched, the obtained task is put into a preset dispatched queue, so that the task executor can be removed from the dispatched queue. Obtain tasks in the dispatch queue and execute the obtained tasks.
  • the embodiment of the present disclosure also provides a task execution system.
  • the system includes a plurality of task executors 60 and a plurality of dispatch nodes 61; each dispatch node 61 It is connected to a plurality of task executors 60 in communication.
  • the above dispatch node 61 is set to: obtain the task to be dispatched by the target tenant; wherein the target tenant corresponds to the dispatch node; and put the task to be dispatched into the preset queue to be dispatched for the dispatch node or multiple dispatch nodes
  • the dispatching nodes other than the dispatching node dispatch the task to be dispatched to the task executor 60.
  • the above-mentioned task executor 60 is configured to execute the task to be dispatched.
  • the above-mentioned task execution system includes multiple task executors and multiple dispatch nodes, wherein the dispatch node is set to obtain the tasks to be dispatched by the target tenant, and put the tasks to be dispatched into a preset queue for dispatch for dispatch.
  • the node or dispatching nodes other than the dispatching node among the dispatching nodes dispatch the task to be dispatched to the task executor; the task executor is set to execute the task to be dispatched.
  • the dispatching node in the system is in charge of different tenants, so that multiple dispatching nodes can dispatch tasks at the same time, thereby improving the efficiency of task dispatching and execution; at the same time, the system can meet the needs of massive task dispatching, and the system's capabilities can be added by adding The new instance easily realizes the current expansion.
  • the embodiment of the present disclosure also provides a server.
  • the server includes a processor 101 and a memory 100.
  • the memory 100 stores machine executable instructions that can be executed by the processor 101.
  • the processor 101 executes the machine Executable instructions to implement the above task dispatch method.
  • the server shown in FIG. 7 further includes a bus 102 and a communication interface 103, and the processor 101, the communication interface 103, and the memory 100 are connected through the bus 102.
  • the memory 100 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • the communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, a wide area network, a local network, a metropolitan area network, etc. may be used.
  • the bus 102 may be an ISA bus, a PCI bus, an EISA bus, or the like.
  • the bus can be divided into an address bus, a data bus, a control bus, and so on. For ease of presentation, only one bidirectional arrow is used in FIG. 7, but it does not mean that there is only one bus or one type of bus.
  • the processor 101 may be an integrated circuit chip with signal processing capability. In the implementation process, the steps of the foregoing method may be completed by an integrated logic circuit of hardware in the processor 101 or instructions in the form of software.
  • the foregoing processor 101 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP), etc.; it may also be a digital signal processor (Digital Signal Processor, DSP for short), etc. ), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • the methods, steps, and logical block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the steps of the method disclosed in combination with the embodiments of the present disclosure may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
  • the storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100, and completes the steps of the method of the foregoing embodiment in combination with its hardware.
  • the embodiment of the present disclosure also provides a machine-readable storage medium, the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor
  • the foregoing task dispatching method is implemented. For specific implementation, please refer to the method embodiment, which will not be repeated here.
  • the tasks to be dispatched by multiple tenants can be distributed to each dispatch node for separate management.
  • this The method can disperse the pressure of dispatching tasks to each dispatching node, even when the overall task volume is large, the pressure distributed to each dispatching node is small, so as to ensure the smooth operation of the task scheduling system and improve the efficiency of task dispatch.

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Human Resources & Organizations (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • General Physics & Mathematics (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Economics (AREA)
  • Educational Administration (AREA)
  • Development Economics (AREA)
  • Game Theory and Decision Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Marketing (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Telephonic Communication Services (AREA)

Abstract

A task distribution method and apparatus, and a task execution system and a server, relating to the field of cloud computing. The method comprises: first obtaining a task to be distributed of a target tenant, the target tenant corresponding to a first distribution node (S202); and putting said task into a preset queue to be distributed, so that the first distribution node or distribution nodes except the first distribution node distribute said task to a task executor (S204). According to the method, each distribution node manages the corresponding target tenant; tasks to be distributed of corresponding target tenants can be put into a queue to be distributed; all the distribution nodes can distribute all said tasks in said queue; compared with the mode that a distribution node distributes the tasks of all tenants, the mode has the advantages that the pressure of the distribution tasks can be dispersed to all the distribution nodes, even if the task quantity is large, the pressure dispersed to all the distribution nodes is small, and therefore stable operation of the task scheduling system is guaranteed, and the distribution efficiency of the tasks is improved.

Description

任务派发方法、装置、任务执行系统和服务器Task dispatching method, device, task execution system and server
本公开要求于2020年03月26日提交中国专利局、申请号为202010226220.1、发明名称为“任务派发方法、装置、任务执行系统和服务器”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。This disclosure claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 202010226220.1, and the invention title is "task dispatch method, device, task execution system and server" on March 26, 2020, the entire content of which is incorporated by reference In this disclosure.
技术领域Technical field
本公开涉及任务调度技术领域,具体涉及一种任务派发方法、装置、任务执行系统和服务器。The present disclosure relates to the technical field of task scheduling, in particular to a task dispatch method, device, task execution system and server.
背景技术Background technique
相关技术中,任务调度系统通常是通过派发节点将任务派发至执行节点,且同一时间只有一个派发节点可以派发任务,该方式可以避免多个派发节点间的任务派发冲突,且操作简单,但是当任务量增大时,某一时间点上的派发节点的压力突增,容易达到该派发节点的性能瓶颈,导致整个任务调度系统故障,从而影响任务的派发效率。In related technologies, the task scheduling system usually dispatches tasks to execution nodes through dispatching nodes, and only one dispatching node can dispatch tasks at the same time. This method can avoid task dispatch conflicts among multiple dispatching nodes, and the operation is simple. When the amount of tasks increases, the pressure of the dispatch node at a certain point in time suddenly increases, and it is easy to reach the performance bottleneck of the dispatch node, resulting in the failure of the entire task scheduling system, thereby affecting the efficiency of task dispatch.
发明内容Summary of the invention
本公开实施例的目的在于提供一种任务派发方法、装置、任务执行系统和服务器,以提高任务派发的效率。The purpose of the embodiments of the present disclosure is to provide a task dispatching method, device, task execution system and server, so as to improve the efficiency of task dispatching.
第一方面,本公开实施例提供一种任务派发方法,该方法应用于第一派发节点;该方法包括:获取目标租户的待派发任务;其中,该目标租户与第一派发节点相对应;将该待派发任务放入预设的待派发队列中,以供第一派发节点或除第一派发节点以外的派发节点将待派发任务派发至任务执行器。In the first aspect, the embodiments of the present disclosure provide a task dispatching method, which is applied to a first dispatching node; the method includes: obtaining tasks to be dispatched by a target tenant; wherein the target tenant corresponds to the first dispatching node; The task to be dispatched is placed in a preset queue to be dispatched for the first dispatching node or dispatching nodes other than the first dispatching node to dispatch the task to be dispatched to the task executor.
在一实施方式中,上述获取目标租户的待派发任务的步骤之前,上述方法还包括:从预设的租户池中,获取目标租户;其中,该租户池中包括至少一个租户,每个租户被第一派发节点或除第一派发节点以外的一个派发节点获取。In one embodiment, before the step of obtaining the task to be dispatched by the target tenant, the method further includes: obtaining the target tenant from a preset tenant pool; wherein the tenant pool includes at least one tenant, and each tenant is Obtained by the first dispatching node or a dispatching node other than the first dispatching node.
在一实施方式中,上述将待派发任务放入预设的待派发队列中的步骤之后,该方法还包括:将目标租户放入租户池中,以供第一派发节点或除第一派发节点以外的派发节点从租户池中获取目标租户。In one embodiment, after the above step of placing the task to be dispatched into the preset queue for dispatch, the method further includes: putting the target tenant into the tenant pool for the first dispatching node or other than the first dispatching node Dispatching nodes other than those obtain the target tenant from the tenant pool.
在一实施方式中,上述目标租户预设有作业就绪队列;该作业就绪队列用于保存目标租户的待派发任务;上述获取目标租户的待派发任务的步骤,包括: 从作业就绪队列中获取目标租户的待派发任务。In one embodiment, the target tenant is preset with a job ready queue; the job ready queue is used to store the tasks to be dispatched by the target tenant; the above step of obtaining the tasks to be dispatched by the target tenant includes: obtaining the target from the job ready queue Tenant's tasks to be dispatched.
在一实施方式中,上述作业就绪队列中保存的待派发任务,携带有待派发任务的优先级;其中,该优先级通过Redis服务中的优先级配置指令设置。In an embodiment, the tasks to be dispatched stored in the job ready queue carry the priority of the tasks to be dispatched; wherein, the priority is set by a priority configuration instruction in the Redis service.
在一实施方式中,上述优先级配置指令包括zset指令或list指令设置。In an embodiment, the above-mentioned priority configuration command includes a zset command or a list command setting.
在一实施方式中,上述将待派发任务放入预设的待派发队列中的步骤之后,该方法还包括:判断待派发任务是否符合预设的派发条件;如果不符合派发条件,将待派发任务退回至目标租户。In one embodiment, after the above step of placing the task to be dispatched into the preset queue for dispatch, the method further includes: judging whether the task to be dispatched meets the preset dispatch conditions; if the dispatch conditions are not met, it will be dispatched The task is returned to the target tenant.
在一实施方式中,上述预设的派发条件包括:待派发任务的资源占用量小于或者等于系统剩余可用资源,且当前正在派发的待派发任务的个数小于或者等于系统剩余的能够同时派发的待派发任务的个数。In one embodiment, the above-mentioned preset dispatch conditions include: the resource occupation of the tasks to be dispatched is less than or equal to the remaining available resources of the system, and the number of tasks to be dispatched currently being dispatched is less than or equal to the remaining resources that can be dispatched at the same time in the system. The number of tasks to be dispatched.
在一实施方式中,上述目标租户预设有派发记录队列;该派发记录队列用于保存目标租户的已派发任务,以及该已派发任务的资源占用量;上述方法还包括:如果符合派发条件,将待派发任务放入目标租户的派发记录队列中。In one embodiment, the target tenant is preset with a dispatch record queue; the dispatch record queue is used to store the dispatched tasks of the target tenant and the resource occupancy of the dispatched tasks; the above method further includes: if the dispatch conditions are met, Put the task to be dispatched into the dispatch record queue of the target tenant.
在一实施方式中,上述方法还包括:如果从待派发队列中获取到任务,将获取到的任务放入预设的已派发队列中,以使任务执行器从已派发队列中获取任务,并执行获取到的任务。In one embodiment, the above method further includes: if a task is obtained from the queue to be dispatched, putting the obtained task into a preset dispatched queue, so that the task executor obtains the task from the dispatched queue, and Perform the acquired task.
第二方面,本公开实施例提供一种任务派发装置,该装置设置为第一派发节点;该装置包括:任务获取模块,设置为获取目标租户的待派发任务;其中,该目标租户与第一派发节点相对应;任务派发模块,设置为将待派发任务放入预设的待派发队列中,以供第一派发节点或除第一派发节点以外的派发节点将待派发任务派发至任务执行器。In a second aspect, embodiments of the present disclosure provide a task dispatching device, which is set as a first dispatching node; the device includes: a task acquisition module, which is set to acquire tasks to be dispatched by a target tenant; wherein, the target tenant and the first dispatch node Corresponding to the dispatch node; the task dispatch module is set to place the task to be dispatched into the preset queue for dispatch, so that the first dispatch node or dispatch nodes other than the first dispatch node can dispatch the task to be dispatched to the task executor .
在一实施方式中,上述装置还包括目标租户确定模块,设置为:从预设的租户池中,获取目标租户;其中,租户池中包括至少一个租户,每个租户被第一派发节点或第一派发节点以外的一个派发节点获取。In one embodiment, the above-mentioned device further includes a target tenant determination module, which is configured to: obtain target tenants from a preset tenant pool; wherein, the tenant pool includes at least one tenant, and each tenant is assigned by the first dispatch node or the second tenant. Obtained by a dispatching node other than a dispatching node.
在一实施方式中,上述装置还包括租户回放模块,设置为:将目标租户放入租户池中,以供第一派发节点或除第一派发节点以外的派发节点从租户池中获取目标租户。In an embodiment, the above-mentioned apparatus further includes a tenant playback module, configured to put the target tenant into the tenant pool, so that the first dispatch node or dispatch nodes other than the first dispatch node can obtain the target tenant from the tenant pool.
在一实施方式中,上述目标租户预设有作业就绪队列;该作业就绪队列设 置为保存目标租户的待派发任务;上述任务获取模块,设置为:从作业就绪队列中获取目标租户的待派发任务。In one embodiment, the target tenant is preset with a job ready queue; the job ready queue is set to store the tasks to be dispatched by the target tenant; the task acquisition module is set to: acquire the tasks to be dispatched by the target tenant from the job ready queue .
在一实施方式中,上述作业就绪队列中保存的待派发任务,携带有待派发任务的优先级;其中,该优先级通过Redis服务中的优先级配置指令设置。In an embodiment, the tasks to be dispatched stored in the job ready queue carry the priority of the tasks to be dispatched; wherein, the priority is set by a priority configuration instruction in the Redis service.
在一实施方式中,上述优先级配置指令包括zset指令或list指令。In an embodiment, the above-mentioned priority configuration command includes a zset command or a list command.
在一实施方式中,上述装置还包括派发判断模块,设置为:判断待派发任务是否符合预设的派发条件;如果不符合派发条件,将待派发任务退回至目标租户。In one embodiment, the above-mentioned device further includes a dispatch judging module configured to judge whether the task to be dispatched meets the preset dispatch conditions; if the dispatch conditions are not met, the task to be dispatched is returned to the target tenant.
在一实施方式中,上述预设的派发条件包括:待派发任务的资源占用量小于或者等于系统的剩余可用资源,且当前正在派发的待派发任务的个数小于或者等于系统剩余的能够同时派发的待派发任务的个数。In one embodiment, the above-mentioned preset dispatch conditions include: the resource occupation of the tasks to be dispatched is less than or equal to the remaining available resources of the system, and the number of tasks to be dispatched currently being dispatched is less than or equal to the remaining of the system that can be dispatched at the same time The number of tasks to be dispatched.
在一实施方式中,上述目标租户预设有派发记录队列;该派发记录队列设置为保存目标租户的已派发任务,以及已派发任务的资源占用量;上述派发判断模块,还设置为:如果符合派发条件,将待派发任务放入目标租户的派发记录队列中。In one embodiment, the target tenant has a preset dispatch record queue; the dispatch record queue is set to store the dispatched tasks of the target tenant and the resource occupancy of dispatched tasks; the dispatch judgment module is also set as follows: Dispatch condition, put the task to be dispatched into the dispatch record queue of the target tenant.
在一实施方式中,上述装置还包括派发任务获取模块,设置为:如果从待派发队列中获取到任务,将获取到的任务放入预设的已派发队列中,以使任务执行器从已派发队列中获取任务,并执行获取到的任务。In one embodiment, the above-mentioned device further includes a dispatched task obtaining module, which is configured to: if a task is obtained from the queue to be dispatched, the obtained task is put into a preset dispatched queue, so that the task executor can be removed from the dispatched queue. Obtain tasks in the dispatch queue and execute the obtained tasks.
第三方面,本公开实施例提供一种任务执行系统,该系统包括多个任务执行器和多个派发节点;每个派发节点与多个任务执行器通信连接;该派发节点设置为:获取目标租户的待派发任务;其中,目标租户与派发节点相对应;将待派发任务放入预设的待派发队列中,以供派发节点或多个派发节点中除派发节点以外的派发节点将待派发任务派发至任务执行器;任务执行器设置为:执行该待派发任务。In a third aspect, embodiments of the present disclosure provide a task execution system, which includes multiple task executors and multiple dispatch nodes; each dispatch node is in communication connection with multiple task executors; and the dispatch node is set to: obtain a target Tasks to be dispatched by the tenant; among them, the target tenant corresponds to the dispatch node; put the tasks to be dispatched into the preset queue for dispatch, so that the dispatch node or dispatch nodes other than the dispatch node among multiple dispatch nodes will be dispatched The task is dispatched to the task executor; the task executor is set to execute the task to be dispatched.
第四方面,本公开实施例提供一种服务器,包括处理器和存储器,该存储器存储有能够被处理器执行的机器可执行指令,该处理器执行机器可执行指令以实现上述任务派发方法。In a fourth aspect, embodiments of the present disclosure provide a server including a processor and a memory, the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above task dispatch method.
第五方面,本公开实施例提供一种机器可读存储介质,所述机器可读存储 介质存储有机器可执行指令,所述机器可执行指令在被处理器调用和执行时,所述机器可执行指令促使处理器实现上述任务派发方法。In a fifth aspect, embodiments of the present disclosure provide a machine-readable storage medium that stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine can The execution of the instructions prompts the processor to implement the above-mentioned task dispatch method.
本公开实施例带来了以下有益效果:The embodiments of the present disclosure bring the following beneficial effects:
本公开实施例提供了一种任务派发方法、装置、任务执行系统和服务器,首先获取目标租户的待派发任务;其中,目标租户与第一派发节点相对应;然后将该待派发任务放入预设的待派发队列中,以供第一派发节点或除该第一派发节点以外的派发节点将待派发任务派发至任务执行器。本发明中每个派发节点分别管理相应的目标租户,可以将相应的目标租户的待派发任务放入待派发队列中,所有派发节点可派发待派发队列中的所有待派发任务,该方式可以将多个租户的待派发任务分散至各个派发节点分别管理,相对于一个派发节点派发所有租户的任务的方式,该方式可以将派发任务的压力分散至各个派发节点,即使在任务量整体较大时,分散至各个派发节点的压力也较小,从而保证任务调度系统的平稳运行,提高了任务的派发效率。The embodiments of the present disclosure provide a task dispatch method, device, task execution system, and server. First, obtain the task to be dispatched by the target tenant; wherein the target tenant corresponds to the first dispatch node; and then put the task to be dispatched into the pre-dispatch node In the queue to be dispatched, the first dispatching node or dispatching nodes other than the first dispatching node may dispatch the task to be dispatched to the task executor. In the present invention, each dispatch node separately manages the corresponding target tenants, and can put the tasks to be dispatched of the corresponding target tenants into the dispatch queue. All dispatch nodes can dispatch all the tasks to be dispatched in the dispatch queue. The tasks to be dispatched by multiple tenants are distributed to each dispatching node to manage separately. Compared with the way that one dispatching node dispatches the tasks of all tenants, this method can spread the pressure of dispatching tasks to each dispatching node, even when the overall task volume is large , The pressure distributed to each dispatch node is also small, so as to ensure the smooth operation of the task scheduling system and improve the efficiency of task dispatch.
附图说明Description of the drawings
为了更清楚的说明本公开实施例或相关技术的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单的介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly describe the technical solutions of the embodiments of the present disclosure or related technologies, the following will briefly introduce the accompanying drawings that need to be used in the description of the embodiments or related technologies. Obviously, the accompanying drawings in the following description are merely the present invention. For some of the embodiments, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work.
图1为本公开提供的相关技术中的任务派发场景的结构示意图;FIG. 1 is a schematic structural diagram of a task dispatch scenario in related technologies provided by the present disclosure;
图2为本公开提供的一种任务派发方法的流程图;Figure 2 is a flowchart of a task dispatch method provided by the present disclosure;
图3为本公开提供的另一种任务派发方法的流程图;FIG. 3 is a flowchart of another task dispatching method provided by the present disclosure;
图4为本公开提供的另一种任务派发方法的流程图;FIG. 4 is a flowchart of another task dispatching method provided by the present disclosure;
图5为本公开提供的一种任务派发装置的结构示意图;FIG. 5 is a schematic structural diagram of a task dispatching device provided by the present disclosure;
图6为本公开提供的一种任务执行系统的结构示意图;FIG. 6 is a schematic structural diagram of a task execution system provided by the present disclosure;
图7为本公开提供的一种服务器的结构示意图。FIG. 7 is a schematic structural diagram of a server provided by the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本公开实施例的一部分实施例,而不是全部的实施例。通常 在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。In order to make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be described clearly and completely in conjunction with the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments It is a part of the embodiments of the present disclosure, but not all of the embodiments. The components of the embodiments of the present disclosure generally described and illustrated in the drawings herein may be arranged and designed in a variety of different configurations.
因此,以下对在附图中提供的本公开实施例的详细描述并非旨在限制要求保护的本公开实施例的范围,而是仅仅表示本发明的选定实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本公开实施例保护的范围。Therefore, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed embodiments of the present disclosure, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the embodiments of the present disclosure.
在调度系统中,任务派发是很重要的功能,任务派发也即是从多个待选的任务执行节点中按某种策略选出合适的执行节点执行任务。相关技术中,任务调度系统中的任务派发通常是通过派发节点将任务派发至执行节点,且同一时间只有一个主派发节点可以派发任务,如图1所示为相关技术中的任务派发场景。例如,elastic-job、xxl-job等常见的任务调度系统,通过如ZooKeeper之类的分布式协调组件实现动态选主功能,选择出某一时间派发任务的主派发节点,由该主派发节点进行任务派发。该方式可以避免多个派发节点间的任务派发冲突,且操作简单,但是当任务量增大时,某一时间点上的派发节点的压力突增,容易达到该派发节点的性能瓶颈,导致整个任务调度系统故障,从而影响任务的派发效率。In the scheduling system, task dispatch is a very important function. Task dispatch is to select a suitable execution node to execute the task according to a certain strategy from a plurality of task execution nodes to be selected. In related technologies, task dispatch in a task scheduling system usually dispatches tasks to execution nodes through dispatch nodes, and only one master dispatch node can dispatch tasks at the same time. Figure 1 shows a task dispatch scenario in related technologies. For example, common task scheduling systems such as elastic-job and xxl-job implement dynamic master selection through distributed coordination components such as ZooKeeper, and select the master dispatch node that dispatches tasks at a certain time, and the master dispatch node performs Task dispatch. This method can avoid task dispatch conflicts among multiple dispatching nodes, and the operation is simple. However, when the amount of tasks increases, the pressure of the dispatching node at a certain point in time increases suddenly, which easily reaches the performance bottleneck of the dispatching node, resulting in the entire The task scheduling system fails, which affects the efficiency of task dispatch.
基于此,本公开实施例提供了一种任务派发方法、装置、任务执行系统和服务器,该技术可以应用于业务规模比较大的私有云或公有云下的任务派发场景中。为了便于对本公开实施例进行理解,首先对本公开实施例所公开的一种任务派发方法进行详细介绍,如图2所示,该方法应用于第一派发节点,该方法包括如下步骤:Based on this, the embodiments of the present disclosure provide a task dispatch method, device, task execution system, and server. The technology can be applied to a task dispatch scenario in a private cloud or a public cloud with a relatively large business scale. In order to facilitate the understanding of the embodiments of the present disclosure, a task dispatch method disclosed in the embodiments of the present disclosure is first introduced in detail. As shown in FIG. 2, the method is applied to the first dispatch node, and the method includes the following steps:
步骤S202,获取目标租户的待派发任务;其中,该目标租户与第一派发节点相对应。Step S202: Obtain the tasks to be dispatched by the target tenant; wherein, the target tenant corresponds to the first dispatch node.
上述第一派发节点通常是任务调度系统中多个派发节点中的任意一个。该第一派发节点通常是一个服务器,也可以是服务器上的一个服务进程。每个派发节点都有其对应的目标租户,其中,每个派发节点可以对应有一个或者多个目标租户,每个派发节点对应的目标租户不同,且同一个目标租户只能对应一个派发节点。上述目标租户通常是指使用某公司云环境的客户,该客户可以是一个项目组、工作组、公司等。The above-mentioned first dispatch node is usually any one of a plurality of dispatch nodes in the task scheduling system. The first dispatch node is usually a server, and may also be a service process on the server. Each dispatch node has its corresponding target tenant, where each dispatch node can correspond to one or more target tenants, each dispatch node corresponds to a different target tenant, and the same target tenant can only correspond to one dispatch node. The aforementioned target tenant usually refers to a customer who uses a company's cloud environment, and the customer can be a project team, work group, company, etc.
上述第一派发节点可以获取到其对应的目标租户的待派发任务,该待派发任务可以是租户通过终端设备发送的计算、存储等任务。在一实施方式中,第一派发节点可以从目标租户对应的终端设备上获取待派发任务,也可以接收目标租户发送的待派发任务。由于每个派发节点分管不同的目标租户,在多个派发节点同时获取待派发任务时,可以避免不同派发节点同时获取同一租户的待派发任务时的冲突现象。The above-mentioned first dispatching node may obtain the task to be dispatched of its corresponding target tenant, and the task to be dispatched may be tasks such as calculation and storage sent by the tenant through the terminal device. In an embodiment, the first dispatch node may obtain the task to be dispatched from the terminal device corresponding to the target tenant, and may also receive the task to be dispatched from the target tenant. Since each dispatch node is in charge of different target tenants, when multiple dispatch nodes obtain tasks to be dispatched at the same time, conflicts when different dispatch nodes obtain tasks to be dispatched from the same tenant at the same time can be avoided.
步骤S204,将上述待派发任务放入预设的待派发队列中,以供第一派发节点或除第一派发节点以外的派发节点将待派发任务派发至任务执行器。Step S204: Put the above-mentioned task to be dispatched into a preset queue for dispatch, so that the first dispatch node or a dispatch node other than the first dispatch node dispatches the task to be dispatched to the task executor.
上述待派发队列通常采用MQ(Message Queue,消息队列)对应的数据结构存放待派发任务,该MQ消息队列可以看成是一个存放传输数据的容器,该传输数据也即是待派发任务。该MQ消息队列通常是一种异步的服务间通信方式,也是分布式系统中重要的组件,可以解决应用耦合、异步消息、流量削锋等问题;它也是实现高性能、高可用、可伸缩和最终一致性的架构,MQ消息队列通常有RocketMQ、RabbitMQ、Kafka等形式。The above-mentioned queue to be dispatched usually adopts a data structure corresponding to MQ (Message Queue) to store the tasks to be dispatched. The MQ message queue can be regarded as a container for storing transmission data, and the transmission data is also the task to be dispatched. The MQ message queue is usually an asynchronous inter-service communication method, and it is also an important component in a distributed system. It can solve the problems of application coupling, asynchronous messaging, traffic cutting, etc.; it also achieves high performance, high availability, scalability and Eventually consistent architecture, MQ message queue usually has RocketMQ, RabbitMQ, Kafka and other forms.
在一实施方式中,所有的派发节点均订阅待派发队列,以使每个派发节点均可以派发待派发队列中的任意一个待派发任务,也可以理解为第一派发节点不仅可以派发待派发队列中的与其相应的目标租户的待派发任务,还可以派发待派发队列中的与除第一派发节点以外的派发节点相应的目标租户的待派发任务。In one embodiment, all dispatch nodes subscribe to the dispatch queue, so that each dispatch node can dispatch any task to be dispatched in the dispatch queue. It can also be understood that the first dispatch node can not only dispatch the dispatch queue The tasks to be dispatched by the target tenants corresponding to the tasks in the dispatch queue can also be dispatched to the tasks to be dispatched by the target tenants corresponding to the dispatch nodes other than the first dispatch node.
通常可以采用订阅MQ下的主题(topic)的方式,使所有的派发节点订阅待派发队列。上述订阅MQ下的topic的方式通常是每个派发节点将获取的到待派发任务放入topic下的消息队列中,所有订阅该topic的派发节点可以从该topic下的消息队列中获取到任意一个待派发任务。在一实施方式中,所有的派发节点可以订阅相同的topic,以使所有的派发节点可以派发待派发队列中的所有待派发任务。Generally, subscribing to topics under MQ can be used to make all the dispatching nodes subscribe to the dispatch queue. The above-mentioned way of subscribing to the topic under MQ is usually that each dispatch node puts the obtained task to be dispatched into the message queue under the topic, and all the dispatch nodes subscribed to the topic can obtain any one from the message queue under the topic. Tasks to be dispatched. In an embodiment, all the dispatch nodes can subscribe to the same topic, so that all the dispatch nodes can dispatch all the tasks to be dispatched in the dispatch queue.
在派发的过程中,如果某一个待派发任务已经被派发,在待派发队列中可以将已派发的待派发任务标记为“已派发”,以防止该待派发任务被重复派发,且该方式可以实现多个派发节点同时派发,从而提高了任务派发的派发效率。In the process of dispatch, if a task to be dispatched has been dispatched, the dispatched task can be marked as "dispatched" in the dispatch queue to prevent the task to be dispatched from being dispatched repeatedly, and this method can be used Realize multiple dispatch nodes to dispatch at the same time, thereby improving the dispatch efficiency of task dispatch.
本公开实施例提供了一种任务派发方法,首先获取目标租户的待派发任 务;其中,目标租户与第一派发节点相对应;然后将该待派发任务放入预设的待派发队列中,以供第一派发节点或除该第一派发节点以外的派发节点将待派发任务派发至任务执行器。本公开实施例中每个派发节点分别管理相应的目标租户,可以将相应的目标租户的待派发任务放入待派发队列中,所有派发节点可派发待派发队列中的所有待派发任务,该方式可以将多个租户的待派发任务分散至各个派发节点分别管理,相对于一个派发节点派发所有租户的任务的方式,该方式可以将派发任务的压力分散至各个派发节点,即使在任务量整体较大时,分散至各个派发节点的压力也较小,从而保证任务调度系统的平稳运行,提高了任务的派发效率。The embodiment of the present disclosure provides a task dispatch method. Firstly, the target tenant's task to be dispatched is obtained; wherein the target tenant corresponds to the first dispatch node; and then the task to be dispatched is placed in a preset queue to be dispatched. For the first dispatching node or dispatching nodes other than the first dispatching node to dispatch the task to be dispatched to the task executor. In the embodiment of the present disclosure, each dispatch node manages the corresponding target tenants, and can put the tasks to be dispatched of the corresponding target tenants into the dispatch queue, and all dispatch nodes can dispatch all the tasks to be dispatched in the dispatch queue. This way The tasks to be dispatched by multiple tenants can be distributed to each dispatching node for management separately. Compared with the way that one dispatching node dispatches the tasks of all tenants, this method can spread the pressure of dispatching tasks to each dispatching node, even when the overall task volume is relatively high. When it is large, the pressure distributed to each dispatch node is also small, so as to ensure the smooth operation of the task scheduling system and improve the efficiency of task dispatch.
本公开实施例还提供了另一种任务派发方法,该方法在上述实施例方法的基础上实现;该方法重点描述获取目标租户的待派发任务的具体过程(通过下述步骤S304实现);如图3所示,该方法包括如下步骤:The embodiment of the present disclosure also provides another task dispatch method, which is implemented on the basis of the method in the above embodiment; the method focuses on the specific process of obtaining the task to be dispatched by the target tenant (implemented through the following step S304); As shown in Figure 3, the method includes the following steps:
步骤S302,从预设的租户池中,获取目标租户;其中,目标租户预设有作业就绪队列,该作业就绪队列用于保存目标租户的待派发任务;该租户池中包括至少一个租户,每个租户被第一派发节点或除第一派发节点以外的一个派发节点获取。Step S302: Obtain a target tenant from a preset tenant pool; wherein the target tenant has a preset job ready queue, and the job ready queue is used to store tasks to be dispatched by the target tenant; the tenant pool includes at least one tenant, each Ten tenants are acquired by the first dispatching node or a dispatching node other than the first dispatching node.
上述预设的租户池通常是通过Redis(Remote Dictionary Server,远程字典服务)对租户进行池化,得到租户池。上述Redis通常是一个key-value存储系统,该Redis还支持不同方式的排序。上述租户池中保存有所有的租户,所有派发节点从该租户池中争夺租户资源,也即是每个派发节点从该租户池中获取相应的目标租户,每个派发节点可以获取到一个或者多个租户,且每个租户只能被一个派发节点获取到。例如,租户池中有6个租户,分别用T1、T2、T3、T4、T5、T6表示,任务调度系统中有3个派发节点,那么第一派发节点对应的目标租户可以是T1和T3,第二派发节点对应的目标租户可以是T6,第三派发节点对应的租户为T2、T4和T5。The above-mentioned preset tenant pool usually pools tenants through Redis (Remote Dictionary Server) to obtain the tenant pool. The Redis mentioned above is usually a key-value storage system, and Redis also supports sorting in different ways. All tenants are stored in the above tenant pool, and all dispatch nodes compete for tenant resources from the tenant pool, that is, each dispatch node obtains the corresponding target tenant from the tenant pool, and each dispatch node can obtain one or more Tenants, and each tenant can only be obtained by one dispatch node. For example, there are 6 tenants in the tenant pool, represented by T1, T2, T3, T4, T5, T6, and there are 3 dispatching nodes in the task scheduling system, then the target tenants corresponding to the first dispatching node can be T1 and T3. The target tenant corresponding to the second dispatching node may be T6, and the tenants corresponding to the third dispatching node are T2, T4, and T5.
上述目标租户预设有作业就绪队列,该作业就绪队列用于保存目标租户的待派发任务。通常每个租户都对应有相应的作业就绪队列,该作业就绪队列可以采用Redis对应的数据结构保存目标租户对应的待派发任务,该数据结构依靠Redis内存中操作数据的优势,又提供一些列实用独特的接口操控数据、使 用简便、速度快,且能实现特有的数据特征排序读写等。The aforementioned target tenant is preset with a job ready queue, and the job ready queue is used to store tasks to be dispatched by the target tenant. Usually each tenant has a corresponding job ready queue. The job ready queue can use the data structure corresponding to Redis to save the tasks to be dispatched corresponding to the target tenant. This data structure relies on the advantages of operating data in Redis memory and provides a series of practicalities. The unique interface controls data, is easy to use, fast, and can realize unique data feature sorting and reading.
在一实施方式中,上述作业就绪队列中保存的待派发任务,携带有待派发任务的优先级;其中,该优先级通过Redis服务中的优先级配置指令设置。该优先级配置指令可以是zset指令或list指令。In an embodiment, the tasks to be dispatched stored in the job ready queue carry the priority of the tasks to be dispatched; wherein, the priority is set by a priority configuration instruction in the Redis service. The priority configuration command can be a zset command or a list command.
上述待派发任务的优先级可以表征待派发任务派发的顺序,通常会优先派发优先级高的待派发任务。在一实施方式中,可以根据Redis服务中的zset指令或list指令设置在作业就绪队列中设置待派发任务的优先级。The priority of the tasks to be dispatched above may characterize the order in which the tasks to be dispatched are dispatched, and the tasks to be dispatched with higher priority are usually given priority. In an embodiment, the priority of the task to be dispatched can be set in the job ready queue according to the zset instruction or the list instruction in the Redis service.
当采用zset指令时,作业就绪队列可采用zset数据结构,该zset数据结构与集合相似,且在集合的基础上增加了顺序属性。该顺序属性在添加待派发队列时可以指定优先级,每次指定优先级后,zset会自动重新调整队列中任务的顺序,也可以理解为在作业就绪队列中有两列表,一列存待派发任务,一列存该待派发任务对应的优先级。When the zset instruction is used, the job ready queue can adopt the zset data structure, which is similar to the set, and adds the sequence attribute on the basis of the set. The order attribute can specify the priority when adding the queue to be dispatched. After each priority is specified, zset will automatically re-adjust the order of the tasks in the queue. It can also be understood that there are two lists in the job ready queue, one for the tasks to be dispatched , A column stores the priority corresponding to the task to be dispatched.
当采用list指令时,作业就绪队列可采用list数据结构,该list数据结构通常是一个链表结构,该作业就绪队列中可以包括多个list数据结构的列表,每个列表对应一个优先级,例如,待派发任务的优先级分5级,作业就绪队列中有五个list数据结构的列表,分别存储不同的优先级的待派发任务。When the list instruction is used, the job ready queue can adopt a list data structure. The list data structure is usually a linked list structure. The job ready queue can include multiple lists of list data structures, and each list corresponds to a priority, for example, The priority of the task to be dispatched is divided into 5 levels. There are five lists of list data structure in the job ready queue, and the tasks to be dispatched of different priority are stored respectively.
步骤S304,从上述作业就绪队列中获取目标租户的待派发任务。Step S304: Obtain the tasks to be dispatched by the target tenant from the above-mentioned job ready queue.
在派发节点从作业就绪队列中获取待派发任务时,通常优先获取优先级别高的待派发任务,以使派发节点可以优先派发优先级高的待派发任务,从而可以优先执行该待派发任务,可以提升租户的体验感。When the dispatch node obtains the task to be dispatched from the job ready queue, it usually first obtains the task to be dispatched with high priority, so that the dispatch node can first dispatch the task to be dispatched with high priority, so that the task to be dispatched can be executed first. Enhance the experience of tenants.
步骤S306,将上述待派发任务放入预设的待派发队列中,以供第一派发节点或除第一派发节点以外的派发节点将待派发任务派发至任务执行器。Step S306: Put the above-mentioned task to be dispatched into a preset queue to be dispatched, so that the first dispatching node or dispatching nodes other than the first dispatching node can dispatch the task to be dispatched to the task executor.
在一实施方式中,第一派发节点将待派发任务放入预设的待派发队列中后,该方法还包括:将目标租户放入租户池中,以供第一派发节点或除第一派发节点以外的派发节点从租户池中获取目标租户。In one embodiment, after the first dispatching node puts the task to be dispatched into the preset dispatch queue, the method further includes: putting the target tenant into the tenant pool for the first dispatching node or other than the first dispatching node. The dispatch node other than the node obtains the target tenant from the tenant pool.
每个派发节点获取到的目标租户是动态变化的,也即是当派发节点将目标租户的待派发任务放入到待派发队列后,该派发节点会把该目标租户放回至租户池中。当派发节点下一次派发任务时,可以再次从该租户池中获取租户,获取到的租户可能是上述目标租户,也可能是除目标租户之外的其他租户,从而 可以合理、高效的派发每个租户的待派发任务。The target tenant acquired by each dispatch node changes dynamically, that is, when the dispatch node puts the target tenant's to-be-dispatched tasks into the dispatch queue, the dispatch node will put the target tenant back into the tenant pool. When the dispatching node dispatches tasks next time, it can obtain tenants from the tenant pool again. The obtained tenants may be the target tenants mentioned above, or they may be other tenants besides the target tenants, so that each tenant can be dispatched reasonably and efficiently. Tenant's tasks to be dispatched.
上述任务派发方法,首先从预设的租户池中,获取目标租户;再从目标租户对应的作业就绪队列中获取目标租户的待派发任务;然后将该待派发任务放入预设的待派发队列中,以供第一派发节点或除第一派发节点以外的派发节点将待派发任务派发至任务执行器。该方式中每个派发节点分别管理相应的目标租户,避免了多个派发节点同时派发一个租户的待派发任务时的冲突现象,同时由于所有的派发节点可同时派发待派发队列中的待派发任务,因此该方式不存在单个派发节点压力突增的现象,保证了任务调度系统正常运行,从而提高了任务派发的效率。The above task dispatch method firstly obtains the target tenant from the preset tenant pool; then obtains the task to be dispatched by the target tenant from the job ready queue corresponding to the target tenant; then puts the task to be dispatched into the preset queue to be dispatched , For the first dispatching node or dispatching nodes other than the first dispatching node to dispatch the task to be dispatched to the task executor. In this way, each dispatch node manages the corresponding target tenant separately, which avoids the conflict phenomenon when multiple dispatch nodes dispatch the tasks to be dispatched by one tenant at the same time. At the same time, all dispatch nodes can dispatch the tasks to be dispatched in the dispatch queue at the same time. Therefore, there is no sudden increase in the pressure of a single dispatch node in this method, which ensures the normal operation of the task scheduling system, thereby improving the efficiency of task dispatch.
本公开实施例还提供了另一种任务派发方法,该方法在上述实施例方法的基础上实现;该方法重点描述将上述待派发任务放入预设的待派发队列之后的具体派发过程;如图4所示,该方法包括如下步骤:The embodiment of the present disclosure also provides another task dispatching method, which is implemented on the basis of the method in the above-mentioned embodiment; the method focuses on describing the specific dispatching process after placing the above-mentioned task to be dispatched into the preset waiting queue; As shown in Figure 4, the method includes the following steps:
步骤S402,获取目标租户的待派发任务;其中,该目标租户与第一派发节点相对应。Step S402: Obtain the tasks to be dispatched by the target tenant; wherein, the target tenant corresponds to the first dispatch node.
步骤S404,将上述待派发任务放入预设的待派发队列中。Step S404: Put the above-mentioned task to be dispatched into a preset queue for dispatch.
步骤S406,判断上述待派发任务是否符合预设的派发条件;如果不符合该派发条件,执行步骤S408;如果符合派发条件,执行步骤S410。In step S406, it is judged whether the above task to be dispatched meets the preset dispatch conditions; if the dispatch conditions are not met, step S408 is executed; if the dispatch conditions are met, step S410 is executed.
通常通过业务逻辑判断待派发任务是否符合预设的派发条件,该业务逻辑定义了完成一个动作,必须满足的条件,也即是定义了派发任务时,需要满足的派发条件。上述业务逻辑通常保存在预设的数据库中,该数据库可以采用Redis数据库中的string数据类型保存业务逻辑,其中,string通常为字符串,为最简单的数据类型。上述业务逻辑可以包括系统的剩余可用资源、系统剩余的能够同时派发的待派发任务的个数等;该系统的剩余可用资源也可称为逻辑资源组可以包括多种类型的剩余可用资源,例如,Oracle连接的剩余量、内存剩余量等;该系统剩余的能够同时派发的待派发任务的个数,可以是指当前时刻系统允许多个派发节点可同时派发的待派发任务的数量。Usually, business logic is used to determine whether the task to be dispatched meets the preset dispatch conditions. The business logic defines the conditions that must be met to complete an action, that is, defines the dispatch conditions that need to be met when the task is dispatched. The above business logic is usually stored in a preset database. The database can use the string data type in the Redis database to store the business logic. Among them, string is usually a string, which is the simplest data type. The above-mentioned business logic may include the remaining available resources of the system, the remaining number of tasks to be dispatched that can be dispatched at the same time, etc.; the remaining available resources of the system may also be referred to as a logical resource group, which may include multiple types of remaining available resources, for example , The remaining amount of the Oracle connection, the remaining amount of memory, etc.; the remaining number of tasks to be dispatched in the system that can be dispatched at the same time can refer to the number of tasks to be dispatched that the system allows multiple dispatching nodes to dispatch at the same time.
在一实施方式中,不同待派发任务需要用到的业务逻辑可能相同也可能不同,例如,待派发任务1需要用到的Oracle连接数为10个,待派发任务2需要用到的Oracle连接为20个。In one embodiment, the business logic required for different tasks to be dispatched may be the same or different. For example, the number of Oracle connections required for task 1 to be dispatched is 10, and the number of Oracle connections required for task 2 to be dispatched is 20.
上述预设的派发条件包括:待派发任务的资源占用量小于或者等于系统的剩余可用资源,且当前正在派发的待派发任务的个数小于或者等于系统剩余的能够同时派发的待派发任务的个数。The aforementioned preset dispatch conditions include: the resource occupation of the tasks to be dispatched is less than or equal to the remaining available resources of the system, and the number of tasks to be dispatched currently being dispatched is less than or equal to the number of remaining tasks to be dispatched in the system that can be dispatched at the same time. number.
只有待派发任务满足上述派发条件时,才可以对待派发队列中的任务进行派发,当待派发任务派发完成后需要根据该待派发任务的资源占用量,更新上述预设数据库中的业务逻辑。例如,假设系统的剩余可以资源量为100,系统剩余的能够同时派发的待派发任务的个数为20,待派发任务的资源占用量为40,此时派发节点正在派发的任务的个数为10,那么派发节点可以派发该待派发任务,该待派发任务派发完成后,预设数据库中的剩余可用资源量更新为60。Only when the task to be dispatched meets the above dispatch conditions, can the task in the dispatch queue be dispatched. After the dispatch of the task to be dispatched is completed, it is necessary to update the business logic in the preset database according to the resource occupation of the task to be dispatched. For example, assuming that the remaining available resources of the system is 100, the remaining number of tasks to be dispatched in the system that can be dispatched at the same time is 20, and the resource occupancy of tasks to be dispatched is 40, the number of tasks being dispatched by the dispatching node at this time is 10. Then the dispatch node can dispatch the task to be dispatched. After the dispatch of the task to be dispatched is completed, the remaining available resource amount in the preset database is updated to 60.
步骤S408,将上述待派发任务退回至目标租户。Step S408: Return the task to be dispatched to the target tenant.
在一实施方式中,如果待派发任务不符合派发条件,将该待派发任务退回至目标租户对应的作业就绪队列中,以等待派发节点重新将该待派发任务从作业就绪队列中取出,放入待派发队列中。In one embodiment, if the task to be dispatched does not meet the dispatch conditions, the task to be dispatched is returned to the job ready queue corresponding to the target tenant, so as to wait for the dispatch node to take the task to be dispatched from the job ready queue and put it in In the queue to be dispatched.
步骤S410,将上述待派发任务放入目标租户的派发记录队列中;其中,目标租户预设有派发记录队列,该派发记录队列用于保存目标租户的已派发任务,以及已派发任务的资源占用量。Step S410: Put the aforementioned tasks to be dispatched into the dispatch record queue of the target tenant; the target tenant presets a dispatch record queue, and the dispatch record queue is used to store the dispatched tasks of the target tenant and the resource occupation of the dispatched tasks quantity.
上述派发记录队列通常采用Redis的list数据结构,通常每个租户对应有一个派发记录队列,该派发记录队列可以根据记录目标租户的已派发任务,以及该已派发任务的资源占用量,可以统计已派发任务总的资源占用量,也可以将统计结果与数据库中的业务逻辑中的剩余可用资源进行比对,以确保数据可中记录的剩余可用资源的准确性。The above-mentioned dispatch record queue usually adopts the Redis list data structure. Usually, each tenant has a dispatch record queue. The dispatch record queue can record the dispatched tasks of the target tenant and the resource occupation of the dispatched tasks. The total resource occupancy of dispatch tasks can also be compared with the remaining available resources in the business logic in the database to ensure the accuracy of the remaining available resources recorded in the data.
步骤S412,将上述派发记录队列中的待派发任务放入已派发队列中,以供第一派发节点或除第一派发节点以外的派发节点将待派发任务派发至任务执行器。Step S412: Put the tasks to be dispatched in the aforementioned dispatch record queue into the dispatched queue, so that the first dispatch node or dispatch nodes other than the first dispatch node can dispatch the tasks to be dispatched to the task executor.
上述待派发记录队列记录完成后,派发节点将记录的待派发任务派发至已派发队列中,以使所有的派发节点可以将已派发队列中的待派发任务派发至任务执行器。上述已派发队列可以采用MQ对应的数据结构存放待派发任务。After the record queue to be dispatched is recorded, the dispatching node dispatches the recorded tasks to be dispatched to the dispatched queue so that all dispatching nodes can dispatch the dispatched tasks in the dispatched queue to the task executor. The above-mentioned dispatched queue may use the data structure corresponding to MQ to store the tasks to be dispatched.
在一些实施例中,如果从待派发队列中获取到任务,将获取到的任务放入 预设的已派发队列中,以使任务执行器从已派发队列中获取任务,并执行获取到的任务。在一实施方式中,任务执行器可以订阅已派发队列中的任务,以使该任务执行器可以主动从已派发队列中获取待执行任务,并执行获取的该待执行任务。In some embodiments, if a task is obtained from the queue to be dispatched, the obtained task is put into the preset dispatched queue, so that the task executor obtains the task from the dispatched queue and executes the obtained task . In one embodiment, the task executor can subscribe to tasks in the dispatched queue, so that the task executor can actively obtain the task to be executed from the dispatched queue and execute the acquired task to be executed.
上述任务派发方法,首先获取目标租户的待派发任务;再将该待派发任务放入预设的待派发队列中,进而判断该待派发任务是否符合预设的派发条件;如果不符合该派发条件,将该待派发任务退回至目标租户;如果符合派发条件,将该待派发任务放入目标租户的派发记录队列中,然后将派发记录队列中的待派发任务放入已派发队列中,以供第一派发节点或除第一派发节点以外的派发节点将待派发任务派发至任务执行器。该方式可以实现多个派发节点并行派发任务,在任务量大的情况下,仍能有较高的派发效率。The above task dispatch method first obtains the tasks to be dispatched by the target tenant; then puts the tasks to be dispatched into the preset dispatch queue, and then determines whether the dispatch tasks meet the preset dispatch conditions; if the dispatch conditions are not met , Return the task to be dispatched to the target tenant; if the dispatch conditions are met, put the task to be dispatched into the dispatch record queue of the target tenant, and then put the dispatched task in the dispatch record queue into the dispatched queue for The first dispatch node or dispatch nodes other than the first dispatch node dispatch the task to be dispatched to the task executor. In this way, multiple dispatch nodes can dispatch tasks in parallel, and in the case of a large amount of tasks, higher dispatch efficiency can still be achieved.
对应于上述任务派发方法的实施例,本公开实施例还提供了一种任务派发装置,该装置设置为第一派发节点;如图5所示,该装置包括:Corresponding to the embodiment of the task dispatching method described above, the embodiment of the present disclosure also provides a task dispatching device, which is set as the first dispatching node; as shown in FIG. 5, the device includes:
任务获取模块50,设置为获取目标租户的待派发任务;其中,该目标租户与第一派发节点相对应。The task acquisition module 50 is configured to acquire the tasks to be dispatched by the target tenant; wherein, the target tenant corresponds to the first dispatch node.
任务派发模块51,设置为将待派发任务放入预设的待派发队列中,以供第一派发节点或除第一派发节点以外的派发节点将待派发任务派发至任务执行器。The task dispatch module 51 is configured to put the tasks to be dispatched into a preset queue for dispatch, so that the first dispatch node or dispatch nodes other than the first dispatch node dispatch the tasks to be dispatched to the task executor.
上述任务派发装置,首先获取目标租户的待派发任务;其中,目标租户与第一派发节点相对应;然后将该待派发任务放入预设的待派发队列中,以供第一派发节点或除该第一派发节点以外的派发节点将待派发任务派发至任务执行器。该方式中每个派发节点分别管理相应的目标租户,可以将相应的目标租户的待派发任务放入待派发队列中,所有派发节点可派发待派发队列中的所有待派发任务,该方式可以将多个租户的待派发任务分散至各个派发节点分别管理,相对于一个派发节点派发所有租户的任务的方式,该方式可以将派发任务的压力分散至各个派发节点,即使在任务量整体较大时,分散至各个派发节点的压力也较小,从而保证任务调度系统的平稳运行,提高了任务的派发效率。The above task dispatching device first obtains the tasks to be dispatched by the target tenant; among them, the target tenant corresponds to the first dispatch node; and then puts the tasks to be dispatched into the preset waiting queue for the first dispatch node or other The dispatch node other than the first dispatch node dispatches the task to be dispatched to the task executor. In this method, each dispatch node manages the corresponding target tenants, and can put the tasks to be dispatched of the corresponding target tenants into the dispatch queue. All dispatch nodes can dispatch all the tasks to be dispatched in the dispatch queue. The tasks to be dispatched by multiple tenants are distributed to each dispatching node to manage separately. Compared with the way that one dispatching node dispatches all tenants' tasks, this method can spread the pressure of dispatching tasks to each dispatching node, even when the overall task volume is large , The pressure distributed to each dispatch node is also less, so as to ensure the smooth operation of the task scheduling system and improve the efficiency of task dispatch.
在一实施方式中,上述装置还包括目标租户确定模块,设置为从预设的租 户池中,获取目标租户;其中,该租户池中包括至少一个租户,每个租户被第一派发节点或除第一派发节点以外的一个派发节点获取。In one embodiment, the above-mentioned device further includes a target tenant determination module, which is configured to obtain target tenants from a preset tenant pool; wherein the tenant pool includes at least one tenant, and each tenant is removed by the first dispatch node or Obtained by a dispatch node other than the first dispatch node.
在一实施方式中,上述装置还包括租户回放模块,设置为:将目标租户放入租户池中,以供第一派发节点或述第一派发节点以外的派发节点从租户池中获取目标租户。In one embodiment, the above-mentioned apparatus further includes a tenant playback module, configured to put the target tenant into the tenant pool, so that the first dispatching node or dispatching nodes other than the first dispatching node can obtain the target tenant from the tenant pool.
在一实施方式中,上述目标租户预设有作业就绪队列;该作业就绪队列设置为保存目标租户的待派发任务;上述任务获取模块50,设置为:从作业就绪队列中获取目标租户的待派发任务。In one embodiment, the target tenant is preset with a job ready queue; the job ready queue is set to store the tasks to be dispatched by the target tenant; the task acquisition module 50 is set to: obtain the job ready queues to be dispatched from the target tenant Task.
上述作业就绪队列中保存的待派发任务,携带有待派发任务的优先级;其中,该优先级通过Redis服务中的优先级配置指令设置。The task to be dispatched stored in the above job ready queue carries the priority of the task to be dispatched; wherein, the priority is set by a priority configuration instruction in the Redis service.
在一实施方式中,上述优先级配置指令包括zset指令或list指令。In an embodiment, the above-mentioned priority configuration command includes a zset command or a list command.
上述装置还包括派发判断模块,设置为:判断待派发任务是否符合预设的派发条件;如果不符合派发条件,将待派发任务退回至目标租户。The above-mentioned device also includes a dispatch judging module, which is configured to judge whether the task to be dispatched meets the preset dispatch conditions; if the dispatch condition is not met, the task to be dispatched is returned to the target tenant.
上述预设的派发条件包括:待派发任务的资源占用量小于或者等于系统的剩余可用资源,且当前正在派发的待派发任务的个数小于或者等于系统剩余的能够同时派发的待派发任务的个数。The aforementioned preset dispatch conditions include: the resource occupation of the tasks to be dispatched is less than or equal to the remaining available resources of the system, and the number of tasks to be dispatched currently being dispatched is less than or equal to the number of remaining tasks to be dispatched in the system that can be dispatched at the same time. number.
在一实施方式中,上述目标租户预设有派发记录队列;该派发记录队列设置为保存目标租户的已派发任务,以及已派发任务的资源占用量;上述派发判断模块,还设置为:如果符合派发条件,将待派发任务放入目标租户的派发记录队列中。In one embodiment, the target tenant is preset with a dispatch record queue; the dispatch record queue is set to store the dispatched tasks of the target tenant and the resource occupancy of dispatched tasks; the dispatch judgment module is also set as follows: Dispatch condition, put the task to be dispatched into the dispatch record queue of the target tenant.
在一实施方式中,上述装置还包括派发任务获取模块,设置为:如果从待派发队列中获取到任务,将获取到的任务放入预设的已派发队列中,以使任务执行器从已派发队列中获取任务,并执行获取到的任务。In one embodiment, the above-mentioned device further includes a dispatched task obtaining module, which is configured to: if a task is obtained from the queue to be dispatched, the obtained task is put into a preset dispatched queue, so that the task executor can be removed from the dispatched queue. Obtain tasks in the dispatch queue and execute the obtained tasks.
本公开实施例所提供的任务派发装置,其实现原理及产生的技术效果和前述方法实施例相同,为简要描述,装置实施例部分未提及之处,可参考前述方法实施例中相应内容。The implementation principles and technical effects of the task dispatching device provided in the embodiments of the present disclosure are the same as those of the foregoing method embodiments. For a brief description, for the parts not mentioned in the device embodiments, please refer to the corresponding content in the foregoing method embodiments.
对应于上述任务派发方法的实施例,本公开实施例还提供了一种任务执行系统,如图6所示,该系统包括多个任务执行器60和多个派发节点61;每个派发节点61与多个任务执行器60通信连接。Corresponding to the embodiment of the above-mentioned task dispatch method, the embodiment of the present disclosure also provides a task execution system. As shown in FIG. 6, the system includes a plurality of task executors 60 and a plurality of dispatch nodes 61; each dispatch node 61 It is connected to a plurality of task executors 60 in communication.
上述派发节点61设置为:获取目标租户的待派发任务;其中,该目标租户与派发节点相对应;将待派发任务放入预设的待派发队列中,以供派发节点或多个派发节点中除派发节点以外的派发节点将待派发任务派发至任务执行器60。The above dispatch node 61 is set to: obtain the task to be dispatched by the target tenant; wherein the target tenant corresponds to the dispatch node; and put the task to be dispatched into the preset queue to be dispatched for the dispatch node or multiple dispatch nodes The dispatching nodes other than the dispatching node dispatch the task to be dispatched to the task executor 60.
上述任务执行器60设置为:执行该待派发任务。The above-mentioned task executor 60 is configured to execute the task to be dispatched.
上述任务执行系统,包括多个任务执行器和多个派发节点,其中,派发节点设置为获取目标租户的待派发任务,并将将待派发任务放入预设的待派发队列中,以供派发节点或多个派发节点中除派发节点以外的派发节点将待派发任务派发至任务执行器;任务执行器设置为执行该待派发任务。该系统中的派发节点通过分管不同租户,可以实现多个派发节点同时派发任务,从而提高了任务派发和执行的效率;同时该系统可满足海量任务派发的需求,而且该系统的能力可以通过加入新的实例轻松实现现行扩展。The above-mentioned task execution system includes multiple task executors and multiple dispatch nodes, wherein the dispatch node is set to obtain the tasks to be dispatched by the target tenant, and put the tasks to be dispatched into a preset queue for dispatch for dispatch The node or dispatching nodes other than the dispatching node among the dispatching nodes dispatch the task to be dispatched to the task executor; the task executor is set to execute the task to be dispatched. The dispatching node in the system is in charge of different tenants, so that multiple dispatching nodes can dispatch tasks at the same time, thereby improving the efficiency of task dispatching and execution; at the same time, the system can meet the needs of massive task dispatching, and the system's capabilities can be added by adding The new instance easily realizes the current expansion.
本公开实施例还提供了一种服务器,参见图7所示,该服务器包括处理器101和存储器100,该存储器100存储有能够被处理器101执行的机器可执行指令,该处理器101执行机器可执行指令以实现上述任务派发方法。The embodiment of the present disclosure also provides a server. As shown in FIG. 7, the server includes a processor 101 and a memory 100. The memory 100 stores machine executable instructions that can be executed by the processor 101. The processor 101 executes the machine Executable instructions to implement the above task dispatch method.
进一步地,图7所示的服务器还包括总线102和通信接口103,处理器101、通信接口103和存储器100通过总线102连接。Further, the server shown in FIG. 7 further includes a bus 102 and a communication interface 103, and the processor 101, the communication interface 103, and the memory 100 are connected through the bus 102.
其中,存储器100可能包含高速随机存取存储器(RAM,Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个通信接口103(可以是有线或者无线)实现该系统网元与至少一个其他网元之间的通信连接,可以使用互联网,广域网,本地网,城域网等。总线102可以是ISA总线、PCI总线或EISA总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图7中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。The memory 100 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, a wide area network, a local network, a metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, an EISA bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, and so on. For ease of presentation, only one bidirectional arrow is used in FIG. 7, but it does not mean that there is only one bus or one type of bus.
处理器101可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器101中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器101可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(Digital Signal Processor,简称DSP)、专用集成 电路(Application Specific Integrated Circuit,简称ASIC)、现场可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本公开实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本公开实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器100,处理器101读取存储器100中的信息,结合其硬件完成前述实施例的方法的步骤。The processor 101 may be an integrated circuit chip with signal processing capability. In the implementation process, the steps of the foregoing method may be completed by an integrated logic circuit of hardware in the processor 101 or instructions in the form of software. The foregoing processor 101 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP), etc.; it may also be a digital signal processor (Digital Signal Processor, DSP for short), etc. ), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps, and logical block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like. The steps of the method disclosed in combination with the embodiments of the present disclosure may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100, and completes the steps of the method of the foregoing embodiment in combination with its hardware.
本公开实施例还提供了一种机器可读存储介质,该机器可读存储介质存储有机器可执行指令,该机器可执行指令在被处理器调用和执行时,该机器可执行指令促使处理器实现上述任务派发方法,具体实现可参见方法实施例,在此不再赘述。The embodiment of the present disclosure also provides a machine-readable storage medium, the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor The foregoing task dispatching method is implemented. For specific implementation, please refer to the method embodiment, which will not be repeated here.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的装置和/或电子设备的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and conciseness of the description, the specific working process of the device and/or electronic device described above can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: The technical solutions recorded in the foregoing embodiments can still be modified, or some or all of the technical features can be equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the embodiments of the present invention. Scope.
工业实用性Industrial applicability
基于本公开实施例提供的任务派发方法、装置、任务执行系统和服务器,可以将多个租户的待派发任务分散至各个派发节点分别管理,相对于一个派发节点派发所有租户的任务的方式,该方式可以将派发任务的压力分散至各个派发节点,即使在任务量整体较大时,分散至各个派发节点的压力也较小,从而保证任务调度系统的平稳运行,提高了任务的派发效率。Based on the task dispatch method, device, task execution system, and server provided by the embodiments of the present disclosure, the tasks to be dispatched by multiple tenants can be distributed to each dispatch node for separate management. Compared with the way that one dispatch node dispatches the tasks of all tenants, this The method can disperse the pressure of dispatching tasks to each dispatching node, even when the overall task volume is large, the pressure distributed to each dispatching node is small, so as to ensure the smooth operation of the task scheduling system and improve the efficiency of task dispatch.

Claims (23)

  1. 一种任务派发方法,所述方法应用于第一派发节点;所述方法包括:A task dispatch method, the method is applied to a first dispatch node; the method includes:
    获取目标租户的待派发任务;其中,所述目标租户与所述第一派发节点相对应;Acquiring tasks to be dispatched by the target tenant; wherein the target tenant corresponds to the first dispatch node;
    将所述待派发任务放入预设的待派发队列中,以供所述第一派发节点或除所述第一派发节点以外的派发节点将所述待派发任务派发至任务执行器。Put the task to be dispatched into a preset queue for dispatch, so that the first dispatch node or a dispatch node other than the first dispatch node dispatches the task to be dispatched to a task executor.
  2. 根据权利要求1所述的方法,其中,所述获取目标租户的待派发任务的步骤之前,所述方法还包括:从预设的租户池中,获取目标租户;其中,所述租户池中包括至少一个租户,每个所述租户被所述第一派发节点或所述第一派发节点以外的一个派发节点获取。The method according to claim 1, wherein before the step of obtaining the tasks to be dispatched by the target tenant, the method further comprises: obtaining the target tenant from a preset tenant pool; wherein the tenant pool includes At least one tenant, and each tenant is acquired by the first dispatching node or a dispatching node other than the first dispatching node.
  3. 根据权利要求1所述的方法,其中,所述将所述待派发任务放入预设的待派发队列中的步骤之后,所述方法还包括:The method according to claim 1, wherein after the step of placing the task to be dispatched into a preset queue for dispatch, the method further comprises:
    将所述目标租户放入所述租户池中,以供所述第一派发节点或除所述第一派发节点以外的派发节点从租户池中获取所述目标租户。Put the target tenant into the tenant pool, so that the first dispatch node or a dispatch node other than the first dispatch node obtains the target tenant from the tenant pool.
  4. 根据权利要求1所述的方法,其中,所述目标租户预设有作业就绪队列;所述作业就绪队列用于保存所述目标租户的待派发任务;The method according to claim 1, wherein the target tenant is preset with a job ready queue; the job ready queue is used to store tasks to be dispatched by the target tenant;
    所述获取目标租户的待派发任务的步骤,包括:从所述作业就绪队列中获取所述目标租户的待派发任务。The step of obtaining the task to be dispatched by the target tenant includes: obtaining the task to be dispatched by the target tenant from the job ready queue.
  5. 根据权利要求4所述的方法,其中,所述作业就绪队列中保存的待派发任务,携带有所述待派发任务的优先级;其中,所述优先级通过Redis服务中的优先级配置指令设置。The method according to claim 4, wherein the task to be dispatched stored in the job ready queue carries the priority of the task to be dispatched; wherein the priority is set by a priority configuration instruction in the Redis service .
  6. 根据权利要求5所述的方法,其中,所述优先级配置指令包括zset指令或list指令。The method according to claim 5, wherein the priority configuration instruction includes a zset instruction or a list instruction.
  7. 根据权利要求1所述的方法,其中,所述将所述待派发任务放入预设的待派发队列中的步骤之后,所述方法还包括:The method according to claim 1, wherein after the step of placing the task to be dispatched into a preset queue for dispatch, the method further comprises:
    判断所述待派发任务是否符合预设的派发条件;Determine whether the task to be dispatched meets the preset dispatch conditions;
    如果不符合所述派发条件,将所述待派发任务退回至所述目标租户。If the dispatch conditions are not met, the task to be dispatched is returned to the target tenant.
  8. 根据权利要求7所述的方法,其中,所述预设的派发条件包括:所述待派发任务的资源占用量小于或者等于系统的剩余可用资源,且当前正在派发 的所述待派发任务的个数小于或者等于所述系统剩余的能够同时派发的所述待派发任务的个数。The method according to claim 7, wherein the preset dispatch condition comprises: the resource occupation of the task to be dispatched is less than or equal to the remaining available resources of the system, and the number of the task to be dispatched currently being dispatched The number is less than or equal to the number of remaining tasks to be dispatched in the system that can be dispatched at the same time.
  9. 根据权利要求7所述的方法,其中,所述目标租户预设有派发记录队列;所述派发记录队列用于保存所述目标租户的已派发任务,以及所述已派发任务的资源占用量;The method according to claim 7, wherein the target tenant is preset with a dispatch record queue; the dispatch record queue is used to store the dispatched tasks of the target tenant and the resource occupancy of the dispatched tasks;
    所述方法还包括:如果符合所述派发条件,将所述待派发任务放入所述目标租户的派发记录队列中。The method further includes: if the dispatch condition is met, placing the task to be dispatched into the dispatch record queue of the target tenant.
  10. 根据权利要求1所述的方法,其中,所述方法还包括:The method according to claim 1, wherein the method further comprises:
    如果从所述待派发队列中获取到任务,将获取到的任务放入预设的已派发队列中,以使任务执行器从所述已派发队列中获取任务,并执行获取到的任务。If a task is obtained from the to-be-dispatched queue, the obtained task is put into the preset dispatched queue, so that the task executor obtains the task from the dispatched queue and executes the obtained task.
  11. 一种任务派发装置,所述装置设置为第一派发节点;所述装置包括:A task dispatching device, the device is set as a first dispatching node; the device includes:
    任务获取模块,设置为获取目标租户的待派发任务;其中,所述目标租户与所述第一派发节点相对应;A task acquisition module, configured to acquire tasks to be dispatched from a target tenant; wherein the target tenant corresponds to the first dispatch node;
    任务派发模块,设置为将所述待派发任务放入预设的待派发队列中,以供所述第一派发节点或所述第一派发节点以外的派发节点将所述待派发任务派发至任务执行器。The task dispatch module is configured to put the task to be dispatched into a preset queue for dispatch, so that the first dispatch node or a dispatch node other than the first dispatch node dispatches the task to be dispatched to a task Actuator.
  12. 根据权利要求11所述的装置,其中,所述装置还包括目标租户确定模块,设置为:从预设的租户池中,获取目标租户;其中,所述租户池中包括至少一个租户,每个所述租户被所述第一派发节点或所述第一派发节点以外的一个派发节点获取。The device according to claim 11, wherein the device further comprises a target tenant determination module, configured to: obtain a target tenant from a preset tenant pool; wherein the tenant pool includes at least one tenant, each The tenant is acquired by the first dispatching node or a dispatching node other than the first dispatching node.
  13. 根据权利要求11所述的装置,其中,所述装置还包括租户回放模块,设置为:The device according to claim 11, wherein the device further comprises a tenant playback module configured to:
    将所述目标租户放入所述租户池中,以供所述第一派发节点或除所述第一派发节点以外的派发节点从租户池中获取所述目标租户。Put the target tenant into the tenant pool, so that the first dispatch node or a dispatch node other than the first dispatch node obtains the target tenant from the tenant pool.
  14. 根据权利要求11所述的装置,其中,所述目标租户预设有作业就绪队列;所述作业就绪队列设置为保存所述目标租户的待派发任务;The device according to claim 11, wherein the target tenant has a job ready queue preset; the job ready queue is set to store tasks to be dispatched by the target tenant;
    所述任务获取模块,设置为:从所述作业就绪队列中获取所述目标租户的待派发任务。The task obtaining module is configured to obtain the task to be dispatched by the target tenant from the job ready queue.
  15. 根据权利要求14所述的装置,其中,所述作业就绪队列中保存的待 派发任务,携带有所述待派发任务的优先级;其中,所述优先级通过Redis服务中的优先级配置指令设置。The device according to claim 14, wherein the task to be dispatched stored in the job ready queue carries the priority of the task to be dispatched; wherein the priority is set by a priority configuration instruction in the Redis service .
  16. 根据权利要求15所述的装置,其中,所述优先级配置指令包括zset指令或list指令。The device according to claim 15, wherein the priority configuration instruction includes a zset instruction or a list instruction.
  17. 根据权利要求11所述的装置,其中,所述装置还包括派发判断模块,设置为:The device according to claim 11, wherein the device further comprises a dispatch judgment module configured to:
    判断所述待派发任务是否符合预设的派发条件;Determine whether the task to be dispatched meets the preset dispatch conditions;
    如果不符合所述派发条件,将所述待派发任务退回至所述目标租户。If the dispatch conditions are not met, the task to be dispatched is returned to the target tenant.
  18. 根据权利要求17所述的装置,其中,所述预设的派发条件包括:所述待派发任务的资源占用量小于或者等于系统的剩余可用资源,且当前正在派发的所述待派发任务的个数小于或者等于所述系统剩余的能够同时派发的所述待派发任务的个数。The device according to claim 17, wherein the preset dispatch condition comprises: the resource occupation of the task to be dispatched is less than or equal to the remaining available resources of the system, and the number of the task to be dispatched currently being dispatched The number is less than or equal to the number of remaining tasks to be dispatched in the system that can be dispatched at the same time.
  19. 根据权利要求17所述的装置,其中,所述目标租户预设有派发记录队列;所述派发记录队列设置为保存所述目标租户的已派发任务,以及所述已派发任务的资源占用量;The device according to claim 17, wherein the target tenant is preset with a dispatch record queue; the dispatch record queue is set to store the dispatched tasks of the target tenant and the resource occupancy of the dispatched tasks;
    所述派发判断模块,还设置为:如果符合所述派发条件,将所述待派发任务放入所述目标租户的派发记录队列中。The dispatch judgment module is further configured to: if the dispatch condition is met, put the task to be dispatched into the dispatch record queue of the target tenant.
  20. 根据权利要求11所述的装置,其中,所述装置还包括派发任务获取模块,设置为:The device according to claim 11, wherein the device further comprises a dispatch task obtaining module, configured to:
    如果从所述待派发队列中获取到任务,将获取到的任务放入预设的已派发队列中,以使任务执行器从所述已派发队列中获取任务,并执行获取到的任务。If a task is obtained from the to-be-dispatched queue, the obtained task is put into the preset dispatched queue, so that the task executor obtains the task from the dispatched queue and executes the obtained task.
  21. 一种任务执行系统,所述系统包括多个任务执行器和多个派发节点;每个所述派发节点与所述多个任务执行器通信连接;A task execution system, the system includes a plurality of task executors and a plurality of dispatch nodes; each of the dispatch nodes is in communication connection with the plurality of task executors;
    所述派发节点设置为:获取目标租户的待派发任务;其中,所述目标租户与所述派发节点相对应;将所述待派发任务放入预设的待派发队列中,以供所述派发节点或所述多个派发节点中所述派发节点以外的派发节点将所述待派发任务派发至任务执行器;The dispatch node is set to: obtain the task to be dispatched by the target tenant; wherein the target tenant corresponds to the dispatch node; and put the task to be dispatched into a preset queue to be dispatched for the dispatch A node or a dispatch node other than the dispatch node among the plurality of dispatch nodes dispatches the task to be dispatched to a task executor;
    所述任务执行器设置为:执行所述待派发任务。The task executor is set to execute the task to be dispatched.
  22. 一种服务器,包括处理器和存储器,所述存储器存储有能够被所述处 理器执行的机器可执行指令,所述处理器执行所述机器可执行指令以实现权利要求1-10任一项所述的任务派发方法。A server comprising a processor and a memory, the memory storing machine executable instructions that can be executed by the processor, and the processor executing the machine executable instructions to implement any one of claims 1-10 The task dispatch method described above.
  23. 一种机器可读存储介质,所述机器可读存储介质存储有机器可执行指令,所述机器可执行指令在被处理器调用和执行时,所述机器可执行指令促使处理器实现权利要求1-10任一项所述的任务派发方法。A machine-readable storage medium, the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement claim 1 -10 Any one of the task dispatching methods.
PCT/CN2021/071014 2020-03-26 2021-01-11 Task distribution method and apparatus, and task execution system and server WO2021190088A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010226220.1 2020-03-26
CN202010226220.1A CN111459666A (en) 2020-03-26 2020-03-26 Task dispatching method and device, task execution system and server

Publications (1)

Publication Number Publication Date
WO2021190088A1 true WO2021190088A1 (en) 2021-09-30

Family

ID=71678918

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/071014 WO2021190088A1 (en) 2020-03-26 2021-01-11 Task distribution method and apparatus, and task execution system and server

Country Status (2)

Country Link
CN (1) CN111459666A (en)
WO (1) WO2021190088A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111459666A (en) * 2020-03-26 2020-07-28 北京金山云网络技术有限公司 Task dispatching method and device, task execution system and server
CN112365114A (en) * 2020-08-24 2021-02-12 南方电网数字电网研究院有限公司 Power operation plan management method based on operation and maintenance management platform

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050097556A1 (en) * 2003-10-30 2005-05-05 Alcatel Intelligent scheduler for multi-level exhaustive scheduling
US20090094605A1 (en) * 2007-10-09 2009-04-09 International Business Machines Corporation Method, system and program products for a dynamic, hierarchical reporting framework in a network job scheduler
CN104820616A (en) * 2015-04-24 2015-08-05 中国联合网络通信集团有限公司 Task scheduling method and device
CN105824699A (en) * 2015-01-06 2016-08-03 中国移动通信集团山东有限公司 Distributed task scheduling apparatus and method
CN111459666A (en) * 2020-03-26 2020-07-28 北京金山云网络技术有限公司 Task dispatching method and device, task execution system and server

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10193963B2 (en) * 2013-10-24 2019-01-29 Vmware, Inc. Container virtual machines for hadoop
CN107025136A (en) * 2016-01-29 2017-08-08 中兴通讯股份有限公司 A kind of decentralization resource regulating method and system
CN106909451A (en) * 2017-02-28 2017-06-30 郑州云海信息技术有限公司 A kind of distributed task dispatching system and method
US10686728B2 (en) * 2017-07-06 2020-06-16 Huawei Technologies Co., Ltd. Systems and methods for allocating computing resources in distributed computing
CN107590002A (en) * 2017-09-15 2018-01-16 东软集团股份有限公司 Method for allocating tasks, device, storage medium, equipment and distributed task scheduling system
CN109992403B (en) * 2017-12-30 2021-06-01 中国移动通信集团福建有限公司 Optimization method and device for multi-tenant resource scheduling, terminal equipment and storage medium
CN108769254B (en) * 2018-06-25 2019-09-20 星环信息科技(上海)有限公司 Resource-sharing application method, system and equipment based on preemption scheduling
CN109298897A (en) * 2018-06-29 2019-02-01 杭州数澜科技有限公司 A kind of system and method that the task using resource group is distributed
CN110825535B (en) * 2019-10-12 2022-06-28 中国建设银行股份有限公司 Job scheduling method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050097556A1 (en) * 2003-10-30 2005-05-05 Alcatel Intelligent scheduler for multi-level exhaustive scheduling
US20090094605A1 (en) * 2007-10-09 2009-04-09 International Business Machines Corporation Method, system and program products for a dynamic, hierarchical reporting framework in a network job scheduler
CN105824699A (en) * 2015-01-06 2016-08-03 中国移动通信集团山东有限公司 Distributed task scheduling apparatus and method
CN104820616A (en) * 2015-04-24 2015-08-05 中国联合网络通信集团有限公司 Task scheduling method and device
CN111459666A (en) * 2020-03-26 2020-07-28 北京金山云网络技术有限公司 Task dispatching method and device, task execution system and server

Also Published As

Publication number Publication date
CN111459666A (en) 2020-07-28

Similar Documents

Publication Publication Date Title
CN107241281B (en) Data processing method and device
WO2021190088A1 (en) Task distribution method and apparatus, and task execution system and server
CN105159736B (en) A kind of construction method for the SaaS software deployment schemes for supporting performance evaluation
US20110022861A1 (en) Reducing power consumption in data centers having nodes for hosting virtual machines
CN103970520A (en) Resource management method and device in MapReduce framework and framework system with device
WO2022151668A1 (en) Data task scheduling method and apparatus, storage medium, and scheduling tool
US10095562B2 (en) System and method for transforming a queue from non-blocking to blocking
WO2020192649A1 (en) Data center management system
CN106130960B (en) Judgement system, load dispatching method and the device of steal-number behavior
CN104750690A (en) Query processing method, device and system
CN104144202B (en) Access method, system and the device of Hadoop distributed file system
CN111427694A (en) Task execution method, device, system and server
US20240073298A1 (en) Intelligent scheduling apparatus and method
US20120102224A1 (en) Optimized consumption of third-party web services in a composite service
CN112783874A (en) Data analysis method, device and system
US10740332B2 (en) Memory-aware plan negotiation in query concurrency control
US8510426B2 (en) Communication and coordination between web services in a cloud-based computing environment
CN113157411B (en) Celery-based reliable configurable task system and device
CN113658351A (en) Product production method and device, electronic equipment and storage medium
CN111831408A (en) Asynchronous task processing method and device, electronic equipment and medium
CN116842090A (en) Accounting system, method, equipment and storage medium
CN107911484B (en) Message processing method and device
CN115562886A (en) Intelligent outbound system and method
US20230393782A1 (en) Io request pipeline processing device, method and system, and storage medium
CN114090409A (en) Message processing method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21774204

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21774204

Country of ref document: EP

Kind code of ref document: A1