WO2020119029A1 - 分布式任务调度方法、系统及存储介质 - Google Patents

分布式任务调度方法、系统及存储介质 Download PDF

Info

Publication number
WO2020119029A1
WO2020119029A1 PCT/CN2019/088631 CN2019088631W WO2020119029A1 WO 2020119029 A1 WO2020119029 A1 WO 2020119029A1 CN 2019088631 W CN2019088631 W CN 2019088631W WO 2020119029 A1 WO2020119029 A1 WO 2020119029A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
controller
available execution
tasks
available
Prior art date
Application number
PCT/CN2019/088631
Other languages
English (en)
French (fr)
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 WO2020119029A1 publication Critical patent/WO2020119029A1/zh

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/5083Techniques for rebalancing the load in a distributed system

Definitions

  • the present application relates to the technical field of computer task management, and in particular, to a distributed task scheduling method, system, and computer-readable storage medium.
  • task scheduling systems can be divided into two categories: distributed task scheduling systems and distributed task scheduling systems.
  • distributed task scheduling system there is a controller as a central scheduler, which can receive the status information of all the execution machines. All tasks are uniformly scheduled by the central scheduler, and then distributed to each execution machine for execution.
  • the distributed task scheduling system has multiple controllers, which jointly complete the scheduling strategy. The biggest advantage of the distributed task scheduling system is its good scalability.
  • distributed task scheduling systems usually use synchronous communication between multiple controllers to achieve load balancing among multiple execution machines.
  • scheduling efficiency cannot be guaranteed.
  • the main purpose of the present application is to provide a distributed task scheduling method, system and computer-readable storage medium for improving the scheduling efficiency of the distributed task scheduling system.
  • the present application provides a distributed task scheduling method, which is applied to a distributed task scheduling system.
  • the method includes:
  • Setting step setting the executable task threshold of each available execution machine and recording the number of allocable tasks for each available execution machine by each controller of the distributed task scheduling system;
  • Mapping step Obtain the task to be allocated from any controller, and calculate the hash value of the task to be allocated according to the attribute information of the task to be allocated;
  • Calculation step calculating a first residual value of the hash value and the number of available execution machines, and determining an available execution machine corresponding to the first residual value from the available execution machines;
  • Assignment step when the number of assignable tasks of the determined available execution machine by the controller is greater than 0, assign the task to be assigned to the determined available execution machine for execution; when the controller When the determined number of allocable tasks of the available execution machine is not greater than 0, the task to be distributed is allocated to any other available execution machine whose number of allocable tasks of the controller is greater than 0; when the controller When the number of assignable tasks of the available execution machines is not greater than 0, an available execution machine is randomly selected to execute the tasks to be assigned.
  • the attribute information of the task to be allocated includes a task name and a task owner name.
  • mapping step includes:
  • the first hash function and the second hash function are one or two of MD5 and SHA-1.
  • the process of recording the number of tasks that each controller can assign to each of the available execution machines in the setting step includes the following steps:
  • a one-dimensional array is defined on each controller, so that the elements of the one-dimensional array correspond one-to-one to the available execution machines, and the initial value of each element corresponds to each controller for each available execution machine.
  • the initial value of the number of assignable tasks is equal;
  • the controller decrements the number of available tasks for the available execution machine by 1;
  • the controller adds 1 to the number of allocable tasks for the available execution machine.
  • the process of allocating the task to be allocated to any other available execution machine with the number of allocable tasks greater than 0 in the allocation step includes the following steps:
  • the scan step size determine in sequence whether the number of allocable tasks of the controller for each available execution machine is greater than 0;
  • the controller assigns the tasks to be assigned to the available execution machine for execution, and ends the assignment step.
  • the present application also provides a distributed task scheduling system.
  • the distributed task scheduling system includes a memory, a processor, and a number of execution machines.
  • the memory is characterized by including a task scheduling program.
  • the task scheduling program is used by the processor.
  • Setting step setting the executable task threshold of each available execution machine and recording the number of allocable tasks for each available execution machine by each controller of the distributed task scheduling system;
  • Mapping step Obtain the task to be allocated from any controller, and calculate the hash value of the task to be allocated according to the attribute information of the task to be allocated;
  • Calculation step calculating a first residual value of the hash value and the number of available execution machines, and determining an available execution machine corresponding to the first residual value from the available execution machines;
  • Assignment step when the number of assignable tasks of the determined available execution machine by the controller is greater than 0, assign the task to be assigned to the determined available execution machine for execution; when the controller When the determined number of allocable tasks of the available execution machine is not greater than 0, the task to be distributed is allocated to any other available execution machine whose number of allocable tasks of the controller is greater than 0; when the controller When the number of assignable tasks of the available execution machines is not greater than 0, an available execution machine is randomly selected to execute the tasks to be assigned.
  • the present application also provides a computer-readable storage medium in which a task scheduling program is stored, and when the task scheduling program is executed, any step in the distributed task scheduling method described above is implemented.
  • the distributed task scheduling method, system and computer-readable storage medium provided by this application, by obtaining the available state of the execution machine, counting the number of available execution machines, and then setting the executable task threshold of each available execution machine, through the controller
  • a one-dimensional array is defined above to record the number of tasks that each controller of the distributed task scheduling system can assign to each of the available execution machines.
  • the use of the hash value and the number of available execution machines to calculate the available execution machines of the task to be assigned is to preferentially assign tasks of the same type with the same attribute information to the same available execution machines to implement Resource reuse, improve the efficiency of task execution.
  • FIG. 1 is a schematic diagram of an embodiment of a distributed task scheduling system of this application.
  • FIG. 2 is a program module diagram of an embodiment of the task scheduling program in FIG. 1;
  • FIG. 3 is a schematic flowchart of an embodiment of a distributed task scheduling method of the present application.
  • FIG. 1 it is a schematic diagram of an embodiment of a distributed task scheduling system 1 of the present application.
  • the distributed task scheduling system 1 includes a memory 11, a processor 12, a network interface 13, and an execution machine cluster 14.
  • the memory 11 includes at least one type of readable storage medium.
  • the at least one type of readable storage medium may be a non-volatile storage medium such as flash memory, hard disk, multimedia card, card-type memory, and the like.
  • the readable storage medium may be an internal storage unit of the distributed task scheduling system 1, such as a host hard disk in the distributed task scheduling system 1.
  • the readable storage medium may also be the external memory 11 of the distributed task scheduling system 1, for example, a plug-in hard disk equipped on the distributed task scheduling system 1, a smart memory card ( Smart, Media, Card (SMC), Secure Digital (SD) card, Flash card (Flash), etc.
  • the readable storage medium of the memory 11 is generally used to store the task scheduler 10.
  • the memory 11 can also be used to temporarily store data that has been or will be output.
  • the processor 12 includes multiple controllers.
  • the multiple controllers randomly receive and schedule tasks to be distributed, and distribute them to each execution machine in the execution machine cluster 14 for execution. It should be noted that different controllers can be deployed in the same processor or in different processors (not shown in the figure).
  • the processor 12 may be a central processing unit (CPU), a microprocessor, or other data processing chip, which is used to run the program code stored in the memory 11, for example, to execute the task scheduling Procedure 10.
  • the network interface 13 may include a standard wired interface and a wireless interface (such as a WI-FI interface). Usually used to establish a communication connection between the distributed task scheduling system 1 and other systems or electronic devices.
  • the execution machine cluster 14 includes several execution machines.
  • the execution machine may be various electronic devices with computing functions, including but not limited to servers, smart phones, telephone watches, tablet computers, portable computers, desktop computers, game devices, e-book readers, MP3 players ( Moving Pictures, Groups, Audio, Layer III), MP4 players (Moving Pictures, Groups, Audio, Layer IV), etc.
  • the server when the execution machine is a server, the server may be one or more of a rack server, a blade server, a tower server, or a rack server.
  • different execution machines can also be deployed in the same server.
  • execution machines in the execution machine group 14 are the same type of execution machines, and have the same configuration and processing capabilities.
  • FIG. 1 only shows a distributed task scheduling system 1 having components 11-14 and a task scheduler 10, but it should be understood that it is not required to implement all the components shown, and more or fewer alternatives may be implemented. Components.
  • the distributed task scheduling system 1 may further include an input unit such as a keyboard, a voice input device such as a microphone (Microphone) and other devices with voice recognition functions, and a voice output device such as a stereo and headphones. The user can use these devices and equipment to set and adjust the task scheduler 10.
  • an input unit such as a keyboard
  • a voice input device such as a microphone (Microphone) and other devices with voice recognition functions
  • a voice output device such as a stereo and headphones. The user can use these devices and equipment to set and adjust the task scheduler 10.
  • the distributed task scheduling system 1 may further include a display, which may also be called a display screen or a display unit.
  • a display which may also be called a display screen or a display unit.
  • it may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an organic light-emitting diode (Organic Light-Emitting Diode, OLED) display, or the like.
  • the display is used to display information processed in the distributed task scheduling system 1 and to display a visual user interface.
  • the distributed task scheduling system 1 may further include a radio frequency (Radio Frequency) circuit, a sensor, an audio circuit, a wired interface, a wireless interface, and so on, which will not be repeated here.
  • a radio frequency (Radio Frequency) circuit may further include a radio frequency (Radio Frequency) circuit, a sensor, an audio circuit, a wired interface, a wireless interface, and so on, which will not be repeated here.
  • the processor 12 may implement the following steps when executing the task scheduler 10 stored in the memory 11:
  • Setting step setting the executable task threshold of each available execution machine and recording the number of allocable tasks for each available execution machine by each controller of the distributed task scheduling system;
  • Mapping step Obtain the task to be allocated from any controller, and calculate the hash value of the task to be allocated according to the attribute information of the task to be allocated;
  • Calculation step calculating a first residual value of the hash value and the number of available execution machines, and determining an available execution machine corresponding to the first residual value from the available execution machines;
  • Assignment step when the number of assignable tasks of the determined available execution machine by the controller is greater than 0, assign the task to be assigned to the determined available execution machine for execution; when the controller When the determined number of allocable tasks of the available execution machine is not greater than 0, the task to be distributed is allocated to any other available execution machine whose number of allocable tasks of the controller is greater than 0; when the controller When the number of assignable tasks of the available execution machines is not greater than 0, an available execution machine is randomly selected to execute the tasks to be assigned.
  • the task scheduler 10 may be divided into multiple modules, which are stored in the memory 12 and executed by the processor 13 to complete the application.
  • the module referred to in this application refers to a series of computer program instruction segments capable of performing specific functions.
  • the task scheduler 10 may be divided into: a statistics module 110, a setting module 120, a mapping module 130, a calculation module 140, and an allocation module 150.
  • the statistics module 110 is used to obtain the possible state of the execution machine and calculate the number of available execution machines. Specifically, the statistics module 110 may send a broadcast message for determining the available state of the node device to each execution machine, and calculate the number of available execution machines in the execution machine cluster 14 according to the received response message. The statistics module 110 can also be used to number the available execution machines, assigning each of the available execution machines a unique available execution machine number, for example, starting from 0 and incrementing an integer to each available execution machine number : 0, 1, 2...
  • the setting module 120 is configured to set an executable task threshold of each available execution machine, and record the number of allocable tasks for each available execution machine by each controller of the distributed task scheduling system. Specifically, the user can set the executable task threshold of each available execution machine according to the configuration and bearing capacity of the available execution machine through the setting module 120, and then the executable task threshold and the distributed task scheduling system 1
  • the number of controllers included is divided and rounded to obtain the number of tasks that each controller can assign to each of the available execution machines. For example, assuming that the executable task thresholds of the available execution machines are all 10, and the distributed task scheduling system 1 has three controllers for completing scheduling strategies, then each controller has The number of assignable tasks is 3.
  • the controller executes the available execution
  • the number of allocable tasks of the machine is decreased by 1, and when the available execution machine completes the task, the controller adds 1 to the number of allocable tasks of the available execution machine.
  • the elements of the one-dimensional array are in one-to-one correspondence with the available execution machines, and the value of each element is
  • the value of the number of assignable tasks of the available execution machines is always equal, that is, when a task to be assigned obtained from a controller is assigned to an available execution machine for execution, the corresponding element value is decremented by 1, when the available When the executor executes the task, the corresponding element value is increased by 1.
  • the mapping module 130 is configured to obtain a task to be allocated from any controller, and calculate a hash value of the task to be allocated according to the attribute information of the task to be allocated.
  • the attribute information of the task to be allocated includes a task name and a task owner name.
  • the name of the task to be allocated can be MD5 calculated to obtain a first calculation result, and then the owner name of the task to be allocated can be SHA-1 calculated to obtain a second calculation result, and finally The last 128 bits of the second operation result (160 bits) are XORed with the first operation result (128 bits) to obtain a third operation result, and the third operation result is used as the ha Hopefully. It can be understood that similar tasks usually have the same task name and the same task owner. Therefore, according to the above hash value calculation method, similar tasks will get the same hash value.
  • the calculation module 140 is configured to calculate a first residual value of the hash value and the number of available execution machines, and determine an available execution machine corresponding to the first residual value from the available execution machines. For example, when the numbers of the available execution machines are 0, 1, 2, ... i, if the hash value of a certain task to be allocated and the number of available execution machines (i+1) are the remainder When 0, the available execution machine with the number 0 is the available execution machine corresponding to the first residual value. Because the hash values of similar tasks are the same, the determined available execution machines are the same for similar tasks.
  • the function of the calculation module 130 is to give priority to assigning tasks of the same type to the same available execution machine for execution, so as to realize resource reuse and improve task execution efficiency.
  • the allocation module 150 is configured to select an available execution machine that executes the to-be-allocated task according to the number of tasks that can be allocated by the controller that schedules the task to be allocated to the determined available execution machine and other available execution machines. Specifically, when the number of assignable tasks of the determined available execution machine by the controller is greater than 0, the task to be assigned is assigned to the determined available execution machine for execution; when the controller When the determined number of allocable tasks of the available execution machine is not greater than 0, the task to be distributed is allocated to any other available execution machine whose number of allocable tasks of the controller is greater than 0; when the controller When the number of assignable tasks of the available execution machines is not greater than 0, an available execution machine is randomly selected to execute the tasks to be assigned.
  • the process of allocating the task to be distributed to any other available execution machine whose number of allocable tasks of the controller is greater than 0 includes the following operations:
  • the scan step size determine in sequence whether the number of allocable tasks of the controller for each available execution machine is greater than 0;
  • the controller assigns the tasks to be assigned to the available execution machine for execution, and ends the assignment operation.
  • the scan step may be one of 1, 3, 7, and 9.
  • the number of the determined available execution machine calculated by the calculation module 140 is 2, and if the scan step size is 1, when the controller assigns tasks to the determined available execution machine
  • the allocation module 150 will sequentially determine whether the number of tasks that can be allocated by the controller to the available execution machines numbered 3, 4, 5, ...
  • the allocation module 150 will sequentially determine whether the number of allocable tasks of the controller for the available execution machines numbered 1, 0, 9, 8, ... 3 is greater than 0, until all When the number of assignable tasks of the available execution machine is greater than 0, the controller allocates the task to be assigned to the available execution machine for execution, and ends the assignment operation.
  • this application does not specify the scan step size as 1, but selects a certain number as the scan step size of a certain task to be allocated by calculating a limited natural number (including 1) that meets the requirements, is In order to reduce the possibility of uneven distribution of tasks.
  • the determined available execution machine calculated by the calculation module 140 may be the same.
  • the scan step size is also the same, the task assignment process will appear this The situation where multiple types of tasks are gathered on individual available execution machines cannot achieve the purpose of load balancing.
  • the scan steps of multi-type tasks calculated by the above calculation method are not necessarily equal, which can reduce the possibility of task aggregation, and is more conducive to achieving the purpose of load balancing.
  • the present application also provides a distributed task scheduling method.
  • FIG. 3 it is a schematic flowchart of an embodiment of a distributed task scheduling method of the present application.
  • the processor 12 of the distributed task scheduling system 1 implements the following steps of the distributed task scheduling method when executing the task scheduling program 10 stored in the memory 11:
  • step S300 the statistics module 110 is used to obtain the available state of the execution machine, and the number of available execution machines is calculated.
  • the available state of the execution machine in the distributed task scheduling system 1 is obtained by sending a broadcast message for determining the available state of the node device to each execution machine and receiving a response message, and then statistics of available execution The number of machines. Then, the available execution machines can also be numbered, and each of the available execution machines can be assigned a unique available execution machine number, for example, starting from 0 and incrementing an integer for each available execution machine number: 0, 1 , 2...i.
  • Step S301 using the setting module 120 to set the executable task threshold of each available execution machine, and record the number of allocable tasks for each available execution machine by each controller of the distributed task scheduling system .
  • the executable task threshold of each available execution machine can be estimated and set according to the configuration information of the available execution machines, and then the executable task threshold and the distributed task scheduling system 1 are included Divide the number of controllers and round off the number to obtain the initial value of the number of tasks that each controller can assign to each of the available execution machines. Then define a one-dimensional array on each controller, make the elements of the one-dimensional array correspond to the available execution machines one by one, and make the initial value of each element correspond to the The initial values of the allocable tasks of the available execution machines are equal. When a task to be allocated obtained from a controller is allocated to an available execution machine for execution, the corresponding element value is decreased by 1, and when the available execution machine completes the task, the corresponding element value is increased by 1.
  • the mapping module 130 is used to obtain the task to be allocated from any controller, and the hash value of the task to be allocated is calculated according to the attribute information of the task to be allocated.
  • the attribute information of the task to be allocated includes a task name and a task owner name.
  • the last 128 bits of (160 bits) are XORed with the first operation result (128 bits) to obtain a third operation result, and the third operation result is used as the hash value of the task to be allocated. Because similar tasks usually have the same task name and the same task owner, the same tasks will have the same hash value.
  • Step S303 the calculation module 140 is used to calculate a first residual value of the hash value and the number of available execution machines, and an available execution machine corresponding to the first residual value is determined from the available execution machines . Because the hash values of similar tasks are the same, the determined available execution machines are the same for similar tasks. Priority is given to assigning similar tasks to the same available execution machine for execution, which can realize resource reuse and improve task execution efficiency.
  • the allocation module 150 is used to select an available execution machine that executes the task to be allocated according to the number of tasks that can be allocated by the controller that schedules the task to be allocated to the determined available execution machine and other available execution machines. Specifically, when the number of assignable tasks of the determined available execution machine by the controller is greater than 0, the task to be assigned is assigned to the determined available execution machine for execution; when the controller When the determined number of allocable tasks of the available execution machine is not greater than 0, the task to be distributed is allocated to any other available execution machine whose number of allocable tasks of the controller is greater than 0; when the controller When the number of assignable tasks of the available execution machines is not greater than 0, an available execution machine is randomly selected to execute the tasks to be assigned.
  • the process of allocating the task to be allocated to any other available execution machine for which the controller has an allocable task number greater than 0 includes the following operations:
  • step coprimeList(NumInvokers).get(hash%size(coprimerList(NumInvokers)));
  • Invoker number (homeInvoker+m*step)%NumInvokers;
  • step S304 is ended;
  • NumInvokers represents the number of available execution machines
  • coprimeList(NumInvokers) represents obtaining a list of natural numbers smaller than NumInvokers and co-prime with NumInvokers
  • size(coprimeList(NumInvokers)) represents the number of natural numbers in the natural number list
  • get(hash %Size(coprimeList(NumInvokers))) means to first use the hash value of the task to be allocated to perform the remainder calculation on the number of natural numbers in the natural number list, and then obtain the corresponding residual value from the natural number list Numerical value
  • homeInvoker represents the number of the determined available execution machine
  • the variable m represents an integer value from 1 to NumInvokers-1.
  • the present application also provides a computer-readable storage medium, which may be a hard disk, a multimedia card, an SD card, a flash memory card, an SMC, a read-only memory (ROM), and an erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, etc. any one or any combination of several.
  • the computer-readable storage medium includes a task scheduler 10. For the functions implemented when the task scheduler 10 is executed, please refer to the above descriptions of FIG. 2 and FIG. 3, which will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)
  • Computer And Data Communications (AREA)

