Task scheduling method and device
By selecting work nodes to distribute tasks in the cloud monitoring system, the problem of high pressure on management service centers is solved, and the delay of task processing and the improvement of processing capabilities is achieved.
Patent Information
- Application Number
- CN202411739084.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-21
AI Technical Summary
When existing cloud monitoring systems manage large number of node clusters, the management service center has a high processing pressure, resulting in time delay.
By selecting some work nodes, distributing the target tasks to these work nodes, and then each of these work nodes manages the corresponding target tasks to reduce the pressure on a single node.
It effectively reduces the pressure on a single node, shortens the delay in task processing, and improves the processing capabilities of the cloud monitoring system.
Smart Images

Figure CN119668805A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud monitoring technology, and in particular to a task scheduling method and device. Background Art
[0002] As an important component of smart cities, cloud monitoring systems play an important role. Existing cloud monitoring systems generally include clients, management service centers, and node clusters, where the node clusters include a large number of nodes that can be used to perform monitoring tasks, storage tasks, and the like.
[0003] In existing cloud monitoring systems, a management service center usually manages a node cluster. Specifically, the management service center obtains tasks from a client and then distributes the tasks to each node in the node cluster so that the nodes can execute the tasks.
[0004] When the node cluster is relatively large, the number of tasks that the management service center needs to manage will be very large. For example, the node cluster includes 500,000 recordings, and the management service center needs to manage more than 500,000 tasks, which will cause great processing pressure on the management service center and extend the processing time. Summary of the invention
[0005] The embodiment of the present application provides a task scheduling method and device, which selects some working nodes, distributes target tasks to these working nodes, and then these working nodes manage the corresponding target tasks respectively. In this way, the number of target tasks managed by a single working node is small, which reduces the pressure on a single node and shortens the delay.
[0006] In the first aspect, an embodiment of the present application proposes a task scheduling method, which is applied to a master node in a cluster system. The cluster system includes multiple nodes, and the master node is a node elected by multiple nodes. The method includes: obtaining multiple target tasks from a client; assigning multiple target tasks to multiple preset work groups, and generating first association information so that the working node schedules the target tasks distributed to the work group corresponding to the working node based on the first association information; wherein the first association information includes the correspondence between the target task information and the work group to which the target task is assigned; the working node is determined by the master node from multiple nodes.
[0007] Optionally, after allocating the multiple target tasks to the preset multiple working groups, the method further includes: updating first association information according to the allocation results of the multiple target tasks, the first association information including the correspondence between the target task information and the working groups to which the target tasks are allocated.
[0008] Optionally, the method further includes: determining the number of working groups currently required according to the number of the plurality of nodes; and changing the working group according to the number of working groups currently required and the number of working groups actually currently required.
[0009] Optionally, the method further includes: determining the number of working groups according to the number of multiple nodes and a preset configuration ratio, wherein the configuration ratio indicates a proportional relationship between the number of working groups and the total number of nodes; and creating a working group based on the number of working groups.
[0010] Optionally, the number of working groups is determined based on the number of multiple nodes and a preset configuration ratio, including: determining a first value based on the number of multiple nodes and a preset configuration ratio; if the first value is a non-integer, rounding the first value and adding 1 to obtain a second value, and using the second value as the number of working groups; if the first value is an integer, using the first value as the number of working groups.
[0011] Optionally, the method further includes: allocating a working node to each working group, creating second association information according to a corresponding relationship between the working group and the working node, the second association information being used for each node among the multiple nodes to determine whether it is a working node.
[0012] Optionally, the method further includes: publishing second association information to a shared memory in the cluster system.
[0013] Optionally, the method further includes: detecting whether there is an abnormality in each working node in the second association information; if there is an abnormality in a working node, switching the working group corresponding to the abnormal working node to a new working node.
[0014] Optionally, the method further includes: redistributing the target tasks of the work group corresponding to the working node with the abnormality to the working groups corresponding to other working nodes without the abnormality.
[0015] Optionally, the method further includes: periodically acquiring the online status of multiple nodes, determining the number of workgroups currently required according to the number of online nodes among the multiple nodes; and changing the workgroup according to the number of workgroups currently required and the current actual number of workgroups.
[0016] Optionally, the workgroup is changed based on the number of workgroups currently required and the number of workgroups currently actually present, including: generating one or more new workgroups when the number of workgroups currently required is greater than the number of workgroups currently actually present; determining corresponding work nodes for each new workgroup from online nodes; and updating the second association information based on the work nodes corresponding to each new workgroup.
[0017] Optionally, the method further comprises:
[0018] The target tasks that have been assigned to each working group are reallocated to each new working group, and the first association information is updated according to the assignment result.
[0019] Optionally, the workgroup is changed based on the number of workgroups currently required and the number of workgroups currently actually required, including: when the number of workgroups currently required is less than the number of workgroups currently actually required, determining one or more first workgroups that need to be changed; deleting the first workgroup and the correspondence between the first workgroup and the work node corresponding to the first workgroup from the second association information.
[0020] Optionally, the method further includes: reallocating the target task that has been allocated to the first working group to the remaining other working groups, and updating the first association information according to the allocation result.
[0021] Optionally, the workgroup is changed based on the number of workgroups currently required and the number of workgroups currently actually required, including: when the number of workgroups currently required is less than the number of workgroups currently actually required, determining one or more first workgroups that need to be changed; determining a target workgroup from the remaining other workgroups, and switching the target task that has been assigned to the first workgroup to the target workgroup.
[0022] Optionally, determining one or more first working groups that need to be changed includes: sorting the working groups according to the number of target tasks accessed by each working group; and determining one or more working groups sorted later as the first working group.
[0023] Optionally, the method also includes: detecting the number of working groups corresponding to each working node; for each working node, when the number of working groups corresponding to the working node is greater than a first threshold, determining a second working group that needs to be removed from the working group corresponding to the working node; determining a new working node from multiple nodes, and replacing the working node corresponding to the second working group with the new working node in the second association information.
[0024] Optionally, the method also includes: detecting whether there is an abnormality in each working node in the second association information; if there is an abnormality in a working node, determining a new working node from multiple nodes, and replacing the abnormal working node with the new working node in the second association information.
[0025] Optionally, the method also includes: detecting the number of target tasks accessed by each working group; for each working group, when the number of target tasks accessed by the working group is greater than a second threshold, determining a first target task from the target tasks accessed by the working group, the first target task being a task that needs to be removed from the working group, and the second threshold being the average number of target tasks accessed by the working group; when the number of target tasks accessed by the working group is less than the second threshold, increasing the target tasks allocated to the working group.
[0026] In the second aspect, an embodiment of the present application proposes a task scheduling method, which is applied to nodes other than the master node in a cluster system. The cluster system includes multiple nodes, and the master node is a node elected by multiple nodes. The method includes: determining whether the current node is a working node, and the working node is determined by the master node from multiple nodes; if the current node is a working node, based on the first association information, obtaining multiple target tasks assigned by the master node to the work group corresponding to the working node; the first association information includes the correspondence between the target task information and the work group to which the target task is assigned; scheduling multiple target tasks, and updating the third association information according to the task information of the multiple target tasks, the nodes executing the target tasks, and the work group to which the target tasks are connected, and the third association information includes the correspondence between the target task information, the nodes executing the target tasks, and the work group to which the target tasks are assigned.
[0027] Optionally, determining whether the node is a working node includes: obtaining second association information from a shared memory in the cluster system, the second association information including a correspondence between a work group and a working node; determining whether the node is currently a working node based on the second association information; if the node is currently a working node, determining the work group corresponding to the node based on the second association information, and obtaining a target task assigned to the work group corresponding to the node, and updating the third association information based on the first association information; if the node is currently not a working node, deleting the target task accessed by the work group corresponding to the node from the memory, and deleting the third association information.
[0028] Optionally, the work group corresponding to the node is determined according to the second association information, and the target task assigned to the work group corresponding to the node is obtained, including: detecting whether the number of work groups corresponding to the node increases according to the second association information, and if increased, obtaining the target task corresponding to the newly added work group; detecting whether the number of work groups corresponding to the node decreases according to the second association information, and if decreased, deleting the target task corresponding to the decreased work group.
[0029] In the third aspect, an embodiment of the present application proposes a task scheduling device, which is applied to a master node in a cluster system. The cluster system includes multiple nodes, and the master node is a node elected by multiple nodes. The device includes: an acquisition unit, which is used to obtain multiple target tasks from a client; a processing unit, which is used to assign multiple target tasks to multiple preset work groups, and generate first association information so that the working node schedules the target tasks distributed to the work group corresponding to the working node based on the first association information; wherein the first association information includes the correspondence between the target task information and the work group to which the target task is assigned; the working node is determined by the master node from multiple nodes.
[0030] In the fourth aspect, an embodiment of the present application proposes a task scheduling device, which is applied to nodes other than the master node in a cluster system. The cluster system includes multiple nodes, and the master node is a node elected by multiple nodes. The device includes: a determination unit, used to determine whether the node is a working node, and the working node is determined by the master node from multiple nodes; an acquisition unit, used to obtain multiple target tasks assigned by the master node to the work group corresponding to the working node based on the first association information if the node is a working node; the first association information includes the correspondence between the target task information and the work group to which the target task is assigned; a processing unit, used to schedule multiple target tasks, and update the third association information according to the task information of the multiple target tasks, the node executing the target task, and the work group to which the target task is connected, and the third association information includes the correspondence between the target task information, the node executing the target task, and the work group to which the target task is assigned.
[0031] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to call the computer program to execute the task scheduling method in the above-mentioned first aspect and any possible implementation of the first aspect, or to execute the task scheduling method in the above-mentioned second aspect and any possible implementation of the second aspect.
[0032] In the sixth aspect, an embodiment of the present application provides a cluster system, including a master node and other nodes, wherein the master node is used to implement the functions of the master node in the above-mentioned first aspect and any possible implementation method of the first aspect; the other nodes are used to implement the functions of the other nodes in the above-mentioned second aspect and any possible implementation method of the second aspect.
[0033] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instruction is stored. When the computer program or instruction is executed, the task scheduling method in the above-mentioned first aspect and any possible implementation method of the first aspect is implemented; or, the task scheduling method in the above-mentioned second aspect and any possible implementation method of the second aspect is implemented.
[0034] In an eighth aspect, an embodiment of the present application provides a computer program product, characterized in that it includes a computer program, which, when run, enables the computer to execute the task scheduling method in the above-mentioned first aspect and any possible implementation of the first aspect; or, enables the computer to execute the above-mentioned second aspect and any possible implementation of the second aspect.
[0035] The task scheduling method provided in the embodiment of the present application selects some working nodes, distributes the target tasks to these working nodes, and then these working nodes manage the corresponding target tasks respectively. In this way, the number of target tasks managed by a single working node is small, which reduces the pressure on a single node and shortens the delay. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A schematic diagram of the architecture of a cloud monitoring system provided by the prior art is shown.
[0037] Figure 2 A schematic diagram of the architecture of a cloud monitoring system provided in an embodiment of the present application is shown.
[0038] Figure 3 A schematic diagram showing a cluster system updating second association information is shown.
[0039] Figure 4 A schematic diagram of updating first association information in a cluster system is shown.
[0040] Figure 5 A flowchart of a task scheduling method provided in an embodiment of the present application is shown.
[0041] Figure 6 A logical schematic diagram of a task scheduling method provided in an embodiment of the present application is shown.
[0042] Figure 7 A flow chart of a method for a master node to maintain a working group is shown.
[0043] Figure 8 A schematic diagram of reducing the working group is shown.
[0044] Fig. 9 A flow chart of a method for a master node to periodically inspect node status is shown.
[0045] Fig.10 A flowchart of another task scheduling method provided in an embodiment of the present application is shown.
[0046] Fig.11 A flowchart of another task scheduling method provided in an embodiment of the present application is shown.
[0047] Fig.12 A structural block diagram of a task scheduling device provided in an embodiment of the present application.
[0048] Fig.13 A structural block diagram of a computer device is shown. DETAILED DESCRIPTION
[0049] The technical solutions in the embodiments of the present application are described below in conjunction with the accompanying drawings.
[0050] The cloud monitoring system consists of two parts: cloud monitoring and cloud storage. It is a system that uses cluster and network technology to centrally store different types of encoding devices in the network through application software, and provides data storage and business access functions to the outside world. The cloud monitoring architecture mainly includes video acquisition, video processing, video storage, and video distribution. This model can support a large amount of video data and meet the needs of large-scale monitoring systems.
[0051] The current specifications of 4.0 cloud surveillance are to support 500,000 video recordings and 1,024 storages. Among them, it supports 500,000 video recordings, which means that the cloud surveillance system can simultaneously process and store video data from 500,000 different video sources. In addition, it also supports 1,024 storage devices, which means that the entire cloud surveillance system can integrate and manage data from a large number of independent storage devices, thus forming a large and scalable storage solution.
[0052] Cloud monitoring systems of this scale are generally used in scenarios that require large-scale monitoring coverage, such as monitoring systems in large urban monitoring networks, airports, railway stations and other important public places.
[0053] In existing solutions, cloud monitoring systems generally use centralized management solutions to manage nodes in the cluster. Figure 1 As shown, Figure 1 The schematic diagram of the architecture of a cloud monitoring system provided by the prior art is shown. The system includes a client, a management service center and a node cluster, and the node cluster includes a large number of nodes, such as Figure 1 As shown in the circular pattern, these nodes can be used to perform monitoring tasks, storage tasks, etc.
[0054] The client is the user-oriented interface. Figure 1 As shown in the figure, the user can send the target task through the client. After receiving the user's instruction, the client sends the target task corresponding to the user's instruction to the management service center. The management service center obtains the target task from the client, then determines the node that executes the target task one by one, and sends the target task to the corresponding node. After receiving the target task, the node executes the task.
[0055] according to Figure 1 It can be seen that in the existing centralized management solution, the flow of target tasks is: client-management service center-each node in the node cluster. Among them, the workload of distributing target tasks is all concentrated on the management service center, and the nodes in the node cluster are not related to each other.
[0056] If this management method is applied to the 4.0 cloud monitoring system, the management service center will need to manage more than 500,000 tasks, which will cause great processing pressure on the management service center and extend the processing time.
[0057] In addition, there is a performance bottleneck in the management of target tasks by the management service center. As the specifications of cloud monitoring become larger and larger, the existing centralized management solution is no longer suitable.
[0058] In order to solve this technical problem, an embodiment of the present application provides a task scheduling method, which is applied to a cluster system of a fully symmetric architecture, wherein the cluster system of the fully symmetric architecture includes multiple nodes, a part of the multiple nodes are master nodes and working nodes, and the rest are idle nodes, and the master node is elected by the multiple nodes. After obtaining a large number of target tasks, the master node distributes the target task hierarchy to pre-created work groups, and then the working nodes corresponding to the work groups each manage the target tasks corresponding to their respective associated work groups, determine the nodes that execute the target tasks one by one, and send the target tasks to the corresponding nodes. In this process, through hierarchical differentiation, the number of target tasks managed by a single master node and working node is reduced, reducing the pressure on a single node and shortening the delay.
[0059] In this solution, when more than 500,000 tasks need to be managed, the master node can first divide the 500,000 tasks into multiple work groups, for example, into 5 work groups, so that on average each work group's work node manages 100,000 tasks. Obviously, the amount of tasks managed by a single work node becomes less. And the parallel management of 5 work groups can effectively shorten the latency.
[0060] Please refer to Figure 2 , Figure 2 A schematic diagram of the architecture of a cloud monitoring system provided by an embodiment of the present application is shown. Figure 2 As shown, the cloud monitoring system provided by the embodiment of the present application includes a client and a cluster system with a fully symmetric architecture (hereinafter referred to as the cluster system), wherein one node in the cluster system assumes the role of a master node, other nodes assume the role of working nodes, and the remaining nodes except the master node and the working nodes assume the role of idle nodes.
[0061] Among them, the master node is responsible for obtaining the target task from the client and distributing the target task to the working nodes corresponding to multiple pre-set working groups. The working node is used to send the target task from the master node again to the idle node that executes the target task. The idle node is used to execute the target task.
[0062] according to Figure 2It can be seen that in the task scheduling scheme provided by the embodiment of the present application, the flow direction of the target task is: client-master node of the cluster system-working node of the cluster system-node of the cluster system that performs the target task. Wherein, the node that performs the target task can be any one of the master node, working node and idle node. In this scheme, there is no need to set up a special third-party hardware device for managing the target task, and the workload of distributing the target task is shared by the master node and multiple working nodes, and each node (master node or working node) only processes a part of the total workload.
[0063] In addition, it should be noted that in the embodiment of the present application, in the cluster system, the role assumed by a node can be changed, and the change process is described below.
[0064] In addition, it should be noted that in the embodiment of the present application, the master node and the working node still retain the function of executing specific target tasks during the process of managing target tasks. It can be understood that the master node and the working node have developed new task management functions based on the original functions of executing target tasks.
[0065] The architecture of the cluster system with a fully symmetric architecture provided in an embodiment of the present application is described below.
[0066] 1. Glossary:
[0067] MS: Service monitoring module.
[0068] CPM: Target task management module.
[0069] CVA: Targeted task execution module.
[0070] Main CPM: responsible for managing work groups, allocating work nodes, and allocating and scheduling target tasks to work nodes.
[0071] Work CPM: Execute target task management, responsible for target task allocation and dispatching to CVA for recording execution.
[0072] Master node: The node that runs the main CPM thread.
[0073] Worker node: A node that runs a worker CPM thread.
[0074] Idle nodes: nodes other than the master node and worker node.
[0075] Workgroup: The group_id recorded internally by the master CPM, used to associate work nodes and target tasks.
[0076] 2. Cluster system with fully symmetric architecture
[0077] A fully symmetric cluster system is a distributed computing architecture that includes multiple nodes, each of which is symmetric in processing power, storage, and functionality. All nodes can equally access shared resources for task processing and load balancing.
[0078] In the embodiment of the present application, each node includes a target task management module CPM and a target task execution module CVA, wherein the target task management module CPM can run a main CPM thread or a working CPM thread. The target task execution module CVA can run and execute a target task thread.
[0079] For a certain node A, when node A is the master node of the cluster system, node A runs the main CPM thread, which is responsible for managing work groups, allocating work nodes, and allocating and scheduling target tasks to work nodes.
[0080] When node A is a working node of the cluster system, node A runs a working CPM thread, which is responsible for target task management and allocating and scheduling target tasks to nodes that execute target tasks.
[0081] When node A is an idle node of the cluster system, node A does not run the CPM thread.
[0082] In addition, it should be noted that, regardless of whether node A is a master node, a working node or an idle node, node A can run the CVA process to execute the target task. The function of managing the target task and the function of executing the target task of node A can be performed in parallel.
[0083] In the embodiment of the present application, the cluster system further includes a MS service (Monitoring service, service monitoring module) and a database. The MS service is used to provide services for accessing shared resources, such as information synchronization between multiple nodes of the cluster system. The database can be used to store target tasks.
[0084] In this cluster system, since each node has exactly the same capabilities, when an abnormality occurs in the master node or working node, a new replacement can be quickly determined to ensure the normal operation of the cluster system. Therefore, this architecture has high availability.
[0085] In addition, in the embodiment of the present application, each node in the cluster system can run a CVA process to perform a target task. In other words, new functions are expanded while maintaining the original functions, such as the functions that can be achieved by running the main CPM thread and the functions that can be achieved by running the working CPM thread.
[0086] 3. Leader election mechanism
[0087] In the embodiment of the present application, the cluster system includes multiple nodes, and the multiple nodes can autonomously elect a master node according to established rules.
[0088] In one implementation, after the cluster system is started, each node needs to actively report its online status to the MS service. At the same time, each node can obtain the online status of other nodes in the cluster system from the MS service.
[0089] Corresponding to node A, when node A determines that the master node in the cluster system is offline or does not exist, node A starts the master election thread. Similarly, all nodes in the cluster system start the master election thread.
[0090] The operating principle of the master election thread includes: each node generates a globally unique IP in memory. In the starting state, all nodes are in the LOOKING state, and there is no Leader (master node). Then each node starts a round of voting and receives votes from other nodes. For a certain node SS, if more than half or more than 2 / 3 of the nodes support it among the received votes, and the IP of the node SS is the largest, then at this time, the node SS becomes the leader (master node). The specific implementation of the master election process can refer to the zookeeper master election mechanism, which will not be repeated here.
[0091] Among them, each node can obtain the votes of other nodes, so it can judge by itself that node SS has the support of more than half or more than 2 / 3 of the nodes, thereby determining that node SS is the master node of the cluster system.
[0092] In another implementation, after the cluster system is started, each node needs to actively report its online status to the MS service. At the same time, each node can obtain the online status of other nodes in the cluster system from the MS service. In this process, each node can obtain the node IP of other nodes, and each node determines the node with the largest IP as the master node. When the node SS determines that its own IP is the largest in the cluster system, then the node SS becomes the leader (master node).
[0093] In the embodiment of the present application, when the node SS becomes the leader, the node SS will start the main CPM thread and assume the role of the master node. It should be noted that the main CPM and CVA on the node SS are two independent program modules, which actually run on the node SS.
[0094] In the embodiment of the present application, all nodes including the master node need to periodically update their online status in the MS service. Similarly, all nodes including the master node need to periodically obtain the online status of other nodes from the MS service.
[0095] For any node B, when it is found that the master node has not been updated for more than the specified period of time or the master node is offline, node B will actively start the master election thread. Similarly, all nodes in the cluster system start the master election thread to elect a new master node.
[0096] In the embodiment of the present application, after a new master node appears, the new master node will start the main CPM thread, and correspondingly, the original master node stops running the main CPM thread.
[0097] It should be noted that, although the elected node is named as the master node in the embodiment of the present application, there is no master-slave relationship between the master node and other nodes in the cluster system. Any online node in the cluster system may become the master node.
[0098] 4. Master Node
[0099] In the embodiment of the present application, the master node runs the main CPM thread to mainly implement two functions, one is to manage the work group, and the other is to manage the target task.
[0100] The master node management working group includes:
[0101] In the start state, the master node creates multiple work groups. The master node can designate some nodes in the cluster system as work nodes to manage the work groups. Based on this, the master node can generate second association information, which includes the correspondence between the work groups and the work nodes.
[0102] It should be noted that in the embodiment of the present application, the management of the working group by the master node also involves adding a working group, reducing a working group, etc., which are explained below.
[0103] The following is an explanation of the various working groups.
[0104] In the embodiment of the present application, the master node creates multiple working groups which are not real groups, each working group does not include fixed group members, and the multiple working groups do not group the nodes in the cluster system.
[0105] In the embodiment of the present application, the master node creating multiple working groups may refer to the master node generating multiple identifiers (or group identifiers) represented by group_id. One group_id represents one working group, and the group_ids of multiple working groups may be arranged in a certain order.
[0106] In the embodiment of the present application, the number of working groups is related to the number of multiple nodes included in the cluster system.
[0107] Optionally, the master node may calculate the number of working groups required by the cluster system according to the number of multiple nodes included in the cluster system and a preset configuration ratio.
[0108] The master node may determine the number of working groups according to the number of multiple nodes and a preset configuration ratio, wherein the configuration ratio indicates the proportional relationship between the number of working groups and the total number of nodes; and create working groups based on the number of working groups.
[0109] Optionally, the master node determines a first value based on the number of multiple nodes and a preset configuration ratio; if the first value is a non-integer, the first value is rounded and added to 1 to obtain a second value, and the second value is used as the number of working groups; if the first value is an integer, the first value is used as the number of working groups.
[0110] For example, the number of the plurality of nodes is 100, and the preset configuration ratio is 1:10, which means that the corresponding relationship between the number of working groups and the number of the plurality of nodes is 1 to 10. Then the number of working groups = 100 / 10.
[0111] For another example, the number of multiple nodes is 123, and the preset configuration ratio is 1:10. Since the calculated number of work groups includes a decimal part, in this case, the required number of work groups needs to be increased by 1. That is, the required number of work groups = 123 / 10+1.
[0112] Optionally, in the embodiment of the present application, the number of the multiple nodes may be the number of online nodes in the cluster system.
[0113] The second associated information is described below.
[0114] In the embodiment of the present application, the master node can designate some nodes from multiple nodes as working nodes to manage the work group.
[0115] It should be noted that the master node specifies the working nodes, which actually means that the master node specifies CPM work on some nodes. These nodes running working CPM threads are called working nodes.
[0116] In one implementation, the master node first excludes the master node itself and abnormally offline nodes, then sorts the remaining online nodes according to the remaining online node ID dictionary, and finally distributes the work group group_id load balancing to the corresponding nodes in sequence. The nodes assigned with the work group are the working nodes designated by the master node. This process establishes the second association information, which includes the corresponding relationship between the work group and the working node.
[0117] In another implementation, the master node can select the same number of nodes from the online nodes according to the number of the above-mentioned working groups, and the selected nodes are working nodes. Then the master node can randomly determine the working group corresponding to each working node, and determine the corresponding relationship between the working node and the working group, that is, establish the second association information. Usually in the starting state, one working node usually corresponds to one working group.
[0118] In another implementation, the master node may select nodes that are less than the number of working groups from the online nodes as working nodes according to the number of working groups, and then the master node may determine the working group corresponding to each working node. A working node may manage one or more working groups, that is, the second association information is established.
[0119] Optionally, the second association information can be expressed as {"group_id":1,"node_id":"5E04A02205C01002A604"}, {"group_id":2,"node_id":"5E04A02335C01002A608"}, ….
[0120] Optionally, in an embodiment of the present application, the second association information may be reflected in the form of a working group table, as shown in Table 1.
[0121] Table 1
[0122] type describe group_id int Workgroup ID, primary key domain int Field ID, primary key node_id varchar(64) Worker Node ID
[0123] Among them, node_id is the working node ID.
[0124] In the present application embodiment, Figure 3 As shown, Figure 3 A schematic diagram of updating the second association information of a cluster system is shown. The master node can update the second association information to the MS service (shared memory), and the MS service returns the update result to the master node. Then, each node (working node and idle node) in the cluster can obtain the second association information from the MS service at a regular time to determine the changes of the working nodes and working groups in the cluster system.
[0125] It should be noted that, in the embodiment of the present application, in the starting state, the master node also needs to establish first association information, wherein the first association information includes the correspondence between the target task information and the work group to which the target task is assigned.
[0126] Among them, the first association information can be reflected in the form of a camera table, as shown in Table 2.
[0127] Table 2
[0128] type describe camera_id varchar(64) Encoder ID, primary key group_id int Workgroup ID domain int Domain ID
[0129] Among them, camera_id is the key to identify the target task information. In Table 2, the corresponding relationship between camera_id and group_id represents the corresponding relationship between the target task information and the target task assigned to the work group corresponding to group_id.
[0130] It should be noted that, since in the starting state, the master node has not yet distributed the target task to the working nodes of each working group, in this case, the camera_id in Table 2 is empty.
[0131] When the master node subsequently distributes the target task to the working nodes of each working group, the first association information will be updated according to the target task distribution result.
[0132] Please refer to Figure 4 , Figure 4 FIG. 2 shows a schematic diagram of a cluster system updating first association information. Figure 4 As shown, after updating the first association information, the master node can generate an update message and publish the update message in the MS service. Then, each node in the cluster (working nodes and idle nodes) can obtain the update message from the MS service at a regular interval. Generally speaking, after receiving the update message, the idle node can ignore the update message. After receiving the update message, the working node can actively obtain the updated first association information from the master node. Or actively obtain the changed part of the first association information from the master node. The working node updates the information in the local memory based on the obtained first association information or the changed part of the first association information.
[0133] In the embodiment of the present application, after the master node runs the main CPM thread, it can passively receive the target task sent by the client, or actively obtain the target task from the client.
[0134] 5. Working nodes and idle nodes
[0135] In an embodiment of the present application, other nodes (hereinafter referred to as idle nodes) other than the master node can obtain the second association information from the MS service. The second association information includes multiple working groups and multiple working nodes, and the working nodes corresponding to each working group. Then, the idle node can detect whether the node is currently a working node based on the second association information.
[0136] The idle node obtains the second association information in, for example:
[0137] When the master node updates the second association information, the idle nodes in the cluster system may obtain an update notification from the master node, and obtain the updated second association information from the MS service in response to the update notification.
[0138] Alternatively, other nodes except the master node may periodically obtain the second association information from the MS service.
[0139] The process of an idle node detecting whether the node is currently a working node is, for example:
[0140] If the node ID exists in the second association information and corresponds to one or several working groups, it is determined that the node is a working node.
[0141] If the node ID does not appear in the second association information and does not correspond to any working group, it is determined that the node is not a working node but an idle node.
[0142] In the embodiment of the present application, for any node, when the node determines that the node is a working node, the working CPM thread will be started. When the node determines whether the node is a working node or an idle node, the working CPM thread will not be started.
[0143] It should be noted that in an embodiment of the present application, after starting the working CPM thread, the working node will establish third association information, wherein the third association information includes the correspondence between the target task information, the node executing the target task, and the working group to which the target task is assigned.
[0144] The third associated information may be reflected in the form of a target task table, as shown in Table 3.
[0145] type describe camera_id varchar(64) Encoder ID, primary key group_id int Workgroup ID domain int Domain ID plan_info varchar(6144) Target mission information cva_id varchar(32) Execute the target task node ID
[0146] Among them, camera_id is the key to identify the target task information, cva_id represents the node ID that executes the target task, and plan_info represents the target task information.
[0147] It should be noted that in the embodiment of the present application, the working node can obtain the target task information (camera_id) through the first association information, and then the working node can assign the target task to a certain node by itself, and the assigned target task is executed by the certain node. After the working node determines the execution node corresponding to the target task, the corresponding relationship between camera_id and cva_id can be determined, where cva_id represents the node executing the CVA thread, and the execution node obtains the task data according to camera_id and writes it to the cloud to complete the cloud storage process. The camera_id assigned to the execution node can be one or more.
[0148] In Table 3, the correspondence between camera_id and group_id may come from the first association information. After obtaining the target task assigned to the work group corresponding to itself, the working node may construct the third association information in combination with the target task information and the first association information.
[0149] It should be noted that, since in the starting state, the master node has not yet distributed the target tasks to the working nodes of each working group, in this case, camera_id, cva_id, and plan_info in Table 3 are all empty.
[0150] When the master node subsequently distributes the target tasks to the working nodes of each working group, the working nodes may update the third association information according to the distributed target tasks.
[0151] It should be noted that in the embodiment of the present application, whether a node in the cluster is a working node or an idle node is not fixed, but may change with the update of the second association information and the first association information. The change process is described below.
[0152] The task scheduling method provided in the embodiment of the present application is described below with reference to the accompanying drawings.
[0153] Please refer to Figure 5 , Figure 5 A flow chart of a task scheduling method provided by an embodiment of the present application is shown. The method can be applied to a cluster system of a fully symmetric architecture (hereinafter referred to as a cluster system), which includes a master node, a working node, and an idle node. The determination method of the master node, the working node, and the idle node can refer to the above description, which is not repeated here. The method includes the following steps.
[0154] Step 501: The master node obtains multiple target tasks from the client.
[0155] In the embodiment of the present application, the client is user-oriented, can receive user instructions, generate target tasks according to the user instructions, and send the target tasks to the master node.
[0156] The master node may periodically and actively obtain the target task from the client, or the master node may respond to a notification from the client to obtain the target task.
[0157] Step 502: The master node allocates multiple target tasks to multiple preset working groups.
[0158] Based on the preset second association information, multiple target tasks are sent to the work nodes corresponding to each work group.
[0159] The second association information includes a correspondence between a working group and a working node. The working node is determined by the master node from a plurality of nodes and is used to forward the target task to a node that executes the target task.
[0160] In the embodiment of the present application, after the master node obtains multiple target tasks, the multiple target tasks can be load-balancedly distributed to all working groups. Specifically, the master node sends the multiple target tasks to the working nodes that manage the working group.
[0161] In one implementation, the master node may evenly distribute multiple target tasks to each work group one by one.
[0162] Exemplarily, there are target tasks 1-3 and there are working groups 1-2.
[0163] The master node assigns target task 1 to work group 1, target task 2 to work group 2, and target task 3 to work group 1. Then the master node determines that the working node of work group 1 is node1 and the working node of work group 2 is node2 based on the second association information. Then the master node assigns target task 1 and target task 3 to the working node node1 of work group 1, and assigns target task 2 to the working node node2 of work group 2.
[0164] In another implementation, the master node may preferentially allocate multiple target tasks to the work group with the least number of current tasks.
[0165] For example, there are target tasks 1-10, there are working groups 1-2, the number of tasks currently accessed by working group 1 is 50, and the number of tasks currently accessed by working group 2 is 60. The master node can assign target tasks 1-10 to working group 1, so that the number of tasks accessed by group 1 reaches 60.
[0166] In another implementation, the master node may evenly distribute multiple target tasks to each work group one by one, and each time the distribution is made, the work group with the least number of current tasks is given priority.
[0167] Exemplarily, there are target tasks 1-20, there are working groups 1-2, the number of tasks currently accessed by working group 1 is 50, and the number of tasks currently accessed by working group 2 is 60.
[0168] The master node can first assign target tasks 1-10 to work group 1, so that the number of tasks connected to group 1 reaches 60. Then, the master node evenly assigns target tasks 11-20 to work group 1 and work group 2 in turn.
[0169] In an embodiment of the present application, after the master node allocates multiple target tasks, the master node may update first association information according to the allocation result, where the first association information includes a correspondence between the target task information and the work group to which the target task is allocated.
[0170] Following the above example, the allocation result is: target task 1 and target task 3 are allocated to work group 1, and target task 2 is allocated to work group 2. Exemplarily, the first association information may be as shown in Table 4 and Table 5.
[0171] Table 4
[0172] type describe camera_1 varchar(64) Encoder ID, primary key camera_3 varchar(64) Encoder ID, primary key group_1 int Working Group 1 domain int Domain ID
[0173] Table 5
[0174] type describe camera_2 varchar(64) Encoder ID, primary key group_2 int Working Group 2 domain int Domain ID
[0175] In the embodiment of the present application, after updating the first association information, the master node may generate an update message and update the update message to the MS service, so that the working node may obtain the first association information from the master node based on the update message. Optionally, the master node may also update the updated first association information to the MS service.
[0176] Please refer to Figure 4 It can be seen that the working node can obtain the updated first association information, or obtain the updated part of the first association information, and update the local third association information accordingly.
[0177] Step 503: The working node obtains multiple target tasks assigned by the master node to the working group corresponding to the working node, and schedules and distributes the target tasks to the working group corresponding to the working node according to the first association information.
[0178] In the embodiment of the present application, after the master node issues the target task, the working nodes in the cluster system can obtain the second association information and the first association information from the MS service at a regular interval. Each working node manages the target task corresponding to its own associated working group.
[0179] The working node may determine the working group corresponding to itself according to the second association information, and then read the target task of the working group associated with the working node from the database.
[0180] In an embodiment of the present application, after obtaining the target task, the working node can schedule the target task to the execution node and determine the corresponding relationship between the execution node and the target task information.
[0181] On this basis, in the embodiment of the present application, the working node updates the third association information according to the task information of the multiple target tasks, the node executing the target task, and the working group to which the target task is connected, and the third association information includes the corresponding relationship between the target task information, the node executing the target task, and the working group to which the target task is assigned. The third association information can be shown in Table 3.
[0182] Step 504, executing the target task.
[0183] For any node, the node may be a master node, a working node or an idle node. After receiving the target task assigned by the working node, the node starts the CVA process to execute the target task.
[0184] For example, please refer to Figure 6 , Figure 6 FIG. 1 shows a logic diagram of a task scheduling method provided by an embodiment of the present application. Figure 6 As shown, node 1 is the master node, nodes 2-4 are working nodes, where node 2 manages the target task corresponding to group 1, node 3 manages the target task corresponding to group 2, and node 4 manages the target task corresponding to group 3. All nodes except nodes 1-4 are idle nodes.
[0185] It should be noted that Figure 6 This is only an example and does not constitute a limitation on the cluster system. The cluster system may include more or fewer working nodes and idle nodes.
[0186] Among them, node 1 runs the main CPM thread and obtains the target tasks plan1-plan300 from the client. Then, node 1 load balances these target tasks to each work group (group1, group2, group3). For example, plan1-plan100 is assigned to group1, and accordingly, node 2 obtains plan1-plan100. Plan101-plan200 is assigned to group2, and accordingly, node 3 obtains plan101-plan200. Plan201-plan300 is assigned to group3, and accordingly, node 4 obtains plan201-plan300.
[0187] Taking node 2 as an example, node 2 manages the target tasks accessed by group 1. Specifically, it sends the target tasks to the nodes that execute the target tasks one by one, such as Figure 6 The process of nodes 1-N in the example. The process of nodes 3 and 4 sending target tasks is the same as the process of node 2 sending target tasks, which will not be repeated here.
[0188] This solution introduces the concept of workgroups to balance the load of all target tasks in the cluster to all workgroups, and all workgroups in the cluster to all working nodes. All target tasks in the cluster are evenly distributed to different working nodes for load balancing scheduling. The target tasks in the entire cluster are scheduled on the management node without performance bottlenecks or management scale bottlenecks.
[0189] Eliminate the traditional separate planning and scheduling server architecture. Each node is deployed with planning and scheduling services and access services, without a separate configuration management server.
[0190] In the embodiment of the present application, during the operation of the cluster system, there are actually various situations such as capacity expansion and node failure replacement. Correspondingly, the number of nodes joining the cluster system will increase or decrease. In this case, the number of work groups also needs to be dynamically increased or decreased. Based on this, in the embodiment of the present application, the master node needs to regularly maintain the number of work groups. Figure 7 As shown, Figure 7 A flow chart of a method for a master node to maintain a working group is shown. The method comprises the following steps:
[0191] Step 701: The master node obtains the number of working groups currently required.
[0192] Step 702: The master node changes the working group according to the number of working groups currently required and the number of working groups actually present.
[0193] Changing a work group includes adding a work group, deleting a work group, modifying the work nodes corresponding to a work group, etc. The following are explained separately:
[0194] 1. The master node obtains the number of working groups currently required.
[0195] The number of working groups required by the cluster system is calculated according to the number of multiple online nodes included in the cluster system and a preset configuration ratio.
[0196] The number of working groups currently required = the number of online nodes joining the cluster system / 10.
[0197] If the number is not divisible, the number of working groups currently required is increased by one.
[0198] 2. Get the current actual number of working groups.
[0199] 3. When the number of work groups currently required is greater than the number of actual work groups currently, generate one or more new work groups; determine corresponding work nodes for each new work group from online nodes; and update the second association information according to the work nodes corresponding to each new work group.
[0200] Exemplarily, if it is determined that the current actual number of working groups M is less than the current required number of working groups N, a new working group is created.
[0201] Optionally, the number of new work groups created may be NM.
[0202] Optionally, the target tasks that have been assigned to each working group are reallocated to each new working group, and the first association information is updated according to the assignment result.
[0203] 4. When the number of work groups currently required is less than the number of actual work groups currently, determine one or more first work groups that need to be changed; and delete the first work groups and the corresponding relationship between the first work groups and the work nodes corresponding to the first work groups from the second association information.
[0204] Exemplarily, it is determined that the current actual number of working groups M>the current required number of working groups N, and the number of existing working groups is reduced.
[0205] Optionally, the number of reduced working groups may be MN.
[0206] Optionally, the target task that has been assigned to the first working group is reallocated to the remaining other working groups, and the first association information is updated according to the assignment result.
[0207] Optionally, a target working group is determined from the remaining other working groups, and the target task that has been assigned to the first working group is switched to the target working group.
[0208] The logic for creating a new workgroup includes:
[0209] The master node may generate one or more new working groups, and then determine corresponding working nodes for each new working group from the online nodes, and update the second association information according to the working nodes corresponding to each new working group.
[0210] In one method, the master node can obtain a list of all available nodes from the cluster system, and the list of all available nodes includes all online nodes in the cluster system, but offline and faulty nodes are not included.
[0211] Then, the master node may exclude the working nodes that have been connected to the working group from the list of available nodes, and then select some nodes from the remaining working nodes as the working nodes corresponding to each working group.
[0212] For example, two new working groups are added, and the group_id of the two working groups is the existing maximum group_id+1 (hereinafter represented as group_A) and the maximum group_id+2 (hereinafter represented as group_B). The master node designates node 6 and node 7 as new working nodes, and determines node 6 as the working node corresponding to group_A, and node 7 as the working node corresponding to group_B.
[0213] In another way, the master node can obtain a list of all available nodes from the cluster system. The list of all available nodes includes all online nodes in the cluster system, such as idle nodes and working nodes.
[0214] Then, the master node can sort all available nodes (including working nodes and idle nodes) according to the number of work groups to which they have been connected, and select the node with the least data connected to the work group. It can be understood that the node with the least number of connected work groups is the node with 0 connected work groups. Then, the newly created work group is associated with the selected node and saved to the database.
[0215] It should be noted that in an embodiment of the present application, after the master node creates a new work group and specifies the corresponding working node for the new work group, it is also necessary to update the second association information, that is, to add the correspondence between the new work group and the new working node in the second association information.
[0216] In the embodiment of the present application, the master node may update the second association information to the MS service. The master node may also generate an update notification so that the working node and the idle node can obtain the updated second association information in time. The process can be referred to Figure 3 shown.
[0217] It should be noted that, in the embodiment of the present application, after a new working group is added, the master node can distribute the target task to the new working group when distributing the target task next time.
[0218] Alternatively, after adding a new working group, the master node may reallocate the target tasks that have been allocated to each working group to each new working group, and update the first association information according to the allocation result.
[0219] For example, there are workgroups 1-2, the target task assigned to workgroup 1 is plan1-100, and the target task assigned to workgroup 2 is plan101-200. After adding workgroup 3-4, the master node can re-load balance plan1-100 and plan101-200 to four workgroups, so that each workgroup has access to 50 target tasks. For example, workgroup 1 accesses plan1-50, workgroup 2 accesses plan51-100, workgroup 3 accesses plan101-150, and workgroup 4 accesses plan151-100.
[0220] Accordingly, before reallocation, the first association information includes the correspondence between the nodes executing plan1-100 and workgroup 1, and includes the correspondence between the nodes executing plan101-200 and workgroup 2.
[0221] After reallocation, the master node needs to update the first association information. The updated first association information includes the correspondence between the nodes executing plan1-50 and workgroup 1, the correspondence between the nodes executing plan51-100 and workgroup 2, the correspondence between the nodes executing plan101-150 and workgroup 3, and the correspondence between the nodes executing plan151-200 and workgroup 4.
[0222] In the embodiment of the present application, the master node may update the first association information to the MS service. The master node may also generate an update notification so that the working node can obtain the updated first association information in a timely manner. The process can be referred to Figure 4 shown.
[0223] The logic of reducing the working group includes:
[0224] In an embodiment of the present application, when the number of work groups currently required is less than the number of work groups currently actually required, one or more first work groups that need to be changed are determined; and the first work group and the corresponding relationship between the first work group and the work node corresponding to the first work group are deleted from the second association information. The first work group is the work group that needs to be deleted.
[0225] It should be noted that in the embodiment of the present application, when the number of working groups currently required is less than the number of working groups currently actually required, the master node may not perform any corresponding processing. In other words, it is not necessary to reduce the number of working groups.
[0226] In the embodiment of the present application, the master node can arbitrarily select one or more work groups from the current actual work groups as the first work group. Or the master node can arbitrarily select MN work groups from the current actual work groups as the first work group. Alternatively, the master node can sort the work groups according to the number of target tasks accessed by each work group; and determine the one or more work groups sorted later as the first work group.
[0227] In an embodiment of the present application, after determining the first working group, the master node needs to update the second association information and the first association information. Specifically, the master node can delete the selected first working group and the correspondence between the first working group and the working node corresponding to the first working group from the second association information. Accordingly, the master node can delete the correspondence between the first working group and the node that executes the target task accessed by the first working group and the first working group from the first association information.
[0228] Then the master node can update the updated second association information and the first association information to the MS service. It should be noted that after deleting the first working group, the working node corresponding to the first working group will become an idle node. This aspect is explained below.
[0229] In the embodiment of the present application, after deleting the first working group, the master node may also reallocate the target task that has been allocated to the first working group to the remaining working groups, and update the first association information according to the allocation result.
[0230] For example, please refer to Figure 8 , Figure 8 A schematic diagram of reducing the working group is shown. Figure 8 (a) in FIG. 1 shows the master node, work group 1-node 1, work group 2-node 2, work group 3-node 3, and work group 4-node 4, among which work group 2 has the least number of target tasks accessed, and the master node can determine work group 2 as the first work group. Then, the master node redistributes the target tasks of work group 2 to the remaining three work groups, so that the number of target tasks of work group 1 after redistribution is 136, the number of target tasks of work group 3 after redistribution is 137, and the number of target tasks of work group 4 after redistribution is 137.
[0231] In practice, the process in which the master node reallocates the target tasks accessed by the deleted first working group to other working groups involves a relatively large amount of work, and according to the above description, it can be known that the process involves the redistribution of the target tasks, updating of the second associated information, the first associated information, etc. When the number of first working groups is large and the number of target tasks accessed by the first working group is large, the workload involved in the process is relatively large.
[0232] Based on this, an embodiment of the present application proposes that after determining the first working group, the master node determines the target working group from the remaining other working groups, and then switches the target tasks accessed by the first working group to the target working group as a whole.
[0233] For example, please refer to Figure 8 As shown in (b), among them, work group 1-node 1, work group 2-node 2, work group 3-node 3, work group 4-node 4, among which work group 2 has the least number of target tasks connected, and the master node can determine work group 2 as the first work group. Then, the master node determines the target work group from work group 1, work group 3 and work group 4.
[0234] The master node may determine the work group with the least number of access tasks among the remaining work groups as the target work group. Figure 8 As shown in (b), the master node determines workgroup 1 as the target workgroup, and then switches all the target tasks accessed by the first workgroup to workgroup 1. It can be seen that after the switch, the number of target tasks accessed by workgroup 1 is the sum of the number of target tasks accessed by workgroup 1 and workgroup 2 before the switch.
[0235] like Figure 8 As shown in (b), when it is necessary to further reduce the number of work groups, work group 3 can be determined as the first work group, work group 4 can be determined as the target work group, and then all the target tasks connected to work group 3 can be connected to node 4 corresponding to work group 4. It can be seen that the number of work groups has been reduced from 4 to 2. Nodes 2 and 3 have changed from working nodes to idle nodes. The number of target tasks connected to the work groups corresponding to nodes 1 and 4 has increased.
[0236] Based on this, after the switch, the master node also needs to update the second association information and the first association information. Specifically, the first work group and the working node corresponding to the first work group are deleted in the second association information. At the same time, in the first association information, the first work group associated with the target task accessed by the first work group is replaced as a whole with the target working node.
[0237] Optionally, an embodiment of the present application also proposes that after determining the first working group, the master node determines the target working node from the working nodes corresponding to the remaining other working groups, and then replaces the working node corresponding to the first working group with the target working node in the second association information.
[0238] That is, the target working node is responsible for associating the original working group and the newly connected first working group, and the number of working groups corresponding to the target working group is greater than one.
[0239] In this way, when the master node maintains the second association information, it only needs to replace the working node corresponding to the first working group, which is relatively simple. And because the first working group is not deleted, the first association information has not changed, so it does not involve the update of the first association information.
[0240] The above two implementations reduce the workload caused by the change of the maintenance work group as much as possible, simplify the process of reallocating the target tasks accessed by the first work group, improve efficiency and reduce workload.
[0241] In the embodiment of the present application, by regularly inspecting the working group and dynamically increasing or reducing the working group, it is possible to avoid structural redundancy caused by too many working groups in the cluster system, and it is also possible to avoid too few working groups in the cluster system, resulting in reduced efficiency in task allocation.
[0242] It should be noted that, in addition to the above-mentioned embodiments, in the case of increasing or decreasing the number of working groups, the target tasks are reallocated. In the embodiments of the present application, since the number of working groups will increase or decrease dynamically, the master node can also perform timed load balancing, that is, periodically time all target tasks to be load balanced in all working groups, and evenly distribute them to all working groups according to the number of target tasks. It includes the following contents:
[0243] 1. Count the number of target tasks currently accessed by all working groups.
[0244] 2. Determine the second threshold.
[0245] The second threshold is the average number of target tasks accessed by the working group.
[0246] Average number = the number of target tasks currently accessed by all working groups / the number of working groups. If it cannot be divided evenly, the average number is increased by 1.
[0247] 3. For each working group, when the number of target tasks currently accessed by the working group is greater than the second threshold, a first target task is determined from the target tasks accessed by the working group, and the first target task is a task that needs to be removed from the working group.
[0248] 4. For each working group, when the number of target tasks currently accessed by the working group is less than the second threshold, increase the target tasks allocated to the working group.
[0249] In order to ensure that the target tasks accessed by each work group are balanced, the first target task in the work group with more access target tasks is switched to the work group with fewer access target tasks. After the switch is completed, since the work group corresponding to the first target task has changed, it is necessary to update the first association information. Specifically, in the first association information, the correspondence between the node executing the first target task and the work group before the switch is released, and then the correspondence between the node executing the first target task and the work group after the switch is re-established.
[0250] Accordingly, the master node needs to update the updated first association information to the MS service so that the working node can obtain the updated first association information. Figure 4 shown.
[0251] In the embodiment of the present application, the master node balances the load of all target tasks in all working groups by timing, thereby avoiding uneven distribution of workload of each working node in the cluster system and affecting the efficiency of task distribution.
[0252] In the process of cluster system operation, there are many situations such as capacity expansion and node failure replacement. Correspondingly, the number of nodes joining the cluster system will increase or decrease. Based on this, on the basis of the above embodiment, in the embodiment of this application, the master node needs to regularly inspect the node status. Fig. 9 As shown, Fig. 9 A flow chart of a method for a master node to periodically inspect node status is shown. The method comprises the following steps:
[0253] Step 901: The master node detects whether each working node has an abnormality based on the second association information.
[0254] As can be seen from the foregoing, each node in the cluster system needs to actively report its online status to the MS service. Therefore, the master node can periodically obtain the online status of the working nodes corresponding to each working group in the second association information from the MS service.
[0255] If the working node does not update its online status within the preset time, or the online status of the working node changes to offline, the master node determines that there is an abnormality in the working node.
[0256] Step 902: If the working node is abnormal, the master node re-determines a new working node and replaces the abnormal working node with the new working node in the second association information.
[0257] In the embodiment of the present application, the master node can obtain a list of all available nodes, which includes all online nodes in the cluster system, excluding offline and faulty nodes.
[0258] Then, the master node may select a new working node from all online nodes, and replace the abnormal working node with the new working node in the second association information.
[0259] Optionally, the master node may obtain a list of all available nodes from the cluster system, where the list of all available nodes includes all online nodes in the cluster system, such as idle nodes and working nodes.
[0260] Then, the master node can sort all available nodes (including working nodes and idle nodes) according to the number of working groups that have been connected, and select the node with the least access to the working group data. It can be understood that the node with the least number of access to the working group is the node with 0 access to the working group, and a new working node is selected from the node with 0 access to the working group. Then, the new working node replaces the abnormal working node in the second association information.
[0261] Among them, the master node needs to update the second association information to the MS service. The new working node determines that it is a working node based on the updated second association information. After determining its corresponding working group, it can load the target task corresponding to its corresponding working group from the database into the memory and distribute it.
[0262] In an embodiment of the present application, by periodically detecting the status of working nodes and promptly replacing abnormal working nodes with new working nodes, the normal operation of each working group can be guaranteed, thereby preventing the target task accessed by a working group from being in an unprocessable state.
[0263] Under normal circumstances, after creating or adding a work group, the master node will load balance all work groups to the work nodes. If a work node is associated with two work groups, the master node can determine the new work node and switch one of the work groups to the new work node. This process includes: obtaining all work groups, counting the number of currently connected work groups on the node, and calculating the average number of connected work groups on the node.
[0264] 1. Detect the number of working groups corresponding to each working node according to the second association information.
[0265] 2. For each working node, when the number of working groups corresponding to the working node is greater than the first threshold, a second working group to be removed is determined from the working groups corresponding to the working node, a new working node is determined from the multiple nodes of the cluster system, and the working node corresponding to the second working group is replaced with the new working node in the second association information.
[0266] The first threshold may refer to the average number of working groups corresponding to all working nodes. That is, if the number of working groups currently accessed by the working node is greater than the average number of accessed working groups, the working group is cut out.
[0267] For example, work node 1 corresponds to work group 1 and work group 2, and the first threshold is 1. In this case, one of the two work groups needs to be cut out. For example, if the master node determines work group 2 as the second work group that needs to be removed, the master node first determines a new work node for work group 2, for example, the new work node is work node 3, and then the master node deletes the correspondence between work node 1 and work group 2 in the second association information, and replaces the work node corresponding to work group 2 from work node 1 to work node 3.
[0268] In this process, only the second association information is updated, and the first association information is not involved. The master node can update the second association information to the MS service.
[0269] 3. For each working node, when the number of working groups corresponding to the working node is less than the first threshold, a corresponding working group is determined for the working node. That is, if the number of working groups currently accessed by the working node is less than the average number of accessed working groups, the working group is switched into.
[0270] When the master node specifies a new work node, the number of work groups corresponding to the new work node is 0, which is less than the average number of work groups connected to the cluster. In this case, the master node needs to associate the corresponding work group with the work node.
[0271] Continuing with the above example, the new working node is working node 3, and the working group determined for the working node is working group 2, then the master node determines the corresponding relationship between working node 3 and working group 2 in the second association information. At this point, the process of switching to the working group is completed.
[0272] Based on the above embodiments, the present application also provides a task scheduling method, which is applied to a working node in a cluster system with a fully symmetric architecture, such as Fig.10 As shown, Fig.10 A flowchart of another task scheduling method provided by an embodiment of the present application is shown, and the method comprises the following steps:
[0273] Step 1001: The working node obtains second association information.
[0274] The second association information includes the corresponding relationship between the working group and the working node.
[0275] Optionally, the working node may also obtain first association information. The first association information includes a correspondence between target task information and a working group to which the target task is assigned.
[0276] In the embodiment of the present application, the working node may periodically obtain the second association information and / or the first association information from the MS service.
[0277] Alternatively, the working node may actively acquire the second association information and / or the first association information from the MS service upon receiving an update notification from the master node that the second association information and / or the first association information is updated.
[0278] Step 1002: The working node determines whether the node is currently a working node based on the second association information.
[0279] In the embodiment of the present application, each time a working node obtains the second association information, it needs to confirm whether the node is currently a working node.
[0280] When the identifier of the node is in the second association information, it means that the node is currently a working node. When the identifier of the node is not in the second association information, it means that the node is currently not a working node.
[0281] When the node is currently a working node, the node determines the working group corresponding to the node according to the second association information, and then loads the target task assigned to the working group from the database.
[0282] Then the node updates the third association information according to the first association information and the target task information.
[0283] Alternatively, the node may determine the target task information according to the target task information, and then update the third association information according to the target task information, the work group corresponding to the target task, and the node executing the target task.
[0284] It should be noted that, according to the above embodiments, there may be a situation where the node was a working node before and is still a working node currently, but the work group corresponding to the node may increase or decrease. In this case, the node detects whether the number of work groups corresponding to the node increases according to the second association information. If it increases, the target task corresponding to the newly added work group is obtained; the node detects whether the number of work groups corresponding to the node decreases according to the second association information. If it decreases, the target task corresponding to the decreased work group is deleted.
[0285] For example, this node previously managed the work group with group_id 1, and currently manages the work groups with group_id 1 and 2. In this case, this node needs to load the target task of work group 2 from the database and schedule the management.
[0286] For another example, the node previously managed work groups with group_id 1 and 2, and currently only manages the work group with group_id 1. In this case, the node needs to remove the target task connected to the work group with group_id 2 from the memory.
[0287] When the node is not a working node currently, the node deletes the target task accessed by the work group corresponding to the node from the memory, and deletes the third association information.
[0288] In the embodiment of the present application, since this node has previously loaded the target task accessed by the corresponding work group and is still performing the management of the corresponding target task, when this node changes from a working node to an idle node, it will stop running the working CPM thread and stop the target task management business.
[0289] Based on the above embodiments, the present application also provides a task scheduling method, which is applied to idle nodes in a cluster system with a fully symmetric architecture. In the present application, the idle nodes can run CVA processes to execute target tasks from working nodes. In addition, the idle nodes can also obtain information updated by the master node from the MS service at regular intervals. Fig.11 As shown, Fig.11 A flowchart of another task scheduling method provided by an embodiment of the present application is shown, and the method comprises the following steps:
[0290] Step 1101: An idle node obtains second association information.
[0291] The second association information includes the corresponding relationship between the working group and the working node.
[0292] Optionally, the node may also obtain first association information, where the first association information includes a correspondence between target task information and a work group to which the target task is assigned.
[0293] Step 1102: The idle node determines whether the idle node is currently a working node according to the second association information.
[0294] Step 1103, if the idle node is currently a working node, the idle node determines the work group corresponding to the idle node according to the second association information and the first association information, obtains the target task assigned to the work group, and sends the target task assigned to the work group to the nodes that execute the target task.
[0295] The working node is determined by the master node from multiple idle nodes and is used to forward the target task to the node that executes the target task.
[0296] In the embodiment of the present application, after the idle node obtains the second association information from the MS service each time, it needs to detect whether the working node in the second association information is the current node. The detection method is, for example, to determine whether the current node is the working node in the second association information. For example, if node_id=7A0180730480AA06D57A is the current node id, it means that the current node is currently a working node.
[0297] This situation indicates that the node was previously an idle node and is currently a working node. Based on this, the node needs to start the working CPM thread and start the target task management service. Correspondingly, the node can determine the work group corresponding to the node based on the second association information and the first association information, read the target task connected to the work group from the database into the memory, manage the target task connected to the work group, and send the target task to the node that executes the target task.
[0298] Furthermore, the node also needs to generate third association information according to the target task assigned to the work group and the first association information, and the third association information includes the correspondence between the target task information, the node executing the target task, and the work group to which the target task is assigned.
[0299] If the node does not exist in the second association information, it means that the node is not a working node but an idle node. In this case, the node only needs to execute the received target task.
[0300] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0301] Based on the same inventive concept, an embodiment of the present application also provides a task scheduling device, and the implementation solution for solving the problem provided by the device is similar to the implementation solution recorded in the above method. Therefore, the specific limitations in the task scheduling device embodiment provided below can be referred to the limitations on the task scheduling method above, and will not be repeated here. Fig.12 A structural block diagram of a task scheduling device provided in an embodiment of the present application, such as Fig.12 As shown, the device includes: a processing unit 1201 and an acquisition unit 1202.
[0302] In one implementation, the task scheduling device 1200 is used to implement the functions performed by the master node in the cluster system of the fully symmetric architecture in the above method embodiment, and the acquisition unit 1202 is used to obtain multiple target tasks from the client; the processing unit 1201 is used to assign the multiple target tasks to a preset multiple work groups, and generate first association information so that the working node schedules the target tasks distributed to the work group corresponding to the working node based on the first association information; wherein the first association information includes the correspondence between the target task information and the work group to which the target task is assigned; the working node is determined by the master node from multiple nodes.
[0303] Among them, the task scheduling device 1200 is also used to implement other functions that the master node can implement, which will not be described in detail here.
[0304] In one implementation, the task scheduling device 1200 is used to implement the functions executed by the working node in the cluster system of the fully symmetric architecture in the above method embodiment, and the acquisition unit 1202 is used to obtain multiple target tasks assigned by the master node to the work group corresponding to the working node based on the first association information if the node is a working node; the first association information includes the correspondence between the target task information and the work group to which the target task is assigned; the processing unit 1201 is used to schedule multiple target tasks, and update the third association information according to the task information of the multiple target tasks, the node executing the target task, and the work group to which the target task is connected, and the third association information includes the correspondence between the target task information, the node executing the target task, and the work group to which the target task is assigned.
[0305] Among them, the task scheduling device 1200 is also used to implement other functions that can be implemented by the working node, which will not be described in detail here.
[0306] In one implementation, the task scheduling device 1200 is used to implement the function executed by the idle node in the cluster system of the fully symmetric architecture in the above method embodiment, and the acquisition unit 1202 is used to obtain the second association information and the first association information, wherein the second association information includes the correspondence between the work group and the working node; the first association information includes the correspondence between the target task information and the work group to which the target task is assigned; the processing unit 1201 is used to determine whether the idle node is currently a working node based on the second association information, and the working node is determined by the master node from multiple idle nodes, and is used to forward the target task to the node that executes the target task; if the idle node is currently a working node, the work group corresponding to the idle node is determined based on the second association information and the first association information, the target task assigned to the work group is obtained, and the target task assigned to the work group is sent to the node that executes the target task respectively; if the idle node is not currently a working node, the received target task is executed.
[0307] The task scheduling device 1200 is also used to implement other functions that can be implemented by idle nodes, which will not be described in detail here.
[0308] Each module in the above task scheduling device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0309] In one embodiment, a computer device is provided. The computer device is a task scheduling device in the embodiment of the present application. Its internal structure diagram can be as follows: Fig.13 shown. Fig.13 A block diagram of a computer device is shown. The computer device includes a processor, a memory and a network interface connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The processor may include one or more processing units. The processor may be a CPU (Central Processing Unit) or a DSP (Digital Signal Processing), etc. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store preset data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a task scheduling method is implemented.
[0310] Based on the above embodiments, an embodiment of the present application also provides a computer-readable storage medium, which stores a computer program (or computer-executable instructions). When the computer program is executed by one or more processors, the processor executes the steps of the task scheduling method in the above embodiments.
[0311] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps of the task scheduling method.
[0312] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0313] The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above are only specific implementation methods of the present application and are not used to limit the protection scope of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present application should be included in the protection scope of the present application.
Claims
1. A task scheduling method, characterized in that: Applied to a master node in a cluster system, the cluster system includes multiple nodes, the master node is a node elected by the multiple nodes, and the method includes: Get multiple target tasks from the client; The multiple target tasks are assigned to multiple preset work groups, and first association information is generated so that the working node schedules the target tasks distributed to the work group corresponding to the working node based on the first association information; wherein the first association information includes the correspondence between the target task information and the work group to which the target task is assigned; the working node is determined by the master node from the multiple nodes.
2. The method according to claim 1, characterized in that The method further comprises: Determining the number of working groups according to the number of the plurality of nodes and a preset configuration ratio, wherein the configuration ratio indicates a proportional relationship between the number of working groups and the total number of nodes; The work groups are created based on the number of the work groups.
3. The method according to claim 2, characterized in that The determining the number of working groups according to the number of the plurality of nodes and a preset configuration ratio includes: Determining a first value according to the number of the plurality of nodes and the preset configuration ratio; If the first value is a non-integer, rounding the first value and adding 1 to obtain a second value, and using the second value as the number of the working groups; If the first value is an integer, the first value is used as the number of the working groups.
4. The method according to claim 1, characterized in that: The method further comprises: A working node is allocated to each of the working groups, and second association information is created according to a corresponding relationship between the working groups and the working nodes, where the second association information is used for each of the multiple nodes to determine whether it is a working node.
5. The method according to claim 4, characterized in that The method further comprises: The second association information is published to a shared memory in the cluster system.
6. The method according to claim 4, characterized in that The method further comprises: Detecting whether each of the working nodes in the second association information is abnormal; If a working node is abnormal, the working group corresponding to the abnormal working node will be switched to a new working node.
7. The method according to claim 6, characterized in that The method further comprises: The target tasks of the work group corresponding to the abnormal work node are redistributed to the work groups corresponding to other work nodes without abnormalities.
8. A task scheduling method, characterized in that: Applied to nodes other than a master node in a cluster system, the cluster system includes multiple nodes, the master node is a node elected by the multiple nodes, and the method includes: Determine whether the node is a working node, where the working node is determined by the master node from the multiple nodes; If the node is a working node, based on the first association information, a plurality of target tasks assigned by the master node to the working group corresponding to the working node are obtained; the first association information includes a correspondence between target task information and the working group to which the target task is assigned; Schedule the multiple target tasks, and update the third association information according to the task information of the multiple target tasks, the nodes executing the target tasks, and the working groups to which the target tasks are connected, wherein the third association information includes the correspondence between the target task information, the nodes executing the target tasks, and the working groups to which the target tasks are assigned.
9. The method according to claim 8, characterized in that The step of determining whether the node is a working node includes: Acquire second association information from a shared memory in the cluster system, where the second association information includes a correspondence between a work group and a work node; Determine whether the node is currently a working node according to the second association information; If the node is currently a working node, determine the work group corresponding to the node according to the second association information, obtain the target task assigned to the work group corresponding to the node, and update the third association information according to the first association information; If the node is not a working node currently, the target task accessed by the working group corresponding to the node is deleted from the memory, and the third association information is deleted.
10. A task scheduling device, characterized in that: The device is applied to a master node in a cluster system, wherein the cluster system includes a plurality of nodes, the master node is a node elected by the plurality of nodes, and the device includes: An acquisition unit, used for acquiring multiple target tasks from a client; A processing unit is used to assign the multiple target tasks to a preset multiple work groups, and generate first association information so that the working node schedules the target tasks distributed to the work group corresponding to the working node based on the first association information; wherein the first association information includes the correspondence between the target task information and the work group to which the target task is assigned; the working node is determined by the master node from the multiple nodes.
11. A task scheduling device, characterized in that: Applied to nodes other than a master node in a cluster system, the cluster system includes multiple nodes, the master node is a node elected by the multiple nodes, and the device includes: an acquisition unit, configured to acquire, if the node is a working node, a plurality of target tasks assigned by the master node to the working group corresponding to the working node based on first association information; the first association information includes a correspondence between target task information and the working group to which the target task is assigned; A processing unit is used to schedule the multiple target tasks and update the third association information according to the task information of the multiple target tasks, the nodes executing the target tasks and the working groups to which the target tasks are connected, wherein the third association information includes the correspondence between the target task information, the nodes executing the target tasks and the working groups to which the target tasks are assigned.
12. An electronic device, characterized in that: It comprises a memory and a processor, the memory is used to store a computer program, and the processor is used to call the computer program to execute the task scheduling method as described in any one of claims 1 to 7, or execute the task scheduling method as described in any one of claims 8 to 9.
13. A cluster system, characterized in that: Including the master node and other nodes, among which, The master node is used to implement the function of the master node in the task scheduling method according to any one of claims 1 to 7; The other nodes are used to implement the functions of the other nodes in the task scheduling method as described in any one of claims 8 to 9.