A Spark task scheduling method and system based on heterogeneous resources
Through the Spark task scheduling method based on heterogeneous resources, the problem of low efficiency of traditional system resource management and data processing is solved, accurate resource allocation, data parallel processing and real-time anomaly detection are realized, and task scheduling performance is improved.
Patent Information
- Application Number
- CN202210464762.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-25
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-04-25
AI Technical Summary
Traditional task scheduling systems have deficiencies in resource management and data processing, leading to resource waste, inefficient performance, lack of anomaly detection, and unoptimized data structures.
The Spark task scheduling method based on heterogeneous resources is used to create a cluster manager by obtaining system resource information, generate a DAG diagram to divide task stages, perform data re-aggregation and division, use HashMap to store data, and update resource status in real time for anomaly detection.
It achieves precise allocation of resources, improves task scheduling efficiency, reduces repeated calculations for data reorganization, improves storage efficiency, detects and interrupts abnormal tasks in a timely manner, and improves overall performance.
Smart Images

Figure CN114816704B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and more specifically, relates to a Spark task scheduling method and system based on heterogeneous resources. Background Art
[0002] Task scheduling is an important part of the operating system, and for real-time operating systems, task scheduling directly affects their real-time performance. The task scheduling system is a very core component in the data platform. In daily data processing, it is very common to run some services on a regular basis, such as importing new data from the database to the data platform on a regular basis, and exporting the processed data from the data platform to the database or file system; it can be said that the task scheduling system is similar to the commander of the army, commanding the operation of each component on the data platform and supervising the operation of tasks at all times.
[0003] However, the traditional task scheduling system has some defects that cannot be ignored: First, the traditional resource manager is limited to collecting the number of CPU cores but does not include detailed information on the CPU type and other related computing power evaluations, which results in a waste of system resources; Second, the spark task scheduling process involves a large number of RDD data reorganization operations and the performance optimization during the reorganization operation is poor, which greatly reduces the operating efficiency, and does not support real-time status updates of the resource manager through the running results to set up anomaly detection. Third, the traditional task scheduling system does not select an efficient storage data structure during the execution of the task node, resulting in a loss of efficient performance during the operation process. Fourth, the running results obtained during the spark task scheduling process will not be updated to the resource manager in real time, so that the operation is still in progress despite the abnormal operation. Summary of the invention
[0004] In view of the above defects or improvement needs of the prior art, the present invention provides a Spark task scheduling method based on heterogeneous resources. Its purpose is to solve the technical problem that the resource manager of the existing task scheduling system is limited to collecting the number of CPU cores, which leads to waste of system resources, and the technical problem that the spark task scheduling process involves a large number of RDD data reorganization operations, and the performance optimization during the reorganization operation is poor, which greatly reduces the operation efficiency, and does not support the real-time status update of the resource manager through the operation results to set the abnormality detection, and the technical problem that the data structure with efficient storage is not selected during the execution of the task node, resulting in the loss of efficient performance during the operation, and the technical problem that the operation results obtained during the spark task scheduling process will not be updated to the resource manager in real time, so that the operation abnormality cannot be detected.
[0005] To achieve the above object, according to one aspect of the present invention, a Spark task scheduling method based on heterogeneous resources is provided, which specifically includes the following steps:
[0006] A Spark task scheduling method based on heterogeneous resources includes the following steps:
[0007] (1) The server obtains the resource information required by the system based on Linux commands and submits it to the resource manager to create a cluster manager and complete initialization;
[0008] (2) The server receives the task job submitted by the client and submits the task job to the cluster manager created in step (1) to convert the task job into multiple resilient distributed datasets (RDDs), and parses all the obtained RDDs to obtain an RDD graph representing the dependency relationship between the multiple RDDs;
[0009] (3) The server generates a directed acyclic graph (DAG) for the scheduling phase based on the dependency relationships between all RDDs in the RDD graph obtained in step (2);
[0010] (4) The server divides all RDDs in the DAG graph into the first task stage, the second task stage, and the third task stage according to their corresponding dependencies.
[0011] (5) The server sets the counter i=1;
[0012] (6) The server determines whether i is greater than the total number of RDDs in the DAG graph in step (4). If so, the process ends; otherwise, it goes to step (7);
[0013] (7) The server determines whether the i-th RDD in the DAG graph belongs to the first task scheduling stage, the second task scheduling stage, or the third task scheduling stage. If it belongs to the first task scheduling stage, the server proceeds to step (9); if it belongs to the second task scheduling stage or the third task scheduling stage, the server proceeds to step (8);
[0014] (8) The server re-aggregates and partitions the data in the data partition of the i-th RDD in the DAG graph to obtain the re-aggregated and partitioned data partition in the i-th RDD, and proceeds to step (9);
[0015] (9) The server evenly distributes action operators to the data partitions in the i-th RDD after reaggregation and partitioning, so as to obtain multiple independent task nodes corresponding to the i-th RDD that can be executed concurrently;
[0016] (10) The server executes all independent task nodes corresponding to the i-th RDD obtained in step (9) to obtain task results, and updates the status of the cluster manager according to the task running results to obtain an updated cluster manager;
[0017] (11) The server performs resource information anomaly detection on the cluster manager updated in step (10) to determine whether there is an abnormal alarm. If so, the process ends, otherwise it goes to step (12);
[0018] (12) The server sets the counter i=i+1 and returns to step (5).
[0019] Preferably, the resource information mainly includes but is not limited to the number and type of CPU cores, memory information, and disk I / O information.
[0020] Preferably, the RDD is composed of a series of data partitions, and the dependencies between the RDDs are mainly wide dependencies or narrow dependencies, and the RDD can be recalculated based on the previous RDD to achieve the conversion of wide and narrow dependencies;
[0021] If there is a one-to-one mapping relationship between the data partitions in the RDD on one side and the data partitions in the RDD on the other side in the RDD graph, the dependency relationship corresponding to the RDD on that side is a narrow dependency;
[0022] If there is a one-to-many mapping relationship between the data partitions in the RDD on one side and the data partitions in the RDD on the other side, the dependency relationship corresponding to the RDD on that side is a wide dependency.
[0023] Preferably, if the dependency relationship corresponding to a certain RDD in the DAG graph is a narrow dependency, the RDD belongs to the first task scheduling stage; if the dependency relationship corresponding to a certain RDD in the DAG graph is a wide dependency, the RDD belongs to the second task stage; if the dependency relationship corresponding to a certain RDD in the DAG graph changes from a wide dependency to a narrow dependency, or from a narrow dependency to a wide dependency, the RDD belongs to the third task stage;
[0024] Preferably, step (8) comprises the following sub-steps:
[0025] (8-1) For each data in the data partition of the i-th RDD in the DAG graph, the server performs segmentation processing on each field in the data to obtain segmented data, and stores the data in the JAVA virtual machine JVM memory;
[0026] (8-2) The server obtains the data stored in the JVM from the JVM, and processes the data through the Pipeline to obtain the data corresponding to the data partition in the RDD, and then transmits the data to the RDD data partition in sequence;
[0027] (8-3) The server will perform variable vectorization, broadcast variable and deserialization processing on the data transmitted to the data partition in order to obtain the data partition after re-aggregation and division in the i-th RDD.
[0028] Preferably, step (10) comprises the following sub-steps:
[0029] (10-1) The server mobilizes the cluster manager to allocate resources to each independent task node corresponding to the i-th RDD obtained in step (9);
[0030] (10-2) The server stores all data in the independent task nodes corresponding to the i-th RDD after all resources are allocated in the HashMap data structure in the form of key-value pairs;
[0031] (10-3) The server obtains the data in the independent task node corresponding to the i-th RDD from the HashMap data structure, and submits the data to all independent task nodes corresponding to the i-th RDD that have allocated resources for real-time processing to obtain the running results;
[0032] (10-4) The server updates the status of the cluster manager according to the operation result obtained in step (10-3) to obtain an updated cluster manager.
[0033] Preferably, in step (10-4), the status of the cluster manager is updated, specifically, the operating status of all independent task nodes in the cluster manager is updated according to the degree of completion of the operating results. The operating status is mainly divided into the operating completion status, the running status, the operating failure status, or the task node is forced to be closed.
[0034] Preferably, the resource information anomaly detection in step (11) mainly determines the status of all independent task nodes of the cluster manager. If there are still independent task nodes in the running state, the running failure state, or the forced shutdown state, an abnormal alarm is issued.
[0035] According to another aspect of the present invention, a Spark task scheduling system based on heterogeneous resources is provided, which is arranged in a server, and the Spark task scheduling system includes:
[0036] The first module is used to obtain the resource information required by the system based on Linux commands and submit it to the resource manager to create a cluster manager and complete initialization;
[0037] The second module is used to receive the task job submitted by the client, and submit the task job to the cluster manager created by the first module to convert the task job into multiple resilient distributed data sets RDD, and parse all the obtained RDDs to obtain an RDD graph representing the dependency relationship between the multiple RDDs;
[0038] The third module is used to generate a directed acyclic graph (DAG) of the scheduling stage according to the dependency relationship between all RDDs in the RDD graph obtained by the second module;
[0039] The fourth module is used to divide all RDDs in the DAG graph into the first task stage, the second task stage and the third task stage according to their corresponding dependencies.
[0040] The fifth module is used to set the counter i=1;
[0041] The sixth module is used to determine whether i is greater than the total number of RDDs in the DAG graph in the fourth module. If so, the process ends, otherwise it enters the seventh module;
[0042] The seventh module is used to determine whether the i-th RDD in the DAG graph belongs to the first task scheduling stage, the second task scheduling stage or the third task scheduling stage. If it belongs to the first task scheduling stage, it will be transferred to the ninth module; if it belongs to the second task scheduling stage or the third task scheduling stage, it will be transferred to the eighth module;
[0043] The eighth module is used to re-aggregate and partition the data in the data partition of the i-th RDD in the DAG graph to obtain the re-aggregated and partitioned data partition in the i-th RDD, and enter the ninth module;
[0044] The ninth module is used to evenly distribute action operators to the data partitions after re-aggregation and partitioning in the i-th RDD, so as to obtain multiple independent task nodes corresponding to the i-th RDD and capable of concurrent execution;
[0045] The tenth module is used to execute all independent task nodes corresponding to the i-th RDD obtained in the ninth module to obtain task results, and update the status of the cluster manager according to the task running results to obtain an updated cluster manager;
[0046] The eleventh module is used to perform resource information anomaly detection on the cluster manager updated by the tenth module to determine whether there is an abnormal alarm. If so, the process ends, otherwise, the twelfth module is entered;
[0047] The twelfth module is used to set the counter i=i+1 and return to the fifth module.
[0048] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects compared with the prior art:
[0049] 1. Since the present invention adopts step (1), step (2) and step (9), firstly, it pre-creates a cluster manager that obtains system information resources, so that system resources can be allocated as accurately as possible for each independent task node to avoid wasting system resources and achieve efficient task scheduling; secondly, its RDD allows the data in the task operation to be allocated to different independent task nodes and supports parallel operation, without the need to hand over a large amount of data to the same independent task node and increase its burden.
[0050] 2. Since the present invention adopts step (4), step (7) and step (8), firstly, it divides the first task scheduling stage, the second task scheduling stage and the third task scheduling stage in the DAG diagram by the wide and narrow dependency relationship, and judges whether to re-aggregate and divide the internal data partitions of the RDD according to the stage where the RDD is located, and then screens out some RDDs, thereby solving the problem of reorganization of a large number of RDD data; secondly, it adopts the method of persisting and storing Java objects in the JVM memory in the process of re-aggregating and dividing the internal data partitions of the RDD, so that it can directly call the existing calculation results in the JVM without recalculating the existing results, thereby reducing the repeated calculation operations in the process and solving the performance optimization problem in the reorganization process.
[0051] 3. Since the present invention adopts step (10), it stores the data in the independent task nodes in the form of key-value pairs through a HashMap data structure including numbers, linked lists and red-black trees. Therefore, the data in the independent task nodes that have been obtained can be processed in advance without waiting for all the data to be acquired, thereby saving a lot of waiting time and solving the problem of efficient storage.
[0052] 4. Since the present invention adopts step (11), it updates the running status of independent tasks in the cluster manager in real time through the running results and uses this to perform abnormality detection. If the independent task node is in a running state, a running failure state, or is forcibly closed, an abnormal alarm is issued to interrupt the execution in time, thereby solving the problem that the task scheduling execution process is abnormal but still executing. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 is a schematic diagram of the narrow dependency relationship in the present invention;
[0054] Figure 2 is a schematic diagram of a wide dependency relationship in the present invention;
[0055] Figure 3is a DAG graph generated by the present invention;
[0056] Figure 4 It is a flow chart of the Spark task scheduling method based on heterogeneous resources of the present invention. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0058] like Figure 4 As shown, the present invention provides a Spark task scheduling method based on heterogeneous resources, which specifically includes the following steps:
[0059] (1) The server obtains the resource information required by the system based on Linux commands and submits it to the resource manager to create a cluster manager and complete initialization;
[0060] Specifically, resource information mainly includes but is not limited to the number and type of CPU cores, memory information, and disk I / O information. The cluster manager evaluates the corresponding computing power of the processor CPU based on the detailed resource information to enhance the computing power matching capability, so as to achieve efficient operation of each node and reasonable utilization of resource configuration.
[0061] The advantage of this step is that the cluster manager, unlike the traditional resource manager, collects computing power mainly based on the number of CPU cores of each node, without specific information about the type of each CPU core, thus avoiding waste of system resources and improving task scheduling efficiency through accurate allocation of resources;
[0062] (2) The server receives the task job submitted by the client and submits the task job to the cluster manager created in step (1) to convert the task job into multiple resilient distributed datasets (RDDs), and parses all the obtained RDDs to obtain an RDD graph that represents the dependency relationship between the multiple RDDs;
[0063] Specifically, RDD is composed of a series of data partitions, and the number of data partitions can be more or less to reflect the elasticity of RDD. The dependencies between RDDs are mainly wide dependencies or narrow dependencies, and RDD can be recalculated based on the previous RDD to achieve the conversion of wide and narrow dependencies.
[0064] Furthermore, see Figure 1As shown in (a) and (b), we can see that each data partition in the left RDD points to the only data partition in the right RDD with an arrow (that is, there is a one-to-one mapping relationship between the data partitions in the left RDD and the data partitions in the right RDD). At this time, the dependency relationship corresponding to the left RDD is a narrow dependency; see further Figure 2 As shown in (a) and (b), we can see that each data partition in the left RDD points to all data partitions in the right RDD with arrows (that is, there is a one-to-many mapping relationship between the data partitions in the left RDD and the data partitions in the right RDD). At this time, the dependency relationship corresponding to the left RDD is a wide dependency.
[0065] (3) The server generates a directed acyclic graph (DAG) for the scheduling phase based on the dependency relationships between all RDDs in the RDD graph obtained in step (2);
[0066] Specifically, in this step, RDD and RDD graph are mapped layer by layer through dependency relationships to form parent-child RDDs, and finally converge into a DAG graph. When the task node is executed, each data set is executed in the order described in the DAG graph to achieve order and efficiency;
[0067] The advantage of the above steps (1) to (3) is that the initialized cluster manager converts the task job submitted by the client into RDD and generates an RDD dependency graph based on the dependencies between RDDs, so that the data in the task job can be distributed in different independent task nodes and support parallel operation.
[0068] (4) The server divides all RDDs in the DAG graph into the first task stage, the second task stage, and the third task stage according to their corresponding dependencies.
[0069] Specifically, if the dependency relationship corresponding to a certain RDD in the DAG graph is a narrow dependency, then the RDD belongs to the first task scheduling stage; if the dependency relationship corresponding to a certain RDD in the DAG graph is a wide dependency, then the RDD belongs to the second task stage; if the dependency relationship corresponding to a certain RDD in the DAG graph changes from a wide dependency to a narrow dependency, or from a narrow dependency to a wide dependency, then the RDD belongs to the third task stage;
[0070] (5) The server sets the counter i=1;
[0071] (6) The server determines whether i is greater than the total number of RDDs in the DAG graph in step (4). If so, the process ends; otherwise, it goes to step (7);
[0072] (7) The server determines whether the i-th RDD in the DAG graph belongs to the first task scheduling stage, the second task scheduling stage, or the third task scheduling stage. If it belongs to the first task scheduling stage, the server proceeds to step (9); if it belongs to the second task scheduling stage or the third task scheduling stage, the server proceeds to step (8);
[0073] (8) The server re-aggregates and partitions the data in the data partition of the i-th RDD in the DAG graph to obtain the re-aggregated and partitioned data partition in the i-th RDD, and proceeds to step (9);
[0074] Specifically, step (8) includes the following sub-steps:
[0075] (8-1) For each data in the data partition of the i-th RDD in the DAG graph, the server performs segmentation processing on each field in the data to obtain segmented data, and stores the data in the memory of the JAVA virtual machine (Java Virtual Machine, JVM for short);
[0076] Specifically, in this step, the fields are segmented, specifically, each field of the data partition in the RDD is split according to type classification to refine the data;
[0077] The purpose of the segmentation process in this step is to achieve persistence in the form of Java objects;
[0078] The advantage of this step is that by implementing the persistence of Java objects and storing them in the JVM, the generated calculation results can be called in the persistent JVM memory, which can avoid repeating the same operation during a large number of repeated calls of RDD data partitions, thereby reducing the number of calls. In addition, since RDD operations consume a lot of system resources, the efficiency of the entire spark task scheduling can be greatly improved.
[0079] (8-2) The server obtains the data stored in the JVM from the JVM, and processes the data through the Pipeline (pipeline computing mode) to obtain the data corresponding to the data partition in the RDD, and then transmits the data to the RDD data partition in sequence;
[0080] (8-3) The server performs variable vectorization, broadcast variable, and deserialization processing on the data transmitted to the data partition to obtain the re-aggregated and divided data partition in the i-th RDD;
[0081] The purpose of this step is to achieve re-aggregation and partitioning of the i-th RDD;
[0082] The advantage of the above steps (8-1) to (8-3) is that by re-aggregating and partitioning the RDD, the efficiency of spark task scheduling can be improved, thereby improving the performance of the entire system. First, in the persistence process, java objects are used and stored in the JVM memory to achieve efficient storage. In the process of buffering all data, pure memory is fast and does not require CPU resources. Second, Pipeline follows the characteristics of sequential execution in the entire data processing process, that is, the data used in each stage comes from the results provided by the previous stage. At the same time, it supports lazy loading, that is, it will not be executed if no action operator is assigned to the data, thereby avoiding the blind running of independent tasks under the premise of achieving order. Third, after the data variables of all data partitions in the RDD are vectorized, the broadcast variable operation can reduce the variable copies generated by all subsequent independent task nodes during the execution process. In the case of too many variables or independent task nodes, it will increase the consumption of system resources and seriously affect the spark task scheduling performance;
[0083] (9) The server evenly distributes action operators to the data partitions in the i-th RDD after reaggregation and partitioning, so as to obtain multiple independent task nodes corresponding to the i-th RDD that can be executed concurrently;
[0084] (10) The server executes all independent task nodes corresponding to the i-th RDD obtained in step (9) to obtain task results, and updates the status of the cluster manager according to the task running results to obtain an updated cluster manager;
[0085] Specifically, step (10) includes the following sub-steps:
[0086] (10-1) The server mobilizes the cluster manager to allocate resources to each independent task node corresponding to the i-th RDD obtained in step (9);
[0087] Specifically, the resources allocated in this step include the required number of CPU cores, memory, and computing power;
[0088] (10-2) The server stores all data in the independent task nodes corresponding to the i-th RDD after all resources are allocated in the HashMap data structure in the form of key-value pairs;
[0089] Specifically, the HashMap data structure in this step includes an array, a linked list, and a red-black tree.
[0090] (10-3) The server obtains the data in the independent task node corresponding to the i-th RDD from the HashMap data structure, and submits the data to all independent task nodes corresponding to the i-th RDD that have allocated resources for real-time processing to obtain the running results;
[0091] (10-4) The server updates the status of the cluster manager according to the operation result obtained in step (10-3) to obtain an updated cluster manager;
[0092] Specifically, in this step, the status of the cluster manager is updated, specifically, the running status of all independent task nodes in the cluster manager is updated according to the completion degree of the running results. The running status is mainly divided into the running completion status, the running status, the running failure status, or the task node is forced to close the status;
[0093] (11) The server performs resource information anomaly detection on the cluster manager updated in step (10) to determine whether there is an abnormal alarm. If so, the process ends, otherwise it goes to step (12);
[0094] Specifically, the resource information anomaly detection in step (11) mainly determines the status of all independent task nodes of the cluster manager. If there are still independent task nodes in the running state, the running failure state, or the forced shutdown state, an abnormal alarm is issued.
[0095] (12) The server sets the counter i=i+1 and returns to step (5).
[0096] Performance Testing
[0097] The processing efficiency of the Spark task scheduling method based on heterogeneous resources provided by equal amounts of Example 1 and Comparative Examples 1 to 3 is as follows: Comparative Example 1 is substantially the same as the method of Example 1 provided, with the main difference being that step (5) determines whether the scheduled task can be executed; Comparative Example 2 is substantially the same as the method of Example 1 provided, with the main difference being that no abnormal status alarm is set in step (5); Comparative Example 3 is substantially the same as the method of Example 1 provided, with the main difference being that the resource cache data is not deleted in step (4).
[0098] Processing efficiency Example 1 99% Comparative Example 1 89% Comparative Example 2 93% Comparative Example 3 78%
[0099] By analyzing the relevant data in the above tables by the control variable method, it can be seen that the embodiment has a certain improvement in the efficiency of Spark task scheduling. In Example 1, by judging whether the scheduling task is executed correctly, it is possible to conduct a certain analysis on whether cache data errors occur in the RDD persistence process in each scheduling stage and the node operation process after shuffle, thereby avoiding a large amount of resource consumption to improve the operation efficiency; Example 2 shows that the abnormal state alarm can interrupt the scheduling stage tasks that have been running at any time, so that the resources of the task nodes that execute the abnormal state can be reallocated to other nodes to submit the efficiency of Spark task scheduling; Example 3 shows that the resource cache data is deleted, and the RDD data is persisted to the java object and stored in the JVM, and the real-time data processing is realized through HashMap after the RDD data is regularized, which can greatly improve the efficiency of Spark task scheduling.
[0100] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A Spark task scheduling method based on heterogeneous resources, characterized in that: The following steps are involved: (1) The server obtains the resource information required by the system based on Linux commands and submits it to the resource manager to create a cluster manager and complete initialization; (2) The server receives the task job submitted by the client and submits the task job to the cluster manager created in step (1) to convert the task job into multiple resilient distributed datasets RDDs, and parses all the obtained RDDs to obtain an RDD graph that represents the dependency relationship between multiple RDDs; RDD is composed of a series of data partitions, and the dependency relationship between each RDD is mainly wide dependency or narrow dependency, and the RDD can be recalculated based on the previous RDD to achieve the conversion of wide and narrow dependencies; in the RDD graph, if there is a one-to-one mapping relationship between the data partitions in the RDD on one side and the data partitions in the RDD on the other side, then the dependency relationship corresponding to the RDD on this side is narrow dependency; if there is a one-to-many mapping relationship between the data partitions in the RDD on one side and the data partitions in the RDD on the other side, then the dependency relationship corresponding to the RDD on this side is wide dependency; (3) The server generates a directed acyclic graph (DAG) for the scheduling phase based on the dependency relationships between all RDDs in the RDD graph obtained in step (2); (4) The server divides all RDDs in the DAG graph into the first task stage, the second task stage, and the third task stage according to their corresponding dependencies. If the dependency relationship corresponding to a certain RDD in the DAG graph is a narrow dependency, the RDD belongs to the first task scheduling stage. If the dependency relationship corresponding to a certain RDD in the DAG graph is a wide dependency, the RDD belongs to the second task stage. If the dependency relationship corresponding to a certain RDD in the DAG graph changes from a wide dependency to a narrow dependency, or from a narrow dependency to a wide dependency, the RDD belongs to the third task stage. (5) The server sets counter i = 1; (6) The server determines whether i is greater than the total number of RDDs in the DAG graph in step (4). If so, the process ends; otherwise, it goes to step (7); (7) The server determines whether the i-th RDD in the DAG graph belongs to the first task scheduling stage, the second task scheduling stage, or the third task scheduling stage. If it belongs to the first task scheduling stage, it proceeds to step (9); if it belongs to the second task scheduling stage or the third task scheduling stage, it proceeds to step (8); (8) The server re-aggregates and partitions the data in the data partition of the i-th RDD in the DAG graph to obtain the re-aggregated and partitioned data partition in the i-th RDD, and proceeds to step (9); step (8) includes the following sub-steps: (8-1) For each data in the data partition of the i-th RDD in the DAG graph, the server performs segmentation processing on each field in the data to obtain segmented data, and stores the data in the JAVA virtual machine JVM memory; (8-2) The server obtains the data stored in the JVM from the JVM, and processes the data through the Pipeline to obtain the data corresponding to the data partition in the RDD, and then transmits the data to the RDD data partition in sequence; (8-3) The server performs variable vectorization, broadcast variable, and deserialization on the data transmitted to the data partition to obtain the re-aggregated and divided data partition in the i-th RDD; (9) The server evenly distributes action operators to the data partitions in the i-th RDD after reaggregation and partitioning to obtain multiple independent task nodes corresponding to the i-th RDD that can be executed concurrently; (10) The server executes all independent task nodes corresponding to the i-th RDD obtained in step (9) to obtain the task results, and updates the status of the cluster manager according to the task running results to obtain an updated cluster manager; (11) The server performs resource information anomaly detection on the cluster manager updated in step (10) to determine whether there is an abnormal alarm. If so, the process ends, otherwise it goes to step (12); (12) The server sets counter i = i + 1 and returns to step (5).
2. The Spark task scheduling method based on heterogeneous resources according to claim 1 is characterized in that: Resource information mainly includes but is not limited to the number and type of CPU cores, memory information, and disk I / O information.
3. The Spark task scheduling method based on heterogeneous resources according to claim 2 is characterized in that: Step (10) includes the following sub-steps: (10-1) The server mobilizes the cluster manager to allocate resources to each independent task node corresponding to the i-th RDD obtained in step (9); (10-2) The server stores all data in the independent task nodes corresponding to the i-th RDD after all resources are allocated in the HashMap data structure in the form of key-value pairs; (10-3) The server obtains the data in the independent task node corresponding to the i-th RDD from the HashMap data structure, and submits the data to all independent task nodes corresponding to the i-th RDD that have allocated resources for real-time processing to obtain the running results; (10-4) The server updates the status of the cluster manager according to the operation result obtained in step (10-3) to obtain an updated cluster manager.
4. The Spark task scheduling method based on heterogeneous resources according to claim 3 is characterized in that: In step (10-4), the status of the cluster manager is updated. Specifically, the running status of all independent task nodes in the cluster manager is updated according to the completion degree of the running results. The running status is mainly divided into the running completion status, the running status, the running failure status, or the task node is forced to be closed.
5. The Spark task scheduling method based on heterogeneous resources according to claim 4 is characterized in that: The resource information anomaly detection in step (11) mainly determines the status of all independent task nodes of the cluster manager. If there are still independent task nodes in the running state, the running failure state, or the forced shutdown state, an abnormal alarm is issued.
6. A Spark task scheduling system based on heterogeneous resources, which is set in the server, characterized in that: The Spark task scheduling system includes: The first module is used to obtain the resource information required by the system based on Linux commands and submit it to the resource manager to create a cluster manager and complete initialization; The second module is used to receive the task job submitted by the client and submit the task job to the cluster manager created by the first module to convert the task job into multiple elastic distributed data sets RDD, and parse all the obtained RDDs to obtain an RDD graph that represents the dependency relationship between multiple RDDs; RDD is composed of a series of data partitions, and the dependency relationship between each RDD is mainly wide dependency or narrow dependency, and the RDD can be recalculated based on the previous RDD to achieve the conversion of wide and narrow dependencies; in the RDD graph, if there is a one-to-one mapping relationship between the data partitions in the RDD on one side and the data partitions in the RDD on the other side, then the dependency relationship corresponding to the RDD on this side is narrow dependency; if there is a one-to-many mapping relationship between the data partitions in the RDD on one side and the data partitions in the RDD on the other side, then the dependency relationship corresponding to the RDD on this side is wide dependency; The third module is used to generate a directed acyclic graph DAG of the scheduling stage according to the dependency relationship between all RDDs in the RDD graph obtained by the second module; The fourth module is used to divide all RDDs in the DAG graph into the first task stage, the second task stage and the third task stage according to their corresponding dependency relationships; if the dependency relationship corresponding to a certain RDD in the DAG graph is a narrow dependency, the RDD belongs to the first task scheduling stage; if the dependency relationship corresponding to a certain RDD in the DAG graph is a wide dependency, the RDD belongs to the second task stage; if the dependency relationship corresponding to a certain RDD in the DAG graph changes from a wide dependency to a narrow dependency, or from a narrow dependency to a wide dependency, the RDD belongs to the third task stage; The fifth module is used to set the counter i = 1; The sixth module is used to determine whether i is greater than the total number of RDDs in the DAG graph in the fourth module. If so, the process ends, otherwise it enters the seventh module; The seventh module is used to determine whether the i-th RDD in the DAG graph belongs to the first task scheduling stage, the second task scheduling stage or the third task scheduling stage. If it belongs to the first task scheduling stage, it will be transferred to the ninth module; if it belongs to the second task scheduling stage or the third task scheduling stage, it will be transferred to the eighth module; The eighth module is used to re-aggregate and partition the data in the data partition of the i-th RDD in the DAG graph to obtain the re-aggregated and partitioned data partition in the i-th RDD, and enter the ninth module; the eighth module includes: The first submodule is used for the server to perform segmentation processing on each field in each data in the data partition of the i-th RDD in the DAG graph to obtain segmented data, and store the data in the JAVA virtual machine JVM memory; The second submodule is used for the server to obtain the data stored in the JVM from the JVM, and to calculate and process the data through the Pipeline to obtain the data corresponding to the data partition in the RDD, and to sequentially transmit the data to the RDD data partition; The third submodule is used for the server to perform variable vectorization, broadcast variable and deserialization processing on the data transmitted to the data partition in order to obtain the re-aggregated and divided data partition in the i-th RDD; The ninth module is used to evenly distribute action operators to the data partitions after re-aggregation and partitioning in the i-th RDD, so as to obtain multiple independent task nodes corresponding to the i-th RDD and capable of concurrent execution; The tenth module is used to execute all independent task nodes corresponding to the i-th RDD obtained in the ninth module to obtain task results, and update the status of the cluster manager according to the task running results to obtain an updated cluster manager; The eleventh module is used to perform resource information anomaly detection on the cluster manager updated by the tenth module to determine whether there is an abnormal alarm. If so, the process ends, otherwise, the twelfth module is entered; The twelfth module is used to set the counter i = i + 1 and return to the fifth module.
