A real-time data distribution method based on FLINK

Through the real-time data distribution method based on Flink, the problem of data integration and real-time processing from multiple data sources is solved, the intelligent distribution and real-time optimization of data are realized, and the data processing efficiency and system response speed are improved.

CN118945117BActive Publication Date: 2025-01-24ZHEJIANG RADIO & TELEVISION NEW MEDIA CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411427409.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-14
Publication Date
2025-01-24
Estimated Expiration
2044-10-14

AI Technical Summary

Technical Problem

The prior art is difficult to effectively integrate and process data from multiple heterogeneous data sources in real time. There is a lack of dynamic data distribution strategies and it is impossible to adjust the data flow direction based on real-time performance feedback, resulting in high data processing delays and low processing efficiency.

Method used

A real distribution method based on Flink -based data, including initialization data flow, data flow processing, dynamic distribution decision -making, data distribution and monitoring and optimization. Through progressive and dynamic distribution decisions, the intelligent distribution and real -time optimization of data are realized.

Benefits of technology

It achieves efficient integration and real-time processing of data from multiple data sources, dynamically adjusts data distribution paths, optimizes data processing efficiency and response speed, and improves the system's adaptability and processing capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118945117B_ABST
    Figure CN118945117B_ABST
Patent Text Reader

Abstract

The present invention provides a real-time data distribution method based on Flink, which is suitable for processing and distributing the aggregate data stream from multiple data sources. The method includes five main steps: first, initialize the data stream, configure and start the Flink job to receive and merge the data streams from multiple data sources; second, preprocess and progressively homogenize the received data stream, calculate the eigenvalue and generate a linear scoring function; then, dynamically determine the distribution path and target system of the data according to the preset distribution rules; then, distribute the processed data to one or more downstream systems in real time; finally, monitor the performance of data distribution in real time, and adjust the processing logic and distribution rules according to feedback to optimize the processing and distribution efficiency of the data stream. The method can effectively improve the real-time processing and distribution efficiency of data, optimize system resource utilization, reduce latency, and improve the flexibility and response speed of data utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data distribution processing, and in particular to a real-time data distribution method based on FLINK. Background Art

[0002] With the rapid development of modern information technology, real-time processing and distribution of big data has become a key requirement in many fields, especially in industries such as the Internet of Things, Fintech, and social media. Traditional data processing technologies often face challenges such as high processing latency and inability to efficiently process massive data streams, making it difficult to meet the needs of real-time data analysis and decision-making.

[0003] As an efficient stream processing framework, Apache Flink provides low-latency, high-throughput data stream processing capabilities. However, how to optimize Flink's capabilities in dynamic integration, real-time processing, and intelligent distribution of data streams from different data sources is still a technical challenge facing the industry. In particular, the fusion processing of multi-source data and dynamic data routing strategies based on performance indicators require more intelligent algorithms to ensure efficient distribution and accuracy of data streams.

[0004] In addition, with the diversification of data sources and the surge in data volume, how to achieve efficient data integration, accurate distribution to appropriate processing systems or storage systems, and how to optimize data stream processing strategies and distribution rules based on real-time feedback are also issues that need to be urgently addressed by existing technologies. Therefore, developing a real-time data distribution method based on Flink can achieve efficient management and optimized distribution of data streams, which is of great significance to improving data processing performance and system response speed.

[0005] Among existing technologies, real-time data distribution mainly relies on several core technical routes, each of which has its specific application scenarios and limitations.

[0006] 1. Combination of batch processing and stream processing:

[0007] Technical route: Traditional big data processing frameworks such as Hadoop are mainly based on batch processing models. Later, in order to meet the needs of real-time data processing, technologies such as Apache Storm and Spark Streaming were developed to process streaming data. Apache Flink is a framework that integrates batch processing and streaming processing, and can process data streams more flexibly.

[0008] Disadvantages: Although Flink can process both batch and stream data, it is still a challenge to effectively integrate and process data from multiple heterogeneous data sources in real time. In addition, the lack of a dynamic data distribution strategy makes it impossible to adjust the data flow based on real-time performance feedback of data processing.