Abstract

本申请涉及负载调度技术,提供了一种分布式任务调度方法、系统及存储介质。该方法包括:统计可用执行机的数量;设置每个所述可用执行机的可执行任务阈值并记录分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数;从任一控制器获取待分配任务,根据该待分配任务的属性信息计算该待分配任务的哈希值;计算所述哈希值与所述可用执行机的数量的第一取余值,从所述可用执行机中确定与该第一取余值对应的可用执行机;根据调度该待分配任务的控制器对所述确定的可用执行机以及其他可用执行机的可分配任务数,选择执行该待分配任务的可用执行机。利用本申请,有利于提高任务执行效率,还可以提高分布式任务调度系统的调度效率。

Description

分布式任务调度方法、系统及存储介质
本申请基于巴黎公约申明享有2018年12月10日递交的申请号为CN201811503014.X、名称为“分布式任务调度方法、系统及存储介质”的中国专利申请的优先权,该中国专利申请的整体内容以参考的方式结合在本申请中。
技术领域
本申请涉及计算机任务管理技术领域,尤其涉及一种分布式任务调度方法、系统及计算机可读存储介质。
背景技术
按照调度信息在何处存储以及调度算法在何处执行,可将任务调度系统分为两类:分布式任务调度系统和分布式任务调度系统。在分布式任务调度系统中,存在一个作为中心调度器的控制器,可以接收所有执行机的状态信息,所有任务由该中心调度器统一调度,然后再分配到各个执行机上去执行。而分布式任务调度系统具有多个控制器,这些控制器共同完成调度策略。分布式任务调度系统的最大优点是具有良好的扩展性。
目前,分布式任务调度系统通常利用多个控制器间的同步通信,实现多个执行机间的负载均衡,然而,由于无法排除网络延迟等因素的影响,调度效率无法得到保障。
发明内容
本申请的主要目的在于提供一种分布式任务调度方法、系统及计算机可读存储介质,用来提高分布式任务调度系统的调度效率。
为实现上述目的,本申请提供一种分布式任务调度方法,应用于分布式任务调度系统,该方法包括:
统计步骤:获取执行机的可用状态,统计可用执行机的数量;
设置步骤:设置每个所述可用执行机的可执行任务阈值并记录所述分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数;
映射步骤:从任一控制器获取待分配任务,根据该待分配任务的属性信 息计算该待分配任务的哈希值;
计算步骤:计算所述哈希值与所述可用执行机的数量的第一取余值,从所述可用执行机中确定与该第一取余值对应的可用执行机;及
分配步骤:当所述控制器对所述确定的可用执行机的可分配任务数大于0时,将所述待分配任务分配给所述确定的可用执行机执行;当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行;当所述控制器对所述可用执行机的可分配任务数都不大于0时,随机选择一个可用执行机执行所述待分配任务。
优选地,所述待分配任务的属性信息包括任务名称和任务所有者名称。
优选地,所述映射步骤包括:
利用第一哈希函数对所述待分配任务的名称进行哈希运算,得到第一运算结果;
利用第二哈希函数对所述待分配任务的所有者名称进行哈希运算,得到第二运算结果;
对所述第一运算结果和所述第二运算结果进行异或运算,得到第三运算结果,将该第三运算结果作为所述待分配任务的哈希值。
优选地,所述第一哈希函数和所述第二哈希函数为MD5、SHA-1中的一种或两种。
优选地,所述设置步骤中记录每个控制器对每个所述可用执行机的可分配任务数的过程包括如下步骤:
将所述可执行任务阈值与控制器的数量相除并舍位取整,得到每个控制器对每个所述可用执行机的可分配任务数的初始值;
在每个控制器上定义一个一维数组,使该一维数组的元素与所述可用执行机一一对应,且各元素的初始值与所述每个控制器对每个所述可用执行机的可分配任务数的初始值相等;
将从某个控制器获取的一个待分配任务分配给某个可用执行机执行时,该控制器对该可用执行机的可分配任务数减1;
该可用执行机执行完成该任务时,该控制器对该可用执行机的可分配任务数加1。
优选地,所述分配步骤中将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行的过程包括如下步骤:
获取小于所述可用执行机的数量且与所述可用执行机的数量互质的自然数,统计获取的自然数的数量;
计算所述待分配任务的哈希值与所述获取的自然数的数量的第二取余值,选取与该第二取余值对应的所述自然数作为扫描步长;
根据所述扫描步长依次判断所述控制器对各可用执行机的可分配任务数是否大于0;
当所述控制器对某个可用执行机的可分配任务数大于0时,将所述待分配任务分配给该可用执行机执行,结束所述分配步骤。
本申请还提供一种分布式任务调度系统,该分布式任务调度系统包括存储器、处理器和若干执行机,其特征在于,所述存储器中包括任务调度程序,该任务调度程序被所述处理器执行时实现如下步骤:
统计步骤:获取执行机的可用状态,统计可用执行机的数量;
设置步骤:设置每个所述可用执行机的可执行任务阈值并记录所述分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数;
映射步骤:从任一控制器获取待分配任务,根据该待分配任务的属性信息计算该待分配任务的哈希值;
计算步骤:计算所述哈希值与所述可用执行机的数量的第一取余值,从所述可用执行机中确定与该第一取余值对应的可用执行机;及
分配步骤:当所述控制器对所述确定的可用执行机的可分配任务数大于0时,将所述待分配任务分配给所述确定的可用执行机执行;当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行;当所述控制器对所述可用执行机的可分配任务数都不大于0时,随机选择一个可用执行机执行所述待分配任务。
本申请还提供一种计算机可读存储介质,该计算机可读存储介质中存储有任务调度程序,该任务调度程序被执行时实现如上所述的分布式任务调度 方法中的任意步骤。
本申请提供的分布式任务调度方法、系统及计算机可读存储介质,通过获取执行机的可用状态,统计可用执行机的数量,然后设置每个可用执行机的可执行任务阈值,通过在控制器上定义一维数组的方式记录分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数。在从任一控制器获取待分配任务之后,根据该待分配任务的属性信息计算该待分配任务的哈希值,接着利用所述哈希值和所述可用执行机的数量计算所述待分配任务的可用执行机,最后根据调度该待分配任务的控制器对所述计算得到的可用执行机以及其他可用执行机的可分配任务数,选择执行该待分配任务的可用执行机。在本申请中,利用所述哈希值和所述可用执行机的数量计算所述待分配任务的可用执行机是为了优先将属性信息相同的同类任务分配给相同的可用执行机执行,以实现资源复用,提高任务执行效率。另外,通过定义一维数组记录每个控制器对每个所述可用执行机的可分配任务数,使得多个控制器间无须进行同步通信,也能实现负载均衡,提高了调度效率。因此,利用本申请,有利于提高任务执行效率,还可以提高分布式任务调度系统的调度效率。
附图说明
图1为本申请分布式任务调度系统一实施例的示意图;
图2为图1中任务调度程序一实施例的程序模块图;
图3为本申请分布式任务调度方法一实施例的流程示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
应当理解的是,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请提供一种分布式任务调度系统。参照图1所示,为本申请分布式任务调度系统1一实施例的示意图。
所述分布式任务调度系统1包括存储器11、处理器12、网络接口13以及执行机集群14。
其中,所述存储器11包括至少一种类型的可读存储介质。所述至少一种类型的可读存储介质可为如闪存、硬盘、多媒体卡、卡型存储器等的非易失性存储介质。在一些实施例中,所述可读存储介质可以是所述分布式任务调度系统1的内部存储单元,例如该分布式任务调度系统1中的主机硬盘。在另一些实施例中,所述可读存储介质也可以是所述分布式任务调度系统1的外部存储器11,例如所述分布式任务调度系统1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。
在本实施例中,所述存储器11的可读存储介质通常用于存储任务调度程序10。所述存储器11还可以用于暂时地存储已经输出或者将要输出的数据。
所述处理器12包括多个控制器,该多个控制器随机接收待分配任务并对其进行调度,将其分配到所述执行机集群14中的各个执行机上去执行。需要说明的是,不同的控制器可以部署在同一个处理器中,也可以部署在不同的处理器(图中未示出)中。在一些实施例中,所述处理器12可以是中央处理器(Central Processing Unit,CPU),微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码,例如执行所述任务调度程序10。
所述网络接口13可以包括标准的有线接口、无线接口(如WI-FI接口)。通常用于在该分布式任务调度系统1与其他系统或电子设备之间建立通信连接。
所述执行机集群14包括若干执行机。所述执行机可以是各种具有运算功能的电子设备,包括但不限于服务器、智能手机、电话手表、平板电脑、便携式计算机、桌上型计算机、游戏设备、电子书阅读器、MP3播放器(Moving Picture Experts Group Audio Layer III)、MP4播放器(Moving Picture Experts Group Audio Layer IV),等等。在一个实施例中,当所述执行机为服务器时,该服务器可以是机架式服务器、刀片式服务器、塔式服务器或机柜式服务器等的一种或几种。在另一个实施例中,不同的执行机还可以部署在同一个服 务器中。
在本申请中,为了便于描述,假设所述执行机群14中的执行机是同种类型的执行机,具有相同的配置和处理能力。
图1仅示出了具有组件11-14和任务调度程序10的分布式任务调度系统1,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
可选地,该分布式任务调度系统1还可以包括输入单元比如键盘(Keyboard),语音输入装置比如麦克风(Microphone)等具有语音识别功能的设备以及语音输出装置比如音响、耳机等。用户可利用这些装置和设备对所述任务调度程序10进行设置和调整。
可选地,该分布式任务调度系统1还可以包括显示器,也可以称为显示屏或显示单元。在一些实施例中可以是LED显示器、液晶显示器、触控式液晶显示器以及有机发光二极管(Organic Light-Emitting Diode,OLED)显示器等。显示器用于显示在分布式任务调度系统1中处理的信息以及用于显示可视化的用户界面。
该分布式任务调度系统1还可以包括射频(Radio Frequency,RF)电路、传感器、音频电路、有线接口和无线接口等等,在此不再赘述。
在上述实施例中,处理器12执行存储器11中存储的任务调度程序10时可以实现如下步骤:
统计步骤:获取执行机的可用状态,统计可用执行机的数量;
设置步骤:设置每个所述可用执行机的可执行任务阈值并记录所述分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数;
映射步骤:从任一控制器获取待分配任务,根据该待分配任务的属性信息计算该待分配任务的哈希值;
计算步骤:计算所述哈希值与所述可用执行机的数量的第一取余值,从所述可用执行机中确定与该第一取余值对应的可用执行机;及
分配步骤:当所述控制器对所述确定的可用执行机的可分配任务数大于0时,将所述待分配任务分配给所述确定的可用执行机执行;当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,将所述待分配任务分配 给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行;当所述控制器对所述可用执行机的可分配任务数都不大于0时,随机选择一个可用执行机执行所述待分配任务。
关于上述步骤的详细介绍,请参照下述图2关于任务调度程序10实施例的程序模块图以及图3关于分布式任务调度方法实施例的流程图的说明。
在其他实施例中,所述任务调度程序10可以被分割为多个模块,该多个模块被存储于存储器12中,并由处理器13执行,以完成本申请。本申请所称的模块是指能够完成特定功能的一系列计算机程序指令段。
参照图2所示,为图1中任务调度程序10一实施例的程序模块图。在本实施例中,所述任务调度程序10可以被分割为:统计模块110、设置模块120、映射模块130、计算模块140以及分配模块150。
所述统计模块110,用于获取执行机的可以状态,计算可用执行机的数量。具体地,统计模块110可以向各个执行机发送用于确定节点设备可用状态的广播报文,并根据接收到的响应报文计算所述执行机集群14中可用执行机的数量。统计模块110还可以用于对所述可用执行机进行编号,为每个所述可用执行机分配一个唯一的可用执行机编号,例如,从0开始以递增整数为每个所述可用执行机编号:0、1、2……
所述设置模块120,用于设置每个所述可用执行机的可执行任务阈值,并记录所述分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数。具体地,用户可通过设置模块120根据所述可用执行机的配置、承载力等设置每个所述可用执行机的可执行任务阈值,然后将该可执行任务阈值与所述分布式任务调度系统1包含的控制器的数量相除并舍位取整,得到每个控制器对每个所述可用执行机的可分配任务数。例如,假设所述可用执行机的可执行任务阈值都为10,所述分布式任务调度系统1具有3个用于完成调度策略的控制器,那么每个控制器对每个所述可用执行机的可分配任务数为3。可以理解的是,控制器对可用执行机的可分配任务数是变化的,当将从某个控制器获取的一个待分配任务分配给某个可用执行机执行时,该控制器对该可用执行机的可分配任务数减1,当该可用执行机执行完成该任务时,该控制器对该可用执行机的可分配任务数加1。在本实施例中,通过在每个控 制器上定义一个一维数组,使该一维数组的元素与所述可用执行机一一对应,且各元素的值与所述每个控制器对每个所述可用执行机的可分配任务数的值始终相等,即,当将从某个控制器获取的一个待分配任务分配给某个可用执行机执行时,对应元素值减1,当该可用执行机执行完成该任务时,对应元素值加1。
所述映射模块130,用于从任一控制器获取待分配任务,并根据该待分配任务的属性信息计算该待分配任务的哈希值。其中,所述待分配任务的属性信息包括任务名称和任务所有者名称。在一个实施例中,可以对所述待分配任务的名称进行MD5运算,得到第一运算结果,再对所述待分配任务的所有者名称进行SHA-1运算,得到第二运算结果,最后将所述第二运算结果(160位)的后128位与所述第一运算结果(128位)进行异或运算,得到第三运算结果,将该第三运算结果作为所述待分配任务的哈希值。可以理解的是,同类任务通常具有相同的任务名称,其任务所有者也相同,因此,依照上述哈希值计算方法,同类任务将得到相同的哈希值。
所述计算模块140,用于计算所述哈希值与所述可用执行机的数量的第一取余值,从所述可用执行机中确定与该第一取余值对应的可用执行机。例如,当所述可用执行机的编号依次为0、1、2……i时,若某个待分配任务的哈希值与所述可用执行机的数量(i+1)的取余值为0时,则编号为0的可用执行机即为与所述第一取余值对应的可用执行机。因为同类任务的哈希值相同,所以,对于同类任务,所述确定的可用执行机相同。所述计算模块130的作用在于,优先考虑将同类任务分配给相同的可用执行机执行,以实现资源复用,提高任务执行效率。
所述分配模块150,用于根据调度所述待分配任务的控制器对所述确定的可用执行机以及其他可用执行机的可分配任务数,选择执行所述待分配任务的可用执行机。具体地,当所述控制器对所述确定的可用执行机的可分配任务数大于0时,将所述待分配任务分配给所述确定的可用执行机执行;当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行;当所述控制器对所述可用执行机的可分配任务数都不大于0时,随机选择一个可用执行机执行所述待分配任务。其中,将所述待分配任务分配给 任一其他所述控制器对其的可分配任务数大于0的可用执行机执行的过程包括如下操作:
获取小于所述可用执行机的数量且与所述可用执行机的数量互质的自然数,统计获取的自然数的数量;
计算所述待分配任务的哈希值与所述获取的自然数的数量的第二取余值,选取与该第二取余值对应的所述自然数作为扫描步长;
根据所述扫描步长依次判断所述控制器对各可用执行机的可分配任务数是否大于0;
当所述控制器对某个可用执行机的可分配任务数大于0时,将所述待分配任务分配给该可用执行机执行,结束分配操作。
例如,假设所述可用执行机的数量为10,编号为0-9,则所述获取的自然数的数量为4,分别是1、3、7、9。即在为一个待分配任务寻找任一其他所述控制器对其的可分配任务数大于0的可用执行机时,扫描步长可能为1、3、7、9中的一个数。依上述例子,假设所述计算模块140计算得到的所述确定的可用执行机的编号为2,若扫描步长为1,则当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,分配模块150将依次判断所述控制器对编号为3、4、5、……9的可用执行机的可分配任务数是否大于0,直至所述控制器对上述某个可用执行机的可分配任务数大于0时,将所述待分配任务分配给该可用执行机执行,结束分配操作;若扫描步长为9,则当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,分配模块150将依次判断所述控制器对编号为1、0、9、8、……3的可用执行机的可分配任务数是否大于0,直至所述控制器对上述某个可用执行机的可分配任务数大于0时,将所述待分配任务分配给该可用执行机执行,结束分配操作。
需要说明的是,本申请未将扫描步长规定为1,而是通过计算的方式在满足要求的有限的自然数(包括1)中选择确定的数作为某个待分配任务的扫描步长,是为了减少任务分配不均的可能。例如,对于多类任务,计算模块140计算得到的所述确定的可用执行机可能相同,当所述确定的可用执行机相同时,若所述扫描步长也相同,则任务分配过程将出现此多类任务聚集在个别可用执行机上的情况,无法达到负载均衡的目的。而通过上述计算的方式计算出多类任务的扫描步长不一定相等,即可减少任务聚集的可能,更有利于 达到负载均衡的目的。
此外,本申请还提供一种分布式任务调度方法。参照图3所示,为本申请分布式任务调度方法的实施例的流程示意图。分布式任务调度系统1的处理器12执行存储器11中存储的任务调度程序10时实现分布式任务调度方法的如下步骤:
步骤S300,利用所述统计模块110获取执行机的可用状态,计算可用执行机的数量。在本实施例中,通过向各个执行机发送用于确定节点设备可用状态的广播报文并接收响应报文来获取所述分布式任务调度系统1中的执行机的可用状态,进而统计可用执行机的数量。然后还可以对所述可用执行机进行编号,为每个所述可用执行机分配一个唯一的可用执行机编号,例如,从0开始以递增整数为每个所述可用执行机编号:0、1、2……i。
步骤S301,利用所述设置模块120设置每个所述可用执行机的可执行任务阈值,并记录所述分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数。在本实施例中,可根据所述可用执行机的配置信息预估并设置每个所述可用执行机的可执行任务阈值,然后将该可执行任务阈值与所述分布式任务调度系统1包含的控制器的数量相除并舍位取整,得到每个控制器对每个所述可用执行机的可分配任务数的初始值。然后在每个控制器上定义一个一维数组,使该一维数组的元素与所述可用执行机一一对应,且使各元素的初始值与上述计算得到的每个控制器对每个所述可用执行机的可分配任务数的初始值相等。当将从某个控制器获取的一个待分配任务分配给某个可用执行机执行时,对应元素值减1,当该可用执行机执行完成该任务时,对应元素值加1。
步骤S302,利用所述映射模块130从任一控制器获取待分配任务,并根据该待分配任务的属性信息计算该待分配任务的哈希值。在本实施例中,所述待分配任务的属性信息包括任务名称和任务所有者名称。先对所述待分配任务的名称进行MD5运算,得到第一运算结果,再对所述待分配任务的所有者名称进行SHA-1运算,得到第二运算结果,最后将所述第二运算结果(160位)的后128位与所述第一运算结果(128位)进行异或运算,得到第三运算结果,将该第三运算结果作为所述待分配任务的哈希值。因为同类任务通常 具有相同的任务名称,其任务所有者也相同,所以同类任务将具有相同的哈希值。
步骤S303,利用所述计算模块140计算所述哈希值与所述可用执行机的数量的第一取余值,从所述可用执行机中确定与该第一取余值对应的可用执行机。因为同类任务的哈希值相同,所以,对于同类任务,所述确定的可用执行机相同。优先考虑将同类任务分配给相同的可用执行机执行,可实现资源复用,提高任务执行效率。
步骤S304,利用所述分配模块150根据调度所述待分配任务的控制器对所述确定的可用执行机以及其他可用执行机的可分配任务数,选择执行所述待分配任务的可用执行机。具体地,当所述控制器对所述确定的可用执行机的可分配任务数大于0时,将所述待分配任务分配给所述确定的可用执行机执行;当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行;当所述控制器对所述可用执行机的可分配任务数都不大于0时,随机选择一个可用执行机执行所述待分配任务。
在本实施例中,将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行的过程包括如下操作:
计算扫描步长:
step=coprimeList(NumInvokers).get(hash%size(coprimerList(NumInvokers)));
计算任一其他可用执行机的编号:
Invoker编号=(homeInvoker+m*step)%NumInvokers;
判断所述控制器对当前可用执行机的可分配任务数是否大于0;
若所述控制器对当前可用执行机的可分配任务数大于0,则将所述待分配任务分配给该当前可用执行机执行,结束步骤S304;
若所述控制器对当前可用执行机的可分配任务数不大于0,则令m=m+1,计算另一可用执行机的编号,判断所述控制器对该另一可用执行机的可分配任务数是否大于0。
其中,NumInvokers表示可用执行机的数量,coprimeList(NumInvokers) 表示获取小于NumInvokers值且与NumInvokers值互质的自然数列表,size(coprimeList(NumInvokers))表示所述自然数列表中自然数的个数,get(hash%size(coprimeList(NumInvokers)))表示先利用所述待分配任务的哈希值对所述自然数列表中自然数的个数进行取余计算,然后从该自然数列表中取得与所得取余值对应的数值,homeInvoker表示所述确定的可用执行机的编号,变量m表示从1到NumInvokers-1的整数值。
当m=NumInvokers-1时,将完成对所有所述可用执行机对于所述控制器的可分配任务数与0的相对大小的判断。若所述控制器对所述可用执行机的可分配任务数都不大于0,则随机选择一个可用执行机执行所述待分配任务。
此外,本申请还提供一种计算机可读存储介质,该计算机可读存储介质可以是硬盘、多媒体卡、SD卡、闪存卡、SMC、只读存储器(ROM)、可擦除可编程只读存储器(EPROM)、便携式紧致盘只读存储器(CD-ROM)、USB存储器等等中的任意一种或者几种的任意组合。所述计算机可读存储介质中包括任务调度程序10,该任务调度程序10被执行时实现的功能,请参照上述关于图2、图3的介绍,在此不再赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本申请要求的保护范围之内。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质中,包括若干指令用以使得分布式任务调度系统执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种分布式任务调度方法,应用于分布式任务调度系统,其特征在于,该方法包括:
    统计步骤:获取执行机的可用状态,统计可用执行机的数量;
    设置步骤:设置每个所述可用执行机的可执行任务阈值并记录所述分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数;
    映射步骤:从任一控制器获取待分配任务,根据该待分配任务的属性信息计算该待分配任务的哈希值;
    计算步骤:计算所述哈希值与所述可用执行机的数量的第一取余值,从所述可用执行机中确定与该第一取余值对应的可用执行机;及
    分配步骤:当所述控制器对所述确定的可用执行机的可分配任务数大于0时,将所述待分配任务分配给所述确定的可用执行机执行;当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行;当所述控制器对所述可用执行机的可分配任务数都不大于0时,随机选择一个可用执行机执行所述待分配任务。
  2. 如权利要求1所述的分布式任务调度方法,其特征在于,所述设置步骤中记录每个控制器对每个所述可用执行机的可分配任务数的过程包括如下步骤:
    将所述可执行任务阈值与控制器的数量相除并舍位取整,得到每个控制器对每个所述可用执行机的可分配任务数的初始值;
    在每个控制器上定义一个一维数组,使该一维数组的元素与所述可用执行机一一对应,且各元素的初始值与所述每个控制器对每个所述可用执行机的可分配任务数的初始值相等;
    将从某个控制器获取的一个待分配任务分配给某个可用执行机执行时,该控制器对该可用执行机的可分配任务数减1;
    该可用执行机执行完成该任务时,该控制器对该可用执行机的可分配任务数加1。
  3. 如权利要求1所述的分布式任务调度方法,其特征在于,所述待分配 任务的属性信息包括任务名称和任务所有者名称。
  4. 如权利要求3所述的分布式任务调度方法,其特征在于,所述映射步骤包括:
    利用第一哈希函数对所述待分配任务的名称进行哈希运算,得到第一运算结果;
    利用第二哈希函数对所述待分配任务的所有者名称进行哈希运算,得到第二运算结果;
    对所述第一运算结果和所述第二运算结果进行异或运算,得到第三运算结果,将该第三运算结果作为所述待分配任务的哈希值。
  5. 如权利要求4所述的分布式任务调度方法,其特征在于,所述第一哈希函数和所述第二哈希函数为MD5、SHA-1中的一种或两种。
  6. 如权利要求3至5中任意一项所述的分布式任务调度方法,其特征在于,所述设置步骤中记录每个控制器对每个所述可用执行机的可分配任务数的过程包括如下步骤:
    将所述可执行任务阈值与控制器的数量相除并舍位取整,得到每个控制器对每个所述可用执行机的可分配任务数的初始值;
    在每个控制器上定义一个一维数组,使该一维数组的元素与所述可用执行机一一对应,且各元素的初始值与所述每个控制器对每个所述可用执行机的可分配任务数的初始值相等;
    将从某个控制器获取的一个待分配任务分配给某个可用执行机执行时,该控制器对该可用执行机的可分配任务数减1;
    该可用执行机执行完成该任务时,该控制器对该可用执行机的可分配任务数加1。
  7. 如权利要求6所述的分布式任务调度方法,其特征在于,所述分配步骤中将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行的过程包括如下步骤:
    获取小于所述可用执行机的数量且与所述可用执行机的数量互质的自然数,统计获取的自然数的数量;
    计算所述待分配任务的哈希值与所述获取的自然数的数量的第二取余值,选取与该第二取余值对应的所述自然数作为扫描步长;
    根据所述扫描步长依次判断所述控制器对各可用执行机的可分配任务数是否大于0;
    当所述控制器对某个可用执行机的可分配任务数大于0时,将所述待分配任务分配给该可用执行机执行,结束所述分配步骤。
  8. 一种分布式任务调度系统,包括存储器、处理器和若干执行机,其特征在于,所述存储器中包括任务调度程序,该任务调度程序被所述处理器执行时实现如下步骤:
    统计步骤:获取执行机的可用状态,统计可用执行机的数量;
    设置步骤:设置每个所述可用执行机的可执行任务阈值并记录所述分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数;
    映射步骤:从任一控制器获取待分配任务,根据该待分配任务的属性信息计算该待分配任务的哈希值;
    计算步骤:计算所述哈希值与所述可用执行机的数量的第一取余值,从所述可用执行机中确定与该第一取余值对应的可用执行机;及
    分配步骤:当所述控制器对所述确定的可用执行机的可分配任务数大于0时,将所述待分配任务分配给所述确定的可用执行机执行;当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行;当所述控制器对所述可用执行机的可分配任务数都不大于0时,随机选择一个可用执行机执行所述待分配任务。
  9. 如权利要求8所述的分布式任务调度系统,其特征在于,所述设置步骤中记录每个控制器对每个所述可用执行机的可分配任务数的过程包括如下步骤:
    将所述可执行任务阈值与控制器的数量相除并舍位取整,得到每个控制器对每个所述可用执行机的可分配任务数的初始值;
    在每个控制器上定义一个一维数组,使该一维数组的元素与所述可用执行机一一对应,且各元素的初始值与所述每个控制器对每个所述可用执行机的可分配任务数的初始值相等;
    将从某个控制器获取的一个待分配任务分配给某个可用执行机执行时,该控制器对该可用执行机的可分配任务数减1;
    该可用执行机执行完成该任务时,该控制器对该可用执行机的可分配任务数加1。
  10. 如权利要求8所述的分布式任务调度系统,其特征在于,所述待分配任务的属性信息包括任务名称和任务所有者名称。
  11. 如权利要求10所述的分布式任务调度系统,其特征在于,所述映射步骤包括:
    利用第一哈希函数对所述待分配任务的名称进行哈希运算,得到第一运算结果;
    利用第二哈希函数对所述待分配任务的所有者名称进行哈希运算,得到第二运算结果;
    对所述第一运算结果和所述第二运算结果进行异或运算,得到第三运算结果,将该第三运算结果作为所述待分配任务的哈希值。
  12. 如权利要求11所述的分布式任务调度系统,其特征在于,所述第一哈希函数和所述第二哈希函数为MD5、SHA-1中的一种或两种。
  13. 如权利要求10至12中任意一项所述的分布式任务调度系统,其特征在于,所述设置步骤中记录每个控制器对每个所述可用执行机的可分配任务数的过程包括如下步骤:
    将所述可执行任务阈值与控制器的数量相除并舍位取整,得到每个控制器对每个所述可用执行机的可分配任务数的初始值;
    在每个控制器上定义一个一维数组,使该一维数组的元素与所述可用执行机一一对应,且各元素的初始值与所述每个控制器对每个所述可用执行机的可分配任务数的初始值相等;
    将从某个控制器获取的一个待分配任务分配给某个可用执行机执行时,该控制器对该可用执行机的可分配任务数减1;
    该可用执行机执行完成该任务时,该控制器对该可用执行机的可分配任务数加1。
  14. 如权利要求13所述的分布式任务调度系统,其特征在于,所述分配步骤中将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行的过程包括如下步骤:
    获取小于所述可用执行机的数量且与所述可用执行机的数量互质的自然 数,统计获取的自然数的数量;
    计算所述待分配任务的哈希值与所述获取的自然数的数量的第二取余值,选取与该第二取余值对应的所述自然数作为扫描步长;
    根据所述扫描步长依次判断所述控制器对各可用执行机的可分配任务数是否大于0;
    当所述控制器对某个可用执行机的可分配任务数大于0时,将所述待分配任务分配给该可用执行机执行,结束所述分配步骤。
  15. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中包括任务调度程序,该任务调度程序被执行时实现如下步骤:
    统计步骤:获取执行机的可用状态,统计可用执行机的数量;
    设置步骤:设置每个所述可用执行机的可执行任务阈值并记录所述分布式任务调度系统的每个控制器对每个所述可用执行机的可分配任务数;
    映射步骤:从任一控制器获取待分配任务,根据该待分配任务的属性信息计算该待分配任务的哈希值;
    计算步骤:计算所述哈希值与所述可用执行机的数量的第一取余值,从所述可用执行机中确定与该第一取余值对应的可用执行机;及
    分配步骤:当所述控制器对所述确定的可用执行机的可分配任务数大于0时,将所述待分配任务分配给所述确定的可用执行机执行;当所述控制器对所述确定的可用执行机的可分配任务数不大于0时,将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行;当所述控制器对所述可用执行机的可分配任务数都不大于0时,随机选择一个可用执行机执行所述待分配任务。
  16. 如权利要求15所述的计算机可读存储介质,其特征在于,所述待分配任务的属性信息包括任务名称和任务所有者名称。
  17. 如权利要求16所述的计算机可读存储介质,其特征在于,所述映射步骤包括:
    利用第一哈希函数对所述待分配任务的名称进行哈希运算,得到第一运算结果;
    利用第二哈希函数对所述待分配任务的所有者名称进行哈希运算,得到第二运算结果;
    对所述第一运算结果和所述第二运算结果进行异或运算,得到第三运算结果,将该第三运算结果作为所述待分配任务的哈希值。
  18. 如权利要求17所述的计算机可读存储介质,其特征在于,所述第一哈希函数和所述第二哈希函数为MD5、SHA-1中的一种或两种。
  19. 如权利要求15至18中任意一项所述的计算机可读存储介质,其特征在于,所述设置步骤中记录每个控制器对每个所述可用执行机的可分配任务数的过程包括如下步骤:
    将所述可执行任务阈值与控制器的数量相除并舍位取整,得到每个控制器对每个所述可用执行机的可分配任务数的初始值;
    在每个控制器上定义一个一维数组,使该一维数组的元素与所述可用执行机一一对应,且各元素的初始值与所述每个控制器对每个所述可用执行机的可分配任务数的初始值相等;
    将从某个控制器获取的一个待分配任务分配给某个可用执行机执行时,该控制器对该可用执行机的可分配任务数减1;
    该可用执行机执行完成该任务时,该控制器对该可用执行机的可分配任务数加1。
  20. 如权利要求19所述的计算机可读存储介质,其特征在于,所述分配步骤中将所述待分配任务分配给任一其他所述控制器对其的可分配任务数大于0的可用执行机执行的过程包括如下步骤:
    获取小于所述可用执行机的数量且与所述可用执行机的数量互质的自然数,统计获取的自然数的数量;
    计算所述待分配任务的哈希值与所述获取的自然数的数量的第二取余值,选取与该第二取余值对应的所述自然数作为扫描步长;
    根据所述扫描步长依次判断所述控制器对各可用执行机的可分配任务数是否大于0;
    当所述控制器对某个可用执行机的可分配任务数大于0时,将所述待分配任务分配给该可用执行机执行,结束所述分配步骤。
