A method for designing stream-batch integrated indicators based on Flink
By introducing the flow-batch integration method based on Flink into the indicator design, combined with flow computing and interactive analysis engines, we solve the existing technology problems of offline architecture not supporting real-time computing, high development costs, and difficulty in implementation, and achieve high efficiency. , low-latency real-time indicator calculation and on-demand storage, reducing operation and maintenance costs and improving the stability of indicator services.
Patent Information
- Application Number
- CN202011115723.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-19
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2040-10-19
AI Technical Summary
The existing technology has problems in indicator design such that the offline big data architecture does not support real-time calculations, the development and operation and maintenance costs of the Lambda architecture are high, the implementation of the Kappa architecture is difficult, and the data replay throughput capability is low.
The stream-batch integrated indicator design method based on Flink integrates the dual-engine architecture of stream computing and interactive analysis. The stream computing engine is responsible for basic indicator calculations, and the interactive analysis engine is responsible for on-demand calculations. It combines data access, indicator calculation and indicator assignment. The flow of energy can realize real-time full-dimensional basic indicator calculation and on-demand indicator storage, and provide an exception protection mechanism.
It achieves high-throughput and low-latency real-time indicator calculation, quickly responds to changes in business needs, reduces data replay problems, reduces development and operation and maintenance costs, and provides rich and stable indicator services.
Smart Images