[0009] 2. Static data routing strategy:

[0010] Technical route: In some real-time data processing systems, data routing strategies are usually preset, and data distribution is based on static rules, which are pre-defined according to data type or source.

[0011] Disadvantages: Static routing strategies lack flexibility and cannot be adjusted according to the current state of the system or the real-time characteristics of the data flow, which limits the system's adaptability when facing sudden changes in data volume or computing resources.

[0012] 3. Performance monitoring and optimization feedback:

[0013] Technical route: Existing data stream processing systems usually include performance monitoring mechanisms, but these monitorings are mainly concentrated at the infrastructure level, such as server CPU and memory usage.

[0014] Disadvantages: This type of monitoring usually does not provide enough information to optimize the processing logic and distribution strategy of the data flow. Especially in an environment with multiple data sources and high data mobility, there is a lack of in-depth monitoring of the characteristics of the data flow itself and a real-time optimization mechanism.

[0015] Therefore, a real-time data distribution method is needed that can dynamically adapt to various data sources and processing requirements. This method should be able to intelligently determine the optimal distribution path for data and make dynamic adjustments based on real-time feedback from data processing to optimize the efficiency and effectiveness of the entire data processing process. Summary of the invention

[0016] In view of the above problems, the present invention aims to propose: a real-time data distribution method based on Flink, comprising the following steps:

[0017] S1. Initialize data flow: configure and start a Flink job to distribute the aggregate data flow generated from multiple data sources;

[0018] S2, data stream processing: pre-process the aggregate data stream generated by multiple data sources, and perform progressive homogenization to obtain a linear scoring function;

[0019] S3, Dynamic distribution decision: Dynamically determine the data distribution path and target system based on the preset distribution rules;

[0020] S4, data distribution: distribute the processed data to one or more downstream systems in real time according to the decision results;

[0021] S5. Monitoring and optimization: Monitor the performance of data distribution in real time, adjust the processing logic and distribution rules based on feedback, and optimize the processing and distribution efficiency of data streams.

[0022] Furthermore, the aggregate data stream in step S1 includes at least data streams from IoT devices, online trading platforms, and social media, and the aggregate data stream meets the following conditions:

[0023]

[0024] in, Indicates that multiple data sources are at the time The total data flow of Indicates the serial number is The data source at time The data stream sent, Indicates at time The collection of data streams emitted by all data sources; is the start time of data distribution, is the data distribution cycle, Indicates time The time from when data distribution starts Start passing The moment of the distribution cycle, Indicates the maximum distribution period at the current moment; Indicates the time from when data distribution starts Start to obtain the intersection of the data streams emitted by all data sources in each distribution cycle.

[0025] Furthermore, in step S2, the distributed data stream is progressively homogenized by: The total data flow Find the eigenvalue at the moment that satisfies:

[0026]

[0027] in, Indicates the serial number is The data source at time Characteristic values ​​of the outgoing data stream; It means to perform progressive homogenization calculation on the data at any time, satisfying:

[0028]

[0029] in, and Respectively indicate the serial number The data source at time The mean and variance of the outgoing data stream; and The serial number is The data source at time The mean and variance of the data stream sent, at time and time One data distribution cycle difference ; and Indicates that the initial mean and initial variance of the data stream are zero.

[0030] Further, in step S2, the linear evaluation function is described as:

[0031]

[0032] in, Indicates that multiple data sources are at the time The linear evaluation function refers to the combination of data streams from multiple data sources; to Indicates the serial number is to The data source at time Characteristic values ​​of the outgoing data stream; Indicates the offset value.

[0033] Furthermore, in step S3, following the preset distribution rule means: determining a distribution load function and finding a minimum combination of the distribution load function; wherein the distribution load function satisfies:

[0034]

[0035] in, Indicates the serial number is The data source at time The intensity factor of the distribution issued; Indicates is the linear evaluation function of the differential Find partial differentials; Indicated in Distribution load function under the distribution intensity coefficient;