PCT/CN2019/088631 2018-12-10 2019-05-27 分布式任务调度方法、系统及存储介质 WO2020119029A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811503014.X 2018-12-10
CN201811503014.XA CN109669775A (zh) 2018-12-10 2018-12-10 分布式任务调度方法、系统及存储介质

Publications (1)

Publication Number Publication Date
WO2020119029A1 true WO2020119029A1 (zh) 2020-06-18

Family

ID=66143670

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/088631 WO2020119029A1 (zh) 2018-12-10 2019-05-27 分布式任务调度方法、系统及存储介质

Country Status (2)

Country Link
CN (1) CN109669775A (zh)
WO (1) WO2020119029A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112463336A (zh) * 2020-12-07 2021-03-09 深圳集智数字科技有限公司 一种对象分配方法、装置、设备及介质
US20220101194A1 (en) * 2020-09-30 2022-03-31 EMC IP Holding Company LLC Method, electronic device, and computer program product for processing machine learning model

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109669775A (zh) * 2018-12-10 2019-04-23 平安科技(深圳)有限公司 分布式任务调度方法、系统及存储介质
CN110659117A (zh) * 2019-08-23 2020-01-07 阿里巴巴集团控股有限公司 业务指标任务调度及执行方法、装置、系统及存储介质
CN110716796B (zh) * 2019-09-02 2024-05-28 中国平安财产保险股份有限公司 智能任务调度方法及装置、存储介质、电子设备
CN111190710A (zh) * 2019-11-25 2020-05-22 泰康保险集团股份有限公司 一种任务分配方法及装置
CN115171703B (zh) * 2022-05-30 2024-05-24 青岛海尔科技有限公司 分布式语音唤醒方法和装置、存储介质及电子装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103425519A (zh) * 2012-05-16 2013-12-04 富士通株式会社 分布式计算方法和分布式计算系统
CN105335219A (zh) * 2014-07-08 2016-02-17 阿里巴巴集团控股有限公司 一种基于分布式的任务调度方法及系统
CN106126332A (zh) * 2016-06-27 2016-11-16 北京京东尚科信息技术有限公司 分布式定时任务调度系统及方法
CN108762931A (zh) * 2018-05-31 2018-11-06 康键信息技术(深圳)有限公司 基于分布式调度系统的任务调度方法、服务器及存储介质
CN109669775A (zh) * 2018-12-10 2019-04-23 平安科技(深圳)有限公司 分布式任务调度方法、系统及存储介质

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103150213B (zh) * 2011-12-06 2016-06-22 北大方正集团有限公司 负载平衡方法和装置
CN102622273B (zh) * 2012-02-23 2015-04-15 中国人民解放军国防科学技术大学 基于自学习负载预测的集群按需启动方法
CN102882973B (zh) * 2012-10-11 2015-05-20 北京邮电大学 基于p2p技术的分布式负载均衡系统和方法
CN105786600B (zh) * 2016-02-02 2019-05-03 北京京东尚科信息技术有限公司 任务调度方法和装置
CN106130920A (zh) * 2016-07-14 2016-11-16 腾讯科技(深圳)有限公司 一种报文转发方法及装置
CN108268318A (zh) * 2016-12-30 2018-07-10 华为技术有限公司 一种分布式系统任务分配的方法和装置
CN107087031B (zh) * 2017-05-10 2020-07-28 浙江宇视科技有限公司 一种存储资源负载均衡方法及装置
CN107688496B (zh) * 2017-07-24 2020-12-04 深圳壹账通智能科技有限公司 任务分布式处理方法、装置、存储介质和服务器
CN108696581B (zh) * 2018-05-07 2021-08-13 上海智臻智能网络科技股份有限公司 分布式信息的缓存方法、装置、计算机设备以及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103425519A (zh) * 2012-05-16 2013-12-04 富士通株式会社 分布式计算方法和分布式计算系统
CN105335219A (zh) * 2014-07-08 2016-02-17 阿里巴巴集团控股有限公司 一种基于分布式的任务调度方法及系统
CN106126332A (zh) * 2016-06-27 2016-11-16 北京京东尚科信息技术有限公司 分布式定时任务调度系统及方法
CN108762931A (zh) * 2018-05-31 2018-11-06 康键信息技术(深圳)有限公司 基于分布式调度系统的任务调度方法、服务器及存储介质
CN109669775A (zh) * 2018-12-10 2019-04-23 平安科技(深圳)有限公司 分布式任务调度方法、系统及存储介质

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220101194A1 (en) * 2020-09-30 2022-03-31 EMC IP Holding Company LLC Method, electronic device, and computer program product for processing machine learning model
CN112463336A (zh) * 2020-12-07 2021-03-09 深圳集智数字科技有限公司 一种对象分配方法、装置、设备及介质