Figure CN112230894B
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of big data, business support and data business technology, and in particular to a stream-batch integrated indicator design method based on Flink. Background Art
[0002] Existing indicator design methods can be divided into the following categories according to the big data architecture they adopt:
[0003]
[0004] The existing indicator design methods have the following problems:
[0005] 1. Offline Big Data Architecture
[0006] It mainly supports offline indicator calculation and does not support real-time indicator calculation. If the indicator system is not reasonable, it will lead to data redundancy and repeated development.
[0007] (II) Lambda Architecture
[0008] Although it meets the needs of real-time indicator calculation, it brings more development and operation and maintenance costs. The same business needs require the development of two sets of the same code, which not only makes development difficult, but also makes subsequent maintenance more difficult. For example, after the requirements change, two sets of code need to be modified separately, the results need to be tested independently, and the two jobs need to be launched simultaneously.
[0009] (III) Kappa Architecture
[0010] It seems simple, but the implementation is relatively difficult, especially the data replay part. Business requirements modification or historical data reprocessing need to be completed through upstream replay. The throughput of reprocessing historical data will be lower than offline processing, although it can be compensated by increasing computing resources. Summary of the invention
[0011] In order to solve the above technical problems, the present invention provides a stream-batch integrated indicator design method based on Flink, which integrates the dual-engine architecture of stream computing and interactive analysis on the basis of the existing Kappa architecture. In this architecture, the stream computing engine is responsible for the calculation of basic indicators, and the interactive analysis engine is responsible for the on-demand calculation of indicators. The two work together to quickly respond to changes in business needs while ensuring high throughput and low latency, and reduce the problems caused by data replay.
[0012] The technical solution of the present invention is:
[0013] A Flink-based stream-batch integrated indicator design method, based on the data flow of "data access-indicator calculation-indicator empowerment", mainly includes the following three steps:
[0014] 1) Data access
[0015] It is divided into three parts: "data source - data cleaning and conversion - data exchange". The task is to complete real-time data collection and send it to the message queue;
[0016] 2) Index calculation
[0017] It can be divided into two parts: "real-time indicator calculation-indicator storage";
[0018] Real-time indicator calculation uses the stream computing engine Flink, with real-time basic indicators first, to achieve real-time full-dimensional basic indicator calculation; indicator storage, separate storage of hot and cold indicators, divided into real-time indicator and non-real-time indicator storage according to the timeliness of the indicator;
[0019] In addition, a complete abnormal protection mechanism is provided to ensure the accuracy and reliability of indicators;
[0020] 3) Indicator empowerment
[0021] Provide indicator services to empower application systems.
[0022] Furthermore,
[0023] For different business systems, existing real-time data collection technology is used to complete real-time data collection; before outputting to the message queue, data is received and cleaned and converted, and unified data cleaning and conversion rule definition and management are provided to avoid data cleaning and conversion being scattered in different business logics and eliminate data ambiguity.
[0024] In addition to outputting to the message queue, batch data exchange can be performed to store detailed data on disk to support data compensation and playback for real-time calculations and for data verification.
[0025] Furthermore,
[0026] All dimensional basic indicators in real-time indicator calculation are asynchronously written into non-real-time indicator storage in full, and cooperate with the interactive analysis engine to complete on-demand calculation of indicators that meet business needs. Only the subset of key indicators that are truly required for real-time business scenarios will be synchronously written into the real-time indicator storage, supporting warm indicator empowerment.
[0027] Furthermore,
[0028] The real-time basic indicators are first, which can be divided into two links: "data preprocessing-basic indicators";
[0029] Data preprocessing: To optimize the data preprocessing implemented by stream computing, the data definition is simplified, only the attributes that stream computing strongly depends on are retained, and IO consumption is reduced;
[0030] Basic indicators divide and define atomic indicators, time granularity, dimensions, dimension lineage, dimension attributes, and derived indicators, and build a unified indicator matrix and indicator algorithm library.
[0031] The basic indicator calculation is performed layer by layer from bottom to top based on the dimension blood relationship. Only one stream calculation is required to complete the real-time basic indicator calculation of all dimensions.
[0032] Furthermore,
[0033] The cold and hot indicators are stored separately, and are divided into real-time indicator and non-real-time indicator storage according to the timeliness of the indicators;
[0034] Real-time indicator storage includes key indicators, hot indicators, and warm indicators. The storage content includes indicator results and timestamps, and stores indicators with configurable time. The latest data is defined as hot indicators, the data in the last hour is defined as warm indicators, and key indicators are the indicators that are the focus of business scenarios.
[0035] Non-real-time indicator storage is subdivided into cold indicators, ultra-long-term granularity aggregation, and indicator OLAP cubes; cold indicators are full historical indicators, and ultra-long-term granularity aggregation is based on cold indicators, supporting indicator aggregation that can be freely scaled at any time.
[0036] Furthermore,
[0037] The abnormal protection mechanism is divided into the following four parts:
[0038] 1) Response to data loss;
[0039] After data is received, cleaned and converted, it is pushed to the message queue in real time for real-time calculation. At the same time, the data is pushed in batches in the form of detailed files and persisted in HDFS to retain the source data. Based on the message queue Kafka consumption displacement mechanism, data playback is provided and any playback position can be specified. The retained detailed files support full data playback.
[0040] 2) Dealing with data disorder / delay;
[0041] Relying on the stream computing engine Flink's native support for the watermark waterline mechanism, based on the event time recorded when the data actually occurred, it can effectively handle any data disorder; it supports double guarantee for processing late data: (2.1) watermark ensures that late data is not discarded within a short period of time (2.2) bypass calculation of late data and regularly supplement indicator results;
[0042] 3) Response to special indicators;
[0043] Indicators that meet the commutative / associative laws do not require special processing; indicators that do not meet the commutative / associative laws require special processing; average is indirectly achieved through SUM / COUNT; variance / standard deviation depends on the entire data set and is calculated separately; cardinality counts are calculated separately or stored, requiring the cardinality target value and timestamp to be stored;
[0044] 4) High availability;
[0045] The entire link uses distributed components; real-time computing provides a failover mechanism; Flink provides a Checkpoint snapshot mechanism. When a real-time computing job exits abnormally, it ensures that the calculation continues based on the calculation results before the exit, thereby providing At-least-Once / Exactly-Once high availability guarantees.
[0046] The general technique is as follows:
[0047] 1. Stream computing engine Flink
[0048] Flink is an open source distributed big data processing engine developed by the Apache Software Foundation community based on the Apache License 2.0. It can perform stateful computing on priority data streams and infinite data streams. It can be deployed in various cluster environments and perform fast computing on data of various sizes.
[0049] Flink provides users with more powerful computing capabilities and easier-to-use programming interfaces. Its advantages include:
[0050] Layered API. Flink provides three different APIs based on the level of abstraction. Each API has different emphasis on simplicity and expressiveness and is targeted at different application scenarios. It provides high-throughput, low-latency computing capabilities and more powerful SQL support.
[0051] Excellent performance. Supports low latency, high throughput, and in-memory computing.
[0052] Large-scale computing. A job can be broken down into thousands of tasks, distributed across a cluster and executed in parallel.
[0053] Ecosystem compatibility. It is integrated with Hadoop Yarn / Apache Mesos / Kubernetes and supports standalone mode operation.
[0054] Correctness guarantee. Supports mature late data processing, event time processing, and Exactly-Once state consistency.
[0055] 2. Interactive Analysis Engine
[0056] Interactive analysis engine (OLAP, On-Line Analysis Processing) is a fast analysis technology that shares multi-dimensional information. Its main function is to facilitate large-scale data analysis and statistical calculations, and provide reference and support for decision-making. Features include: large data volume, high-speed response, flexible interaction and multi-dimensional analysis.
[0057] According to the architecture implementation, the mainstream interactive analysis engines are mainly divided into the following three types:
[0058] Based on MPP architecture (Presto / Impala / SparkSQL / Drill, etc.), it mainly starts from the query engine and uses a distributed query engine instead of Hive and MapReduce architecture to improve query efficiency.
[0059] Search engine architecture (es, sol, etc.). When entering the database, the data is converted into an inverted index and the Scatter-Gathe calculation model is used, sacrificing flexibility in exchange for good performance. It can achieve sub-second response for search queries. However, for queries that are mainly scanned and aggregated, as the amount of data processed increases, the response time will also degenerate to minutes.
[0060] Pre-computation engine architecture (Druid / Kylin, etc.). Pre-aggregate data when it is ingested, further sacrificing flexibility for performance to achieve a second-level response to very large data sets.
[0061] The present invention adopts a pre-calculation engine architecture and can calculate the selection of Kylin. Kylin is an open source interactive distributed analysis engine, a complete pre-calculation engine, which enumerates all combinations of dimensions, builds various cubes for advance aggregation, and provides SQL query interface and multidimensional analysis (OLAP) capabilities on Hadoop based on HBase to support ultra-large-scale data. It is suitable for queries that do not require real-time data but have a high response time.
[0062] The beneficial effects of the present invention are
[0063] 1. It realizes the integration of stream and batch computing. It no longer needs to maintain two links, offline computing and real-time computing, and no longer needs to develop two sets of the same code. Based on the stream computing engine Flink, you only need to maintain the real-time computing link and develop one set of code, which reduces the development and operation and maintenance costs.
[0064] 2. The dual-engine architecture of stream computing and interactive analysis takes real-time indicators first, realizes real-time and on-demand calculation of indicators, and quickly responds to changes in business needs.
[0065] 3. Cold and hot indicators are stored separately to provide richer, more stable and warmer indicator services to empower application systems.
[0066] 4. Provide a rich set of exception protection mechanisms to ensure the accuracy and reliability of indicators. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 It is a schematic diagram of the workflow of the present invention. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0069] The present invention provides a flow-batch integrated indicator design method based on Flink, the data flow diagram is as follows Figure 1 As shown, the recommended technology selection is also listed in the figure.
[0070] According to the data flow of "data access-indicator calculation-indicator empowerment", it mainly includes the following three steps:
[0071] 1. Data access
[0072] It can be divided into three parts: "data source-data cleaning and conversion-data exchange". The main task is to complete real-time data collection and send it to the message queue (Kafka can be selected as the technology). For different business systems, existing real-time data collection technologies can be used to complete real-time data collection. Before outputting to the message queue, data is received and cleaned and converted, and unified data cleaning and conversion rule definition and management are provided to avoid data cleaning and conversion being scattered in different business logics and eliminate data ambiguity. In addition to outputting to the message queue, batch data exchange can be performed to store detailed data on disk (HDFS can be selected as the technology) to support data compensation and playback for real-time calculations and for data verification.
[0073] 2. Indicator calculation
[0074] It can be divided into two parts: "real-time indicator calculation-indicator storage". For real-time indicator calculation, the stream computing engine Flink is used, and the real-time basic indicators are taken first to realize the calculation of real-time full-dimensional basic indicators. For indicator storage, cold and hot indicators are stored separately, and the storage is divided into real-time indicators and non-real-time indicators according to the timeliness of the indicators. The full-dimensional basic indicators in the real-time indicator calculation are all asynchronously written to the non-real-time indicator storage, and the interactive analysis engine (Kylin can be selected as the technology) is used to complete the on-demand calculation of indicators that meet business needs. Only the subset of key indicators that are really needed for real-time business scenarios will be synchronously written to the real-time indicator storage (Redis / HBase can be selected as the technology), supporting temperature indicator empowerment. In addition, a complete exception protection mechanism is provided to ensure the accuracy and reliability of indicators.
[0075] 3. Indicator empowerment
[0076] Provide easy-to-use, low-cost, stable and warm indicator services to empower application systems.
[0077] The real-time basic indicators are first, which can be divided into two links: "data preprocessing-basic indicators". Data preprocessing is to optimize the data preprocessing implemented by stream computing, simplify the data definition, retain only the attributes that stream computing strongly depends on, and reduce IO consumption. Basic indicators divide and define atomic indicators, time granularity, dimensions, dimension lineage, dimension attributes, derived indicators, etc., and build a unified indicator matrix and indicator algorithm library. Basic indicators can be flexibly defined, following the definition method of "atomic indicators + time granularity + dimension", such as the number of 4G users in a certain city area every 1 minute. The calculation of basic indicators is calculated layer by layer from the bottom up based on the dimension lineage. Only one stream calculation is required to complete the calculation of real-time basic indicators of all dimensions.
[0078] The cold and hot indicators are stored separately, and are divided into real-time indicator and non-real-time indicator storage according to the timeliness of the indicators. Real-time indicator storage is subdivided into key indicators, hot indicators, and warm indicators. The storage content includes indicator results and timestamps (such as minute granularity, example: 202002181844), and stores indicators for the last hour (configurable). The latest data is defined as hot indicators, the last hour as warm indicators, and key indicators as indicators that are focused on in business scenarios. Identification is added to ensure key protection in storage, monitoring, and other aspects. Non-real-time indicator storage is subdivided into cold indicators, ultra-long-term granularity aggregation, and indicator OLAP cubes. Cold indicators are full historical indicators. Ultra-long-term granularity aggregation is based on cold indicators, and supports indicator aggregation that can be freely scaled at any time. The indicator OLAP cube relies on an interactive analysis engine to provide more three-dimensional and comprehensive on-demand calculation of non-real-time indicators.
[0079] The abnormal protection mechanism is divided into the following four parts:
[0080] 1. Dealing with data loss. After receiving, cleaning and converting data, it is pushed to the message queue in real time for real-time calculation. At the same time, the data is pushed in batches in the form of detailed files to HDFS for persistence to retain the source data. Based on the message queue Kafka consumption displacement mechanism, limited data playback is provided, and any playback position can be specified. The retained detailed files support full data playback.
[0081] 2. Dealing with data disorder / late arrival. Relying on the native support of the watermark watermark mechanism of the stream computing engine Flink, based on the event time recorded when the data actually occurred, it can effectively handle any data disorder. It supports double guarantee for handling late data: (1) Watermark ensures that late data will not be discarded within a short period of time, but it will sacrifice a certain degree of timeliness (2) Bypass calculation of late data, regularly supplement indicator results, and ensure the accuracy of results as much as possible while ensuring timeliness.
[0082] 3. Dealing with special indicators. Indicators that meet the commutative / associative laws do not require special processing, for example: MAX / MIN / SUM / COUNT. Indicators that do not meet the commutative / associative laws require special processing. The average is indirectly implemented through SUM / COUNT. The variance / standard deviation must rely on the entire data set and can only be calculated and processed separately. Cardinality counts can be calculated and processed separately, or stored (requires the cardinality target value and timestamp to be stored).
[0083] 4. High availability. The entire link uses distributed components to provide high availability. Real-time computing provides a failover mechanism. Flink provides a Checkpoint snapshot mechanism. When a real-time computing job exits abnormally due to reasons such as the machine, network, or dirty data, it ensures that the calculation continues based on the calculation results before the exit, ensuring data accuracy and providing high availability guarantees such as At-least-Once / Exactly-Once.
[0084] (1) Real-time basic indicators come first. Relying on the stream computing engine Flink, it follows the definition of "atomic indicators + time granularity + dimension". Internally, it calculates layer by layer from bottom to top based on the dimension blood relationship. Only one stream calculation is needed to complete the calculation of real-time basic indicators of all dimensions.
[0085] (2) Separate storage of hot and cold indicators. Indicators are divided into real-time and non-real-time indicator storage according to their timeliness, supporting "warm" indicator empowerment. The focus is on non-real-time indicator storage, which relies on the interactive analysis engine to calculate indicators on demand, quickly respond to changes in business needs, and reduce problems caused by data replay.
[0086] (3) Abnormal protection mechanism: The accuracy and reliability of indicators are guaranteed by dealing with four aspects: data loss, data disorder / delay, special indicators and high availability.
[0087] The above description is only a preferred embodiment of the present invention, which is only used to illustrate the technical solution of the present invention, and is not used to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for designing stream-batch integrated indicators based on Flink, characterized in that: According to the data flow of "data access-indicator calculation-indicator empowerment", it mainly includes the following three steps: 1) Data access It is divided into three parts: "data source - data cleaning and conversion - data exchange". The task is to complete real-time data collection and send it to the message queue; 2) Indicator calculation It can be divided into two parts: "real-time indicator calculation-indicator storage"; Real-time indicator calculation uses the stream computing engine Flink, with real-time basic indicators first, to achieve real-time full-dimensional basic indicator calculation; indicator storage, separate storage of hot and cold indicators, divided into real-time indicator and non-real-time indicator storage according to the timeliness of the indicator; In addition, a complete abnormal protection mechanism is provided to ensure the accuracy and reliability of indicators; 3) Indicator empowerment Provide indicator services to empower application systems; in, All the basic indicators of all dimensions in real-time indicator calculation are asynchronously written into non-real-time indicator storage. Together with the interactive analysis engine, on-demand calculation of indicators that meet business needs is completed. Only the subset of key indicators that are truly required by real-time business scenarios are synchronously written into real-time indicator storage, supporting warm indicator empowerment. The cold and hot indicators are stored separately, and are divided into real-time indicator and non-real-time indicator storage according to the timeliness of the indicators; Real-time indicator storage includes key indicators, hot indicators, and warm indicators. The storage content includes indicator results and timestamps, and stores indicators with configurable time. The latest data is defined as hot indicators, the data in the last hour is defined as warm indicators, and key indicators are the indicators that are the focus of business scenarios. Non-real-time indicator storage is subdivided into cold indicators, ultra-long-term granularity aggregation, and indicator OLAP cubes. Cold indicators are all historical indicators. Ultra-long-term granularity aggregation is based on cold indicators, supporting indicator aggregation that can be freely scaled at any time. The abnormal protection mechanism is divided into the following four parts: 1) Response to data loss; After data is received, cleaned and converted, it is pushed to the message queue in real time for real-time calculation. At the same time, the data is pushed in batches in the form of detailed files and persisted in HDFS to retain the source data. Based on the message queue Kafka consumption displacement mechanism, data playback is provided and any playback position can be specified. The retained detailed files support full data playback. 2) Dealing with data disorder / delay; Relying on the stream computing engine Flink's native support for the watermark waterline mechanism, based on the event time recorded when the data actually occurred, it can effectively handle any data disorder; it supports double protection for processing late data: (2.1) watermark ensures that late data is not discarded within a short period of time (2.2) bypass calculation of late data and regularly supplement indicator results; 3) Response to special indicators; Indicators that satisfy the commutative / associative laws do not require special treatment; indicators that do not satisfy the commutative / associative laws require special treatment; The special processing described: average, indirectly realized by SUM / COUNT; variance / standard deviation, dependent on the entire data set, calculated separately; cardinality count, calculated separately or stored, requiring the cardinality target value and timestamp to be stored; 4) High availability; The entire link uses distributed components; real-time computing provides a failover mechanism; Flink provides a Checkpoint snapshot mechanism. When a real-time computing job exits abnormally, it ensures that the calculation continues based on the calculation results before the exit, thereby providing At-least-Once / Exactly-Once high availability guarantees.
2. The method according to claim 1, characterized in that For different business systems, existing real-time data collection technology is used to complete real-time data collection; before outputting to the message queue, data is received and cleaned and converted, and unified data cleaning and conversion rule definition and management are provided to avoid data cleaning and conversion being scattered in different business logics and eliminate data ambiguity.
3. The method according to claim 2, characterized in that In addition to outputting to the message queue, batch data exchange can be performed to store detailed data on disk to support data compensation and playback for real-time calculations and for data verification.
4. The method according to claim 1, characterized in that: The real-time basic indicators come first, which can be divided into two parts: "data preprocessing-basic indicators"; Data preprocessing: To optimize the data preprocessing implemented by stream computing, the data definition is simplified, only the attributes that stream computing strongly depends on are retained, and IO consumption is reduced; Basic indicators divide and define atomic indicators, time granularity, dimensions, dimension lineage, dimension attributes, and derived indicators, and build a unified indicator matrix and indicator algorithm library.
5. The method according to claim 4, characterized in that The basic indicator calculation is performed layer by layer from bottom to top based on the dimension blood relationship. Only one stream calculation is required to complete the real-time basic indicator calculation of all dimensions.