[0036] Find the minimum combination of distribution load functions that satisfies:

[0037]

[0038] in, To minimize the value function, it means to find a function that makes Get the minimum value The combination of .

[0039] Furthermore, in step S4, the decision result refers to configuring distribution strength coefficients for the multiple data sources according to the obtained optimal solution.

[0040] Furthermore, the monitoring and optimization in step S5 includes real-time tracking of the latency, throughput, and error rate of data processing and distribution, and adjusting the Flink job configuration based on these indicators.

[0041] Furthermore, the preprocessing in step S2 uses a user-defined function to achieve data standardization and serialization.

[0042] Furthermore, the data distribution in step S4 includes dynamically distributing the data stream to a storage system, and the storage system includes at least one of a relational database, a NoSQL database, or a file storage system.

[0043] Furthermore, an error handling mechanism is included, which is capable of identifying errors in data processing or distribution and executing a predefined error recovery or notification process.

[0044] Beneficial effects:

[0045] 1. Dynamic data stream processing: By processing and dynamically distributing the aggregate data streams generated by multiple data sources in real time, this solution can effectively adapt to changing data processing requirements and network conditions. This flexibility allows the system to dynamically adjust processing strategies and distribution paths for different types of data streams, thereby optimizing data processing efficiency and response speed.

[0046] 2. Progressive homogenization: In this solution, the data stream is processed by progressive homogenization to ensure the quality and consistency of the data before analysis. This processing step reduces the possible differences between different data sources by standardizing the mean and variance of the data stream, and improves the accuracy and reliability of subsequent data analysis.

[0047] 3. Optimized distribution strategy: By implementing dynamic distribution decisions based on optimization algorithms, this solution can not only adjust the distribution path according to the real-time characteristics of the data, but also adjust the data distribution intensity in real time through the calculated optimal distribution load function. This method reduces the risk of network congestion and system overload, and improves the overall processing capacity and stability of the system.

[0048] 4. Real-time performance monitoring and self-optimization: This solution includes a comprehensive monitoring and optimization module that can monitor data distribution performance indicators such as latency, throughput, and error rate in real time, and automatically adjust processing logic and distribution rules accordingly. This self-optimization mechanism ensures that the system can continue to provide efficient and reliable services when facing large-scale data flows.

[0049] In summary, this solution provides an efficient, reliable and adaptive solution through dynamic and intelligent data stream processing and distribution strategies. It is suitable for various large-scale data processing and distribution scenarios, especially for real-time data analysis and decision support systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 It is a schematic diagram of the method flow of the present invention. DETAILED DESCRIPTION

[0051] In order to deepen the understanding of the present invention, the present invention will be further described in detail below in conjunction with examples. The examples are only used to explain the present invention and do not constitute a limitation on the protection scope of the present invention.

[0052] Embodiment 1

[0053] according to Figure 1 As shown, this embodiment provides a real-time data distribution method based on Flink, including the following steps:

[0054] S1. Initialize data flow: configure and start a Flink job to distribute the aggregate data flow generated from multiple data sources;

[0055] S2, data stream processing: pre-process the aggregate data stream generated by multiple data sources, and perform progressive homogenization to obtain a linear scoring function;

[0056] S3, Dynamic distribution decision: Dynamically determine the data distribution path and target system based on the preset distribution rules;

[0057] S4, data distribution: distribute the processed data to one or more downstream systems in real time according to the decision results;

[0058] S5. Monitoring and optimization: Monitor the performance of data distribution in real time, adjust the processing logic and distribution rules based on feedback, and optimize the processing and distribution efficiency of data streams.

[0059] Furthermore, the aggregate data stream in step S1 includes at least data streams from IoT devices, online trading platforms, and social media, and the aggregate data stream meets the following conditions:

[0060]

[0061] in, Indicates that multiple data sources are at the time The total data flow of Indicates the serial number is The data source at time The data stream sent, Indicates at time The collection of data streams emitted by all data sources; is the start time of data distribution, is the data distribution cycle, Indicates time The time from when data distribution starts Start passing The moment of the distribution cycle, Indicates the maximum distribution period at the current moment; Indicates the time from when data distribution starts Start to obtain the intersection of the data streams emitted by all data sources in each distribution cycle.