Also Published As

Publication number Publication date
CN109669775A (zh) 2019-04-23

Similar Documents

Publication Publication Date Title
WO2020119029A1 (zh) 分布式任务调度方法、系统及存储介质
US20190324819A1 (en) Distributed-system task assignment method and apparatus
CN107241281B (zh) 一种数据处理方法及其装置
CN113641457B (zh) 容器创建方法、装置、设备、介质及程序产品
WO2019205371A1 (zh) 服务器、消息分配的方法及存储介质
JP6083290B2 (ja) 分散処理システム
CN109309712B (zh) 基于接口异步调用的数据传输方法、服务器及存储介质
US20220156115A1 (en) Resource Allocation Method And Resource Borrowing Method
CN110852882B (zh) 用于区块链网络的分组共识方法、装置、设备和介质
US10114866B2 (en) Memory-constrained aggregation using intra-operator pipelining
CN110209348B (zh) 数据存储方法、装置、电子设备及存储介质
CN109684080A (zh) 集中式任务调度方法、系统及存储介质
WO2015001850A1 (ja) タスク割り当て判定装置、制御方法、及びプログラム
JP6129290B1 (ja) 分散計算におけるアプリケーションパラメータ設定およびシステム仕様設定を推奨する方法およびシステム
CN104102693A (zh) 对象处理方法和装置
CN111338779B (zh) 资源分配方法、装置、计算机设备和存储介质
CN113285886B (zh) 一种带宽分配的方法、装置、电子设备及可读存储介质
CN111858055A (zh) 任务处理方法、服务器及存储介质
WO2021237630A1 (zh) 多键值命令的处理方法、装置、电子设备及存储介质
CN109165135B (zh) 一种数据管理方法、计算机可读存储介质及终端设备
CN108647090B (zh) 一种资源分配方法及装置、服务器集群
WO2020024207A1 (zh) 处理业务请求的方法、装置与存储系统
CN114675954A (zh) 任务调度方法及装置
CN114942833A (zh) 定时任务资源动态调度方法及相关装置
CN111858542B (zh) 数据处理方法、装置、设备及计算机可读存储介质

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: 19896872

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: 19896872

Country of ref document: EP

Kind code of ref document: A1