A distributed data processing method
By building an independent Python execution environment on the client and dynamically adjusting parameters, the problem of Python environment establishment and monitoring is solved, and the stability and data processing efficiency of the Python execution environment are improved.
Patent Information
- Application Number
- CN202410866198.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-07-01
AI Technical Summary
Existing technologies fail to effectively establish and monitor the Python environment, causing the stability and data processing efficiency of the Python environment to be affected.
Build a Python execution environment independent of the Spark cluster on the client, parse dependency parameters through Spark Driver and automatically download and deploy dependent libraries, dynamically update the Python environment, and adjust the number of nodes and data transmission compression ratio based on the number of characters transmitted and the character ratio to optimize execution. environment.
Significantly improves the flexibility and stability of the Python execution environment, improves data processing efficiency, adapts to various scenarios and optimizes task execution performance.
Smart Images

Figure CN118394454B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a distributed data processing method. Background Art
[0002] With the help of PySpark technology, Spark developers can use Python in Spark tasks, thereby making full use of Python's ecosystem in scientific computing and machine learning, greatly expanding Spark's computing capabilities. However, PySpark often requires the deployment of the Python environment and the Python libraries used in the development process on each node in the Spark cluster. There are two common solutions:
[0003] One is to manually deploy it in all Spark clusters. However, as the cluster size increases, the deployment and operation and maintenance workload will increase significantly. At the same time, it cannot meet the dynamic needs of developers for Python environment and Python libraries. Developers may need to introduce new Python libraries at any time.
[0004] The second is to package and carry all Python environments and dependent libraries when submitting Spark tasks. Although this solves the problem of dynamic demand, each Spark task consumes a lot of network traffic, and the Python environment needs to be rebuilt before each task is executed.
[0005] Chinese Patent Publication No.: CN114996148A, discloses an automated testing method, device, computer equipment and storage medium based on pyspark, including: regularly obtaining the missing monitoring task in the task scheduling platform; when running the missing monitoring task, obtaining the pyspark logic written in the preset editing platform, executing the automated testing scripts corresponding to multiple data clusters respectively through the pyspark logic, and monitoring the monitoring data in each data cluster through the automated testing script to obtain the monitoring results; displaying the monitoring results to the preset receiving platform through the task process display platform; it can be seen that the above technical solution has the following problems: it does not consider the establishment of the Python environment, and does not consider the monitoring of the specific operation status of the data after the establishment of the Python environment is completed, which affects the stability of the Python environment and thus affects the data processing efficiency. Summary of the invention
[0006] To this end, the present invention provides a distributed data processing method to overcome the problem that the prior art does not consider the establishment of a Python environment, and does not consider monitoring the specific operating conditions of the data after the establishment of the Python environment, which affects the stability of the Python environment and further affects the data processing efficiency.
[0007] To achieve the above object, the present invention provides a distributed data processing method, comprising:
[0008] When submitting a PySpark application on the client, a Python execution environment independent of the Spark cluster is built. The Python execution environment includes several nodes, each of which includes an independent Python dependency module and Python execution module. A single node includes several Spark Executors.
[0009] Spark Driver parses the Python dependency parameters of the PySpark application and sends the dependency parameters to each node of the Python execution environment through the Python building module;
[0010] The Python dependency module checks the local Python environment. If the dependency library already exists, it directly returns a success message to the Spark Driver. If the dependency library does not exist, it automatically downloads and deploys the dependency library through the Python tool, and returns a success message to the Spark Driver after completion.
[0011] The Spark Driver dispatches the PySpark task to the Spark Executor for execution;
[0012] The Spark Executor sends the pyspark.worker build command to each node through the pyspark.remote.daemon module;
[0013] The Spark Executor performs task and data interaction with the pyspark.worker through the pyspark.remote.daemon module, and the Spark Executor completes the computing task and returns the result;
[0014] The Spark Executor returns the result to the Spark Driver, and the Spark Driver returns the result to the client;
[0015] Determine a handling method for the fact that the construction parameters of the execution environment do not meet the preset standards according to the number of transmission characters received by the Spark Driver within the preset analysis time, or determine whether the construction parameters of the execution environment meet the preset standards according to the ratio of the number of characters commented in the PySpark application to the total number of characters in the file;
[0016] According to the transmission difference between the second preset transmission character number and the transmission character number, determining to adjust the number of nodes to a corresponding value, adjusting the number of Spark Executors corresponding to each node to a corresponding value, or adjusting the compression ratio of data transmission to a corresponding value;
[0017] When all computing tasks are completed, the Spark Executor destroys the local pyspark.remote.daemon and remote pyspark.worker.
[0018] Further, the number of characters received by the Spark Driver within the obtained preset analysis time is recorded as the number of transmitted characters, and whether the construction parameters of the execution environment meet the preset standards is determined according to the number of transmitted characters;
[0019] If the number of transmitted characters is less than or equal to the first preset number of transmitted characters, determining a processing method for the construction parameters of the execution environment not meeting the preset standard according to the difference between the second preset number of transmitted characters and the number of transmitted characters;
[0020] If the number of transmitted characters is less than or equal to the second preset number of transmitted characters and greater than the first preset number of transmitted characters, whether the construction parameters of the execution environment meet the preset standards is re-determined based on the ratio of the number of annotated characters in the PySpark application to the total number of characters in the file.
[0021] Further, the ratio of the number of characters in the comments of the obtained PySpark application to the total number of characters in the file is recorded as the character ratio, and whether the construction parameters of the execution environment meet the preset standards is re-determined according to the character ratio;
[0022] adjusting the first preset number of transmitted characters and the second preset number of transmitted characters to corresponding values according to the difference between the preset character ratio and the character ratio;
[0023] A processing method for the construction parameter of the execution environment not meeting the preset standard is determined according to the difference between the second preset transmission character number and the transmission character number.
[0024] Further, the difference between the second preset number of transmission characters and the number of transmission characters is recorded as a transmission difference, and a processing method for the construction parameters of the execution environment not meeting the preset standard is determined according to the transmission difference;
[0025] Determine the processing method for each node according to the number of characters output by each node within the preset analysis time;
[0026] Re-determine the processing method for the build parameters of the execution environment that do not meet the preset standards according to the number of each character within the preset historical time length;
[0027] Adjust the number of nodes to the corresponding value based on the total data volume of the PySpark application.
[0028] Furthermore, the variance of the number of characters output by each node within the calculated preset analysis time is recorded as the character variance, and the processing method for each node is determined according to the character variance;
[0029] According to the difference between the preset character variance and the character variance, the number of Spark Executors corresponding to each node is adjusted to the corresponding value;
[0030] According to the number of characters output by each node, the number of Spark Executors of the node with the smallest number of characters output is adjusted to a corresponding value.
[0031] Further, the number of transmitted characters corresponding to each preset analysis duration within the preset historical duration is obtained, and the variance of each calculated number of transmitted characters is recorded as the transmission variance, and the processing method for the construction parameters of the execution environment not meeting the preset standard is re-determined according to the transmission variance;
[0032] Adjust the number of nodes to the corresponding value according to the total data volume of the PySpark application;
[0033] The compression ratio of the data transmission is adjusted to a corresponding value according to the difference between the transmission variance and the preset transmission variance.
[0034] Furthermore, based on the difference between the preset character ratio and the character ratio, a plurality of standard adjustment methods for the first preset number of transmitted characters and the second preset number of transmitted characters are provided, and the adjustment ranges of the first preset number of transmitted characters and the second preset number of transmitted characters in each standard adjustment method are different;
[0035] Based on the adjusted first preset number of transmission characters and the second preset number of transmission characters, whether the construction parameters of the execution environment meet the preset standards is re-determined; if the number of transmission characters is still less than or equal to the adjusted second preset number of transmission characters and greater than the adjusted first preset number of transmission characters, the processing method for the construction parameters of the execution environment not meeting the preset standards is determined according to the difference between the adjusted second preset number of transmission characters and the number of transmission characters.
[0036] Furthermore, based on the difference between the preset character variance and the character variance, several process adjustment methods for the number of Spark Executors corresponding to each node are provided, and the adjustment range of each process adjustment method for the number of Spark Executors corresponding to each node is different.
[0037] Furthermore, the node with the smallest number of characters output by each node is recorded as a calibration node, the average value of the number of characters output by each node is calculated, and the difference between the calculated average value and the number of characters corresponding to the calibration node is recorded as the calibration difference, and based on the calibration difference, several calibration adjustment methods for the number of Spark Executors of the calibration nodes are provided, and the adjustment range of the number of Spark Executors of the calibration nodes by each calibration adjustment method is different.
[0038] Furthermore, based on the total data volume of the PySpark application, several node adjustment methods for the number of nodes are provided, and the adjustment range of the number of nodes in each node adjustment method is different;
[0039] Based on the difference between the transmission variance and the preset transmission variance, a plurality of compression adjustment modes for the compression ratio of data transmission are provided, and the adjustment range of the compression ratio of data transmission in each compression adjustment mode is different.
[0040] Compared with the prior art, the beneficial effect of the present invention lies in that, by building an independent Python execution environment for PySpark and extending the Spark Driver and Spark Executor functions, the present invention supports dynamic updating of the Python execution environment, significantly improves the flexibility of Python execution environment construction, and ensures efficient and dynamic PySpark execution capabilities.
[0041] Furthermore, a Python execution environment is established, and after the establishment of the Python execution environment is completed, the specific operation status of the data is monitored, and the construction parameters of the execution environment are determined according to the Spark Driver data reception status; when the number of transmitted characters is less than or equal to the second preset number of transmitted characters and greater than the first preset number of transmitted characters, the analysis module cannot only analyze the Spark data within the preset analysis time. The number of characters received by the Driver determines whether the construction parameters of the execution environment meet the preset standards. In this case, the ratio of the number of characters commented in the PySpark application to the total number of characters in the file is comprehensively considered to redetermine whether the construction parameters of the execution environment meet the preset standards; when the character ratio is less than or equal to the preset character ratio, the proportion of comments is small, and the transmitted data includes a small number of comments. The Python execution module needs to process a large number of programs. In this case, the Python execution module's slow processing of data meets the preset standard. At this time, the first preset number of transmitted characters and the second preset number of transmitted characters are adjusted to ensure that the determination of the execution environment can be applied to a variety of scenarios; when the character ratio is greater than the preset character ratio, the transmitted data includes a large number of comments. In this case, the amount of programs that the Python execution module needs to process is small. At this time, if the Python execution module processes the data slowly, the analysis module determines that the construction parameters of the execution environment do not meet the preset standards, and specifically determines the processing method for those that do not meet the preset standards; while improving the stability of the Python execution environment, the data processing efficiency is thereby improved.
[0042] Furthermore, a Python execution environment is established, and after the establishment of the Python execution environment is completed, the specific operation status of the data is monitored, and the construction parameters of the execution environment are determined according to the Spark Driver data reception status; when the number of transmitted characters is less than or equal to the second preset number of transmitted characters and greater than the first preset number of transmitted characters, the analysis module cannot only analyze the Spark data within the preset analysis time. The number of characters received by the Driver determines whether the construction parameters of the execution environment meet the preset standards. In this case, the ratio of the number of characters commented in the PySpark application to the total number of characters in the file is comprehensively considered to redetermine whether the construction parameters of the execution environment meet the preset standards; when the character ratio is less than or equal to the preset character ratio, the proportion of comments is small, and the transmitted data includes a small number of comments. The Python execution module needs to process a large number of programs. In this case, the Python execution module's slow processing of data meets the preset standard. At this time, the first preset number of transmitted characters and the second preset number of transmitted characters are adjusted to ensure that the determination of the execution environment can be applied to a variety of scenarios; when the character ratio is greater than the preset character ratio, the transmitted data includes a large number of comments. In this case, the amount of programs that the Python execution module needs to process is small. At this time, if the Python execution module processes the data slowly, the analysis module determines that the construction parameters of the execution environment do not meet the preset standards, and specifically determines the processing method for those that do not meet the preset standards; while improving the stability of the Python execution environment, the data processing efficiency is thereby improved.
[0043] Furthermore, a processing method for the execution environment construction parameters not meeting the preset standards is determined based on the difference between the second preset number of transmitted characters and the number of transmitted characters. When the transmission difference is less than or equal to the first preset transmission difference, in this case, the data transmission is only slightly slow. At this time, the task execution performance is unstable due to the low number of Spark Executors, and the cluster resources cannot be fully utilized for task execution. In this case, the analysis module obtains the specific transmission status of each node. When the character variance is less than or equal to the preset character variance, the data processing of each node is slow, and the difference in processing capacity between the nodes is small. At this time, a unified adjustment is performed on each node, and the Spark corresponding to each node is adjusted according to the difference between the preset character variance and the character variance. The number of executors is adjusted; when the number of transmitted characters is low and the task execution speed of each node is uniformly slow, the difference between the preset character variance and the character variance is inversely proportional to the adjustment range of the number of SparkExecutors corresponding to each node; when the character variance is greater than the preset character variance, the task processing speed of each node is quite different. In this case, only a small number of nodes have low task processing speed. At this time, only the node with the smallest number of characters output by each node is processed. The construction parameters of the execution environment are specifically determined according to the specific actual operating conditions, which improves the flexibility of Python execution environment construction and thus improves data processing efficiency.
[0044] Furthermore, when the transmission difference is less than or equal to the second preset transmission difference and greater than the first preset transmission difference, the analysis module comprehensively considers the stability of each data transmission in the historical transmission situation, and obtains the variance of each number of transmission characters corresponding to each preset analysis time within the preset historical time. When the transmission variance is less than or equal to the preset transmission variance, the number of characters transmitted within each preset analysis time is relatively stable. In this case, the task is queued for execution due to the low number of nodes, which causes task congestion and affects the overall task execution efficiency and response time. At this time, the number of nodes is adjusted; when the transmission variance is greater than the preset transmission variance, the data transmission is unstable. Due to network problems, the number of characters transmitted within the current preset analysis time is too low. At this time, the compression ratio of the transmitted data is adjusted to improve the data transmission efficiency, thereby improving the data processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A flowchart of the steps of the distributed data processing method according to an embodiment of the present invention;
[0046] Figure 2 A module block diagram of the Python execution environment of an embodiment of the present invention;
[0047] Figure 3A flowchart of an embodiment of the present invention for determining whether construction parameters of an execution environment meet preset standards according to the number of transmitted characters;
[0048] Figure 4 The present invention is a flowchart of re-determining whether the construction parameters of the execution environment meet the preset standards according to the character ratio according to the embodiment of the present invention. DETAILED DESCRIPTION
[0049] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0050] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0051] It should be noted that, in the description of the present invention, terms such as "up", "down", "left", "right", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the drawings. This is merely for the convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.
[0052] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0053] See also Figure 1 , Figure 2 , Figure 3 as well as Figure 4 As shown, they are respectively a flow chart of steps of a distributed data processing method according to an embodiment of the present invention, a module block diagram of a Python execution environment, a flow chart for determining whether construction parameters of an execution environment meet preset standards according to the number of transmitted characters, and a flow chart for re-determining whether construction parameters of an execution environment meet preset standards according to a character ratio; a distributed data processing method according to an embodiment of the present invention comprises:
[0054] S1, when the client submits a PySpark application, a Python execution environment independent of the Spark cluster is built. The Python execution environment includes several nodes. The number of nodes is preliminarily determined based on the application memory. Each node includes an independent Python dependency module to receive the Python deployment command of the Spark Driver. Each node includes an independent Python execution module to receive the Python script of the Spark Executor. The Python execution module builds the pyspark.worker subprocess, executes the Python script and returns the execution result. A single node includes several Spark Executors;
[0055] S2, Spark Driver parses the Python dependency parameters of the PySpark application and sends the dependency parameters to each node of the Python execution environment through the Python building module;
[0056] S3, after each node of the Python execution environment receives the dependency parameters, the Python dependency module checks the local Python environment. If the dependency library already exists, it directly returns success to the Spark Driver. If the dependency library does not exist, the Python tool automatically downloads and deploys the dependency library, and returns success information to the Spark Driver after completion;
[0057] S4: After receiving the information that the dependent library is successfully deployed, Spark Driver executes the normal task scheduling logic and schedules the PySpark task to Spark Executor for execution;
[0058] S5, after receiving the PySpark task, Spark Executor remotely sends the pyspark.worker build command to each node of the Python execution environment through the pyspark.remote.daemon module. After receiving the pyspark.worker build command, the node of the Python execution environment builds pyspark.worker locally.
[0059] S6, Spark Executor interacts with remote pyspark.worker through the local pyspark.remote.daemon module to perform tasks and data. Spark Executor completes the computing task and returns the result.
[0060] S7, Spark Executor returns the result to Spark Driver, and Spark Driver returns the result to the client;
[0061] S8, determining a processing method for the construction parameters of the execution environment not meeting the preset standard according to the number of transmission characters received by the Spark Driver within the preset analysis time, or determining whether the construction parameters of the execution environment meet the preset standard according to the ratio of the number of annotated characters in the PySpark application to the total number of characters in the file;
[0062] S9, according to the transmission difference between the second preset transmission character number and the transmission character number, determine to adjust the number of nodes to a corresponding value, adjust the number of Spark Executors corresponding to each node to a corresponding value, or adjust the compression ratio of data transmission to a corresponding value;
[0063] S10, when all computing tasks are completed, Spark Executor destroys the local pyspark.remote.daemon and remote pyspark.worker.
[0064] It should be pointed out that the data in this embodiment are obtained by comprehensive analysis and evaluation of the historical test data and the corresponding historical test results three months before the test. The method of the present invention can determine the single parameter by selecting the highest value as the preset standard parameter according to the data distribution, using weighted summation to use the obtained value as the preset standard parameter or other selection methods, as long as the method of the present invention can clearly define the different specific situations in the single determination process through the obtained value.
[0065] Specifically, the present invention does not limit how to preliminarily determine the number of nodes based on the application memory. It only needs to be able to determine the number of nodes. This is a prior art and will not be described in detail here.
[0066] Specifically, Spark Driver extends the functions as follows: Spark Driver extends the Python execution environment to set the Python environment information required for PySpark execution; Spark Driver can increase the number of Python dependency modules to dynamically set the required Python environment and Python libraries; Spark Driver can increase the number of Python build modules, which are responsible for sending the Python environment and Python libraries configured by the client to the Python dependency module to deploy Python dependencies.
[0067] Spark Executor extended functions: Spark Executor can add the pyspark.remote.daemon module, which adds the ability to remotely execute Python based on the original pyspark.daemon. When Spark Executor executes PySpark tasks, it sends them to the Python execution module through the pyspark.remote.daemon module, builds the pyspark.worker subprocess, and exchanges execution scripts, data, and results through the network.
[0068] Python Environment (Python Env): Spark can use PySpark, which is Spark's Python API. The Python environment refers to the Python interpreter and related environment required to execute Python code in a Spark cluster. On each node, the correct Python environment must be configured to be able to execute PySpark applications.
[0069] Python Library (Lib): PySpark applications usually reference various Python libraries, such as NumPy, Pandas, Matplotlib, etc. These libraries are usually used for tasks such as data processing, analysis, and visualization. In the node, you need to ensure that these Python libraries are installed and compatible with the PySpark application.
[0070] Python environment and Python library are closely related to Python dependencies. Python environment refers to the Python interpreter and related environment configuration, which is the basis for the execution of PySpark applications. Python library refers to the various Python libraries required by PySpark applications, which are usually installed and managed through tools such as pip or conda. Python dependencies refer to the Python libraries and their versions that PySpark applications depend on, as well as the configuration of the Python environment.
[0071] Python Env Node refers to the node in the Spark cluster. Each node needs to be configured with the correct Python environment and Python library to be able to execute PySpark applications. Therefore, the correct configuration of the Python environment and Python library in the node is crucial for the execution of PySpark applications.
[0072] In Spark, Executor is a worker process running in the cluster, which is responsible for executing tasks in Spark applications. Task is a work unit in Executor, which is used to perform specific computing operations.
[0073] When a Spark application is submitted to a cluster for execution, it is divided into multiple stages, and each stage is divided into multiple tasks. These tasks are assigned to Executor for execution. Each task processes a part of the data, such as converting the RDD or calculating the result.
[0074] Specifically, the analysis module records the number of characters received by the Spark Driver within the preset analysis time as the number of transmitted characters, and determines whether the construction parameters of the execution environment meet the preset standards according to the number of transmitted characters;
[0075] If the number of transmitted characters is less than or equal to the first preset number of transmitted characters, the analysis module determines that the construction parameters of the execution environment do not meet the preset standard, and determines a processing method for the construction parameters of the execution environment not meeting the preset standard according to the difference between the second preset number of transmitted characters and the number of transmitted characters;
[0076] If the number of transmitted characters is less than or equal to the second preset number of transmitted characters and greater than the first preset number of transmitted characters, the analysis module cannot determine that the construction parameters of the execution environment do not meet the preset standards, and re-determines whether the construction parameters of the execution environment meet the preset standards based on the ratio of the number of characters annotated in the PySpark application to the total number of characters in the file; the first preset number of transmitted characters is less than the second preset number of transmitted characters;
[0077] If the number of transmitted characters is greater than the second preset number of transmitted characters, the analysis module determines that the construction parameters of the execution environment meet the preset standards, and controls the Python execution environment to continue processing the PySpark application.
[0078] Set the preset analysis time to 60s, the first preset number of transmitted characters to 5746, and the second preset number of transmitted characters to 12831.
[0079] Specifically, the analysis module records the ratio of the number of characters in the annotations in the acquired PySpark application to the total number of characters in the file as the character ratio, and re-determines whether the construction parameters of the execution environment meet the preset standards according to the character ratio;
[0080] If the character ratio is less than or equal to a preset character ratio, the analysis module determines that the construction parameters of the execution environment meet the preset standard, and adjusts the first preset number of transmitted characters and the second preset number of transmitted characters to corresponding values according to the difference between the preset character ratio and the character ratio;
[0081] If the character ratio is greater than the preset character ratio, the analysis module determines that the construction parameters of the execution environment do not meet the preset standards, and determines a processing method for the construction parameters of the execution environment not meeting the preset standards according to the difference between the second preset transmission character number and the transmission character number.
[0082] The default character ratio is set to 0.32.
[0083] Establish the Python execution environment, monitor the specific operation status of the data after the establishment of the Python execution environment, and determine the construction parameters of the execution environment according to the Spark Driver data reception status; when the number of transmitted characters is less than or equal to the second preset number of transmitted characters and greater than the first preset number of transmitted characters, the analysis module cannot only analyze the Spark data within the preset analysis time. The number of characters received by the Driver determines whether the construction parameters of the execution environment meet the preset standards. In this case, the ratio of the number of characters commented in the PySpark application to the total number of characters in the file is comprehensively considered to redetermine whether the construction parameters of the execution environment meet the preset standards; when the character ratio is less than or equal to the preset character ratio, the proportion of comments is small, and the transmitted data includes a small number of comments. The Python execution module needs to process a large number of programs. In this case, the Python execution module's slow processing of data meets the preset standard. At this time, the first preset number of transmitted characters and the second preset number of transmitted characters are adjusted to ensure that the determination of the execution environment can be applied to a variety of scenarios; when the character ratio is greater than the preset character ratio, the transmitted data includes a large number of comments. In this case, the amount of programs that the Python execution module needs to process is small. At this time, if the Python execution module processes the data slowly, the analysis module determines that the construction parameters of the execution environment do not meet the preset standards, and specifically determines the processing method for those that do not meet the preset standards; while improving the stability of the Python execution environment, the data processing efficiency is thereby improved.
[0084] Specifically, the analysis module records the difference between the second preset number of transmission characters and the number of transmission characters as a transmission difference, and determines, according to the transmission difference, a processing method for the construction parameters of the execution environment not meeting the preset standard;
[0085] If the transmission difference is less than or equal to the first preset transmission difference, the analysis module determines a processing method for each node according to the number of characters output by each node within a preset analysis time;
[0086] If the transmission difference is less than or equal to the second preset transmission difference and greater than the first preset transmission difference, the analysis module re-determines the processing method for the construction parameters of the execution environment not meeting the preset standard according to the number of each character within the preset historical time length;
[0087] If the transmission difference is greater than the second preset transmission difference, the analysis module adjusts the number of nodes to a corresponding value according to the total data volume of the PySpark application.
[0088] It is set that the first preset transmission difference is 5604 and the second preset transmission difference is 7917.
[0089] Specifically, the analysis module records the variance of the number of characters output by each node within the preset analysis time as the character variance, and determines the processing method for each node according to the character variance;
[0090] If the character variance is less than or equal to the preset character variance, the analysis module adjusts the number of Spark Executors corresponding to each node to a corresponding value according to the difference between the preset character variance and the character variance;
[0091] If the character variance is greater than the preset character variance, the analysis module adjusts the number of Spark Executors of the node with the smallest number of characters output to a corresponding value according to the number of characters output by each node.
[0092] Set the default character variance to 3.63×10 5 .
[0093] According to the difference between the number of transmitted characters and the first preset number of transmitted characters, the processing method for the construction parameters of the execution environment that do not meet the preset standards is determined. When the transmission difference is less than or equal to the first preset transmission difference, in this case, the data transmission is only slightly slow. At this time, the task execution performance is unstable due to the low number of Spark Executors, and the cluster resources cannot be fully utilized for task execution. In this case, the analysis module obtains the specific transmission situation of each node. When the character variance is less than or equal to the preset character variance, each node processes the data slowly, and the difference in processing capacity between the nodes is small. At this time, a unified adjustment is made for each node, and the number of Spark Executors corresponding to each node is adjusted according to the difference between the preset character variance and the character variance; when the number of transmitted characters itself is low and the task execution speed of each node is uniformly slow, the difference between the preset character variance and the character variance and the Spark Executors corresponding to each node are adjusted. The adjustment range of the number of executors is inversely proportional; when the character variance is greater than the preset character variance, the task processing speed of each node is quite different. In this case, only a small number of nodes have low task processing speed. At this time, only the node with the smallest number of characters output by each node will be processed. The construction parameters of the execution environment are determined according to the specific actual operating conditions, which improves the flexibility of Python execution environment construction and thus improves data processing efficiency.
[0094] Specifically, the analysis module obtains the number of transmitted characters corresponding to each preset analysis duration within the preset historical duration, and records the variance of each calculated number of transmitted characters as the transmission variance. The analysis module re-determines the processing method for the construction parameters of the execution environment that do not meet the preset standards according to the transmission variance;
[0095] If the transmission variance is less than or equal to the preset transmission variance, the analysis module adjusts the number of nodes to a corresponding value according to the total data volume of the PySpark application;
[0096] If the transmission variance is greater than the preset transmission variance, the analysis module adjusts the compression ratio of the data transmission to a corresponding value according to the difference between the transmission variance and the preset transmission variance.
[0097] The transmission variance is set to 1.19×10 7 .
[0098] When the transmission difference is less than or equal to the second preset transmission difference and greater than the first preset transmission difference, the analysis module comprehensively considers the stability of each data transmission in the historical transmission situation, obtains the variance of each number of transmission characters corresponding to each preset analysis time within the preset historical time, and when the transmission variance is less than or equal to the preset transmission variance, in this case, the number of characters transmitted within each preset analysis time is relatively stable. In this case, the task is queued for execution due to the low number of nodes, which causes task congestion and affects the overall task execution efficiency and response time. At this time, the number of nodes is adjusted; when the transmission variance is greater than the preset transmission variance, in this case, the data transmission is unstable, and the number of characters transmitted within the current preset analysis time is too low due to network problems. At this time, the compression ratio of the transmitted data is adjusted to improve the data transmission efficiency, thereby improving the data processing efficiency.
[0099] Specifically, the analysis module records the difference between the preset character ratio and the character ratio as the ratio difference, and determines a standard adjustment method for the first preset number of transmitted characters and the second preset number of transmitted characters according to the ratio difference, the standard adjustment method including:
[0100] If the ratio difference is less than or equal to a first preset ratio difference, the analysis module uses a first preset standard adjustment coefficient to adjust the first preset number of transmission characters and the second preset number of transmission characters to corresponding values;
[0101] If the ratio difference is less than or equal to the second preset ratio difference and greater than the first preset ratio difference, the analysis module uses the second preset standard adjustment coefficient to adjust the first preset number of transmission characters and the second preset number of transmission characters to corresponding values; the first preset ratio difference is less than the second preset ratio difference;
[0102] If the ratio difference is greater than the second preset ratio difference, the analysis module uses a third preset standard adjustment coefficient to adjust the first preset number of transmission characters and the second preset number of transmission characters to corresponding values.
[0103] The analysis module re-determines whether the construction parameters of the execution environment meet the preset standards based on the adjusted first preset number of transmission characters and the second preset number of transmission characters; if the number of transmission characters is still less than or equal to the adjusted second preset number of transmission characters and greater than the adjusted first preset number of transmission characters, the analysis module determines that the construction parameters of the execution environment do not meet the preset standards, and determines the handling method for the construction parameters of the execution environment not meeting the preset standards based on the difference between the adjusted second preset number of transmission characters and the number of transmission characters.
[0104] It is set that the first preset ratio difference is 0.13, the second preset ratio difference is 0.2, the first preset standard adjustment coefficient is 0.92, the second preset standard adjustment coefficient is 0.83, and the third preset standard adjustment coefficient is 0.71.
[0105] Specifically, the analysis module records the difference between the preset character variance and the character variance as the variance difference, and determines the process adjustment method for the number of Spark Executors corresponding to each node according to the variance difference. The process adjustment method includes:
[0106] If the variance difference is less than or equal to a first preset variance difference, the analysis module uses a first preset process adjustment coefficient to adjust the number of Spark Executors corresponding to each node to a corresponding value;
[0107] If the variance difference is less than or equal to the second preset variance difference and greater than the first preset variance difference, the analysis module uses the second preset process adjustment coefficient to adjust the number of Spark Executors corresponding to each node to a corresponding value; the first preset variance difference is less than the second preset variance difference;
[0108] If the variance difference is greater than the second preset variance difference, the analysis module uses a third preset process adjustment coefficient to adjust the number of Spark Executors corresponding to each node to a corresponding value.
[0109] The first preset variance difference is set to 1.37×10 5 The second preset variance difference is 2.13×10 5 , the first preset process adjustment coefficient is 1.27, the second preset process adjustment coefficient is 1.19, and the third preset process adjustment coefficient is 1.11.
[0110] Specifically, the analysis module records the node with the smallest number of characters output by each node as a calibration node, calculates the average value of the number of characters output by each node, and records the difference between the calculated average value and the number of characters corresponding to the calibration node as a calibration difference, and determines a calibration adjustment method for the number of Spark Executors for the calibration node according to the calibration difference, and the calibration adjustment method includes:
[0111] If the calibration difference is less than or equal to the first preset calibration difference, the analysis module uses the first preset calibration adjustment coefficient to adjust the number of Spark Executors of the calibration node to a corresponding value;
[0112] If the calibration difference is less than or equal to the second preset calibration difference and greater than the first preset calibration difference, the analysis module uses the second preset calibration adjustment coefficient to adjust the number of Spark Executors of the calibration node to a corresponding value; the first preset calibration difference is less than the second preset calibration difference;
[0113] If the calibration difference is greater than the second preset calibration difference, the analysis module uses a third preset calibration adjustment coefficient to adjust the number of Spark Executors of the calibration node to a corresponding value.
[0114] It is set that the first preset calibration difference is 532, the second preset calibration difference is 1756, the first preset calibration adjustment coefficient is 1.11, the second preset calibration adjustment coefficient is 1.21, and the third preset calibration adjustment coefficient is 1.31.
[0115] Specifically, the analysis module determines a node adjustment method for the number of nodes based on the total data volume of the PySpark application, and the node adjustment method includes:
[0116] If the total data volume is less than or equal to the first preset total data volume, the analysis module uses the first preset node adjustment coefficient to adjust the number of nodes to a corresponding value;
[0117] If the total data volume is less than or equal to the second preset total data volume and greater than the first preset total data volume, the analysis module uses the second preset node adjustment coefficient to adjust the number of nodes to the corresponding value; the first preset total data volume is less than the second preset total data volume;
[0118] If the total data volume is greater than the second preset total data volume, the analysis module uses a third preset node adjustment coefficient to adjust the number of nodes to a corresponding value.
[0119] It is set that the first preset total data volume is 10TB, the second preset total data volume is 25TB, the first preset node adjustment coefficient is 1.112, the second preset node adjustment coefficient is 1.937, and the third preset node adjustment coefficient is 1.265.
[0120] Specifically, the analysis module records the difference between the transmission variance and the preset transmission variance as a character difference, and determines a compression adjustment method for the compression ratio of data transmission according to the character difference, and the compression adjustment method includes:
[0121] If the character difference is less than or equal to the first preset character difference, the analysis module uses the first preset compression adjustment coefficient to adjust the compression ratio for data transmission to a corresponding value;
[0122] If the character difference is less than or equal to the second preset character difference and greater than the first preset character difference, the analysis module uses the second preset compression adjustment coefficient to adjust the compression ratio for data transmission to a corresponding value; the first preset character difference is less than the second preset character difference;
[0123] If the character difference is greater than the second preset character difference, the analysis module uses a third preset compression adjustment coefficient to adjust the compression ratio for data transmission to a corresponding value.
[0124] The first preset character difference is set to 0.179×10 7 , the second preset character difference is 0.591×10 7 The first preset compression adjustment coefficient is 1.12, the second preset compression adjustment coefficient is 1.21, and the third preset compression adjustment coefficient is 1.27. Example 1
[0125] The client submits a PySpark application and preliminarily determines that the number of nodes is 3. Spark Driver parses the Python dependency parameters of the PySpark application and sends the dependency parameters to each node of the Python execution environment through the Python build module. After each node of the Python execution environment receives the dependency parameters, the Python dependency module checks the local Python environment. If the dependency library does not exist, the Python tool automatically downloads and deploys the dependency library, and returns a success message to SparkDriver after completion. After receiving the successful deployment information of the dependency library, Spark Driver executes the normal task scheduling logic and schedules the PySpark task to Spark Executor for execution. After receiving the PySpark task, Spark Executor remotely sends the pyspark.worker build command to each node of the Python execution environment through the pyspark.remote.daemon module. After receiving the pyspark.worker build command, the nodes of the Python execution environment build pyspark.worker locally. Spark Executor interacts with the remote pyspark.worker through the local pyspark.remote.daemon module for tasks and data. Spark Executor completes the computing task and returns the result.
[0126] The analysis module obtains that the number of transmission characters received by the Spark Driver within the preset analysis time of 60s is 7926, the number of transmission characters is less than or equal to the second preset number of transmission characters of 12831 and greater than the first preset number of transmission characters of 5746, the analysis module cannot determine that the construction parameters of the execution environment do not meet the preset standards, and obtains the character ratio of the number of characters commented in the PySpark application to the total number of characters in the file, which is 0.27, and the character ratio of 0.27 is less than or equal to the preset character ratio of 0.32. The analysis module determines that the construction parameters of the execution environment meet the preset standards, and calculates the ratio difference between the preset character ratio of 0.32 and the character ratio of 0.27 as 0.05, and the ratio difference is less than or equal to the first preset ratio difference of 0.13. The analysis module uses the first preset standard adjustment coefficient of 0.92 to adjust the first preset number of transmission characters of 5746 to 5286.32 and the second preset number of transmission characters of 12831 to 11804.52 in sequence;
[0127] The analysis module re-determines whether the construction parameters of the execution environment meet the preset standards based on the adjusted first preset number of transmission characters 5286.32 and the second preset number of transmission characters 11804.52; the number of transmission characters 7926 is still less than or equal to the adjusted second preset number of transmission characters 12831 and greater than the adjusted first preset number of transmission characters 5286.32, and the analysis module determines that the construction parameters of the execution environment do not meet the preset standards. The analysis module calculates that the difference between the adjusted second preset number of transmission characters 11804.52 and the number of transmission characters 7926 is 3878.52, which is less than or equal to the first preset transmission difference 5604. The analysis module calculates that the character variance of each number of characters output by each node within the preset analysis time is 15.52814×105, and the character variance is greater than the preset character variance 3.63×10 5 The analysis module records the node with the smallest number of characters output by each node as the calibration node, and calculates the calibration difference between the average value and the number of characters corresponding to the calibration node, which is 1521. The calibration difference is less than or equal to the second preset calibration difference 1756 and greater than the first preset calibration difference 532. The analysis module uses the second preset calibration adjustment coefficient 1.21 to adjust the number of Spark Executors 2 of the calibration node to the corresponding value 2.42, and rounds up to adjust the number of Spark Executors 2 of the calibration node to the corresponding value 3;
[0128] The analysis module re-obtains the number of transmission characters received by the Spark Driver within the preset analysis time of 60 seconds, which is 12811, which is greater than the second preset number of transmission characters of 12821. The analysis module determines that the construction parameters of the execution environment meet the preset standards, and controls the Python execution environment to continue processing the PySpark application. Example 2
[0129] The client submits a PySpark application and preliminarily determines that the number of nodes is 3;
[0130] The analysis module obtains that the number of transmission characters received by the Spark Driver within the preset analysis time of 60s is 3741, and the number of transmission characters is less than or equal to the first preset number of transmission characters of 5746. The analysis module calculates that the transmission difference between the second preset number of transmission characters of 12831 and the number of transmission characters of 3741 is 9090, which is greater than the second preset transmission difference of 7917. The analysis module obtains that the total data volume of the PySpark application is 17TB, and the total data volume is less than or equal to the second preset total data volume of 25TB and greater than the first preset total data volume of 10TB. The analysis module uses the second preset node adjustment coefficient of 1.937 to adjust the number of nodes 3 by 5.811, rounds up, and adjusts the number of nodes to 6.
[0131] The task is processed using the adjusted Python execution environment, and the number of transmitted characters received by the Spark Driver within the preset analysis time of 60 seconds is re-obtained as 14812, which is greater than the second preset number of transmitted characters of 12831. The analysis module determines that the construction parameters of the execution environment meet the preset standards, and controls the Python execution environment to continue processing the PySpark application. Example 3
[0132] The client submits the PySpark application and preliminarily determines that the number of nodes is 6. The Spark Driver parses the Python dependency parameters of the PySpark application and sends the dependency parameters to each node of the Python execution environment through the Python construction module. After each node of the Python execution environment receives the dependency parameters, the Python dependency module checks the local Python environment. If the dependency library does not exist, the Python tool automatically downloads and deploys the dependency library, and returns a success message to the SparkDriver after completion. After receiving the successful deployment information of the dependency library, the Spark Driver executes the normal task scheduling logic and schedules the PySpark task to the Spark Executor for execution. After receiving the PySpark task, the Spark Executor remotely sends the pyspark.worker construction command to each node of the Python execution environment through the pyspark.remote.daemon module. After receiving the pyspark.worker construction command, the nodes of the Python execution environment locally build pyspark.worker. The Spark Executor interacts with the remote pyspark.worker through the local pyspark.remote.daemon module for tasks and data. The Spark Executor completes the computing task and returns the result.
[0133] The analysis module obtains that the number of transmission characters received by the Spark Driver within the preset analysis time of 60 seconds is 13279, which is greater than the second preset number of transmission characters of 12831. The analysis module determines that the construction parameters of the execution environment meet the preset standards, and controls the Python execution environment to continue processing the PySpark application.
[0134] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
[0135] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A distributed data processing method, characterized in that: include: When submitting a PySpark application on the client, a Python execution environment independent of the Spark cluster is built. The Python execution environment includes several nodes, each of which includes an independent Python dependency module and Python execution module. A single node includes several Spark Executors. Spark Driver parses the Python dependency parameters of the PySpark application and sends the dependency parameters to each node of the Python execution environment through the Python building module; The Python dependency module checks the local Python environment. If the dependency library already exists, it directly returns a success message to the Spark Driver. If the dependency library does not exist, it automatically downloads and deploys the dependency library through the Python tool, and returns a success message to the Spark Driver after completion. The Spark Driver dispatches the PySpark task to the Spark Executor for execution; The Spark Executor sends the pyspark.worker build command to each node through the pyspark.remote.daemon module; The Spark Executor performs task and data interaction with the pyspark.worker through the pyspark.remote.daemon module, and the Spark Executor completes the computing task and returns the result; The Spark Executor returns the result to the Spark Driver, and the Spark Driver returns the result to the client; Determine a handling method for the fact that the construction parameters of the execution environment do not meet the preset standards according to the number of transmission characters received by the Spark Driver within the preset analysis time, or determine whether the construction parameters of the execution environment meet the preset standards according to the ratio of the number of annotated characters in the PySpark application to the total number of characters in the file; According to the transmission difference between the second preset transmission character number and the transmission character number, determining to adjust the number of nodes to a corresponding value, adjusting the number of Spark Executors corresponding to each node to a corresponding value, or adjusting the compression ratio of data transmission to a corresponding value; When all computing tasks are completed, the Spark Executor destroys the local pyspark.remote.daemon and the remote pyspark.worker; The number of characters received by the Spark Driver within the obtained preset analysis time is recorded as the number of transmitted characters, and whether the construction parameters of the execution environment meet the preset standards is determined according to the number of transmitted characters; If the number of transmitted characters is less than or equal to the first preset number of transmitted characters, determining a processing method for the construction parameters of the execution environment not meeting the preset standard according to the difference between the second preset number of transmitted characters and the number of transmitted characters; If the number of transmitted characters is less than or equal to the second preset number of transmitted characters and greater than the first preset number of transmitted characters, re-determine whether the construction parameters of the execution environment meet the preset standards according to the ratio of the number of characters annotated in the PySpark application to the total number of characters in the file; The ratio of the number of characters in the comments of the obtained PySpark application to the total number of characters in the file is recorded as the character ratio, and whether the construction parameters of the execution environment meet the preset standards is re-determined according to the character ratio; adjusting the first preset number of transmitted characters and the second preset number of transmitted characters to corresponding values according to the difference between the preset character ratio and the character ratio; Determine, according to the difference between the second preset number of transmitted characters and the number of transmitted characters, a processing method for the construction parameters of the execution environment not meeting the preset standard; Recording the difference between the second preset number of transmission characters and the number of transmission characters as a transmission difference, and determining a processing method for the construction parameters of the execution environment not meeting the preset standard according to the transmission difference; Determine the processing method for each node according to the number of characters output by each node within the preset analysis time; Re-determine the processing method for the build parameters of the execution environment that do not meet the preset standards according to the number of each character within the preset historical time length; Adjust the number of nodes to the corresponding value according to the total data volume of the PySpark application; The variance of the number of characters output by each node within the calculated preset analysis time is recorded as the character variance, and the processing method for each node is determined according to the character variance; According to the difference between the preset character variance and the character variance, the number of Spark Executors corresponding to each node is adjusted to the corresponding value; According to the number of characters output by each node, adjust the number of Spark Executors of the node with the smallest number of characters output to the corresponding value; Obtaining the number of transmitted characters corresponding to each preset analysis duration within the preset historical duration, recording the variance of each calculated number of transmitted characters as the transmission variance, and re-determining the processing method for the construction parameters of the execution environment not meeting the preset standard according to the transmission variance; Adjust the number of nodes to the corresponding value according to the total data volume of the PySpark application; adjusting the compression ratio of data transmission to a corresponding value according to the difference between the transmission variance and the preset transmission variance; Based on the difference between the preset character ratio and the character ratio, a plurality of standard adjustment methods for the first preset number of transmitted characters and the second preset number of transmitted characters are provided, and the adjustment ranges of the first preset number of transmitted characters and the second preset number of transmitted characters in each standard adjustment method are different; re-determining whether the construction parameters of the execution environment meet the preset standards based on the adjusted first preset number of transmission characters and the second preset number of transmission characters; If the number of transmitted characters is still less than or equal to the adjusted second preset number of transmitted characters and greater than the adjusted first preset number of transmitted characters, determining a processing method for the construction parameters of the execution environment not meeting the preset standard according to the difference between the adjusted second preset number of transmitted characters and the number of transmitted characters; Based on the difference between the preset character variance and the character variance, a number of process adjustment methods for the number of Spark Executors corresponding to each node are provided, and the adjustment range of each process adjustment method for the number of Spark Executors corresponding to each node is different; The number of characters output by each node is recorded as the node with the smallest number of characters as the calibration node, the average number of characters output by each node is calculated, and the difference between the calculated average value and the number of characters corresponding to the calibration node is recorded as the calibration difference. Based on the calibration difference, a plurality of calibration adjustment methods for the number of Spark Executors of the calibration node are provided, and the adjustment range of the number of Spark Executors of the calibration node by each calibration adjustment method is different; Based on the total data volume of the PySpark application, several node adjustment methods for the number of nodes are provided, and the adjustment range of the number of nodes in each node adjustment method is different; Based on the difference between the transmission variance and the preset transmission variance, a plurality of compression adjustment modes for the compression ratio of data transmission are provided, and the adjustment range of the compression ratio of data transmission in each compression adjustment mode is different.