[0062] Furthermore, in step S2, the distributed data stream is progressively homogenized by: The total data flow Find the eigenvalue at the moment that satisfies:

[0063]

[0064] in, Indicates the serial number is The data source at time Characteristic values ​​of the outgoing data stream; It means to perform progressive homogenization calculation on the data at any time, satisfying:

[0065]

[0066] in, and Respectively indicate the serial number The data source at time The mean and variance of the outgoing data stream; and The serial number is The data source at time The mean and variance of the data stream sent, at time and time One data distribution cycle difference ; and Indicates that the initial mean and initial variance of the data stream are zero.

[0067] Further, in step S2, the linear evaluation function is described as:

[0068]

[0069] in, Indicates that multiple data sources are at the time The linear evaluation function refers to the combination of data streams from multiple data sources; to Indicates the serial number is to The data source at time Characteristic values ​​of the outgoing data stream; Indicates the offset value.

[0070] Furthermore, in step S3, following the preset distribution rule means: determining a distribution load function and finding a minimum combination of the distribution load function; wherein the distribution load function satisfies:

[0071]

[0072] in, Indicates the serial number is The data source at time The intensity factor of the distribution issued; Indicates is the linear evaluation function of the differential Find partial differentials; Indicated in Distribution load function under the distribution intensity coefficient;

[0073] Find the minimum combination of distribution load functions that satisfies:

[0074]

[0075] in, To minimize the value function, it means to find a function that makes Get the minimum value The combination of .

[0076] Furthermore, in step S4, the decision result refers to configuring distribution strength coefficients for the multiple data sources according to the obtained optimal solution.

[0077] Furthermore, the monitoring and optimization in step S5 includes real-time tracking of the latency, throughput, and error rate of data processing and distribution, and adjusting the Flink job configuration based on these indicators.

[0078] Furthermore, the preprocessing in step S2 uses a user-defined function to achieve data standardization and serialization.

[0079] Furthermore, the data distribution in step S4 includes dynamically distributing the data stream to a storage system, and the storage system includes at least one of a relational database, a NoSQL database, or a file storage system.

[0080] Furthermore, an error handling mechanism is included, which is capable of identifying errors in data processing or distribution and executing a predefined error recovery or notification process.

[0081] Embodiment 2

[0082] This embodiment describes a real-time data distribution method based on Flink, which is applicable to an e-commerce company that wants to process and distribute data from multiple data sources in real time, including IoT devices, online trading platforms, and social media.

[0083] Step S1: Initialize data flow:

[0084] The company configured and started a Flink job that receives data streams from three main data sources: IoT device sensor data, online trading platform transaction data, and social media user interaction data. These data streams are merged into a single aggregate data stream. , expressed as:

[0085]

[0086] in, Represents different points in time from the beginning of the data flow.

[0087] Step S2: Data stream processing:

[0088] For in time Total data stream received , the company uses a progressive homogenization method to calculate the eigenvalues ​​of each data source:

[0089]

[0090] in, It is data The function for standardization is defined as:

[0091]

[0092] The mean and standard deviation are updated by:

[0093]

[0094] Step S3: Dynamic distribution decision:

[0095] Distribute the load by defining a function , the company dynamically determines the distribution path of data:

[0096]

[0097] is the weight factor, representing the data source The distribution intensity, It is a linear evaluation function used to evaluate the distribution value of a data stream.

[0098] Step S4: Data distribution:

[0099] According to the optimization decision obtained in step S3, the data stream is dynamically distributed to multiple downstream systems, such as cloud storage services, real-time analysis tools, or marketing automation systems.

[0100] Step S5: Monitoring and Optimization:

[0101] By monitoring system performance, such as latency, throughput, and error rate, Flink job configuration can be adjusted in real time to optimize data distribution efficiency.

[0102] For the above embodiment, an exemplary code is given here:

