Business data processing method, apparatus, device, storage medium, and product
By using a domestically developed technology stack of TiDB+Canal+Flink+Kafka, the problem of replacing MongoDB in the context of domestic IT innovation was solved, achieving high-performance document aggregation and frequent updates, reducing replacement costs and ensuring system stability.
Patent Information
- Application Number
- CN202611335184.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-20
AI Technical Summary
The lack of a direct MongoDB alternative in the current IT innovation technology stack leads to compliance risks and supply security concerns. At the same time, directly migrating to traditional relational databases or other NoSQL products will face problems such as insufficient document structure support, degraded update performance, high development redundancy, and large-scale architecture changes, making it difficult to achieve high-performance document aggregation, frequent updates, and batch queries.
It adopts a domestic technology stack of TiDB+Canal+Flink+Kafka. Canal is used to realize incremental data synchronization, Flink stream processing operators are combined to aggregate data, and a configuration-based approach is used to realize incremental synchronization, extraction, consumption and aggregation of multi-source business data. Smooth switching is achieved through dual-track parallelism and configuration switches.
Without relying on MongoDB, it achieves high-performance document aggregation and frequent updates, reduces replacement costs, supports rapid rollback, and ensures the stability and self-control of business systems.
Smart Images

Figure CN123137752A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a business data processing method, apparatus, equipment, storage medium, and product. Background Technology
[0002] Currently, in near real-time data pipelines, MongoDB is widely used for storing and processing aggregated document data across multiple databases and tables due to its excellent support for complex document structures, flexible data models, and partial update operations. Typical application scenarios include: batch extracting business data via a scheduling service and pushing it to Kafka, then having Flink tasks aggregate, update, and query the data, ultimately outputting it to query engines such as Elasticsearch to support high-performance retrieval and statistics. In addition, MongoDB is also used as a business database in some online transaction processing scenarios. This model demonstrates high throughput and development efficiency in near real-time pipelines with variable data formats, frequent updates, and less stringent real-time requirements.
[0003] However, existing technical solutions have significant drawbacks. Firstly, MongoDB, being a foreign open-source product, does not meet the national requirements for independent and controllable IT infrastructure development. Furthermore, there is no mature direct alternative in the domestic IT innovation (AK) technology stack, posing compliance risks and supply security concerns. Secondly, current replacement solutions lack a unified and efficient technical path. Direct migration to traditional relational databases or other NoSQL products often faces problems such as insufficient document structure support, decreased update performance, high development redundancy, and significant architectural changes, making it difficult to achieve a smooth replacement while maintaining system performance, stability, and business continuity. Simultaneously, existing solutions often lack flexible configuration capabilities, have poor scalability and maintainability, increasing system migration and subsequent operational costs. Summary of the Invention
[0004] The main purpose of this application is to provide a business data processing method, apparatus, device, storage medium and product, which aims to solve the key problems of achieving high-performance document aggregation, frequent updates and batch queries under the information technology stack.
[0005] To achieve the above objectives, this application proposes a business data processing method, the method comprising: Obtain business data from the upstream business database; The business data in the upstream business database is synchronized to the target database through the database incremental synchronization middleware; The scheduling service periodically calls the business service, queries the target database in batches according to the cursor, and pushes the updated data to the corresponding table extraction topic. When the data aggregation task starts, a pre-configured configuration file is loaded, and multiple data extraction topics are dynamically consumed according to the configuration file to obtain multi-source data streams; The multi-source data streams are aggregated using the Map operator and corresponding data aggregation logic to obtain aggregated data.
[0006] In one embodiment, the step of aggregating the multi-source data streams using a Map operator and corresponding data aggregation logic to obtain aggregated data includes: The data stream is received through the WindowAll operator of the Flink data aggregation task, and the primary key of the micro-batch data is deduplicated using a custom Trigger. When the preset triggering conditions are met, the deduplicated primary key set will be distributed to the task slots of the downstream Map operator; In each task slot of the Map operator, the business data extraction interface is called concurrently according to the configuration file to query the target database in batches to obtain complete row data. After all concurrent query results are returned, the data from multiple tables are merged and assembled into the target document structure according to the primary key dimension, and the target document is output to the data aggregation Topic; The downstream data extraction task consumes the data aggregation topic and imports the target documents into the target query engine in batches to complete the closed-loop output of the data link.
[0007] In one embodiment, the incremental synchronization middleware is Canal, and the step of synchronizing business data from the upstream business database to the target database through the database incremental synchronization middleware includes: The Canal simulates the MySQL master-slave replication protocol, subscribes to the binlog of the upstream business database, parses binlog events, and pushes incremental data to the corresponding table in the target database in real time.
[0008] In one embodiment, the step of periodically invoking the business service through the scheduling service, querying the updated data in the target database in batches according to the cursor, and pushing the updated data to the corresponding table extraction topic includes: Batch extraction tasks are triggered by the scheduling service at preset time intervals; The business service executes a cursor pagination query to retrieve data records that have changed since the last extraction from the target database in batches, obtains updated data, and pushes the updated data to the corresponding table extraction topic; wherein, each business table corresponds to an independent extraction topic; After extraction is completed, record the cursor position for use in the next round of scheduling and extraction.
[0009] In one embodiment, receiving the data stream through the WindowAll operator of the Flink data aggregation task and performing primary key deduplication on the micro-batch data using a custom Trigger includes: In the WindowAll operator of the Flink data aggregation task, a dual triggering mechanism based on timers and counters is adopted through a custom trigger. When the number of data entries cached in the window of the WindowAll operator reaches the preset batch size, the window calculation is triggered. At the same time, the timer starts from the first data entry into the window, and when the preset window time is reached, the window calculation is forcibly triggered. After the window is triggered, the micro-batch data is deduplicated according to the primary key field, retaining the final data version under the same primary key.
[0010] In one embodiment, the step of distributing the deduplicated primary key set to the task slots of the downstream Map operator when a preset trigger condition is met includes: When the preset triggering conditions are met, the deduplicated primary key set is dynamically distributed to the task slots of downstream Map operators that are currently idle, using either a round-robin or load balancing strategy.
[0011] In one embodiment, the step of concurrently calling various business data extraction interfaces according to the configuration file in each task slot of the Map operator to batch query the target database to obtain complete row data includes: In each task slot of the Map operator, the primary key set is split into multiple concurrent query subtasks according to the table relationships in the configuration file. Each subtask calls the corresponding business data extraction interface through an HTTP or RPC interface and uses the IN statement to query data from a specific table in the target database in batches. The concurrent query supports configuring the batch size parameter of a single IN query to control the amount of data queried in a single query.
[0012] In one embodiment, the configuration file is used to describe the field mapping, table relationships, primary key fields, aggregation rules, and personalized performance parameters of a single data link; the personalized performance parameters include: Flink task parallelism, concurrent thread pool size, window time, and maximum batch processing size of the window.
[0013] In one embodiment, the method further includes: During the deployment of the new solution for business data processing, the new solution and the original MongoDB solution are run in parallel. After the new solution is verified to meet the standards through comparison, the business traffic is smoothly switched. The business side is unaware of the switch and rollback is supported.
[0014] Furthermore, to achieve the above objectives, this application also proposes a business data processing apparatus, the apparatus comprising: The acquisition module is used to acquire business data from the upstream business database; The synchronization module is used to synchronize business data from the upstream business database to the target database through the database incremental synchronization middleware. The push module is used to periodically call the business service through the scheduling service, query the updated data in the target database in batches according to the cursor, and push the updated data to the corresponding table extraction topic; The loading module is used to load a pre-configured configuration file when the data aggregation task starts, and dynamically consume multiple data extraction topics according to the configuration file to obtain multi-source data streams; The aggregation module is used to aggregate the multi-source data streams by employing the Map operator and corresponding data aggregation logic to obtain aggregated data.
[0015] In addition, to achieve the above objectives, this application also proposes a business data processing device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the business data processing method as described above.
[0016] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the business data processing method described above.
[0017] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the business data processing method described above.
[0018] One or more technical solutions proposed in this application have at least the following technical effects: acquiring business data from an upstream business database; synchronizing the business data from the upstream business database to a target database using a database incremental synchronization middleware; periodically calling business services through a scheduling service, querying updated data in the target database in batches according to a cursor, and pushing the updated data to the corresponding table extraction topic; loading a pre-configured configuration file when the data aggregation task starts, dynamically consuming multiple extraction topics according to the configuration file to obtain multi-source data streams; and using a Map operator and corresponding data aggregation logic to aggregate the multi-source data streams to obtain aggregated data. This application's solution achieves incremental synchronization, extraction, consumption, and aggregation of multi-source business data in a near real-time data link without relying on MongoDB, based on a fully domestic technology stack (TiDB+Canal+Flink+Kafka). This solves the problem that MongoDB has no alternative product in the context of domestic IT innovation. A unified configuration approach reduces the cost of replacing MongoDB; developers can adapt to new aggregation logic simply by modifying configuration files, eliminating the need for repetitive code development. Simultaneously, dual-track parallel processing and configuration switches enable seamless switching on the business side, supporting rapid rollback and reducing system migration risks. Furthermore, the target database (TiDB backup database) isolates the online business database from the near real-time aggregation link, ensuring the stability of the business system. Attached Figure Description
[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a schematic diagram of the original MongoDB architecture in a near real-time pipeline; Figure 2 This is a schematic diagram of the overall architecture involved in the business data processing method of this application; Figure 3 This is a flowchart illustrating the first embodiment of the business data processing method of this application. Figure 4 This is a schematic diagram illustrating the combined use of Flink operators in the embodiments of the business data processing method of this application; Figure 5This is a graph showing the change in database CPU usage during the testing period involved in the implementation of the business data processing method of this application; Figure 6 This is a graph showing the test results of the performance of the business data processing method embodiment of this application as a function of Flink parallelism. Figure 7 This is a performance comparison chart between the proposed solution and the MongoDB solution; Figure 8 This is a schematic diagram of the module structure of the business data processing device according to an embodiment of this application; Figure 9 This is a schematic diagram of the device structure of the hardware operating environment involved in the business data processing method in the embodiments of this application.
[0022] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0023] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0024] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0025] The main solution of this application embodiment is as follows: Business data is acquired from the upstream business database; the business data in the upstream business database is synchronized to the target database using a database incremental synchronization middleware; the business service is periodically called through a scheduling service, and the updated data in the target database is queried in batches according to a cursor, and the updated data is pushed to the corresponding table extraction topic; when the data aggregation task starts, a pre-configured configuration file is loaded, and multiple extraction topics are dynamically consumed according to the configuration file to obtain multi-source data streams; the multi-source data streams are aggregated using the Map operator with corresponding data aggregation logic to obtain aggregated data. This system enables incremental synchronization, extraction, consumption, and aggregation of multi-source business data in a near real-time data pipeline without relying on MongoDB. It utilizes a fully domestically developed technology stack (TiDB + Canal + Flink + Kafka) to solve the problem of MongoDB being irreplaceable in domestic IT innovation scenarios. A unified configuration approach reduces the cost of replacing MongoDB, allowing developers to adapt to new aggregation logic simply by modifying configuration files, eliminating the need for repetitive code development. Furthermore, dual-track parallel processing and configuration switches enable seamless switching on the business side, supporting rapid rollback and reducing system migration risks. Finally, the target database (TiDB backup database) isolates the online business database from the near real-time aggregation pipeline, ensuring the stability of the business system.
[0026] This application's embodiments take into account that, currently, in near real-time data links, MongoDB is widely used for storing and processing aggregated document data across multiple databases and tables due to its excellent support for complex document structures, flexible data models, and partial update operations. For example... Figure 1 As shown, Figure 1 This is a schematic diagram of the original MongoDB architecture in a near real-time data aggregation pipeline. Data is exported from MongoDB, then imported into the Elasticsearch document database via Kafka for high-performance querying and statistics. MongoDB is located at a critical point in the data aggregation pipeline. The main steps are as follows: 1. The scheduling service periodically calls the business service to query new data in batches based on cursors and pushes it to the corresponding Kafka data extraction topic (database and service correspond one-to-one, data table and data extraction topic correspond one-to-one). See [link / details]. Figure 1 ①, ②, and ③ in the text; 2. The Flink data aggregation job reads the configuration and consumes the extracted topics, batch updating and adding MongoDB document data based on the primary key. See [link to Flink data aggregation job]. Figure 1 ④ in the middle; 3. The Flink data extraction job consumes data from the MongoDB table extraction topic, performs batch queries to retrieve updated documents from MongoDB, and finally outputs the documents to the data aggregation topic. See [link / details]. Figure 1 Points ⑤, ⑥, ⑦, and ⑧ in the diagram show that in steps 2 and 3, MongoDB, as an intermediate document database, provides batch data addition, partial update, and query functions.
[0027] In addition, MongoDB is also used as a business database in some online transaction processing scenarios. This model demonstrates high throughput and development efficiency in near real-time scenarios where data formats are not fixed, updates are frequent, and real-time requirements are not high.
[0028] However, existing technical solutions have significant drawbacks. Firstly, MongoDB, being a foreign open-source product, does not meet the national requirements for independent and controllable IT infrastructure development. Furthermore, there is no mature direct alternative in the domestic IT innovation (AK) technology stack, posing compliance risks and supply security concerns. Secondly, current replacement solutions lack a unified and efficient technical path. Direct migration to traditional relational databases or other NoSQL products often faces problems such as insufficient document structure support, decreased update performance, high development redundancy, and significant architectural changes, making it difficult to achieve a smooth replacement while maintaining system performance, stability, and business continuity. Simultaneously, existing solutions often lack flexible configuration capabilities, have poor scalability and maintainability, increasing system migration and subsequent operational costs.
[0029] To address the aforementioned issues, this application proposes a solution that replaces the MongoDB functionality with a domestically developed technology stack.
[0030] This solution proposes a domestic alternative to MongoDB in a near real-time data link, combining... Figure 2 The overall architecture diagram shown aims to address the key technical challenges of achieving high-performance document aggregation, frequent updates, and batch queries within the domestic IT innovation technology stack. This solution introduces the domestically developed distributed database TiDB and the incremental synchronization tool Canal, and optimizes the combination and concurrency mechanisms of Flink stream processing operators. This allows for maintaining or improving the throughput performance of the existing pipeline without relying on MongoDB. Simultaneously, it supports configurable replacement and smooth dual-track switching, minimizing the impact on business systems and providing a feasible, efficient, and self-controllable alternative path for large-scale MongoDB decommissioning.
[0031] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device, business data processing device, or system capable of performing the above functions. The following description uses a business data processing system as an example to illustrate this embodiment and the subsequent embodiments.
[0032] Based on this, the embodiments of this application provide a business data processing method, referring to... Figure 3 , Figure 3 This is a flowchart illustrating the first embodiment of the business data processing method of this application.
[0033] In this embodiment, the business data processing method includes steps S10 to S50. The following provides a detailed explanation of each step.
[0034] like Figure 3 As shown, the first embodiment of this application proposes a business data processing method, the method comprising: Step S10: Obtain business data from the upstream business database; Combination Figure 1 and Figure 2 As shown, Figure 1 The original MongoDB architecture in the near real-time pipeline was demonstrated, in which MongoDB is located in a key link of the data aggregation pipeline and undertakes the functions of batch data addition, partial update and query. Figure 2The overall architecture of this application demonstrates the complete data chain, which synchronizes MySQL business data to TiDB via Canal, and then extracts and aggregates the data using a scheduling service and Flink. Specifically, TiDB, a domestic distributed database, is used instead of MongoDB as the backup database for aggregation queries. Canal is used to achieve incremental data synchronization, and the Flink stream processing framework is used to achieve data deduplication, distribution, and aggregation.
[0035] First, retrieve business data from the upstream business database. Then, combine... Figure 2 As shown in ①, the upstream business database is a relational database, such as a MySQL database, which stores various raw data records of the business system, including but not limited to business data from multiple databases and tables such as user information, order data, and product information. This business data is the raw data source for subsequent data aggregation processing.
[0036] Step S20: Synchronize the business data in the upstream business database to the target database through the database incremental synchronization middleware; Then, the business data in the upstream business database is synchronized to the target database through the database incremental synchronization middleware.
[0037] Combination Figure 2 As shown in ②, the incremental synchronization middleware is Canal. Canal is an open-source component from Alibaba based on incremental log parsing of MySQL databases. Its core function is to provide incremental data subscription and consumption.
[0038] In this embodiment, Canal simulates the MySQL master-slave replication protocol and subscribes to the binlog logs of the upstream business database. Specifically, Canal simulates the interaction protocol of a MySQL slave, disguising itself as a MySQL slave and sending a dump request to the MySQL master. After receiving the dump request, the MySQL master begins pushing binary logs to Canal. Canal receives and parses the binlog object (originally a byte stream), and pushes incremental data (including data change events such as INSERT, UPDATE, and DELETE) to the corresponding tables in the target database in real time.
[0039] The target database is TiDB, a domestically developed distributed database. TiDB is an open-source distributed database developed in China, compatible with the MySQL protocol, and possesses excellent horizontal scalability.
[0040] Through the aforementioned Canal synchronization mechanism, incremental data in the upstream MySQL business database is synchronized to TiDB in real time, with synchronization latency controlled within milliseconds to seconds. This synchronization process is non-intrusive to the upstream business database and does not affect normal online transaction processing (OLTP). The purpose of synchronizing data to TiDB is twofold: firstly, to isolate the real-time online business database from the near-real-time link, avoiding pressure on the business database from high-frequency batch queries during subsequent data aggregation; secondly, TiDB, as a domestically developed database, meets the requirements of independent and controllable information technology construction.
[0041] Step S30: Periodically call the business service through the scheduling service, query the updated data in the target database in batches according to the cursor, and push the updated data to the corresponding table extraction topic; Next, combined Figure 2 As shown in ③, ④, and ⑤, the scheduling service periodically calls the business service, queries the updated data in the target database in batches according to the cursor, and pushes the updated data to the corresponding table extraction topic.
[0042] The scheduling service is an independent background service process that triggers batch extraction tasks at preset time intervals (e.g., every minute). The cursor is a mechanism used in database queries to paginate and traverse result sets. By recording the position of each query (i.e., the position of the last record extracted last time), incremental extraction is achieved—only data records that have changed since the last extraction are queried each time, avoiding a full scan.
[0043] The updated data refers to data records that have been added or changed since the last extraction. Each business table corresponds to an independent extraction topic (i.e., a topic in Kafka) to achieve data source isolation. Batch extraction size (e.g., 1000 records per extraction) and scheduling frequency (e.g., once per minute) support personalized configuration to adapt to the throughput requirements of different pipelines. After the push is completed, the cursor position is recorded for use in the next round of scheduling and continued extraction. Through the scheduling service and cursor mechanism, efficient periodic and batch extraction of incremental data from TiDB is achieved.
[0044] Step S40: When the data aggregation task starts, load the pre-configured configuration file, and dynamically consume multiple data extraction topics according to the configuration file to obtain multi-source data streams; Then, when the data aggregation task starts, a pre-configured configuration file is loaded, and multiple data extraction topics are dynamically consumed according to the configuration file to obtain multi-source data streams. The data aggregation task is a Flink stream processing task. Flink is an open-source distributed stream processing framework that supports high-throughput, low-latency stream data processing.
[0045] The configuration file is a document that uniformly describes the metadata of a single data link. Its content includes at least: field mapping (defining the correspondence between source table fields and target document fields), table association (defining the primary and foreign key association methods between multiple tables), primary key field (the field that identifies the uniqueness of data records), aggregation rules (defining how to merge data from multiple tables into the target document structure), and personalized performance parameters.
[0046] The personalized performance parameters include, but are not limited to: Flink task parallelism (controlling the number of parallel threads executing a task), concurrent thread pool size (controlling the number of threads performing concurrent queries in the Map operator), window duration (controlling the duration of the window in the WindowAll operator), and maximum batch size of the window (controlling the maximum number of data rows cached in the window in the WindowAll operator).
[0047] Furthermore, the details of the configuration implementation of the configuration file can be as follows: The configuration file can be in JSON, YAML, or XML format; this example uses YAML. Field mapping defines the correspondence between source table fields and target document fields. Through field mapping, developers can flexibly control which source table fields are included in the target document, as well as the names and data types of the fields in the target document. Table relationships define the association methods between multiple tables participating in the aggregation. The primary key field defines the field that identifies the uniqueness of data records. Aggregation rules define the specific method of data aggregation, such as simple field merging or calculations (e.g., summation, average, etc.). For most document aggregation scenarios, field merging is sufficient. Developers can complete the configuration and integration by modifying the configuration file and importing the JAR package encapsulated in this solution, without requiring additional code development. The JAR package encapsulates the core logic of this solution, including Canal synchronization configuration, scheduling extraction logic, Flink window operator logic, Map operator aggregation logic, etc. Developers only need to import this JAR package into their project and provide the configuration file to achieve a smooth switch from the original MongoDB to the new solution. Compared to the original MongoDB solution, which required writing separate aggregation code for each table, this solution's configuration-based approach significantly reduces the amount of code development, making the configuration more centralized and easier to maintain.
[0048] When a Flink task starts, it parses the configuration file and automatically creates the corresponding number of KafkaConsumer connections based on the configuration. Each data extraction topic corresponds to a data source input stream (DataStream), and the data is consumed in parallel. Developers only need to maintain one configuration file and can access multiple data streams without writing additional connection code.
[0049] Step S50: Using the Map operator and corresponding data aggregation logic, aggregate the multi-source data streams to obtain aggregated data.
[0050] Finally, the multi-source data streams are aggregated using the Map operator and corresponding data aggregation logic to obtain aggregated data. Figure 2 As shown in ⑥, the Map operator is a transformation operator in Flink, used to perform a transformation operation on each input data element and output the transformed result. In this scheme, the Map operator undertakes the core data aggregation and computation tasks, including operations such as deduplication based on the primary key, concurrently querying the target database to obtain complete row data, and merging data from multiple tables by the primary key dimension to generate the target document structure.
[0051] Through the above steps, incremental synchronization, extraction, consumption, and aggregation of multi-source business data in a near real-time data link were achieved without relying on MongoDB, based on a fully domestic technology stack (TiDB+Canal+Flink+Kafka). This solves the problem that MongoDB is irreplaceable in the context of domestic IT innovation. A unified configuration approach reduces the cost of replacing MongoDB; developers can adapt to new aggregation logic simply by modifying configuration files, eliminating the need for repetitive code development. Simultaneously, a smooth, seamless switching between business systems is achieved through dual-track parallel processing and configuration switches, supporting rapid rollback and reducing system migration risks. Furthermore, the TiDB backup database isolates the online business database from the near real-time aggregation link, ensuring the stability of the business system.
[0052] Based on the first embodiment described above, a second embodiment of this application is proposed. In this embodiment, step S50 is further refined by using the Map operator and employing corresponding data aggregation logic to aggregate the multi-source data streams and obtain aggregated data.
[0053] As one implementation method, step S50 involves aggregating the multi-source data streams using a Map operator and corresponding data aggregation logic, including: The data stream is received through the WindowAll operator of the Flink data aggregation task, and the primary key of the micro-batch data is deduplicated using a custom Trigger. When the preset triggering conditions are met, the deduplicated primary key set will be distributed to the task slots of the downstream Map operator; In each task slot of the Map operator, the business data extraction interface is called concurrently according to the configuration file to query the target database in batches to obtain complete row data. After all concurrent query results are returned, the data from multiple tables are merged and assembled into the target document structure according to the primary key dimension, and the target document is output to the data aggregation Topic; The downstream data extraction task consumes the data aggregation topic and imports the target documents into the target query engine in batches to complete the closed-loop output of the data link.
[0054] Specifically, in combination Figure 2 and Figure 4 As shown, Figure 2 Figures ⑤ to ⑧ illustrate the complete flow of data from the Flink aggregation task to the data aggregation topic. Figure 4 This is a schematic diagram illustrating the combined use of Flink operators in this application. Figure 4 It details the dual-trigger mechanism of the custom Trigger in the WindowAll operator, as well as the process of distributing the primary key set from WindowAll to the Map operator, including the collaborative working mechanism between the WindowAll operator and the Map operator.
[0055] First, combined Figure 4 As shown in ① and ②, the data stream is received by the WindowAll operator of the Flink data aggregation task, and primary key deduplication is performed on the micro-batch data using a custom Trigger. The WindowAll operator is a window operator in Flink used to perform window operations on non-keyed data streams.
[0056] The custom trigger is a core component of Flink's window mechanism, determining when a window can be processed by window functions. Flink provides a default trigger for each window allocator; if the default trigger is insufficient, a custom trigger can be specified by calling the trigger(...) method.
[0057] Specifically, in the WindowAll operator of the Flink data aggregation task, a dual-trigger mechanism based on timers and counters is adopted through a custom trigger. Specifically, window calculation is triggered when the number of data entries cached within the window of the WindowAll operator reaches the preset batch size (i.e., the maximum batch size of the window). This is the counter-based triggering logic—when data enters the window, the onElement method is called to count the number of data entries; when the count reaches a preset threshold, window calculation is triggered. Simultaneously, a timer is started from the first data entry into the window; when the preset window time (e.g., configured as 5 seconds) is reached, window calculation is forcibly triggered. This is the timer-based triggering logic—a processing time timer is registered through Flink's TimeService; when the timer expires, window calculation is triggered. The dual-trigger mechanism adopts a "first-come, first-served" strategy, meaning that if the count reaches the threshold first, the count triggers; if the timer expires first, the timer triggers, effectively preventing data backlog or excessive waiting time.
[0058] Furthermore, the specific implementation details of the custom trigger are as follows: The custom Trigger is a custom implementation class of the Flink Trigger interface, for example, named CountAndTimeTrigger. This class needs to implement several core methods of the Trigger interface: onElement(), onProcessingTime(), onEventTime(), and clear(). In the onElement() method, this method is called whenever a data element enters the window. It maintains a counter, incrementing it by 1 for each new data element. Then, it checks if the counter value has reached the preset batch size. If it has, it returns TriggerResult.FIRE, indicating that window calculation is triggered. Simultaneously, if it is the first data element in the window (the counter changes from 0 to 1), a processing timer is registered through TriggerContext, with a timing duration equal to the preset window time. In the onProcessingTime() method, when the registered processing timer expires, it checks if the window has already been counted and triggered (recorded by a flag). If it hasn't been triggered yet, it returns TriggerResult.FIRE to trigger window calculation; if it has already been triggered, it returns TriggerResult.CONTINUE to prevent re-triggering.
[0059] The core of the dual-trigger mechanism lies in the "OR" relationship between counting trigger and timing trigger, meaning that window calculation is triggered whenever either condition is met. The advantage of this design is twofold: when data traffic is high, counting trigger ensures timely processing of the window after a certain amount of data has accumulated, preventing infinite data backlog and memory overflow; when data traffic is low, timing trigger ensures forced processing of the window after a certain waiting period, preventing excessive latency caused by prolonged data retention. These two trigger mechanisms complement each other, ensuring both processing efficiency in high-throughput scenarios and real-time data transmission in low-throughput scenarios.
[0060] After the window is triggered, the window function is called to process the micro-batch data within the window: it iterates through all data elements within the window, groups them by primary key field, and for multiple records with the same primary key, only the record with the latest timestamp (or the last record to enter the window) is retained, while the rest are discarded, retaining the final data version under the same primary key. The micro-batch data refers to a batch of data records cached within the window, the size of which is controlled by both the window time and the batch size.
[0061] When the preset trigger conditions are met, combined with Figure 4 As shown in ③, the deduplicated primary key set is distributed to the task slots of downstream Map operators. Specifically, when a preset trigger condition is met, the deduplicated primary key set is dynamically distributed to the task slots of downstream Map operators that are currently idle, using either a round-robin or load-balanced strategy. Figure 5 The diagram shows a task slot, which is the basic resource unit for executing tasks in a Flink cluster. Each task slot can run one or more operator subtasks.
[0062] The round-robin strategy involves sequentially assigning the primary key set to each Map task slot. For example, with three Map task slots, the first primary key set is assigned to slot 0, the second to slot 1, the third to slot 2, and so on. Its advantages are simplicity and even load distribution. The load balancing strategy assigns a new primary key set to the least loaded task slot based on its current load (e.g., the number of tasks being processed). Its advantage is dynamic adjustment based on the actual load of each task slot, preventing some slots from becoming overloaded. Regardless of the strategy used, the distributed content is the primary key set (not the complete data record), which significantly reduces the amount of data transferred between the WindowAll operator and the Map operator because the primary key set is much smaller than the complete document data.
[0063] After receiving the primary key set, the Map operator queries the target database for complete row data based on the primary key and then performs aggregation. This "lightweight distribution, heavy computation" design pattern effectively reduces network transmission overhead. By dynamically distributing tasks to idle task slots, it fully utilizes computing resources, avoiding overloading some task slots while leaving others idle. This fully leverages the scalable parallelism of the Map operator and effectively alleviates the single-point performance bottleneck of the WindowAll operator.
[0064] In each task slot of the Map operator, combined Figure 4 As shown in ④ and ⑤, the various business data extraction interfaces are concurrently called according to the configuration file to batch query the target database to obtain complete row data. Specifically, in each task slot of the Map operator, the primary key set is split into multiple concurrent query subtasks based on the table relationships in the configuration file. For example, if the target document needs to associate data from three tables, A, B, and C, the primary key set is split into three concurrent subtasks to query tables A, B, and C respectively. Each subtask calls the corresponding business data extraction service through an HTTP or RPC interface, using the IN statement to batch query data from a specific table in the target database (TiDB), with the query condition being "WHERE primary key IN (primary key list)". The concurrent query supports configuring the batch size parameter for a single IN query to control the amount of data queried in a single query and avoid excessive SQL parsing and compilation overhead caused by an excessively long single IN condition. If the size of the primary key set is greater than the batch size of a single IN query, a query subtask is further split into multiple batches, and multiple IN queries are executed serially or in parallel, and then the results are merged. By splitting the primary key set into multiple concurrent subtasks for parallel querying, the total query time can be significantly reduced.
[0065] After all concurrent query results are returned, combine Figure 4 As shown in ⑤, data from multiple tables is merged and assembled into a target document structure based on the primary key dimension, and the target document is output to the data aggregation Topic. Specifically, the main task waits for all concurrent subtasks to return results (or a similar asynchronous programming mechanism to implement timeout control), and then constructs a Map structure using the primary key as the key to associate data from different tables according to the primary key. During the assembly process, if data from a certain table is missing, it is handled according to the fault tolerance strategy in the configuration file: it can be set to set the field to null, skip the record, or fill it with a default value. After aggregation is completed, combined with... Figure 4 As shown in ⑥, the complete document object is written to the data aggregation topic (i.e., the topic in Kafka).
[0066] Finally, combining Figure 2As shown in ⑧, the downstream data extraction task consumes the data aggregation topic, importing the target documents in batches into the target query engine to complete the closed-loop output of the data chain. The target query engine is, for example, Elasticsearch, a distributed search and analysis engine based on Lucene, suitable for high-performance query and statistical scenarios. The downstream data extraction task consumes the data aggregation topic, obtains document data in batches, and then imports it in batches into Elasticsearch for high-performance query and statistical analysis by the front-end business.
[0067] Combination Figures 5 to 8 The performance test results shown are as follows: Figure 5 As shown, Figure 5 The changes in CPU utilization of the business database during the test were demonstrated, and the difference in CPU utilization between directly querying the business database and querying the TiDB backup database was compared. This verified that the CPU utilization of the business database returned to normal levels after introducing TiDB as the read database. This application introduces the middleware Canal to synchronize data to the domestic TiDB database, changing the high-frequency batch queries in the Flink data aggregation process from querying the business database to querying TiDB. The real-time online business database is isolated from the near-real-time link. This improves the throughput performance of data aggregation without affecting normal business queries.
[0068] The test results are analyzed as follows: Figure 5 As shown, with the increase in Flink's computational parallelism, the CPU utilization of the business database increases, and the interface processing time also increases. The analysis revealed that the query SQL was an IN statement (1000 rows at a time), causing significant database CPU consumption. Further analysis of the IN query execution plan showed that the cost-based query optimizer had already used an index for a range query, but it still caused considerable database pressure. After replacing it with TiDB as Flink's read database, the business database CPU usage returned to normal levels.
[0069] like Figure 6 As shown, Figure 6The test results demonstrate the performance variation with Flink parallelism, showing the trend of system throughput as parallelism increases, and verifying that extending the parallelism of the Map operator can significantly improve system throughput. Observing the curves of Schemes 2 and 3 as parallelism increases reveals that: below a certain parallelism level, system throughput is positively correlated with parallelism, showing a linear increase, indicating that extending the parallelism of the Map operator can significantly improve system throughput and effectively solve the single-point performance problem of the WindowAll operator; beyond this parallelism level, throughput tends to stabilize, indicating that a performance bottleneck has been reached in a certain part of the overall architecture; furthermore, with increasing parallelism, there is no significant change in interface response time and TiDB database CPU utilization. This indicates that introducing TiDB as a data extraction and aggregation read database does not cause database query pressure issues.
[0070] like Figure 7 As shown, Figure 7 This paper presents a performance comparison between our proposed solution and the MongoDB solution, demonstrating the throughput performance of both solutions under different parallelism configurations. It verifies that under reasonable parallelism, the throughput performance of our proposed solution is similar to that of MongoDB. When the parallelism is 1, the throughput performance of the MongoDB solution gradually increases with the number of tables, while the performance of our proposed solution gradually decreases with the number of tables. This is because MongoDB supports partial updates to each table, and each table occupies a task slot; multiple tables are equivalent to multiple degrees of parallelism. In Scheme 3, each interface call in the concurrency process serially queries all table data, so the performance deteriorates with more tables. When the parallelism of our proposed solution increases, its throughput performance is similar to that of the MongoDB solution.
[0071] Through the above steps, on the one hand, the dual-trigger mechanism of the custom trigger in the WindowAll operator achieves fast data deduplication and efficient distribution, effectively alleviating the single-point bottleneck of WindowAll and achieving a balanced optimization of throughput and real-time performance; on the other hand, the scalable parallelism and concurrent query mechanism of the Map operator achieves parallel aggregation of multi-table data, with system throughput increasing nearly linearly with the increase of parallelism. Figure 7 The performance comparison test results shown indicate that, with proper parallelism configuration, the overall performance reaches or even surpasses that of the original MongoDB solution.
[0072] This application's solution standardizes the fields and structure of a data pipeline based on a unified document configuration file. Developers can customize parameters such as parallelism, concurrent thread pool size, window duration, and maximum batch size for each window, depending on the specific pipeline configuration. Furthermore, developers only need to import the JAR package encapsulated in the new solution to achieve a smooth transition from the original MongoDB to the new solution. Compared to the original solution, this requires less configuration and is more centralized, significantly reducing the workload for the team when decommissioning MongoDB and making subsequent iterations and maintenance easier.
[0073] Based on any of the above embodiments, a third embodiment of this application is proposed. In this embodiment, the specific implementation of step S30, which involves periodically calling the business service through the scheduling service, querying the updated data in the target database in batches according to the cursor, and pushing the updated data to the corresponding table extraction topic, is described.
[0074] As one implementation method, step S30, which involves periodically calling the business service through a scheduling service, querying updated data in the target database in batches according to a cursor, and pushing the updated data to the corresponding table extraction topic, may include: Batch extraction tasks are triggered by the scheduling service at preset time intervals; The business service executes a cursor pagination query to retrieve data records that have changed since the last extraction from the target database in batches, obtains updated data, and pushes the updated data to the corresponding table extraction topic; wherein, each business table corresponds to an independent extraction topic; After extraction is completed, record the cursor position for use in the next round of scheduling and extraction.
[0075] Specifically, in combination Figure 1 and Figure 2 As shown, Figure 1 In the existing solution, the scheduling service periodically calls the business service to query new data in batches based on cursors and push it to the corresponding table extraction topic. Figure 2 This solution replaces the query source from MongoDB to TiDB while keeping the interfaces of the scheduling service and the data extraction topic unchanged, thus minimizing the impact on the original business architecture.
[0076] First, combined Figure 2As shown in ③, batch extraction tasks are triggered by a scheduling service at preset time intervals. The scheduling service is an independently running background process, and its triggering mechanism can be implemented using a scheduled task framework (such as Quartz, Elastic-Job, etc.). The preset time interval can be configured according to the business's requirements for data freshness; for example, for near real-time links, it is usually set to 1 minute, 5 minutes, or 10 minutes. The shorter the time interval, the lower the data synchronization latency, but the greater the pressure on the scheduling service and the target database; the longer the time interval, the lower the system overhead, but the lower the data freshness. Users can flexibly adjust this parameter in the configuration file according to actual business needs.
[0077] Then, combine Figure 2 As shown in ④, a cursor pagination query is executed through the business service to retrieve data records that have changed since the last extraction from the target database in batches, thus obtaining updated data, combined with... Figure 2 As shown in ⑤, the updated data is pushed to the corresponding table extraction topic.
[0078] The business service is a service process that provides a data query interface. After receiving a call request from the scheduling service, it executes the specific query logic. The cursor pagination query is a cursor-based pagination traversal technique. Unlike traditional OFFSET pagination, cursor pagination uses the ID or timestamp of the last record in each query as the starting position for the next query, achieving efficient incremental extraction of massive amounts of data.
[0079] The changed data records include newly added records (INSERT) and updated records (UPDATE). To identify which records have changed, an update timestamp field is typically added to the business table, and this field is updated to the current time each time data changes. The conditions for cursor pagination queries are: query records whose update_time is greater than the last extracted timestamp, sort by update_time, and limit the number of records returned to the batch size. After the query is completed, the maximum update_time found in this query is recorded as the new cursor position.
[0080] Each business table corresponds to an independent data extraction topic (i.e., a topic in Kafka). The advantages of this approach are: data from different tables is written to different topics, making it easier for downstream Flink tasks to consume and process data by table dimension, achieving data source isolation, and facilitating the configuration of different consumption strategies and parallelism for different tables. Kafka, as a high-throughput distributed message queue, can well support this multi-topic data distribution scenario. During push operations, a batch sending method can be used, serializing a batch of data records into JSON or Avro format and sending them all at once to the corresponding topic to reduce network I / O operations.
[0081] The batch size is configurable. A larger batch size results in a larger amount of data queried per query, and also increases network transmission and serialization overhead, but reduces the number of queries. A smaller batch size results in more queries, but lower overhead per query. Users can configure this based on network bandwidth, database performance, and real-time requirements.
[0082] After extraction is completed, the cursor position is recorded for use in the next round of scheduling. The cursor position refers to the location identifier of the last record extracted, usually stored in external storage to ensure that extraction can resume after the scheduling service restarts. The stored content includes at least: table name, timestamp of the last extraction, and the maximum ID of the last extraction. When the next round of scheduling is triggered, the last cursor position of the table is first read from external storage, and then the query conditions are constructed based on that position for incremental extraction. By recording the cursor position, the incremental extraction can resume from the breakpoint, ensuring that data is not lost or duplicated. Through this mechanism, even if the scheduling service restarts, extraction can continue from the breakpoint, ensuring that data is not lost or duplicated.
[0083] Combination Figure 5 The test results shown indicate that as Flink's computational parallelism increases, directly querying the business database leads to a significant increase in the business database's CPU utilization. Figure 5 (the upper middle curve), while switching the query to TiDB ( Figure 5 (The lower curve shows that the CPU usage of the business database has returned to normal levels, verifying the effectiveness of offloading queries from the business database to the TiDB standby database.)
[0084] Through the above steps, this embodiment implements an incremental data extraction mechanism based on timestamp cursors. Compared to full extraction, this mechanism significantly reduces the amount of data extracted, lowering the load on the scheduling service and the target database. Simultaneously, it achieves breakpoint resumption functionality through cursor position persistence, ensuring data integrity and continuity. The one-to-one correspondence between tables and topics achieves data source isolation, facilitating subsequent multi-source data consumption and aggregation processing. Configurable extraction batch size and scheduling frequency provide a stable, reliable, flexible, and controllable data source input for Flink aggregation tasks. Figure 5 The test results shown demonstrate that by introducing TiDB as Flink's read database, the CPU usage of the business database returned to normal levels, effectively isolating the online business from the near real-time aggregation link, and providing an efficient and reliable data source for near real-time data aggregation.
[0085] Based on any of the above embodiments, a fourth embodiment of this application is proposed. In this embodiment, the method further includes: During the deployment of the new solution for business data processing, the new solution and the original MongoDB solution are run in parallel. After the new solution is verified to meet the standards through comparison, the business traffic is smoothly switched. The business side is unaware of the switch and rollback is supported.
[0086] Furthermore, this solution supports the parallel operation of the new solution and the original MongoDB solution. After verifying the data accuracy and performance of the new solution through comparison, traffic will be gradually switched to the new solution.
[0087] Specifically, during the dual-track operation phase, upstream business data is simultaneously written to both the original MongoDB and the new TiDB (synchronized via Canal). The scheduling service and Flink tasks run two independent pipelines concurrently: one based on the original MongoDB pipeline, and the other based on the new TiDB solution. Each pipeline produces aggregated document data, which is written to its respective output topic. Operations and testing personnel continuously compare the document data produced by the two pipelines using data comparison tools to verify the data consistency and integrity of the new solution; simultaneously, they compare performance metrics such as throughput, latency, and resource consumption of the two pipelines through a monitoring system to ensure that the performance of the new solution is no less than that of the original solution.
[0088] Once verification is successful, the consumption target on the business side is switched from the output topic of the original MongoDB link to the output topic of the new solution link via a configuration switch. Since the business side consumes the same topic name (achieved through configuration mapping), the switching process is completely transparent to the business side, and the business application is unaware of it.
[0089] If problems are discovered after the switch, a quick rollback to the original MongoDB solution can be achieved through a configuration switch, enabling rapid fault recovery. This dual-track parallel approach and configuration switch mechanism ensure the security and controllability of the new solution's deployment, reducing migration risks.
[0090] Through the above steps, a smooth dual-track switch between the new solution and the original MongoDB solution was achieved without any impact on the business side, and fast rollback was supported, which greatly reduced the risk of system migration and the difficulty of operation and maintenance.
[0091] Compared with existing technologies, the domestic alternative implementation method for MongoDB in the near real-time data link provided in this application has the following technical effects: 1. Domestic Substitution: This project is the first to systematically propose using the domestically developed distributed database TiDB, combined with Canal incremental synchronization and the Flink stream computing framework, to completely replace MongoDB's document aggregation function in a near real-time data link scenario, filling the gap in MongoDB replacement solutions within the domestic IT innovation technology stack. The entire chain adopts a domestic technology stack (TiDB+Canal+Flink+Kafka), meeting the requirements of independent controllability.
[0092] 2. High-performance aggregation: Innovatively combining the custom trigger dual-trigger mechanism of the WindowAll operator with the scalable parallelism of the Map operator, a stream processing mode of "single-point fast distribution + multi-point parallel computation" is formed. Figure 6 and Figure 7 The test results shown demonstrate that, with proper parallelism configuration, the system throughput reaches or even surpasses that of the original MongoDB solution.
[0093] 3. Business Decoupling: Canal is used to synchronize MySQL business data to TiDB, offloading high-frequency batch IN queries from the Flink aggregation task from the business database to the TiDB standby database, achieving physical isolation between online business processes and data aggregation. Combined with... Figure 5 The test results shown indicate that after replacing the database with TiDB as the read database for Flink, the CPU usage of the business database returned to normal levels, avoiding CPU resource contention for online transactions and ensuring the stability of the business system.
[0094] 4. Low-cost migration: The entire data aggregation chain is driven by a unified configuration file. Developers only need to modify the configuration file and import the encapsulated JAR package to complete the switch from MongoDB to the new solution. There is no need to repeat code development, which greatly saves migration costs.
[0095] 5. Smooth Switching: Supports the parallel operation of the new solution and the original MongoDB solution. A smooth switching without the business side being aware can be achieved through configuration switches, and fast rollback is also supported, reducing the risk of system migration.
[0096] Furthermore, to achieve the above objectives, this application also proposes a business data processing apparatus, such as... Figure 8 As shown, the device includes: Module 10 is used to obtain business data from the upstream business database; Synchronization module 20 is used to synchronize business data from the upstream business database to the target database through database incremental synchronization middleware; The push module 30 is used to periodically call the business service through the scheduling service, query the updated data in the target database in batches according to the cursor, and push the updated data to the corresponding table extraction topic; The loading module 40 is used to load a pre-configured configuration file when the data aggregation task starts, and dynamically consume multiple data extraction topics according to the configuration file to obtain multi-source data streams; The aggregation module 50 is used to aggregate the multi-source data streams by using the Map operator and corresponding data aggregation logic to obtain aggregated data.
[0097] The business data processing apparatus provided in this application, employing the business data processing method described in the above embodiments, achieves incremental synchronization, extraction, consumption, and aggregation of multi-source business data in a near real-time data link based on a fully domestically developed technology stack (TiDB+Canal+Flink+Kafka) without relying on MongoDB. This solves the problem of MongoDB being irreplaceable in domestic IT innovation scenarios. It reduces the cost of replacing MongoDB through a unified configuration method; simultaneously, it achieves seamless switching on the business side through dual-track parallelism and configuration switches, supporting rapid rollback and reducing system migration risks; furthermore, it isolates the online business database from the near real-time aggregation link through the target database (TiDB backup database), ensuring the stability of the business system. Compared with the prior art, the beneficial effects of the business data processing apparatus provided in this application are the same as those of the business data processing method provided in the above embodiments, and other technical features in the business data processing apparatus are the same as those disclosed in the methods of the above embodiments, and will not be elaborated here.
[0098] In addition, to achieve the above objectives, this application also proposes a business data processing device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the business data processing method as described above.
[0099] The following is for reference. Figure 9 This document illustrates a structural diagram of a business data processing device suitable for implementing embodiments of this application. The business data processing device in these embodiments may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 9 The business data processing device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0100] like Figure 9 As shown, the business data processing device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 into a random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the business data processing device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the interface 1006: input devices 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the business data processing equipment to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows business data processing equipment with various systems, it should be understood that it is not required to implement or possess all of the systems shown. More or fewer systems may be implemented alternatively.
[0101] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0102] The business data processing device provided in this application, employing the business data processing method described in the above embodiments, achieves incremental synchronization, extraction, consumption, and aggregation of multi-source business data in a near real-time data link without relying on MongoDB, based on a fully domestically developed technology stack (TiDB+Canal+Flink+Kafka). This solves the problem of MongoDB being irreplaceable in domestic IT innovation scenarios. It reduces the cost of replacing MongoDB through a unified configuration method; simultaneously, it achieves seamless switching on the business side through dual-track parallelism and configuration switches, supporting rapid rollback and reducing system migration risks; furthermore, it isolates the online business database from the near real-time aggregation link through the target database (TiDB backup database), ensuring the stability of the business system. Compared with existing technologies, the beneficial effects of the business data processing device provided in this application are the same as those of the business data processing method provided in the above embodiments, and other technical features of this business data processing device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0103] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0104] In addition, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the business data processing method described above.
[0105] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0106] The aforementioned computer-readable storage medium may be included in the business data processing equipment; or it may exist independently and not be assembled into the business data processing equipment.
[0107] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by the business data processing device, the business data processing device performs the following actions: acquires business data from an upstream business database; synchronizes the business data from the upstream business database to a target database via a database incremental synchronization middleware; periodically calls a business service through a scheduling service, queries updated data in the target database in batches using cursors, and pushes the updated data to the corresponding table extraction topic; when a data aggregation task starts, loads a pre-configured configuration file, dynamically consumes multiple extraction topics according to the configuration file, and acquires multi-source data streams; and performs data aggregation on the multi-source data streams using a Map operator and corresponding data aggregation logic to obtain aggregated data.
[0108] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0109] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0110] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0111] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described business data processing methods. This enables incremental synchronization, extraction, consumption, and aggregation of multi-source business data in a near-real-time data link, based on a fully domestically developed technology stack (TiDB+Canal+Flink+Kafka) without relying on MongoDB. This solves the problem of MongoDB being irreplaceable in domestic IT innovation scenarios. It reduces the cost of replacing MongoDB through a unified configuration method; simultaneously, it achieves seamless switching on the business side through dual-track parallelism and configuration switches, supporting rapid rollback and reducing system migration risks; furthermore, it isolates the online business database from the near-real-time aggregation link through the target database (TiDB backup database), ensuring the stability of the business system. Compared with existing technologies, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the business data processing methods provided in the above embodiments, and will not be elaborated upon here.
[0112] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the business data processing method described above.
[0113] The computer program product provided in this application enables incremental synchronization, extraction, consumption, and aggregation of multi-source business data in a near real-time data link without relying on MongoDB, based on a fully domestically developed technology stack (TiDB+Canal+Flink+Kafka). This solves the problem that MongoDB is irreplaceable in domestic IT innovation scenarios. It reduces the cost of replacing MongoDB through a unified configuration method; simultaneously, it achieves seamless switching on the business side without the business being aware of it through dual-track parallel processing and configuration switches, supporting rapid rollback and reducing system migration risks; furthermore, it isolates the online business database from the near real-time aggregation link through the target database (TiDB backup database), ensuring the stability of the business system. Compared with existing technologies, the beneficial effects of the computer program product provided in this application are the same as those of the business data processing methods provided in the above embodiments, and will not be elaborated upon here.
[0114] One or more technical solutions proposed in this application have at least the following technical effects: acquiring business data from an upstream business database; synchronizing the business data from the upstream business database to a target database using a database incremental synchronization middleware; periodically calling business services through a scheduling service, querying updated data in the target database in batches according to a cursor, and pushing the updated data to the corresponding table extraction topic; loading a pre-configured configuration file when the data aggregation task starts, dynamically consuming multiple extraction topics according to the configuration file to obtain multi-source data streams; and using a Map operator and corresponding data aggregation logic to aggregate the multi-source data streams to obtain aggregated data. This application's solution achieves incremental synchronization, extraction, consumption, and aggregation of multi-source business data in a near real-time data link without relying on MongoDB, based on a fully domestic technology stack (TiDB+Canal+Flink+Kafka). This solves the problem that MongoDB has no alternative product in the context of domestic IT innovation. A unified configuration approach reduces the cost of replacing MongoDB; developers can adapt to new aggregation logic simply by modifying configuration files, eliminating the need for repetitive code development. Simultaneously, dual-track parallel processing and configuration switches enable seamless switching on the business side, supporting rapid rollback and reducing system migration risks. Furthermore, the target database (TiDB backup database) isolates the online business database from the near real-time aggregation link, ensuring the stability of the business system.
[0115] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A business data processing method, characterized in that, The method includes: Obtain business data from the upstream business database; The business data in the upstream business database is synchronized to the target database through the database incremental synchronization middleware; The scheduling service periodically calls the business service, queries the target database in batches according to the cursor, and pushes the updated data to the corresponding table extraction topic. When the data aggregation task starts, a pre-configured configuration file is loaded, and multiple data extraction topics are dynamically consumed according to the configuration file to obtain multi-source data streams; The multi-source data streams are aggregated using the Map operator and corresponding data aggregation logic to obtain aggregated data.
2. The method as described in claim 1, characterized in that, The process of aggregating the multi-source data streams using the Map operator and corresponding data aggregation logic to obtain aggregated data includes: The data stream is received through the WindowAll operator of the Flink data aggregation task, and the primary key of the micro-batch data is deduplicated using a custom Trigger. When the preset triggering conditions are met, the deduplicated primary key set will be distributed to the task slots of the downstream Map operator; In each task slot of the Map operator, the business data extraction interface is called concurrently according to the configuration file to query the target database in batches to obtain complete row data. After all concurrent query results are returned, the data from multiple tables are merged and assembled into the target document structure according to the primary key dimension, and the target document is output to the data aggregation Topic; The downstream data extraction task consumes the data aggregation topic and imports the target documents into the target query engine in batches to complete the closed-loop output of the data link.
3. The method as described in claim 1, characterized in that, The incremental synchronization middleware is Canal. The process of synchronizing business data from the upstream business database to the target database using the database incremental synchronization middleware includes: The Canal simulates the MySQL master-slave replication protocol, subscribes to the binlog of the upstream business database, parses binlog events, and pushes incremental data to the corresponding table in the target database in real time.
4. The method as described in claim 1, characterized in that, The step of periodically calling business services through a scheduling service, querying updated data in the target database in batches according to a cursor, and pushing the updated data to the corresponding table extraction topic includes: Batch extraction tasks are triggered by the scheduling service at preset time intervals; The business service executes a cursor pagination query to retrieve data records that have changed since the last extraction from the target database in batches, obtains updated data, and pushes the updated data to the corresponding table extraction topic; wherein, each business table corresponds to an independent extraction topic; After extraction is completed, record the cursor position for use in the next round of scheduling and extraction.
5. The method as described in claim 2, characterized in that, The process of receiving the data stream via the WindowAll operator of the Flink data aggregation task and performing primary key deduplication on the micro-batch data using a custom trigger includes: In the WindowAll operator of the Flink data aggregation task, a dual triggering mechanism based on timers and counters is adopted through a custom trigger. When the number of data entries cached in the window of the WindowAll operator reaches the preset batch size, the window calculation is triggered. At the same time, the timer starts from the first data entry into the window, and when the preset window time is reached, the window calculation is forcibly triggered. After the window is triggered, the micro-batch data is deduplicated according to the primary key field, retaining the final data version under the same primary key.
6. The method as described in claim 2, characterized in that, The step of distributing the deduplicated primary key set to the task slots of the downstream Map operator when the preset trigger condition is met includes: When the preset triggering conditions are met, the deduplicated primary key set is dynamically distributed to the task slots of downstream Map operators that are currently idle, using either a round-robin or load balancing strategy.
7. The method as described in claim 2, characterized in that, In each task slot of the Map operator, according to the configuration file, each business data extraction interface is concurrently called to query the target database in batches to obtain complete row data, including: In each task slot of the Map operator, the primary key set is split into multiple concurrent query subtasks according to the table relationships in the configuration file. Each subtask calls the corresponding business data extraction interface through HTTP or RPC interface and uses IN statement to query data from specific tables in the target database in batches. The concurrent query supports configuring the batch size parameter of a single IN query to control the amount of data queried in a single query.
8. The method according to any one of claims 1-7, characterized in that, The configuration file is used to describe the field mapping, table relationships, primary key fields, aggregation rules, and personalized performance parameters of a single data link; the personalized performance parameters include: Flink task parallelism, concurrent thread pool size, window time, and maximum batch processing size of the window.
9. The method according to any one of claims 1-7, characterized in that, The method further includes: During the deployment of the new solution for business data processing, the new solution and the original MongoDB solution are run in parallel. After the new solution is verified to meet the standards through comparison, the business traffic is smoothly switched. The business side is unaware of the switch and rollback is supported.
10. A business data processing device, characterized in that, The device includes: The acquisition module is used to acquire business data from the upstream business database; The synchronization module is used to synchronize business data from the upstream business database to the target database through the database incremental synchronization middleware. The push module is used to periodically call the business service through the scheduling service, query the updated data in the target database in batches according to the cursor, and push the updated data to the corresponding table extraction topic; The loading module is used to load a pre-configured configuration file when the data aggregation task starts, and dynamically consume multiple data extraction topics according to the configuration file to obtain multi-source data streams; The aggregation module is used to aggregate the multi-source data streams by employing the Map operator and corresponding data aggregation logic to obtain aggregated data.
11. A business data processing device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the business data processing method as described in any one of claims 1 to 9.
12. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the business data processing method as described in any one of claims 1 to 9.
13. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the business data processing method as described in any one of claims 1 to 9.
