Task distribution method and device, computer readable medium and electronic equipment
By acquiring task requirements and node status information, and dynamically matching target nodes for task allocation, the problem of low efficiency in existing task distribution systems is solved, thereby improving task execution efficiency and resource utilization.
Patent Information
- Application Number
- CN202410763994.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2025-12-16
AI Technical Summary
Existing task distribution systems rely on load balancing algorithms, resulting in low task execution efficiency and low resource utilization. They also lack flexibility and intelligence, and cannot differentiate task distribution based on task characteristics and node capabilities.
By acquiring the resource requirements and node status information of the tasks to be processed, the system dynamically matches target nodes for task allocation, and expands or shrinks the capacity when necessary, and redistributes tasks based on task type and node capabilities.
It achieves flexibility and intelligence in task distribution, improves task execution efficiency and resource utilization, and can perform differentiated distribution based on task characteristics and node capabilities, dynamically adjusting task allocation strategies.
Smart Images

Figure CN121143984A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of task processing, in particular to a task distribution method and device, a computer readable medium and an electronic device. BACKGROUND
[0002] A task distribution system is a kind of software architecture, and its core purpose is to ensure the reliable processing of large-scale workloads. Such a system can receive task requests and then distribute these tasks to available computing resources. However, the current task distribution system only implements task distribution according to various load balancing algorithms, and such a distribution strategy is not only very mechanical and rigid, but also often unreasonable, resulting in low task execution efficiency and low resource utilization. SUMMARY
[0003] Embodiments of the present application provide a task distribution method, device, computer readable medium and electronic device, thereby at least to some extent providing a more flexible and intelligent task distribution scheme, and enabling the decision of task distribution to be more reasonable, improving task execution efficiency and resource utilization.
[0004] Other characteristics and advantages of the present application will become apparent from the following detailed description, or will be learned by practice of the present application.
[0005] According to an aspect of an embodiment of the present application, a task distribution method is provided, the method comprising: when a to-be-processed task is received, obtaining resource requirement information of the to-be-processed task; obtaining node state information of each node in a plurality of nodes of a target cluster, the node state information including resource usage information corresponding to each resource of the node; determining a target node matching the to-be-processed task from the plurality of nodes of the target cluster according to the resource requirement information of the to-be-processed task and the node state information of each node including the resource usage information; and distributing the to-be-processed task to the target node to execute the to-be-processed task on the target node.
[0006] According to an aspect of some embodiments of the present application, a task distribution apparatus is provided, which comprises: a resource requirement information obtaining unit, configured to obtain resource requirement information of a to-be-processed task when the to-be-processed task is received; a node state information obtaining unit, configured to obtain node state information of each node in a plurality of nodes of a target cluster, the node state information comprising resource usage information corresponding to each resource of the node; a node determining unit, configured to determine a target node matching the to-be-processed task from the plurality of nodes of the target cluster according to the resource requirement information of the to-be-processed task and the node state information of each node comprising the resource usage information; and an allocation unit, configured to allocate the to-be-processed task to the target node to execute the to-be-processed task on the target node.
[0007] In some embodiments of the present application, based on the foregoing scheme, the node determining unit is configured to select a candidate node from the plurality of nodes of the target cluster; and if it is determined that the resource usage information of the candidate node meets the resource requirement information of the to-be-processed task, the candidate node is determined as the target node matching the to-be-processed task.
[0008] In some embodiments of the present application, based on the foregoing scheme, the apparatus further comprises an idle state information obtaining unit; before the target node matching the to-be-processed task is determined from the plurality of nodes of the target cluster, the idle state information obtaining unit is configured to obtain idle state information of each node in the plurality of nodes of the target cluster, the idle state information being used to indicate whether the node is in an idle state; and the node determining unit is configured to, if it is determined according to the idle state information that there is an idle node in an idle state in the plurality of nodes of the target cluster, take the idle node as a candidate node.
[0009] In some embodiments of the present application, based on the foregoing scheme, the apparatus further comprises a first capacity expansion unit; after the candidate node is selected from the plurality of nodes of the target cluster, the first capacity expansion unit is configured to, if it is determined that the resource usage information of all candidate nodes does not meet the resource requirement information of the to-be-processed task, perform a capacity expansion operation on the target cluster to add a new node capable of meeting the resource requirement information of the to-be-processed task in the target cluster.
[0010] In some embodiments of the present application, based on the foregoing scheme, the to-be-processed task is received from a task queue, and the device further comprises a task quantity obtaining unit and a second capacity expansion unit; after obtaining the idle state information of each node in the plurality of nodes of the target cluster, the task quantity obtaining unit is configured to: if it is determined according to the idle state information of each node in the plurality of nodes of the target cluster that there is no idle node in the idle state in the plurality of nodes of the target cluster, obtain the quantity of tasks queuing in the task queue; and the second capacity expansion unit is configured to: if the quantity of tasks queuing in the task queue exceeds a first predetermined quantity threshold, perform a capacity expansion operation on the target cluster to add a new node in the target cluster.
[0011] In some embodiments of the present application, based on the foregoing scheme, the device further comprises an idle node quantity determining unit and a capacity reduction unit; after obtaining the idle state information of each node in the plurality of nodes of the target cluster, the idle node quantity determining unit is configured to: if it is determined according to the idle state information of each node in the plurality of nodes of the target cluster that there is an idle node in the idle state in the plurality of nodes of the target cluster, determine the quantity of idle nodes in the idle state in the plurality of nodes of the target cluster in the case that there is no task in the task queue; and the capacity reduction unit is configured to: if the quantity of idle nodes exceeds a second predetermined quantity threshold, perform a capacity reduction operation on the target cluster to remove at least one idle node from the target cluster.
[0012] In some embodiments of the present application, based on the foregoing scheme, the device further comprises a task running state information obtaining unit, a task type determining unit, a backup node selecting unit and a task re-allocating unit; after allocating the to-be-processed task to the target node, the task running state information obtaining unit is configured to: obtain task running state information of the target node; the task type determining unit is configured to: if it is determined according to the task running state information that the to-be-processed task is abnormal, determine the task type of the to-be-processed task; the backup node selecting unit is configured to: select a plurality of backup nodes from the plurality of nodes of the target cluster according to the task type of the to-be-processed task for a specified task type; and the task re-allocating unit is configured to: re-allocate the to-be-processed task to each of the backup nodes to re-execute the to-be-processed task on each of the backup nodes.
[0013] In some embodiments of the present application, based on the foregoing scheme, the apparatus further comprises an available node determining unit; the resource usage information comprises available resource amounts of respective kinds of resources, and the task type determining unit is configured to determine that the task type of the to-be-processed task is a target kind of resource requiring type according to resource requirement information of the to-be-processed task, wherein a task of the target kind of resource requiring type has a demand amount of a target kind of resource greater than that of tasks of other task types; after determining the task type of the to-be-processed task, the available node determining unit is configured to determine, according to the task type of the to-be-processed task being the target kind of resource requiring type, that a node having an available resource amount of the target kind of resource greater than that of the target node is the other node among the plurality of nodes based on the resource usage information of the target kind of resource of each node; and the task re-distributing unit is further configured to re-distribute the to-be-processed task to the other node to re-execute the to-be-processed task on the other node.
[0014] In some embodiments of the present application, based on the foregoing scheme, the node state information obtaining unit is configured to obtain node states respectively reported by each node of the plurality of nodes of the target cluster, and write the node states into a node state table; and obtain the node state information of each node of the plurality of nodes of the target cluster from the node state table.
[0015] According to an aspect of some embodiments of the present application, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements the task distribution method as described in the above embodiments.
[0016] According to an aspect of some embodiments of the present application, there is provided an electronic device comprising: one or more processors; and a storage apparatus configured to store one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the task distribution method as described in the above embodiments.
[0017] According to an aspect of some embodiments of the present application, there is provided a computer program product comprising computer instructions stored in a computer readable storage medium, wherein a processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the task distribution method as described in the above embodiments.
[0018] In the technical solution provided in some embodiments of the present application, when a task to be processed is received, resource requirement information of the task to be processed is acquired, and node state information of each node in the target cluster is also acquired, then the target node to which the task to be processed is matched is determined according to the resource requirement information and the node state information of each node including resource usage information, and finally the task to be processed is allocated to the target node. As can be seen, since the task distribution solution provided in the embodiments of the present application determines the target node to which the task to be processed is allocated according to the acquired node state information of each node including resource usage information and resource requirement information, a very flexible and intelligent task distribution strategy is provided, dynamic perception of node state information is realized, the decision result of task distribution is more accurate and reasonable, and thus the task execution efficiency can be improved and the resource utilization rate can be improved.
[0019] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and are not limiting to the present application. BRIEF DESCRIPTION OF DRAWINGS
[0020] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application. It is apparent that the accompanying drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings. In the drawings:
[0021] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied is shown;
[0022] Figure 2 A schematic diagram of the principle of task distribution according to one embodiment of the present application is shown;
[0023] Figure 3 A flowchart of a task distribution method according to one embodiment of the present application is shown;
[0024] Figure 4 An architectural block diagram of a task distribution system according to one embodiment of the present application is shown;
[0025] Figure 5 A schematic diagram of the principle of a task distribution system according to one embodiment of the present application is shown;
[0026] Figure 6 A schematic diagram of a node state reporting node state on a node state plug-in in a task distribution system according to one embodiment of the present application is shown;
[0027] Figure 7Fig. 1 shows a schematic diagram of a node status plugin reporting task running information in a task distribution system according to an embodiment of the present application;
[0028] Figure 8 Fig. 2 shows a schematic diagram of a scheduler constructing a downstream node status table by maintaining downstream node status in a task distribution system according to an embodiment of the present application;
[0029] Figure 9 Fig. 3 shows a schematic diagram of a task distribution system according to an embodiment of the present application; Figure 3 Fig. 4 shows a flow chart of details of step 320 in an embodiment;
[0030] Figure 10 Fig. 5 shows a schematic diagram of a task distribution system according to an embodiment of the present application; Figure 3 Fig. 6 shows a flow chart of details of step 340 in an embodiment;
[0031] Figure 11 Fig. 7 shows a schematic diagram of a task distribution system according to an embodiment of the present application; Figure 10 Fig. 8 shows a flow chart of details of steps before step 340 and step 341 in an embodiment;
[0032] Figure 12 Fig. 9 shows a flow chart of a task distribution and scaling a node when distributing a task according to an embodiment of the present application;
[0033] Figure 13 Fig. 10 shows a flow chart of scaling and unscaling a downstream cluster according to an embodiment of the present application;
[0034] Figure 14 Fig. 11 shows a schematic diagram of a task distribution system according to an embodiment of the present application; Figure 3 Fig. 12 shows a flow chart of steps after step 350 in an embodiment;
[0035] Figure 15 Fig. 13 shows a flow chart of a task re-distribution when a task is in an abnormal situation according to an embodiment of the present application;
[0036] Figure 16 Fig. 14 shows a block diagram of a task distribution apparatus according to an embodiment of the present application;
[0037] Figure 17 Fig. 15 shows a schematic diagram of a computer system of an electronic device suitable for implementing embodiments of the present application. DETAILED DESCRIPTION
[0038] Example implementations will now be described more fully with reference to the accompanying drawings. Example implementations can be implemented in any
[0039] Moreover, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the application. One skilled in the relevant art will recognize, however, that the application can be practiced without one or more of the specific details, or with other methods, components, materials, and so forth. In other instances, well-known structures, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the application.
[0040] In embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an overall module or unit that includes the functions of the module or unit.
[0041] The block diagrams shown in the accompanying drawings are merely functional entities, and do not necessarily have to correspond to physically independent entities. That is, these functional entities can be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0042] The flowcharts shown in the accompanying drawings are merely exemplary illustrations, and do not necessarily include all contents and operations / steps, nor do they have to be executed in the order described. For example, some operations / steps can be further divided, and some operations / steps can be combined or partially combined, so the actual execution order can be changed according to the actual situation.
[0043] Online task distribution generally refers to the dynamic allocation of tasks or workloads to multiple processing nodes in a network for parallel processing in a distributed system. This distribution can be automatic or manual, with the goal of improving processing efficiency, shortening task completion time, and better utilizing system resources.
[0044] The task distribution system in the related art utilizes a scheduler to implement task distribution, however, this task distribution system has some limitations, the most important of which is that the scheduler only maintains a single table of downstream node IP addresses. This design means that all task processing nodes are considered to be functionally identical, and cannot achieve individualization and differentiation of task distribution. In addition, the scheduler mainly focuses on implementing various load balancing algorithms, the core goal of which is to ensure that tasks are evenly distributed to each downstream node, without considering more flexible distribution strategies.
[0045] In addition, when an exception occurs in task execution, the processing manner of the task distribution system in the related art is relatively single, and usually only retry can be selected. It has no ability to make a more reasonable decision according to the exception information and the real-time state of the node cluster, such as reassigning the task to a node with a healthier state or a node with the ability to process a specific task.
[0046] In summary, the efficiency of the task distribution system in the related art is very low and has no intelligence, and has the following disadvantages:
[0047] 1. The scheduler is not intelligent and cannot perform differentiated distribution according to the characteristics of the task and the ability of the downstream node. For example, for a compute-intensive task, it cannot be preferentially assigned to a node with stronger computing ability.
[0048] 2. The scheduler maintains less information, only an IP address table, and does not include information such as performance indicators, current load, and processing capacity of the node, which is not convenient for making a more reasonable task allocation decision.
[0049] 3. The task distribution strategy is not flexible, such as being unable to dynamically adjust according to factors such as the urgency and priority of the task.
[0050] 4. For the processing of abnormal tasks, the redistribution mechanism is not intelligent and flexible. The system cannot analyze the exception information and combine the real-time state of the node to decide whether to retry, redistribute to other nodes, or take other remedial measures.
[0051] Therefore, the embodiments of the present application first provide a task distribution method. The task distribution method provided by the embodiments of the present application can overcome the above defects and achieve the following effects:
[0052] 1. The intelligence of the scheduler enables it to perform differentiated distribution according to the characteristics of the task and the ability of the downstream node. For example, for a compute-intensive task, it can be preferentially assigned to a node with stronger computing ability.
[0053] 2. The information maintained by the scheduler is expanded, not only an IP address table, but also information such as performance indicators, current load, and processing capacity of the node, so as to facilitate making a more reasonable task allocation decision.
[0054] 3. A more flexible task distribution strategy is introduced, such as dynamically adjusting according to factors such as the urgency and priority of the task.
[0055] 4. For the processing of abnormal tasks, a more intelligent redistribution mechanism is introduced. The system should be able to analyze the exception information and combine the real-time state of the node to decide whether to retry, redistribute to other nodes, or take other remedial measures.
[0056] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solutions of the embodiments of this application can be applied is shown. For example... Figure 1 As shown, the system architecture 100 may include a user terminal 110, a task queue cluster 120, a scheduling server 130, and a node cluster 140. The task queue cluster 120 includes multiple task queue servers such as a first task queue server 121 and a second task queue server 122. The node cluster 140 includes multiple servers such as a first server 141, a second server 142, and a third server 143. Both the user terminal 110 and the scheduling server 130 have established communication connections with the task queue cluster 120, and the scheduling server 130 also has a communication connection with the node cluster 140. A task submission client runs on the user terminal 110, task queue middleware runs on each task queue server, a scheduler is deployed and runs on the scheduling server 130, and task execution programs and node status plugins are deployed on each server in the node cluster 140. The scheduling server 130 can be the execution entity of the scheme in this application embodiment.
[0057] When a task distribution method provided in the embodiments of this application is applied to Figure 1 In the system architecture shown, a process can be as follows: First, each server in the node cluster 140 collects its node status information through a node status plugin and reports this information to the scheduler in the scheduling server 130, where it is stored. Then, the user on the user terminal 110 uses a task submission client to send a task request carrying pending tasks to the task queue cluster 120. These pending tasks include resource requirement information. Next, upon receiving the task request, the task queue cluster 120 uses the task queue middleware to process the pending tasks in each request according to... The received tasks are queued in order, with the most recently received task placed last. Then, the scheduler of the scheduling server 130 pulls the first task from the task queue cluster 120 and obtains the resource requirement information of the task. Next, the scheduler of the scheduling server 130 reads the node status information of each server and, based on the node status information and the resource requirement information of the task, determines the target server from the servers in the node cluster 140, and distributes the task to the target server for processing.
[0058] In some embodiments of this application, the node cluster 140 is located in the cloud.
[0059] In some embodiments of the present application, the node status plug-in in each server is configured to periodically report node status information to the scheduler in the scheduling server.
[0060] In some embodiments of the present application, the task queue middleware is a kafka middleware, and the to-be-processed tasks in the queue are stored in the memory or disk of each task queue server.
[0061] In some embodiments of the present application, the resource requirement information in the to-be-processed tasks is input and submitted by the user through the interactive interface of the task submission client.
[0062] It should be understood that, Figure 1 The number of user terminals, the number of task queue servers included in the task queue cluster, the number of scheduling servers, and the number of servers in the node cluster are only illustrative. According to the implementation needs, there can be any number of user terminals and scheduling servers, and the number of task queue servers included in the task queue cluster and the number of servers in the node cluster can also be any number, i.e., the user terminal can be multiple, and the scheduling server can be a server cluster composed of multiple servers.
[0063] It should be noted that, Figure 1 The shown is only one embodiment of the present application. Although in the above embodiment, Figure 1 In the scheme of the embodiment, the user terminal is a desktop computer, and the node in the node cluster 140 is a server, but in other embodiments of the present application, the user terminal can also be various types of terminal devices such as a desktop computer, a notebook computer, a tablet computer, a vehicle terminal, a portable wearable device, and a workstation, and the node in the node cluster 140 can also be a virtual machine, a container, or other types of nodes; although in the scheme of the embodiment, Figure 1 In the scheme of the embodiment, the receiving and storing of the node status information are both completed on the scheduling server, but in other embodiments of the present application, the node status information can also be stored on other devices (such as a database server) other than the scheduling server; although in the scheme of the embodiment, Figure 1 In the scheme of the embodiment, the scheduling server receives the reported node status information before obtaining the to-be-processed tasks, but in other embodiments of the present application, the scheduling server can also receive the reported node status information after obtaining the to-be-processed tasks; although in the scheme of the embodiment, Figure 1In the solution of the embodiments, the task queue middleware sorts the to-be-processed tasks in the task requests in the order of reception, but in other embodiments of the present application, the to-be-processed tasks can also be sorted in other manners, for example, the to-be-processed tasks can include a task start timestamp, the to-be-processed tasks can be sorted according to the task start timestamp, the to-be-processed tasks can also include a task priority, the to-be-processed tasks can be sorted according to the task priority from high to low, and for to-be-processed tasks of the same task priority, the to-be-processed tasks can be sorted in the order of reception from front to back. The embodiments of the present application do not make any limitation in this regard, and the protection scope of the present application should not be limited in any way either.
[0064] As can be easily understood, the task distribution method provided by the embodiments of the present application is generally executed by a server, and accordingly, the task distribution apparatus is generally arranged in the server. However, in other embodiments of the present application, a terminal device can also have similar functions as the server, so as to execute the task distribution solution provided by the embodiments of the present application.
[0065] Therefore, the embodiments of the present application can be applied to a terminal or a server. The server can be a standalone physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and big data and artificial intelligence platform. The terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal and the server can be directly or indirectly connected through wired or wireless communication, which is not limited in the present application.
[0066] As described above, the solution of the embodiments of the present application can be applied to a cloud computing scenario. Cloud computing is a computing mode that distributes computing tasks on a resource pool composed of a large number of computing devices, so that various application systems can obtain computing power, storage space and information service according to needs. The network providing resources is called "cloud". The resources in the "cloud" are infinitely expandable to users and can be obtained at any time, used on demand, expanded at any time, and paid according to use.
[0067] As a basic capability provider of cloud computing, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform) is established, and a plurality of types of virtual resources are deployed in the resource pool for external customers to select and use. The cloud computing resource pool mainly includes: computing devices (virtualized machines containing operating systems), storage devices, network devices.
[0068] According to logical function division, the PaaS (Platform as a Service) layer can be deployed on the IaaS (Infrastructure as a Service) layer, and the SaaS (Software as a Service) layer is deployed on the PaaS layer, or the SaaS is directly deployed on the IaaS. The PaaS is a platform for software running, such as a database, a web container, and the like. The SaaS is various business software, such as a web portal, a short message massager, and the like. Generally, the SaaS and the PaaS are upper layers relative to the IaaS.
[0069] The implementation details of the technical solutions of the embodiments of the present application are described in detail as follows:
[0070] Figure 2 A principle diagram of task distribution according to an embodiment of the present application is shown. Please refer to FIG. 1. Figure 2 As shown in FIG. 1, the task distribution is to distribute one or more tasks in a task set of a system to one or more nodes in a node set of the system, and the nodes perform parallel processing on the tasks.
[0071] The task distribution method provided by the embodiments of the present application can be applied to the scenario that a computing cluster processes a large number of online tasks. The online task distribution system has a wide range of applications in many fields. The following are some typical use scenarios:
[0072] (1) Cloud computing service: In a cloud platform, the task distribution system can distribute user computing tasks to different virtual machines or containers to optimize resource utilization and improve service quality.
[0073] (2) Big data processing: In big data applications such as Hadoop or Spark clusters, the task distribution system is responsible for distributing data processing tasks to different nodes in the cluster to achieve efficient data processing and analysis.
[0074] (3) Website and application hosting: For websites and applications that need to handle a large number of concurrent requests, the task distribution system can distribute user requests to different servers to balance the load and provide fast response.
[0075] (4) Content delivery network (CDN): The CDN service uses the task distribution system to distribute user content requests to the nearest server nodes to reduce latency and improve content delivery speed.
[0076] Figure 3A flow chart of a task distribution method according to an embodiment of the present application is shown, which can be executed by various devices with processing and computing functions, in particular, it can be executed by a target device such as a user terminal or a cloud server, including but not limited to a mobile phone, a computer, a smart voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, a smart watch, etc. Please refer to Figure 3 The task distribution method includes at least the following steps:
[0077] Step 310, when receiving a to-be-processed task, obtaining resource requirement information of the to-be-processed task.
[0078] Step 320, obtaining node state information of each node in the plurality of nodes of the target cluster, the node state information including resource usage information corresponding to each resource of the node.
[0079] Step 340, determining a target node matched with the to-be-processed task from the plurality of nodes of the target cluster according to the resource requirement information of the to-be-processed task and the node state information including the resource usage information of each node.
[0080] Step 350, assigning the to-be-processed task to the target node to execute the to-be-processed task on the target node.
[0081] Before detailing the steps shown in the embodiments, the steps before the steps shown in the embodiments are introduced. Figure 3 Before detailing the steps shown in the embodiments, the steps before the steps shown in the embodiments are introduced. Figure 3 Before detailing the steps shown in the embodiments, the steps before the steps shown in the embodiments are introduced.
[0082] Figure 4 A framework block diagram of a task distribution system according to an embodiment of the present application is shown. Please refer to Figure 4As shown, the task distribution system can include two parts, a scheduler and a downstream node cluster, the downstream node cluster including a plurality of nodes, each node including a node state plug-in (i.e., the small box in the lower left corner of each node block), the scheduler and the node state plug-in being two main plug-ins of the task distribution system. The scheduler is the core of the task distribution system, responsible for the logic of the entire task distribution, which specifically includes modules such as maintaining downstream node states, scaling downstream nodes, node selection, distributing online tasks, task running state detection, and exception task bottom-up logic. The method provided in the embodiments of the present application can be executed by the scheduler; the node state plug-in has two functions of reporting node states and reporting task running conditions. It is easy to understand that although the node state plug-in in this embodiment of the present application has both the functions of reporting node states and reporting task running conditions, in other embodiments of the present application, two plug-ins can be provided, one of which is used to implement the function of reporting node states, and the other of which is used to implement the function of reporting task running conditions. Such a system design can ensure the efficiency and reliability of task distribution, and at the same time, can also provide flexible scalability and fault tolerance. In actual application, such an architecture can cope with various scales and complexities of task distribution requirements, thereby supporting large-scale online services and applications.
[0083] In the following, the scheme of the embodiments of the present application will be further introduced. Figures 5 to 8 In the following, the scheme of the embodiments of the present application will be further introduced. Figures 5-8 The dashed part in the figure can represent the part of the task distribution system that is running.
[0084] Figure 5 A principle schematic diagram of a task distribution system according to an embodiment of the present application is shown. Please refer to Figure 5 As shown, one or more nodes in the downstream node cluster can be in a running state, or in an idle state or a closed state. The running state can indicate that the corresponding node is running and processing a task, and the idle state can indicate that the corresponding node is not running any task. The node state plug-in of each node in the downstream node cluster can report the node state to the scheduler through the function of reporting the node state; the node state plug-in of each node in the downstream node cluster can also report the task running condition information to the scheduler through the function of reporting the task running condition.
[0085] Figure 6 A schematic diagram of the node state plug-in reporting the node state in the task distribution system according to an embodiment of the present application is shown. Please refer to Figure 6As shown, the node state plug-in of each node in the downstream node cluster reports the node state to the maintenance downstream node state module in the scheduler, and the node state specifically can include: CPU parameter information, memory parameter information, disk parameter information, GPU parameter information, network parameter information, and the like performance indicators, CPU usage, memory usage, disk usage, GPU usage, bandwidth usage, and the like current load information, available resource amount of CPU, memory, disk, GPU, and bandwidth; wherein, the CPU parameter information can include model, core number, thread number, frequency, and the like, the memory parameter information can include capacity, frequency, and the like, the disk parameter information can include capacity, and the like; the GPU parameter information can include core number, video memory, and the like; the network parameter information can include transmission rate, and the like; the available resource amount is the difference between the total resource amount of the corresponding resource and the used resource amount, for example, the available resource amount of the memory can be the remaining memory size. Of course, the node state can also include other information, such as, it can also include network traffic data, delay data, connectivity information, processing capacity, and the like, wherein, the network traffic data can be the information of the service using network resources in the node and the proportion of each service using network resources, the delay data can be the time required for a data packet from the source to the destination, the connectivity information is used to indicate whether the current node can be normally accessed, that is, whether the health status of the current node is normal, and the processing capacity is an index for measuring the processing task capacity calculated according to the available resource amount according to a predetermined rule.
[0086] Figure 7 A schematic diagram of the node state plug-in reporting task running condition information in the task distribution system according to an embodiment of the present application is shown. Please refer to Figure 7 As shown, the node state plug-in of each node in the downstream node cluster reports the node state to the maintenance downstream node state module in the scheduler, and the node state specifically can include: CPU parameter information, memory parameter information, disk parameter information, GPU parameter information, network parameter information, and the like performance indicators, CPU usage, memory usage, disk usage, GPU usage, bandwidth usage, and the like current load information, available resource amount of CPU, memory, disk, GPU, and bandwidth; wherein, the CPU parameter information can include model, core number, thread number, frequency, and the like, the memory parameter information can include capacity, frequency, and the like, the disk parameter information can include capacity, and the like; the GPU parameter information can include core number, video memory, and the like; the network parameter information can include transmission rate, and the like; the available resource amount is the difference between the total resource amount of the corresponding resource and the used resource amount, for example, the available resource amount of the memory can be the remaining memory size. Of course, the node state can also include other information, such as, it can also include network traffic data, delay data, connectivity information, processing capacity, and the like, wherein, the network traffic data can be the information of the service using network resources in the node and the proportion of each service using network resources, the delay data can be the time required for a data packet from the source to the destination, the connectivity information is used to indicate whether the current node can be normally accessed, that is, whether the health status of the current node is normal, and the processing capacity is an index for measuring the processing task capacity calculated according to the available resource amount according to a predetermined rule.
[0087] Figure 8 A schematic diagram of the scheduler constructing the downstream node state table by maintaining the downstream node state in the task distribution system according to an embodiment of the present application is shown. Please refer to Figure 8As shown, in addition to reporting the task running condition information to the task running state detection module in the scheduler, the node state plug-in of each node in the downstream node cluster also reports the task running condition information to the downstream node state maintenance module in the scheduler. The downstream node state maintenance module constructs and updates the downstream node state table based on the received task running condition information and node state. The downstream node state maintenance module can directly write part or all of the task running condition information and node state into the downstream node state table, or further generate additional information based on the task running condition information and / or node state, and write part or all of the task running condition information and node state and the additional information into the downstream node state table. For example, the node idle state information corresponding to the task name in the task running condition information can be generated, and the node idle state information is written into the downstream node state table as additional information. It is easy to understand that the downstream node state table can also include the node name, node address and other information about the node of each node. The node name can be reported by the node state plug-in, and the node address can be determined according to the reporting request.
[0088] In step 310, when receiving the to-be-processed task, the resource requirement information of the to-be-processed task is obtained.
[0089] The to-be-processed task can be obtained by pulling from the task queue or other devices such as a server; the to-be-processed task can also be actively pushed by the task queue or other devices such as a server.
[0090] The to-be-processed task is an independent work unit. The to-be-processed task can be a computing task, a data processing task, a file transmission task, and various types of tasks. The to-be-processed task can be submitted to the task queue by a user.
[0091] A task can include a task name, task processing data, a task start timestamp, and task resource requirement information. The task resource requirement information can be input by a user when submitting the task. Of course, the task can also include the type of the task. An artificial intelligence model can be pre-trained, and then the task processing data and the type of the task can be input into the artificial intelligence model to predict the resource requirement information of the task using the artificial intelligence model. If the artificial intelligence model is deployed on a user terminal, the artificial intelligence model can be called by the user when submitting the task, and after obtaining the prediction result of the artificial intelligence model, the predicted task resource requirement information can be automatically written into the task. Of course, if the artificial intelligence model is not deployed on the user terminal, the task can not include the resource requirement information, and the execution subject of the embodiment of the present application can output the resource requirement information of the task by calling the artificial intelligence model.
[0092] The resource requirement information of the to-be-processed task can be a quantity of requirements for at least one resource. The resource requirement information of the to-be-processed task is used to indicate a resource required for running the to-be-processed task.
[0093] The resource requirement information of the to-be-processed task can include resource requirement information corresponding to one or more resources, for example, the resource requirement information of the to-be-processed task can include a quantity of requirements for memory of 8G and a quantity of requirements for a disk of 50G.
[0094] In step 320, node state information of each node in the plurality of nodes of the target cluster is acquired, and the node state information includes resource usage information corresponding to each resource of the node.
[0095] The target cluster can include a plurality of nodes; the plurality of nodes of the target cluster can be part or all of the nodes in the target cluster. A node is a processing point in a network, which can be a physical server, a virtual machine, a container, or the like.
[0096] The node state information is running condition information of the node obtained by identifying and analyzing the node. The node state information is used to identify the state of the node. For example, the node state information of a node can include a CPU usage rate of 80%, a CPU frequency of 2.4 GHz, a core quantity of twenty-four cores, a memory usage rate of 10%, a memory size of 16GB, a disk usage rate of 40%, and a disk size of 2TB.
[0097] The resource usage information can include at least one of the following: a performance indicator in the foregoing node state, current load information in the foregoing node state, an available resource quantity in the foregoing node state, and processing capability in the foregoing node state.
[0098] It is easy to understand that step 320 can be executed before step 310, after step 310, or simultaneously with step 310.
[0099] Figure 9 A flowchart of details of step 320 in an embodiment of the present application is shown. Figure 3 A flowchart of details of step 320 in an embodiment of the present application is shown. Figure 9 As shown, the node state information of each node in the plurality of nodes of the target cluster is acquired, which can specifically include the following steps:
[0100] In step 321, the node state reported by each node in the plurality of nodes of the target cluster is acquired, and the node state is written into a node state table.
[0101] The target cluster can be Figures 5-8 the downstream node cluster shown; and the node state table can be Figures 5-8 the downstream node state table shown.
[0102] As mentioned earlier, node status can be reported to the scheduler through node status plugins in each node of the downstream node cluster. The scheduler can provide an interface for the node status plugins to report information. Node status can include some or all of the aforementioned performance metrics, current load information, available resources, network traffic data, latency data, connectivity information, processing capacity, and other metrics.
[0103] The node status plugins in each node can periodically collect and report the node status to the scheduler. For example, a node status plugin can collect the node status every 500ms and report the node status to the scheduler immediately after collection.
[0104] The data of each node status can be written to the node status table as fields.
[0105] In step 322, the node status information of each node in the target cluster is obtained from the node status table.
[0106] From Figures 5-8 The node status information of each node can be obtained from the downstream node status table shown.
[0107] The node status information obtained from the node status table can be part or all of the node status of each node in the node status table.
[0108] In this embodiment, by first writing the node status into the node status table and then obtaining the node status information from the downstream node status table, the node status information can be directly obtained from the scheduler. There is no need to obtain the node status information from the node status plugin in the remote target cluster via the network when the node status information is needed. This decouples the acquisition and use of node status information and effectively improves the acquisition efficiency of node status information.
[0109] In one embodiment of this application, obtaining the node status information of each node among multiple nodes in the target cluster from the node status table includes: obtaining the latest reported node status information of each node among multiple nodes in the target cluster from the node status table.
[0110] The tables can be partitioned according to the reporting time. Each time a node reports its status, a new node status table is created, and the node status of each node is written into the node status table.
[0111] In this embodiment of the application, by obtaining the latest reported node status information, it can be ensured that the node status information obtained by the scheduler is closest to the current real status of each node, thereby enabling more accurate task distribution.
[0112] The data in the node state table can be deleted or migrated to a storage space periodically or according to the amount of data in the node state table or according to a requirement, so as to reduce the size of the node state table.
[0113] In step 340, target nodes matching the to-be-processed task are determined from the plurality of nodes of the target cluster according to the resource requirement information of the to-be-processed task and the node state information of each node including resource usage information.
[0114] In an embodiment of the present application, the target nodes can be determined in the following manner: the task type of the to-be-processed task is determined according to the resource requirement information of the to-be-processed task; the node type of each node is determined according to the node state information of each node including resource usage information; and the nodes whose corresponding node type matches the task type of the to-be-processed task are taken as the target nodes.
[0115] For example, the task type of the to-be-processed task can be determined to be computation-intensive according to the resource requirement information of the to-be-processed task, and if the node type of a node is determined to be strong computation ability according to the node state information of the node, the node can be taken as a target node. The node type can be divided into various types such as strong computation ability, relatively strong computation ability, medium computation ability, relatively weak computation ability, and weak computation ability.
[0116] Please continue to see Figures 5-8 As shown, the scheduler further includes a node selection module which selects nodes according to the information in the downstream node state table.
[0117] Figure 10 A flowchart of details of step 340 in the embodiment is shown in FIG. 4. Figure 3 A flowchart of details of step 340 in the embodiment is shown in FIG. 4. Figure 10 As shown, target nodes matching the to-be-processed task are determined from the plurality of nodes of the target cluster according to the resource requirement information of the to-be-processed task and the node state information of each node including resource usage information, which can include the following steps:
[0118] In step 341, candidate nodes are selected from the plurality of nodes of the target cluster.
[0119] The nodes suitable for being target nodes can be preliminarily selected from the plurality of nodes of the target cluster as candidate nodes according to certain rules. For example, the nodes whose processing ability is greater than a predetermined processing ability threshold and whose available resource amount of at least one resource reaches a corresponding available resource amount threshold of the corresponding type of resource can be selected as candidate nodes according to the node state information of each node, and other rules can also be used for the selection of candidate nodes.
[0120] Figure 11 A flowchart of details of step 340 in the embodiment is shown in FIG. 4.Figure 10 Flowchart of details of steps before step 340 and step 341 in the embodiment. Please refer to Figure 11 As shown, before determining the target node matching the to-be-processed task from the plurality of nodes of the target cluster, the task distribution method can further include the following steps:
[0121] In step 330, the idle state information of each node in the plurality of nodes of the target cluster is acquired, and the idle state information is used to indicate whether the node is in an idle state.
[0122] The idle state information of the node can be acquired from the node state table.
[0123] As described above, the corresponding node idle state information can be generated according to the task running condition information, and the node idle state information is written into the downstream node state table as additional information. The generation rule of the idle state information can be: if it is determined according to the task running condition information that there is a task in a running state in the node, the corresponding idle state information can indicate that the node is not in an idle state; if it is determined according to the task running condition information that there is no task in a running state in the node, the corresponding idle state information can indicate that the node is in an idle state.
[0124] As shown, the candidate nodes are selected from the plurality of nodes of the target cluster, which can include the following steps: Figure 11
[0125] In step 341', if it is determined according to the idle state information that there is an idle node in an idle state in the plurality of nodes of the target cluster, the idle node is selected as the candidate node.
[0126] If the idle state information of any node indicates that the node is in an idle state, it can be determined that there is an idle node in an idle state in the plurality of nodes of the target cluster; the idle state information of each node can be judged one by one.
[0127] In the embodiment of the present application, by selecting the idle node as the candidate node, it is ensured that the finally determined target node is an idle node, thereby improving the processing efficiency of the task.
[0128] In other embodiments of the present application, the node in an idle state and with a normal health condition can be further selected as the candidate node according to the connectivity information.
[0129] Please continue to refer to Figure 10 and Figure 11 In step 342, if it is determined that the resource usage condition information of the candidate node meets the resource requirement information of the to-be-processed task, the candidate node is determined as the target node matching the to-be-processed task.
[0130] Before step 342 is performed, the resource requirement information of the to-be-processed task can be compared with the resource usage information in the node state information of the candidate node, and it is determined whether the resource usage information of the candidate node meets the resource requirement information of the to-be-processed task according to the comparison result of the resource requirement information of the to-be-processed task and the resource usage information in the node state information of the candidate node.
[0131] As described above, the resource usage information can include indicators such as available resource amounts corresponding to various resources, and the resource requirement information can also include resource requirement information corresponding to various resources, so the available resource amounts and the resource requirement information corresponding to the same kind of resource can be compared respectively.
[0132] Although only the available resource amounts are used for judgment in the embodiments of the present application, in other embodiments of the present application, the performance indicators, current loads, processing capacities and other information can also be used for judgment, so that more reasonable task allocation decisions can be made.
[0133] The available resource amounts and the resource requirement information corresponding to the same kind of resource can be compared directly, and other comparison methods can also be used. For example, for each kind of resource, the gear to which the available resource amount corresponding to the resource belongs and the gear to which the resource requirement information belongs are determined respectively, and then the two gears are compared, and the gear comparison result is taken as the comparison result of the available resource amount and the resource requirement information.
[0134] The way of determining whether the resource usage information of the candidate node meets the resource requirement information of the to-be-processed task according to the comparison result can be that if the available resource amounts corresponding to various resources in the resource usage information are all greater than the resource requirement information of the corresponding resources, it is determined that the resource usage information of the candidate node meets the resource requirement information of the to-be-processed task.
[0135] In actual application of the scheme of the embodiments of the present application, one idle node can be selected each time, and the step of comparing the resource requirement information of the to-be-processed task with the resource usage information in the node state information of the candidate node and the steps thereafter are performed for the idle node, if it is determined according to the comparison result that the resource usage information thereof does not meet the resource requirement information of the to-be-processed task, the next idle node is selected, and the step of comparing the resource requirement information of the to-be-processed task with the resource usage information in the node state information of the candidate node and the steps thereafter are performed again, until it is determined according to the comparison result that the resource usage information of the candidate node meets the resource requirement information of the to-be-processed task.
[0136] Figure 12 A flowchart of task distribution and node expansion during task distribution according to an embodiment of the present application is shown. Please refer to Figure 12 As shown, the specific processes include the following flows:
[0137] Step 1210, take a task from the task queue.
[0138] Step 1220, determine whether there is an idle node in the downstream node cluster.
[0139] If yes, execute step 1230; if no, execute step 1270.
[0140] Step 1230, select an idle node.
[0141] Select an idle node from the downstream node cluster.
[0142] Step 1240, determine whether the idle node resource meets the requirements of the task.
[0143] If yes, execute step 1250; if no, execute step 1260.
[0144] Step 1250, if the idle node resource meets the requirements of the task, then issue the task to the idle node.
[0145] Step 1260, if the idle node resource does not meet the requirements of the task, then determine whether there is another idle node.
[0146] If yes, i.e., if there is another idle node, then select the other idle node and re-execute step 1230 and the following steps; if no, execute step 1270.
[0147] Step 1270, if there is no idle node in the downstream node cluster, or if there is no other idle node in the downstream node cluster, then determine whether the expansion logic is hit.
[0148] If yes, i.e., if the expansion logic is hit, then execute step 1280; if the expansion logic is not hit, then the task can continue to be executed from the node cluster.
[0149] Step 1280, if the expansion logic is hit, then expand the node.
[0150] The expansion logic can be that none of the existing nodes meets the requirements of the task, such as being in the process of running other tasks, or the resource of the node is not enough for the requirement of the task, and of course, it can also be that the number of queued tasks in the task queue exceeds a predetermined number threshold. After this step is executed, step 1220 and the following steps can be re-executed.
[0151] In an embodiment of the present application, after the candidate nodes are selected from the plurality of nodes of the target cluster, the task distribution method can further include the following steps: if it is determined that the resource usage information of all the candidate nodes does not meet the resource requirement information of the to-be-processed task, performing a capacity expansion operation on the target cluster to add a new node in the target cluster which can meet the resource requirement information of the to-be-processed task.
[0152] After the candidate nodes are selected from the plurality of nodes of the target cluster, the resource requirement information of the to-be-processed task can be compared with the resource usage information in the node state information of each candidate node to determine whether the resource usage information of all the candidate nodes does not meet the resource requirement information of the to-be-processed task.
[0153] Although there are idle nodes, if all the idle nodes cannot provide the required resources of the to-be-processed task, a capacity expansion operation is needed. The purpose of the capacity expansion operation is to expand a new node for the current task, and the node can provide the required resources of the to-be-processed task.
[0154] The capacity expansion operation can be performed by issuing an instruction to the target cluster.
[0155] In the embodiment of the present application, the capacity expansion operation is performed when the resource usage information of all the candidate nodes does not meet the resource requirement information of the to-be-processed task, and the newly added node through the capacity expansion operation can meet the resource requirement information of the to-be-processed task, so that the to-be-processed task can be efficiently processed.
[0156] In an embodiment of the present application, the to-be-processed task is received from a task queue, and after the idle state information of each node of the plurality of nodes of the target cluster is obtained, the method can further include the following steps: if it is determined that there is no idle node in the idle state in the plurality of nodes of the target cluster according to the idle state information of each node of the plurality of nodes of the target cluster, obtaining the number of tasks queuing in the task queue; and if the number of tasks queuing in the task queue exceeds a first predetermined number threshold, performing a capacity expansion operation on the target cluster to add a new node in the target cluster.
[0157] The specific value of the first predetermined number threshold can be set as needed and can also be dynamically adjusted.
[0158] If there is no idle node in the idle state in the plurality of nodes of the target cluster, the capacity expansion operation is not necessarily performed; if the number of tasks queuing in the task queue is small, it indicates that the existing nodes in the target cluster can quickly process these tasks, and the capacity expansion operation is not needed at this time.
[0159] In the embodiments of the present application, by performing the expansion operation only when the number of tasks being queued in the task queue exceeds the first predetermined number threshold in the case that there is no idle node in the idle state in the plurality of nodes of the target cluster, resource waste can be avoided, and resource utilization can be improved.
[0160] It is easy to understand that the step of obtaining the idle state information of each node in the plurality of nodes of the target cluster and the embodiments of the present application can be executed in any case, and is not necessarily executed only after the to-be-processed task is received.
[0161] In one embodiment of the present application, after obtaining the idle state information of each node in the plurality of nodes of the target cluster, the method can further include the following steps: if it is determined according to the idle state information of each node in the plurality of nodes of the target cluster that there is an idle node in the idle state in the plurality of nodes of the target cluster, then in the case that there is no task in the task queue, determining the number of idle nodes in the idle state in the plurality of nodes of the target cluster; and if the number of idle nodes exceeds a second predetermined number threshold, then performing a shrink operation on the target cluster to remove at least one idle node from the target cluster.
[0162] The shrink operation can be performed by issuing an instruction to the target cluster.
[0163] After it is determined that there is an idle node in the idle state in the plurality of nodes of the target cluster, it is judged whether there is a task in the task queue, and if there is a task in the task queue, the shrink operation can not be performed.
[0164] In the embodiments of the present application, by further judging whether there is a task in the task queue in the case that there is an idle node in the idle state in the plurality of nodes of the target cluster, only in the case that there is no task in the task queue, the subsequent judgment is performed, and the influence of shrink on the processing efficiency of the task is avoided.
[0165] Please continue to see Figures 5-8 As shown in the figure, the information maintained by the downstream node state module of the scheduler will also trigger the expansion and shrink, and the expansion and shrink downstream node module of the scheduler will send an expansion and shrink command to the downstream node cluster, and the downstream node cluster will automatically perform the expansion and shrink operation according to the expansion and shrink command.
[0166] Figure 13 A flowchart of the expansion and shrink of the downstream cluster according to one embodiment of the present application is shown. Please see Figure 13 As shown in the figure, it can specifically include the following processes:
[0167] Step 1310, judge whether the node is busy.
[0168] That is, it is determined whether there is no idle node, that is, it is determined whether every node is running a task. If yes, step 1320 is executed; if no, step 1340 is executed.
[0169] Step 1320, if all nodes are busy, it is determined whether the number of tasks queued in the task queue exceeds a threshold.
[0170] If yes, step 1330 is executed; if no, that is, if the number of tasks queued in the task queue does not exceed the threshold, no expansion can be initiated.
[0171] Step 1330, if the number of tasks queued in the task queue exceeds the threshold, expansion is initiated.
[0172] Step 1340, if the nodes are not all busy, it is determined whether there is no task queued in the task queue.
[0173] If yes, step 1350 can be executed.
[0174] Step 1350, if there is no task queued in the task queue, shrinkage logic is executed.
[0175] The shrinkage logic can be to determine whether the number of idle nodes exceeds a threshold by checking the downstream node state table to see the number of idle nodes.
[0176] Step 1360, it is determined whether the shrinkage condition is met.
[0177] The shrinkage condition can be that the node is idle, so this step can determine whether the node is idle. If yes, step 1370 is executed.
[0178] Step 1370, it is determined whether the shrinkage condition is met.
[0179] If a node is idle, shrinkage can be initiated for it.
[0180] Please continue to see Figure 3 In step 350, the to-be-processed task is assigned to the target node to execute the to-be-processed task on the target node.
[0181] The to-be-processed task can be sent to the target node to run and process the to-be-processed task by the target node.
[0182] Figure 14 A flowchart of steps after step 350 in the embodiment according to an embodiment of the present application is shown. Figure 3 The flowchart of steps after step 350 in the embodiment. Please see Figure 14 As shown, after the to-be-processed task is assigned to the target node, the method can further include the following steps:
[0183] In step 360, the task running state information of the target node is acquired.
[0184] As mentioned above, the node state plug-in can report the task running information to the task running state detection module in the scheduler, and the task running state detection module can save part or all of the task running information as the task running state information. Therefore, the task running state information can include the task name, the task running progress, whether the task is abnormal, the task abnormality details, etc.
[0185] In step 370, if it is determined that the to-be-processed task is abnormal according to the task running state information, the task type of the to-be-processed task is determined.
[0186] The task type of the to-be-processed task can be various, such as priority.
[0187] The to-be-processed task can include various information related to the to-be-processed task, such as priority, which can be defined by the user.
[0188] In an embodiment of the present application, the resource usage information includes the available resource amount of the corresponding type of resource, the task type of the to-be-processed task is determined, including: determining the task type of the to-be-processed task as target type resource required type according to the resource requirement information of the to-be-processed task, wherein the task of the target type resource required type has a demand amount of the target type resource greater than that of the task of other task types; after determining the task type of the to-be-processed task, the method further includes: based on the resource usage information of the target type resource of each node, determining that the other node has a greater available resource amount of the target type resource than the target node, according to the task type of the to-be-processed task being the target type resource required type; reassigning the to-be-processed task to the other node to re-execute the to-be-processed task on the other node.
[0189] The resources required by all historical tasks can be counted, for each type of resource, the demand amount of each task for the resource is sorted from high to low to obtain a sorting list corresponding to each type of resource; then, the demand amount of the to-be-processed task for each type of resource is compared with the sorting list of the corresponding type of resource to obtain how many percentage of the demand amount of the corresponding type of resource of the historical tasks the demand amount of the to-be-processed task for each type of resource exceeds, and the demand amount of the target type resource can be the demand amount of the corresponding type of resource of the highest percentage of the historical tasks.
[0190] In the embodiments of the present application, in the case that the to-be-processed task appears an exception, the to-be-processed task is determined to be of the target type of resource requirement, the other nodes of the target node are determined from the multiple nodes according to the target type of resource requirement, and the to-be-processed task is re-assigned to the other nodes, so that the task allocation decision is more reasonable, and thus the success rate of re-execution of the to-be-processed task is improved.
[0191] In other embodiments of the present application, the demand of the to-be-processed task for the target type of resource exceeds the expectation according to the task exception details, and the task type of the to-be-processed task is determined to be of the target type of resource requirement.
[0192] In step 380, multiple backup nodes are selected from the multiple nodes of the target cluster according to the task type of the to-be-processed task.
[0193] The multiple backup nodes can or can not include the target node.
[0194] The specified task type can be high priority. The to-be-processed task carries an identification of priority in the task body, and the identification can be used to determine whether the task type of the to-be-processed task is high priority.
[0195] In step 390, the to-be-processed task is re-assigned to the backup nodes, so as to re-execute the to-be-processed task on the backup nodes.
[0196] When a backup node first executes the to-be-processed task, the backup node can send notification information to the scheduler, and the scheduler can send instructions to other backup nodes according to the notification information, so as to instruct the nodes to stop executing the to-be-processed task, so as to avoid additional resource consumption.
[0197] In other embodiments of the present application, if the task type of the to-be-processed task is high priority, the to-be-processed task can also be assigned to multiple nodes when the task is first distributed.
[0198] In the embodiments of the present application, in the case that the task type of the to-be-processed task is the specified task type, the to-be-processed task is executed by the multiple backup nodes respectively, so that the success rate of executing special tasks is improved.
[0199] Of course, if the to-be-processed task is only a regular task and does not meet the above conditions, other measures such as retrying (re-distributing the to-be-processed task to the target node), warning, etc. can also be used to handle the problem of the to-be-processed task appearing an exception.
[0200] Please continue to see Figures 5-8As shown, the task running state detection module can determine to trigger exception bottoming-up according to the task running state information, and execute exception task bottoming-up logic. The exception task bottoming-up logic can specifically include retrying the task at the current node, re-executing the task in multiple backup nodes, re-allocating the to-be-processed task to other nodes, warning, etc.
[0201] Figure 15 A flowchart of task re-distribution in a task exception is shown according to an embodiment of the present application. Please continue to see Figure 15 As shown, the specific process includes the following steps:
[0202] Step 1510, acquire node task state.
[0203] Step 1520, determine whether the task is abnormal according to the node task state.
[0204] If yes, execute step 1530.
[0205] Step 1530, if it is determined that the task is abnormal, run the bottoming-up logic.
[0206] Step 1540, determine whether the logic of distributing the task to multiple nodes in the bottoming-up logic is triggered.
[0207] If yes, execute step 1550; if no, execute step 1570.
[0208] Step 1550, if the logic of distributing the task to multiple nodes is triggered, select multiple nodes.
[0209] Step 1560, distribute the task to the selected multiple nodes.
[0210] Step 1570, if the logic of distributing the task to multiple nodes is not triggered, select one node.
[0211] Step 1580, distribute the task to the selected node.
[0212] In summary, according to the task distribution method provided by the embodiments of the present application, a more intelligent and flexible task scheduling system is provided, and at least the following technical effects can be achieved:
[0213] (1) Downstream dynamic perception: by collecting and maintaining the metadata information of the downstream nodes, the scheduler can know the state of each node in real time, including but not limited to performance indicators, current load, available resources, etc. This dynamic perception capability enables the scheduler to make more accurate and reasonable task distribution decisions, optimize resource allocation, and improve the efficiency of the overall system.
[0214] (2) Support for differentiated downstream nodes: In traditional task distribution systems, it is usually assumed that all processing nodes are homogeneous. However, the present application allows for differences between nodes, and the scheduler can dynamically plan resources based on these differences, selecting the most suitable nodes to process specific tasks. This differentiated support and dynamic planning capability can better utilize the characteristics of the nodes and improve resource utilization.
[0215] (3) Dynamic scaling of downstream nodes: The scheduler not only can perceive node status, but also can dynamically manage the scaling of nodes based on task volume and task nature. This means that the system can adjust resources according to actual workload, avoiding resource waste while ensuring high efficiency during high load.
[0216] (4) Backup for high priority / failure tasks: For high priority or previously failed tasks, the scheduler can distribute tasks to multiple nodes for running in a backup manner to improve the success rate of tasks. This strategy is very useful for the completion of critical tasks, and can ensure that tasks can be successfully completed even if a node has a problem.
[0217] (5) Task progress management and exception handling: The scheduler can obtain the progress of tasks being processed in real time, and intelligently redistribute tasks based on exception information when an exception occurs. This management capability and the provision of a backup solution greatly improve the success rate of tasks and the robustness of the system.
[0218] In summary, the task distribution method provided by the embodiments of the present application significantly improves the intelligent level and resource utilization efficiency of the task scheduling system, and also enhances the processing capability of the system for abnormal situations. It is an innovative and practical application value solution.
[0219] The following describes an apparatus embodiment of the present application, which can be used to execute the task distribution method in the above embodiments of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above embodiments of the task distribution method of the present application.
[0220] Figure 16 A block diagram of a task distribution apparatus according to an embodiment of the present application is shown. Referring to FIG. 1, the task distribution apparatus includes a task receiving module 101, a task planning module 102, a task scheduling module 103, a task progress monitoring module 104, and a task exception handling module 105. Figure 16As shown, the task distribution apparatus 1600 according to an embodiment of the present application is located in a target device, and the apparatus comprises a resource requirement information acquisition unit 1610, a node state information acquisition unit 1620, a node determination unit 1630, and an allocation unit 1640. The resource requirement information acquisition unit 1610 is configured to acquire resource requirement information of a to-be-processed task when the to-be-processed task is received; the node state information acquisition unit 1620 is configured to acquire node state information of each node in a plurality of nodes of a target cluster, the node state information comprising resource usage information corresponding to each resource of the node; the node determination unit 1630 is configured to determine a target node matching the to-be-processed task from the plurality of nodes of the target cluster according to the resource requirement information of the to-be-processed task and the node state information of each node comprising the resource usage information; and the allocation unit 1640 is configured to allocate the to-be-processed task to the target node to execute the to-be-processed task on the target node.
[0221] In some embodiments of the present application, based on the foregoing scheme, the node determination unit 1630 is configured to select a candidate node from the plurality of nodes of the target cluster; and if it is determined that the resource usage information of the candidate node satisfies the resource requirement information of the to-be-processed task, the candidate node is determined as the target node matching the to-be-processed task.
[0222] In some embodiments of the present application, based on the foregoing scheme, the apparatus further comprises an idle state information acquisition unit; before the target node matching the to-be-processed task is determined from the plurality of nodes of the target cluster, the idle state information acquisition unit is configured to acquire idle state information of each node in the plurality of nodes of the target cluster, the idle state information being used to indicate whether the node is in an idle state; and the node determination unit 1630 is configured to, if it is determined according to the idle state information that there is an idle node in an idle state in the plurality of nodes of the target cluster, take the idle node as a candidate node.
[0223] In some embodiments of the present application, based on the foregoing scheme, the apparatus further comprises a first capacity expansion unit; after the candidate node is selected from the plurality of nodes of the target cluster, the first capacity expansion unit is configured to, if it is determined that the resource usage information of all candidate nodes does not satisfy the resource requirement information of the to-be-processed task, perform a capacity expansion operation on the target cluster to add a new node capable of satisfying the resource requirement information of the to-be-processed task in the target cluster.
[0224] In some embodiments of the present application, based on the foregoing scheme, the to-be-processed task is received from a task queue, and the device further comprises a task quantity acquisition unit and a second capacity expansion unit; after obtaining the idle state information of each node in the plurality of nodes of the target cluster, the task quantity acquisition unit is configured to: if it is determined that there is no idle node in the idle state in the plurality of nodes of the target cluster according to the idle state information of each node in the plurality of nodes of the target cluster, acquire the quantity of tasks queuing in the task queue; and the second capacity expansion unit is configured to: if the quantity of tasks queuing in the task queue exceeds a first predetermined quantity threshold, perform a capacity expansion operation on the target cluster to add a new node in the target cluster.
[0225] In some embodiments of the present application, based on the foregoing scheme, the device further comprises an idle node quantity determination unit and a capacity reduction unit; after obtaining the idle state information of each node in the plurality of nodes of the target cluster, the idle node quantity determination unit is configured to: if it is determined that there is an idle node in the idle state in the plurality of nodes of the target cluster according to the idle state information of each node in the plurality of nodes of the target cluster, determine the quantity of idle nodes in the idle state in the plurality of nodes of the target cluster in the case that there is no task in the task queue; and the capacity reduction unit is configured to: if the quantity of idle nodes exceeds a second predetermined quantity threshold, perform a capacity reduction operation on the target cluster to remove at least one idle node from the target cluster.
[0226] In some embodiments of the present application, based on the foregoing scheme, the device further comprises a task running state information acquisition unit, a task type determination unit, a backup node selection unit and a task reassignment unit; after the to-be-processed task is allocated to the target node, the task running state information acquisition unit is configured to: acquire task running state information of the target node; the task type determination unit is configured to: if it is determined that the to-be-processed task is abnormal according to the task running state information, determine the task type of the to-be-processed task; the backup node selection unit is configured to: select a plurality of backup nodes from the plurality of nodes of the target cluster according to the task type of the to-be-processed task for a specified task type; and the task reassignment unit is configured to: reassign the to-be-processed task to each of the backup nodes to re-execute the to-be-processed task on each of the backup nodes.
[0227] In some embodiments of the present application, based on the foregoing scheme, the device further comprises an available node determination unit; the resource usage information comprises available resource amount of a corresponding kind of resource, and the task type determination unit is configured to: determine, according to the resource requirement information of the to-be-processed task, that the task type of the to-be-processed task is a target kind of resource requiring type, wherein the task of the target kind of resource requiring type has a demand amount of target kind of resource greater than that of tasks of other task types; after determining the task type of the to-be-processed task, the available node determination unit is configured to: based on the resource usage information of the target kind of resource of each node, determine, according to that the task type of the to-be-processed task is the target kind of resource requiring type, a node having an available resource amount of the target kind of resource greater than that of the target node from the plurality of nodes; and the task reallocation unit is further configured to: reallocate the to-be-processed task to the node to re-execute the to-be-processed task on the node.
[0228] In some embodiments of the present application, based on the foregoing scheme, the node state information acquisition unit 1620 is configured to: acquire the node state reported by each node of the plurality of nodes of the target cluster respectively, and write the node state into a node state table; and acquire the node state information of each node of the plurality of nodes of the target cluster from the node state table.
[0229] Figure 17 A structural schematic diagram of a computer system of an electronic device suitable for implementing embodiments of the present application is shown.
[0230] It should be noted that, Figure 17 The computer system 1700 of the electronic device shown is only an example, and should not impose any limitation on the functions and use range of embodiments of the present application.
[0231] As Figure 17 shown, the computer system 1700 includes a central processing unit (CPU) 1701, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 1702 or programs loaded from a storage portion 1708 into a random access memory (RAM) 1703, such as performing the methods described in the above embodiments. In the RAM 1703, various programs and data required for system operation are also stored. The CPU 1701, the ROM 1702, and the RAM 1703 are connected to each other through a bus 1704. An input / output (I / O) interface 1705 is also connected to the bus 1704.
[0232] The following components are connected to the I / O interface 1705: an input part 1706 including a keyboard, a mouse, etc.; an output part 1707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc., and a speaker, etc.; a storage part 1708 including a hard disk, etc.; and a communication part 1709 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication part 1709 performs communication processing via a network such as the Internet. A drive 1710 is also connected to the I / O interface 1705 as necessary. A removable media 1711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 1710 as necessary, so that a computer program read out therefrom is installed in the storage part 1708 as necessary.
[0233] In particular, according to embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication part 1709, and / or installed from the removable media 1711. When the computer program is executed by the central processing unit (CPU) 1701, various functions defined in the system of the present application are executed.
[0234] It should be noted that the computer-readable medium in the embodiments of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination thereof. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present application, the computer-readable signal medium can include a data signal carrying computer-readable program code in a baseband or as a part of a carrier wave. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or apparatus. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, or the like, or any suitable combination thereof.
[0235] The flowcharts and block diagrams in the drawings illustrate the possible implementation architectures, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In the flowcharts or block diagrams, each block can represent a module, a program segment or a part of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders than that shown in the drawings. For example, two blocks that are shown in succession can actually be executed substantially in parallel, and they can also be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams or flowcharts, and the combination of blocks in the block diagrams or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0236] The units described in the embodiments of the present application can be implemented in the form of software, or can be implemented in the form of hardware, and the described units can also be arranged in a processor. In some cases, the names of the units do not constitute a limitation on the units themselves.
[0237] As an aspect, the present application also provides a computer readable medium, which can be included in the electronic device described in the above embodiments, or can exist independently without being assembled into the electronic device. The computer readable medium carries one or more programs, which, when executed by the electronic device, enable the electronic device to implement the method described in the above embodiments.
[0238] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, such division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into a plurality of modules or units.
[0239] From the above description of the embodiments, those skilled in the art can easily understand that the example embodiments described herein can be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solutions according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a U disk, a mobile hard disk, etc.) or a network, and includes a plurality of instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the methods according to the embodiments of the present application.
[0240] Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the embodiments disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the application following the general principles thereof and including such departures from the present disclosure as come within known or customary practice in the art.
[0241] The relevant data collection and processing scheme in the present application should be strictly in accordance with the requirements of relevant national laws and regulations, and the informed consent or separate consent of the personal information subject (or the legal basis provided by the relevant national laws and regulations) should be obtained, and the subsequent data use and processing behavior should be carried out within the scope of authorization of laws and regulations and personal information subject.
[0242] It is to be understood that the application is not limited to the precise construction already described above and shown in the drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application. The scope of the application should only be limited by the claims appended hereto.
Claims
1. A task distribution method, characterized in that, The method includes: When a task to be processed is received, the resource requirement information of the task to be processed is obtained; Obtain the node status information of each node in the target cluster, wherein the node status information includes resource usage information corresponding to each type of resource of the node; Based on the resource requirement information of the task to be processed and the node status information of each node, including the resource usage information, a target node matching the task to be processed is determined from multiple nodes in the target cluster. The task to be processed is assigned to the target node so that the task to be processed is executed on the target node.
2. The task distribution method according to claim 1, characterized in that, The step of determining the target node matching the task to be processed from multiple nodes in the target cluster based on the resource requirement information of the task to be processed and the node status information of each node, including the resource usage information, includes: Candidate nodes are selected from multiple nodes in the target cluster; If it is determined that the resource usage information of the candidate node meets the resource requirements of the task to be processed, then the candidate node is determined as the target node that matches the task to be processed.
3. The task distribution method according to claim 2, characterized in that, Before determining the target node matching the task to be processed from multiple nodes in the target cluster, the method further includes: Obtain the idle status information of each node in the target cluster, wherein the idle status information is used to indicate whether the node is in an idle state; The step of selecting candidate nodes from multiple nodes in the target cluster includes: If, based on the idle state information, it is determined that there is an idle node in the target cluster among multiple nodes that is in an idle state, then the idle node is selected as a candidate node.
4. The task distribution method according to claim 3, characterized in that, After selecting candidate nodes from multiple nodes in the target cluster, the method further includes: If it is determined that the resource usage information of all candidate nodes does not meet the resource requirements of the task to be processed, then the target cluster is expanded to add new nodes that can meet the resource requirements of the task to be processed.
5. The task distribution method according to claim 3, characterized in that, The tasks to be processed are received from the task queue. After obtaining the idle status information of each node in the target cluster, the method further includes: If, based on the idle status information of each node in the target cluster, it is determined that there are no idle nodes in the target cluster, then the number of tasks currently queued in the task queue is obtained. If the number of tasks queued in the task queue exceeds a first predetermined threshold, then the target cluster is expanded to add new nodes to the target cluster.
6. The task distribution method according to claim 5, characterized in that, After obtaining the idle status information of each node in the target cluster, the method further includes: If, based on the idle status information of each node in the target cluster, it is determined that there are idle nodes in the target cluster that are in an idle state, then, if there are no tasks in the task queue, the number of idle nodes in the target cluster that are in an idle state is determined. If the number of idle nodes exceeds a second predetermined threshold, the target cluster is scaled down to remove at least one idle node from the target cluster.
7. The task distribution method according to claim 1, characterized in that, After assigning the task to be processed to the target node, the method further includes: Obtain the task running status information of the target node; If it is determined from the task running status information that the task to be processed has encountered an anomaly, then the task type of the task to be processed is determined. Based on the task type of the task to be processed being a specified task type, multiple backup nodes are selected from multiple nodes in the target cluster; The pending tasks are redistributed to each of the backup nodes so that the pending tasks are re-executed on each of the backup nodes.
8. The task distribution method according to claim 7, characterized in that, The resource usage information includes the available resource quantity for the corresponding type of resource, and determining the task type of the task to be processed includes: Based on the resource requirement information of the task to be processed, the task type of the task to be processed is determined to be target type resource requirement type, wherein the task type of target type resource requirement type has a greater requirement for target type resources than other task types. After determining the task type of the task to be processed, the method further includes: Based on the task type of the task to be processed being target type resource requirement type, and based on the resource usage information of the target type resources of each node, other nodes with a greater amount of available target type resources than the target node are identified among the multiple nodes. The pending task is reassigned to the other nodes so that it can be re-executed on those other nodes.
9. The task distribution method according to any one of claims 1-8, characterized in that, The step of obtaining the node status information of each node in the target cluster includes: Obtain the node status reported by each node in the target cluster, and write the node status into the node status table; Obtain the node status information of each node in the target cluster from the node status table.
10. A task distribution device, characterized in that, The device includes: The resource requirement information acquisition unit is used to acquire the resource requirement information of the task to be processed when a task to be processed is received. The node status information acquisition unit is used to acquire the node status information of each node in the target cluster. The node status information includes resource usage information corresponding to each type of resource of the node. A node determination unit is used to determine a target node that matches the task to be processed from multiple nodes in the target cluster based on the resource requirement information of the task to be processed and the node status information of each node, including the resource usage information. An allocation unit is used to allocate the task to be processed to the target node so that the task to be processed can be executed on the target node.
11. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the task distribution method as described in any one of claims 1 to 9.
12. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the task dispatch method as described in any one of claims 1 to 9.
13. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium, a processor of a computer device reading the computer instructions from the computer-readable storage medium, and the processor executing the computer instructions to cause the computer device to perform the task dispatching method as described in any one of claims 1 to 9.