[0103] from pyflink.datastream import StreamExecutionEnvironment

[0104] from pyflink.table import StreamTableEnvironment

[0105] from pyflink.table.descriptors import Schema, Csv, FileSystem

[0106] from pyflink.table.expressions import col, lit

[0107] # S1. Initialize data stream

[0108] def initialize_data_stream(input_path):

[0109] """

[0110] Initialize the data stream and read the CSV file from the specified path.

[0111] """

[0112] table_env = StreamTableEnvironment.create(StreamExecutionEnvironment.get_execution_environment())

[0113] table_env.connect(FileSystem().path(input_path)) \

[0114] .with_format(Csv()) \

[0115] .with_schema(Schema()

[0116] .field("source", "STRING")

[0117] .field("timestamp", "BIGINT")

[0118] .field("data", "DOUBLE")) \

[0119] .create_temporary_table("input_table")

[0120] return table_env.from_path("input_table"), table_env

[0121] # S2. Data stream processing - progressive homogenization (without using numpy)

[0122] def normalize_data(data_list):

[0123] """

[0124] Perform progressive homogenization to calculate the mean and variance of the data.

[0125] """

[0126] if len(data_list) == 0:

[0127] return 0, 0

[0128] mean = sum(data_list) / len(data_list)

[0129] variance = sum((x - mean) ** 2 for x in data_list) / len(data_list)if len(data_list)>1 else 0

[0130] return mean, variance

[0131] def process_data_stream(table, table_env):

[0132] """

[0133] Perform processing on the data stream, including progressive homogenization.

[0134] """

[0135] # Temporarily simulate the progressive homogenization of each source

[0136] processed_table = table.select(

[0137] col("source"),

[0138] col("data"),

[0139] col("timestamp") )

[0141] return processed_table

[0142] # S3. Dynamic distribution decisions

[0143] def make_dynamic_decision(processed_table):

[0144] """

[0145] Make decisions based on preset distribution rules and distribute data to different target systems.

[0146] """

[0147] # Simple decision logic, if data > 0, distribute to target_system_1, otherwise distribute to target_system_2

[0148] decision_table = processed_table.select(

[0149] col("source"),

[0150] col("data"),

[0151] col("timestamp"),

[0152] col("data").case(

[0153] col("data")>0, lit("target_system_1")

[0154] ).otherwise(lit("target_system_2")).alias("target_system") )

[0156] return decision_table

[0157] # S4. Data distribution

[0158] def distribute_data(decision_table, output_path, table_env):

[0159] """

[0160] Distribute the data after decision making to the specified target system (here we simulate distribution to files).

[0161] """

[0162] table_env.connect(FileSystem().path(output_path)) \

[0163] .with_format(Csv()) \

[0164] .with_schema(Schema()

[0165] .field("source", "STRING")

[0166] .field("data", "DOUBLE")

[0167] .field("timestamp", "BIGINT")

[0168] .field("target_system", "STRING")) \

[0169] .create_temporary_table("output_table")

[0170] decision_table.execute_insert("output_table")

[0171] # S5. Monitoring and optimization (simplified to log output)

[0172] def monitor_and_optimize():

[0173] """

[0174] Simulate, monitor and optimize data stream processing performance.

[0175] """

[0176] print("Monitoring: Real-time monitoring of data distribution performance, optimizing configuration...")

[0177] # Main function, execute Flink job

[0178] def main(input_path, output_path):

[0179] # Initialize the data stream

[0180] table, table_env = initialize_data_stream(input_path)

[0181] # Processing data streams

[0182] processed_table = process_data_stream(table, table_env)

[0183] # Dynamic dispatch decisions

[0184] decision_table = make_dynamic_decision(processed_table)

[0185] Data Distribution

[0186] distribute_data(decision_table, output_path, table_env)

[0187] # Monitoring and Optimization

[0188] monitor_and_optimize()

[0189] if __name__ == '__main__':

[0190] input_path = "path / to / input.csv" # Input file path

[0191] output_path = "path / to / output.csv" # Output file path

