Data processing method and device, electronic equipment and storage medium
By configuring the collection plug-in and writing plug-in for each data synchronization message in the ETL system, combined with the distributed architecture and dynamic weight scheduling, the problem of excessive load and insufficient flexibility of the ETL system during the data synchronization process is solved, and efficient Data processing and load balancing.
Patent Information
- Application Number
- CN202311762192.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-20
- Publication Date
- 2024-10-18
AI Technical Summary
During the data synchronization process, the existing ETL system has problems such as high system load, single points of failure, slave hotspots, and low code limitation flexibility, resulting in low data processing efficiency.
Generate data synchronization messages through management nodes and assign them to back-end nodes, and configure collection plug-ins, write plug-ins and configuration information for each message to achieve multi-process and/or multi-thread processing, optimize collection and writing operations, and dynamically plan task allocation , using distributed locks and weight scheduling to achieve load balancing and disaster recovery.
It improves the efficiency and accuracy of data synchronization message processing, avoids system performance bottlenecks, enhances the flexibility and function reusability of the ETL system, and solves single points of failure and hot spots.
Smart Images

Figure CN118796938A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data processing method, device, electronic device and storage medium. Background Art
[0002] As data is updated and iterated, the construction form of the big data center will inevitably evolve towards a centralized, open, and empowered enterprise-level data center architecture. The construction methods and quality of the core engines of the big data platform in the mobile system, such as collection, cleaning, and conversion (Extract, Transform, Load, ETL) devices, will face more stringent usage challenges.
[0003] The existing ETL devices have the following problems in the process of data synchronization: (1) The collection task scheduling mechanism of traditional ETL is often based on time. This mechanism is relatively simple and direct, but it is easy to cause problems such as excessive system load, overlapping scheduled tasks, and system clock deviation. (2) Distributed architecture load balancing problem. To address the single-point bottleneck problem, the ETL distributed architecture usually adopts the (Master / Slave) master-slave mode. Each node service in the cluster is strictly divided according to the role. The single-point Master node is responsible for distributing tasks, and the Slave is responsible for executing tasks. Centralized distribution is prone to Master single-point failure problems and Slave hot spots. A single Master failure will cause the entire cluster to work abnormally. If the task allocation on the Slave node cannot be dynamically planned, the system performance bottleneck will be concentrated on a certain Slave node when the concurrency is too large or the business logic is too complex, affecting the processing efficiency of the cluster. (3) Low-code ETL systems will limit the flexibility of the ETL system. In the process of simplifying the development process, if the configuration is improperly abstracted or not clearly considered, it will limit the flexibility of the function and fail to handle complex ETL scenarios. At the same time, hiding the underlying design details will limit the program processing performance of the ETL system.
[0004] In summary, the data processing methods of existing ETL systems are inefficient. Summary of the invention
[0005] The embodiments of the present application provide a data processing method, device, electronic device and storage medium to solve the technical problem of low efficiency of the data processing method of the existing ETL system.
[0006] In a first aspect, an embodiment of the present application provides a data processing method, including:
[0007] After receiving the data synchronization request, generating at least one data synchronization message based on the management node, and distributing the data synchronization message to the backend node based on the management node;
[0008] Based on the backend node, configure a collection plug-in, a writing plug-in and configuration information for each data synchronization message;
[0009] Based on the configuration information, synchronizing the data to be synchronized to the target database, wherein the data to be synchronized is acquired based on the acquisition plug-in;
[0010] Based on the write plug-in, the data to be synchronized is written into the target database.
[0011] In one embodiment, based on the acquisition plug-in, obtaining the data to be synchronized includes:
[0012] Acquire the acquisition parameters of the acquisition plug-in from the data synchronization message, wherein the acquisition parameters include the protocol, address, port and path information of the file server;
[0013] Based on the acquisition parameters, the acquisition plug-in is controlled to read the field list and separator of the data file from the file server to obtain the data to be synchronized.
[0014] In one embodiment, writing the to-be-synchronized data to the target database based on the write plug-in includes:
[0015] Obtaining write parameters of the write plug-in, wherein the write parameters include file compression type, directory information, field list, delimiter, and update mode;
[0016] Based on the write parameters, the write plug-in is controlled to write the data to be synchronized into the target database.
[0017] In one embodiment, synchronizing the data to be synchronized to the target database based on the configuration information includes:
[0018] Based on the configuration information, determine the synchronization parameters of the data to be synchronized, the synchronization parameters including transmission speed, number of concurrencies, maximum dirty data record threshold, and dirty data ratio threshold;
[0019] Based on the synchronization parameters, the data to be synchronized is synchronized to the target database.
[0020] In one embodiment, after writing the to-be-synchronized data to the target database based on the write plug-in, the method further includes:
[0021] Determine the return result of the data synchronization message, the return result at least including the number of data read, the number of successful / failed writes, the number of successful / failed data conversions, the time taken for the conversion process, and the total time taken for the entire process;
[0022] Based on the returned result, determining a processing status of the data synchronization message;
[0023] Submit the displacement identifier of the distributed lock to the partition corresponding to the data synchronization message to release the distributed lock, and record the processing status at the same time; wherein, the distributed lock is created based on the subject and partition of the data synchronization message and the displacement identifier.
[0024] In one embodiment, allocating the data synchronization message to the backend node based on the management node includes:
[0025] Determine the CPU load average and available physical memory of the backend node;
[0026] When the CPU load average value and available physical memory of the first target backend node meet the configuration threshold of the data synchronization message, the data synchronization message is allocated to the partition corresponding to the first target backend node; wherein, the first target backend node obtains the data synchronization message from the partition.
[0027] In one embodiment, allocating the data synchronization message to the backend node based on the management node includes:
[0028] Based on the management node, summing the preset weight and the dynamic weight of each backend node to obtain the target weight of the backend node;
[0029] Assign the data synchronization message to the partition corresponding to the second target backend node with the largest target weight, and update the target dynamic weight of the second target backend node; wherein the updated target dynamic weight is obtained by the difference between the target dynamic weight and all the preset weights, and the second target backend node obtains the data synchronization message from the partition.
[0030] In a second aspect, an embodiment of the present application provides a data processing device, including:
[0031] An allocation module, configured to generate at least one data synchronization message based on a management node after receiving a data synchronization request, and allocate the data synchronization message to a backend node based on the management node;
[0032] A configuration module, used to configure the collection plug-in, writing plug-in and configuration information of the back-end node for each data synchronization message;
[0033] A synchronization module, used to synchronize the data to be synchronized to a target database based on the configuration information, wherein the data to be synchronized is acquired based on the acquisition plug-in;
[0034] A writing module is used to write the data to be synchronized into the target database based on the writing plug-in.
[0035] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory storing a computer program, wherein the processor implements the steps of the data processing method described in the first aspect when executing the program.
[0036] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the data processing method described in the first aspect.
[0037] The data processing method, device, electronic device and storage medium provided in the embodiments of the present application are as follows. After receiving a data synchronization request, the embodiments of the present application generate at least one data synchronization message based on the management node, and distribute the data synchronization message to the back-end node based on the management node; based on the back-end node, configure a collection plug-in, a writing plug-in and configuration information for each of the data synchronization messages; based on the configuration information, synchronize the data to be synchronized to the target database, and the data to be synchronized is obtained based on the collection plug-in; based on the writing plug-in, write the data to be synchronized to the target database. The embodiments of the present application configure a collection plug-in, a writing plug-in and configuration information for each data synchronization message, thereby improving the efficiency of processing data synchronization messages. By plug-inizing the collection operation and the writing operation, the accuracy of processing data synchronization messages is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0039] Figure 1 This is one of the flow charts of the data processing method provided in the embodiment of the present application;
[0040] Figure 2 This is the second flow chart of the data processing method provided in the embodiment of the present application;
[0041] Figure 3 It is a configuration diagram of a data synchronization task provided in an embodiment of the present application;
[0042] Figure 4 It is a flowchart of data synchronization message allocation provided by an embodiment of the present application;
[0043] Figure 5 is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0044] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0046] Figure 1 This is one of the flow charts of the data processing method provided in the embodiment of the present application. Figure 1 , the present application embodiment provides a data processing method, including:
[0047] Step 100: after receiving the data synchronization request, generating at least one data synchronization message based on the management node, and distributing the data synchronization message to the backend node based on the management node;
[0048] The execution subject of this application is the ETL system. The ETL system adopts a distributed architecture of management node (Front End, FE) + back-end node (Back End, BE). The management node, which consists of an externally exposed representational state transfer (Representational State Transfer, Restful) interface service and a producer (Producer) of Kafka messages, plays a management role in the distributed architecture. After receiving the data synchronization request, the management node performs authentication judgment, validity verification, and parsing on the data synchronization request. Then, the management node converts the data synchronization request into a data synchronization message (kafka message) through the Producer. The conversion of the data synchronization request into a data synchronization message is initiated by an independent microservice, which can be a stand-alone machine or a cluster composed of multiple microservices. After generating the data synchronization message, the management node distributes the data synchronization message to the back-end node.
[0049] The backend node consists of multiple backend processes, each of which has multiple thread processing capabilities, where a single thread will process a Kafka message. Each backend process (i.e. BE microservice) consists of consumer, message notification parsing, data synchronization task configuration startup, exception handling, logging, database operations, transaction processing and other functions. Figure 4As shown in the figure, each BE microservice can subscribe to a partition in the relevant topic of the Kafka message queue. Each BE microservice reports registration information to the Kafka component of the ETL system, including the average CPU load of the backend node, available physical memory, and partition value. The management node assigns the Kafka message to the corresponding partition, and the backend node obtains the Kafka message from the corresponding partition. The topic of the Kafka message includes the resource data topic and the performance data topic. Figure 4 As shown, the topic of each data synchronization message is divided into multiple shards, and each shard consists of multiple partitions. One BE microservice corresponds to one consumer. Each consumer subscribes to one partition, for example, consumer0 subscribes to partition0; consumer3 subscribes to partition8. For example, the topic of the data synchronization message includes resource data and performance data, wherein the resource data includes hardware resource data and virtual resource data, and the performance data includes version V1 data, version V2 data, and version V3 data.
[0050] When the number of BE microservices is less than the number of partitions, Kafka messages will only be distributed to the subscribed partitions; for example, the resource data topic has 10 partitions, and only 5 BE microservices subscribe to p0, p1, p2, p3, and p4 partitions respectively, then the management node will distribute Kafka messages to p0-p4 partitions.
[0051] When the number of BE microservices is greater than the number of partitions, the extra BE microservices serve as backup services. When a subscribed BE microservice goes down, the backup service will replace the down BE microservice, subscribe to the partition in its topic and replace the information of the Kafka component. For example, topic02 has 5 partitions p0-p4, but 10 microservices b0-b9, then b0-b4 subscribe to p0-p4 respectively, and the remaining b5-b9 serve as backup services. When b3 goes down, the Kafka component does not receive its heartbeat, so it will enable the b5 service and register the new service information to the Kafka component.
[0052] like Figure 2As shown, the ETL system and the data source end pre-negotiate and define the method of data synchronization request, and ETL provides an externally exposed Restful interface as the receiving end of the data synchronization request. When the data source end has data to be synchronized, the data source end pushes the data to be synchronized to the file server of the data source in the negotiated format, for example, the Secure File Transfer Protocol (SFTP) server. The data source generates a data synchronization request based on the data to be synchronized, wherein the data synchronization request contains the connection address, port, account, password of the file server and the path of the data to be synchronized. The data synchronization request is pushed to the Restful interface provided by the ETL end in the form of an http request. After receiving the data synchronization request, the Restful interface parses its notification content and obtains parameters, wherein the parameters include: the connection IP address and port (IP / Port) of the file server, the user name and password of the file server, the path of the file server where the data file to be synchronized is located, the file name list of the data file, and the business type identifier of the data to be synchronized. The management node creates a data synchronization message based on the above parsed content, and distributes the data synchronization message to different partitions of different topics. The back-end node (consumer) obtains the data synchronization message from the corresponding partition.
[0053] Step 200: Based on the backend node, configure the collection plug-in, writing plug-in and configuration information for each data synchronization message;
[0054] like Figure 2 , 3 As shown, the backend node configures the collection plug-in, writing plug-in and configuration information according to different data sources. The backend node obtains the data synchronization message through the consumer. The data synchronization message carries the storage information of the data to be synchronized in the file server. The backend node parses the data synchronization message to obtain the data synchronization object. A data synchronization task is created for each data synchronization object, and a collection plug-in, a writing plug-in and configuration information are configured for each data synchronization task, so as to ensure that the backend node can process the data synchronization message in a multi-threaded and / or multi-process manner.
[0055] Step 300: Based on the configuration information, synchronize the data to be synchronized to the target database, where the data to be synchronized is acquired based on the collection plug-in;
[0056] The backend node parses the data synchronization message and obtains the storage information of the data to be synchronized in the file server. The collection plug-in obtains the storage information and obtains the data to be synchronized from the corresponding file server according to the storage information.
[0057] The configuration information pre-stores synchronization information of the data to be synchronized, and the data to be synchronized is synchronized to the target database according to the synchronization information.
[0058] Optionally, based on the data synchronization message, synchronization information is obtained, and the data to be synchronized is synchronized to the target database according to the synchronization information.
[0059] Step 400: Based on the write plug-in, write the data to be synchronized into the target database.
[0060] The writing plug-in stores writing information of the data to be synchronized in advance, and the writing plug-in writes the data to be synchronized into the target database according to the writing information.
[0061] Optionally, the write plug-in obtains write information based on the data synchronization message, and writes the data to be synchronized into the target database according to the write information.
[0062] The data processing method provided in the embodiment of the present application generates at least one data synchronization message based on the management node after receiving a data synchronization request, and distributes the data synchronization message to the backend node based on the management node; configures a collection plug-in, a writing plug-in and configuration information for each data synchronization message based on the backend node; synchronizes the data to be synchronized to the target database based on the configuration information, and the data to be synchronized is obtained based on the collection plug-in; based on the writing plug-in, writes the data to be synchronized to the target database. The embodiment of the present application realizes multi-process and / or multi-threaded processing of data synchronization messages by configuring a collection plug-in, a writing plug-in and configuration information for each data synchronization message, thereby improving the efficiency of processing data synchronization messages. By plug-inizing the collection operation and the writing operation, the accuracy of processing data synchronization messages is improved.
[0063] In the data synchronization process, the embodiment of the present application separates the acquisition of data synchronization requests and the acquisition of data synchronization tasks, transfers the data synchronization requests to the Kafka queue, and adopts a multi-topic and multi-partition distribution method for data synchronization messages, so as to achieve the purpose of peak shaving of data synchronization messages and avoid the problem of excessive service pressure caused by direct push of data to be synchronized; a centralized distributed + service registration and monitoring method is adopted to achieve pressure load balancing and disaster recovery of each node, and also realize the back-end node expansion and configuration functions to solve the problem of overall performance bottleneck; by collecting plug-ins, writing plug-ins and configuring information, the collection process is standardized and patterned, the repetitive program code writing is reduced, and the functional reusability is improved; the configurable design can also flexibly and conveniently respond to business needs, and quickly realize data synchronization and processing tasks that meet business needs.
[0064] Based on the above embodiment, based on the acquisition plug-in, obtaining the data to be synchronized includes:
[0065] Step 310: Obtaining collection parameters of the collection plug-in from the data synchronization message, the collection parameters including the protocol, address, port and path information of the file server;
[0066] Step 320: Based on the collection parameters, control the collection plug-in to read the field list and separator of the data file from the file server to obtain the data to be synchronized.
[0067] Configure the collection plug-in. The core configuration items of the collection plug-in include the protocol, address, port, and path information of the file server, the field list and separator of the data file to be read, and define the specified string in the read data file as null. Among them, the path information can include multiple. When the data synchronization message carries multiple path messages, multiple remote data files will be specified. Multithreading can be used for data extraction, and the number of concurrent threads is specified by the channel number configuration. Read the field list of the data text. For example, type specifies the type of source data, index specifies that the current column comes from the column in the data text, and value specifies that the current type is a constant.
[0068] like Figure 2 As shown, the backend node parses the data synchronization message to obtain the collection parameters. The collection plug-in obtains the data files corresponding to the data to be synchronized from the file server according to the collection parameters, such as resource data files and performance data files. The collection plug-in reads the field list and separator of the data file, and defines the specified string in the read data file as null, for example, the privacy information in the data file is represented as null, and then obtains the data to be synchronized.
[0069] The embodiment of the present application obtains data files and reads data files based on the collection plug-in, thereby improving the efficiency and accuracy of obtaining the data to be synchronized.
[0070] Based on the above embodiment, based on the write plug-in, writing the data to be synchronized into the target database includes:
[0071] Step 410: Obtain writing parameters of the writing plug-in, the writing parameters including file compression type, directory information, field list, delimiter, and update method;
[0072] Step 420: Based on the write parameters, control the write plug-in to write the data to be synchronized into the target database.
[0073] like Figure 2 As shown, the target database includes a relational database (PostgreSQL). Different write plug-ins are pre-configured for different file systems in the target database, for example, a PostgreSQL write plug-in and a Hadoop distributed file system (HDFS) write plug-in. The PostgreSQL write plug-in writes PostgreSQL resource operational data store (ODS) data to the target database. The HDFS write plug-in writes HDFS performance operational data store (ODS) data to the target database.
[0074] Pre-configure the write parameters of the write plug-in, which include file compression type, directory information, field list, separator, and update mode. The file compression type can be different. For example, the compression type of HDFS files is no compression; the compression types of text files include gzip and bzip2; the compression types of optimized row columnar (orc) files include no compression and quick compression (SNAPPY). The directory information (write path) refers to the directory information stored in the HDFS file system of Hadoop, or the storage directory path of the Hive table on HDFS. The field list is the field list of the structured text to be written. For example, type specifies the type of data, and name refers to the field name. The separator is the separator of the written file. The update mode is the update mode after the data to be synchronized is written. For example, append (Append) means that no processing is performed before the data to be synchronized is written, and the file name generated each time is not conflicting; non-conflict (nonConflict), if there is a file name (fileName) with the same prefix in the directory after writing, an error will be reported, and then the user will be prompted to select a different file name to write the data to be synchronized.
[0075] The embodiment of the present application writes the data to be synchronized into the target database based on the write plug-in, thereby improving the efficiency and accuracy of writing the data to be synchronized.
[0076] Based on the above embodiment, synchronizing the data to be synchronized to the target database based on the configuration information includes:
[0077] Step 330: Based on the configuration information, determine the synchronization parameters of the data to be synchronized, the synchronization parameters including the transmission speed, the number of concurrent connections, the maximum record threshold of dirty data, and the dirty data ratio threshold;
[0078] Step 340: Synchronize the data to be synchronized to the target database based on the synchronization parameters.
[0079] Configuration information includes synchronization parameters for synchronizing data, such as transmission speed, number of concurrent connections, maximum record threshold for dirty data, and threshold for percentage of dirty data. When the collection plug-in is running, it will try to reach the transmission speed but not exceed this value. During data synchronization, the number of concurrent connections during synchronization is controlled. During data synchronization, the maximum record threshold for dirty data is determined. When the collection task exceeds this maximum record threshold, the job reports an error and exits. During data synchronization, the percentage threshold for dirty data is determined. When the collection task exceeds this percentage threshold for dirty data, the job reports an error and exits.
[0080] Furthermore, the configuration information can set general configurations such as cleaning rules.
[0081] The embodiment of the present application synchronizes the data to be synchronized to the target database according to the configuration information, thereby improving the efficiency and accuracy of synchronizing the data to be synchronized.
[0082] Based on the above embodiment, after writing the data to be synchronized into the target database based on the write plug-in, the following steps are also included:
[0083] Step 500: Determine the return result of the data synchronization message, the return result at least includes the number of read data, the number of write success / failure, the number of data conversion success / failure, the conversion process time and the total process time;
[0084] Step 600: Determine the processing status of the data synchronization message based on the returned result;
[0085] Step 700: Submit the displacement identifier of the distributed lock to the partition corresponding to the data synchronization message to release the distributed lock and record the processing status; wherein the distributed lock is created based on the subject of the data synchronization message and its partition and displacement identifier.
[0086] like Figure 2 As shown in the figure, data synchronization message processing consists of producers and consumers. Producers are started as independent microservices and are responsible for creating and distributing data synchronization messages. Consumers consume data synchronization messages and configure and start data synchronization tasks (datax tasks). Each topic of data synchronization messages has multiple partitions, and each partition has its corresponding offset identifier (offset). Non-automatic offset submission is set. Offset is manually submitted only when the data synchronization message is successfully consumed and the writing of the data to be synchronized is completed, ensuring that the data synchronization message is consumed once. When consuming data synchronization messages, a distributed lock is created based on topic+partition+offset. Each time a data synchronization message is consumed, a distributed lock is acquired. After consumption is completed, the distributed lock is released, thereby avoiding repeated consumption of data synchronization messages. Multiple consumers subscribe to different partitions in the topic to share the service pressure of the backend nodes and improve the system operation efficiency.
[0087] During the data synchronization process, the number of read data, the number of successful / failed writes, the number of successful / failed data conversions, the time taken for the conversion process, and the total time taken for the entire process are returned through data synchronization feedback. The program can determine the processing status of the data synchronization message by the returned results. When the processing status is complete, the displacement identifier of the distributed lock is submitted to the partition corresponding to the data synchronization message to release the distributed lock, and the completion of the data synchronization message processing is recorded in the log record. When the processing status is an exception, the exception processing information is recorded in the log record, and the displacement identifier is submitted to the data synchronization message to release the distributed lock.
[0088] Furthermore, when the data synchronization task fails according to the processing process of the data synchronization message, the failure log is recorded, the exception handling process is started, and the node where the exception occurs is determined. If it is determined to be a network connection problem, the data synchronization task is restarted in a loop. If the network connection problem still exists after more than 3 times, the log is recorded to notify the operation and maintenance personnel to handle it. After the network is repaired, the data synchronization message is consumed again and the offset is submitted. If the dirty data exceeds the threshold range during the data synchronization process, it is distributed to the dirty data sorting method to generate a transformer plug-in. After the transformer plug-in converts the data, the task is restarted until it succeeds.
[0089] Furthermore, the ETL system asynchronously returns the processing status of the data synchronization request to the data source end, for example, periodically feeds back the processing status of the data synchronization request to the data source end.
[0090] The embodiment of the present application releases the distributed lock according to the returned result and records the processing flow of each data synchronization message, thereby avoiding repeated processing of data synchronization messages and improving the efficiency of data synchronization message processing.
[0091] Based on the above embodiment, allocating the data synchronization message to the backend node based on the management node includes:
[0092] Step 110: Determine the average CPU load and available physical memory of the backend node;
[0093] Step 120: When the average CPU load and available physical memory of the first target backend node meet the configuration threshold of the data synchronization message, the data synchronization message is distributed to the partition corresponding to the first target backend node; wherein the first target backend node obtains the data synchronization message from the partition.
[0094] Based on the heartbeat mechanism, the backend node reports its service load information to the Kafka component of the ETL system at regular intervals. The management node obtains the service load information of all backend nodes from the Kafka component and determines the overall load of the backend nodes. Based on the load of all backend nodes, it performs polling task distribution on the backend nodes that can send data synchronization messages.
[0095] The basis for the management node to determine the backend node to which the data synchronization message can be sent includes the average CPU load and the available physical memory. For example, the distribution conditions of the data synchronization message are (1) the average CPU load of the backend node is the number of CPU cores × 2; (2) the available physical memory of the backend node is greater than or equal to 0.5G. When the first target backend node meets conditions (1) and (2) at the same time, the data synchronization message is distributed to the first target backend node.
[0096] Furthermore, the maintenance personnel may modify the allocation conditions of the data synchronization messages in the configuration file of the backend node.
[0097] The embodiment of the present application allocates data synchronization messages according to the average CPU load of the backend node and the available physical memory, thereby improving the efficiency of allocating data synchronization messages.
[0098] Based on the above embodiment, allocating the data synchronization message to the backend node based on the management node includes:
[0099] Step 130: Based on the management node, sum the preset weight and dynamic weight of each backend node to obtain the target weight of the backend node;
[0100] Step 140: Assign the data synchronization message to the partition corresponding to the second target backend node with the largest target weight, and update the target dynamic weight of the second target backend node; wherein the updated target dynamic weight is obtained by the difference between the target dynamic weight and all preset weights, and the second target backend node obtains the data synchronization message from the partition.
[0101] In an embodiment of the present application, each backend node has two types of weights: preset weights and dynamic weights. The preset weights are preset weights for each backend node. After the backend node is started, the value of the preset weight remains unchanged. The dynamic weight is an adjustable weight, and the management node calculates and manages the dynamic weights of the backend nodes. The backend node reports its own preset weight to the kafka component based on the heartbeat mechanism. The management node obtains the preset weight of each backend node through the kafka component, and calculates the target weight of each backend node, target weight = preset weight + dynamic weight. The management node selects the second target backend node with the largest target weight, and distributes the data synchronization message to the second target backend node.
[0102] At the same time, the management node sums the preset weights of all backend nodes to obtain the total weight. The difference between the dynamic weight and the total weight of the second target backend node is determined, and the difference is used as the updated target dynamic weight of the second target backend node. In the calculation of the next round of data synchronization message allocation, the updated target dynamic weight is used to calculate the target weight of the second target backend node.
[0103] The embodiment of the present application distributes data synchronization messages according to the preset weight and dynamic weight of the backend node, thereby improving the efficiency of data synchronization message distribution. At the same time, the dynamic weight of the backend node is updated in real time, thereby improving the accuracy of data synchronization message distribution.
[0104] The following describes a data processing device provided in an embodiment of the present application. The data processing device described below and the data processing method described above can be referred to in correspondence with each other. Figure 5 , Figure 5 Schematic diagram of the structure of a data processing device provided in an embodiment of the present application. A data processing device includes:
[0105] The allocation module 501 is used to generate at least one data synchronization message based on the management node after receiving the data synchronization request, and allocate the data synchronization message to the backend node based on the management node;
[0106] Configuration module 502, used to configure the collection plug-in, writing plug-in and configuration information of the backend node for each data synchronization message;
[0107] A synchronization module 503 is used to synchronize the data to be synchronized to the target database based on the configuration information, where the data to be synchronized is obtained based on the acquisition plug-in;
[0108] The writing module 504 is used to write the data to be synchronized into the target database based on the writing plug-in.
[0109] The data processing device provided in the embodiment of the present application generates at least one data synchronization message based on the management node after receiving a data synchronization request, and distributes the data synchronization message to the back-end node based on the management node; configures a collection plug-in, a writing plug-in and configuration information for each data synchronization message based on the back-end node; synchronizes the data to be synchronized to the target database based on the configuration information, and the data to be synchronized is obtained based on the collection plug-in; based on the writing plug-in, writes the data to be synchronized to the target database. The embodiment of the present application realizes multi-process and / or multi-threaded processing of data synchronization messages by configuring a collection plug-in, a writing plug-in and configuration information for each data synchronization message, thereby improving the efficiency of processing data synchronization messages. By plug-inizing the collection operation and the writing operation, the accuracy of processing data synchronization messages is improved.
[0110] In one embodiment, the synchronization module 503 is used to: obtain the data to be synchronized based on the acquisition plug-in, including: obtaining the acquisition parameters of the acquisition plug-in from the data synchronization message, the acquisition parameters including the protocol, address, port and path information of the file server; based on the acquisition parameters, control the acquisition plug-in to read the field list and separator of the data file from the file server to obtain the data to be synchronized.
[0111] In one embodiment, the write module 504 is used to: obtain the write parameters of the write plug-in, which include file compression type, directory information, field list, delimiter and update method; based on the write parameters, control the write plug-in to write the data to be synchronized into the target database.
[0112] In one embodiment, the synchronization module 503 is used to: determine the synchronization parameters of the data to be synchronized based on the configuration information, the synchronization parameters including the transmission speed, the number of concurrency, the maximum record threshold of dirty data, and the dirty data ratio threshold; based on the synchronization parameters, synchronize the data to be synchronized to the target database.
[0113] In one embodiment, the write module 504 is also used to: determine the return result of the data synchronization message, the return result includes at least the number of data read, the number of successful / failed writes, the number of successful / failed data conversions, the time taken for the conversion process, and the total time taken for the entire process; based on the return result, determine the processing status of the data synchronization message; submit the displacement identifier of the distributed lock to the partition corresponding to the data synchronization message to release the distributed lock, and record the processing status at the same time; wherein, the distributed lock is created based on the subject of the data synchronization message and its partition and displacement identifier.
[0114] In one embodiment, the allocation module 501 is used to: allocate data synchronization messages to backend nodes based on the management node, including: determining the average CPU load and available physical memory of the backend nodes; when the average CPU load and available physical memory of the first target backend node meet the configuration threshold of the data synchronization message, allocate the data synchronization message to the partition corresponding to the first target backend node; wherein the first target backend node obtains the data synchronization message from the partition.
[0115] In one embodiment, the allocation module 501 is used to: allocate data synchronization messages to backend nodes based on the management node, including: based on the management node, summing the preset weight and dynamic weight of each backend node to obtain the target weight of the backend node; allocating the data synchronization message to the partition corresponding to the second target backend node with the largest target weight, and updating the target dynamic weight of the second target backend node; wherein the updated target dynamic weight is obtained by the difference between the target dynamic weight and all preset weights, and the second target backend node obtains the data synchronization message from the partition.
[0116] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call a computer program in the memory 630 to execute the steps of the data processing method, for example including:
[0117] After receiving the data synchronization request, at least one data synchronization message is generated based on the management node, and the data synchronization message is distributed to the back-end node based on the management node; based on the back-end node, the collection plug-in, the writing plug-in and the configuration information are configured for each data synchronization message; based on the configuration information, the data to be synchronized is synchronized to the target database, and the data to be synchronized is obtained based on the collection plug-in; based on the writing plug-in, the data to be synchronized is written to the target database.
[0118] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0119] On the other hand, an embodiment of the present application further provides a computer program product, the computer program product comprising a computer program, the computer program may be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer can perform the steps of the data processing method provided in the above embodiments, for example, including:
[0120] After receiving the data synchronization request, at least one data synchronization message is generated based on the management node, and the data synchronization message is distributed to the back-end node based on the management node; based on the back-end node, the collection plug-in, the writing plug-in and the configuration information are configured for each data synchronization message; based on the configuration information, the data to be synchronized is synchronized to the target database, and the data to be synchronized is obtained based on the collection plug-in; based on the writing plug-in, the data to be synchronized is written to the target database.
[0121] On the other hand, an embodiment of the present application further provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores a computer program, wherein the computer program is used to enable a processor to execute the steps of the data processing method provided in the above embodiments, for example, including:
[0122] After receiving the data synchronization request, at least one data synchronization message is generated based on the management node, and the data synchronization message is distributed to the back-end node based on the management node; based on the back-end node, the collection plug-in, the writing plug-in and the configuration information are configured for each data synchronization message; based on the configuration information, the data to be synchronized is synchronized to the target database, and the data to be synchronized is obtained based on the collection plug-in; based on the writing plug-in, the data to be synchronized is written to the target database.
[0123] The non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)), etc.
[0124] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0125] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0126] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A data processing method, characterized in that: include: After receiving the data synchronization request, generating at least one data synchronization message based on the management node, and distributing the data synchronization message to the backend node based on the management node; Based on the backend node, configure a collection plug-in, a writing plug-in and configuration information for each data synchronization message; Based on the configuration information, synchronizing the data to be synchronized to the target database, wherein the data to be synchronized is acquired based on the acquisition plug-in; Based on the write plug-in, the data to be synchronized is written into the target database.
2. The data processing method according to claim 1, characterized in that: Based on the acquisition plug-in, obtaining the data to be synchronized includes: Acquire the acquisition parameters of the acquisition plug-in from the data synchronization message, wherein the acquisition parameters include the protocol, address, port and path information of the file server; Based on the acquisition parameters, the acquisition plug-in is controlled to read the field list and separator of the data file from the file server to obtain the data to be synchronized.
3. The data processing method according to claim 1, characterized in that: The step of writing the to-be-synchronized data into the target database based on the write plug-in includes: Obtaining write parameters of the write plug-in, wherein the write parameters include file compression type, directory information, field list, delimiter, and update mode; Based on the write parameters, the write plug-in is controlled to write the data to be synchronized into the target database.
4. The data processing method according to claim 1, characterized in that: The step of synchronizing the data to be synchronized to the target database based on the configuration information includes: Based on the configuration information, determine the synchronization parameters of the data to be synchronized, the synchronization parameters including transmission speed, number of concurrencies, maximum dirty data record threshold, and dirty data ratio threshold; Based on the synchronization parameters, the data to be synchronized is synchronized to the target database.
5. The data processing method according to claim 1, characterized in that: After the writing plug-in writes the data to be synchronized into the target database, the method further includes: Determine the return result of the data synchronization message, the return result at least including the number of data read, the number of successful / failed writes, the number of successful / failed data conversions, the time taken for the conversion process, and the total time taken for the entire process; Based on the returned result, determining a processing status of the data synchronization message; Submit the displacement identifier of the distributed lock to the partition corresponding to the data synchronization message to release the distributed lock, and record the processing status at the same time; wherein, the distributed lock is created based on the subject and partition of the data synchronization message and the displacement identifier.
6. The data processing method according to claim 1, characterized in that: Allocating the data synchronization message to the backend node based on the management node includes: Determine the CPU load average and available physical memory of the backend node; When the CPU load average value and available physical memory of the first target backend node meet the configuration threshold of the data synchronization message, the data synchronization message is allocated to the partition corresponding to the first target backend node; wherein, the first target backend node obtains the data synchronization message from the partition.
7. The data processing method according to claim 1, characterized in that: Allocating the data synchronization message to the backend node based on the management node includes: Based on the management node, summing the preset weight and the dynamic weight of each backend node to obtain the target weight of the backend node; Assign the data synchronization message to the partition corresponding to the second target backend node with the largest target weight, and update the target dynamic weight of the second target backend node; wherein the updated target dynamic weight is obtained by the difference between the target dynamic weight and all the preset weights, and the second target backend node obtains the data synchronization message from the partition.
8. A data processing device, characterized in that: include: An allocation module, configured to generate at least one data synchronization message based on a management node after receiving a data synchronization request, and allocate the data synchronization message to a backend node based on the management node; A configuration module, used to configure the collection plug-in, writing plug-in and configuration information of the back-end node for each data synchronization message; A synchronization module, used to synchronize the data to be synchronized to a target database based on the configuration information, wherein the data to be synchronized is acquired based on the acquisition plug-in; A writing module is used to write the data to be synchronized into the target database based on the writing plug-in.
9. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, the steps of the data processing method according to any one of claims 1 to 7 are implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and device for transmitting data among multiple data sources
CN105320673A
Data transmission method and streaming data transmission system
CN115473858A
Data synchronization method and device, electronic equipment, medium and program product
CN115544160A
Data synchronization method and device, processor and electronic equipment
CN116414914A
Object tracking method and apparatus, computer device, and storage medium
WO2021031704A1
Cited By
Message forwarding method and device, telecontrol machine and readable storage medium
CN121396972A