[0192] main(input_path, output_path)

[0193] The above shows and describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention. The scope of protection of the present invention is defined by the attached claims and their equivalents.

Claims

1. A real-time data distribution method based on Flink, characterized in that: The following steps are involved: S1. Initialize data flow: configure and start a Flink job to distribute the aggregate data flow generated from multiple data sources; The aggregate data stream includes at least data streams from IoT devices, online trading platforms, and social media, and the aggregate data stream meets the following conditions: ; in, Indicates that multiple data sources are at the time The total data flow of Indicates the serial number is The data source at time The data stream sent, Indicates at time The collection of data streams emitted by all data sources; is the start time of data distribution, is the data distribution cycle, Indicates time The time from when data distribution starts Start passing The moment of the distribution cycle, Indicates the maximum distribution period at the current moment; Indicates the time from when data distribution starts Start to obtain the intersection of the data streams emitted by all data sources in each distribution cycle; S2. Data stream processing: pre-process the aggregate data stream generated by multiple data sources, and perform progressive homogenization to obtain a linear evaluation function; specifically, it includes: The distributed data stream is progressively homogenized as follows: The total data flow Find the eigenvalue at the moment that satisfies: ; in, Indicates the serial number is The data source at time Characteristic values ​​of the outgoing data stream; It means to perform progressive homogenization calculation on the data at any time, satisfying: ; in, and Respectively indicate the serial number The data source at time The mean and variance of the outgoing data stream; and The serial number is The data source at time The mean and variance of the data stream sent, at time and time One data distribution cycle difference ; and Indicates that the initial mean and initial variance of the data stream are zero; The linear evaluation function is described as: ; in, Indicates that multiple data sources are at the time The linear evaluation function refers to the combination of data streams from multiple data sources; to Indicates a sequence number from 1 to The data source at time Characteristic values ​​of the outgoing data stream; Indicates the bias value; S3, Dynamic distribution decision: Dynamically determine the data distribution path and target system based on the preset distribution rules; S4, data distribution: distribute the processed data to one or more downstream systems in real time according to the decision results; S5. Monitoring and optimization: Monitor the performance of data distribution in real time, adjust the processing logic and distribution rules based on feedback, and optimize the processing and distribution efficiency of data streams.

2. According to a Flink-based real-time data distribution method according to claim 1, it is characterized by: In step S3, following the preset distribution rule means: determining a distribution load function and finding a minimum combination of the distribution load function; wherein the distribution load function satisfies: ; in, Indicates the serial number is The data source at time The intensity factor of the distribution issued; Indicates is the linear evaluation function of the differential Find partial differentials; Indicated in Distribution load function under the distribution intensity coefficient; Find the minimum combination of distribution load functions that satisfies: ; in, To minimize the value function, it means to find a function that makes Get the minimum value The combination of .

3. According to a Flink-based real-time data distribution method according to claim 2, it is characterized in that: In step S4, the decision result refers to configuring distribution strength coefficients for the multiple data sources according to the obtained optimal solution.

4. According to the Flink-based real-time data distribution method of claim 3, it is characterized by: The monitoring and optimization in step S5 includes real-time tracking of the latency, throughput, and error rate of data processing and distribution, and adjusting the Flink job configuration based on these indicators.

5. According to a Flink-based real-time data distribution method according to claim 3, it is characterized in that: The preprocessing in step S2 uses user-defined functions to achieve data standardization and serialization.

6. According to a Flink-based real-time data distribution method according to claim 4, it is characterized in that: The data distribution in step S4 includes dynamically distributing the data stream to a storage system, wherein the storage system includes at least one of a relational database, a NoSQL database or a file storage system.

7. The real-time data distribution method based on Flink according to claim 1 is characterized in that: Includes an error handling mechanism that identifies errors during data processing or distribution and executes predefined error recovery or notification procedures.

Citation Information

Patent Citations

  • Data processing method and system based on stream processing framework

    CN114661563A

  • CDN log data processing method and device, equipment, medium and program product

    CN118041763A