A method, device and system for real-time synchronization of application data across data centers

By using pseudo-slave nodes and Redis off-site timing queues between data centers, real-time synchronization of application data across firewalls and long distances is achieved, solving the problems of cumbersome and delayed data center synchronization in the existing technology, and achieving second-level Synchronous and efficient data transfer.

CN118368296BActive Publication Date: 2024-09-03HANGZHOU YUXIN DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410796749.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-20
Publication Date
2024-09-03
Estimated Expiration
2044-06-20

AI Technical Summary

Technical Problem

The existing technology has a master-slave synchronization relationship in the synchronization process between multiple data centers, resulting in cumbersome operation and maintenance operations, long switching time, and the inability to achieve second-level synchronization of remote application data, and different data centers cannot cross firewalls and Long-distance synchronization, network delay affects normal application operation.

Method used

Adopting the real-time synchronization method of application data across data centers, the pseudo slave node simulates the Redis slave node, obtains operation instructions from Redis for filtering processing, and sends the processing results to the receiving data center to support the synchronization of Redis and database data. Use Redis remote time series queue to achieve data synchronization, supporting data synchronization across firewalls and long distances.

Benefits of technology

It achieves second-level synchronization of remote application data, simplifies operation and maintenance operation switching, supports different data centers to use the same set of codes, avoids the impact of network delays, and ensures the normal operation of applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118368296B
    Figure CN118368296B
Patent Text Reader

Abstract

The present invention provides a method, device and system for real-time synchronization of application data across data centers, belonging to the field of data processing, the system comprising: after receiving a data synchronization request at a sending end data center, the synchronization request is written into a corresponding Redis according to the application operation data type; a synchronization proxy component obtains a Redis operation instruction from a corresponding Redis through a pseudo slave node according to the synchronization request, and processes the Redis operation instruction accordingly according to the application operation data type, obtains a processing result, and sends the processing result to a receiving end data center to be synchronized; the synchronization proxy component of the receiving end data center receives the synchronization request sent by the sending end data center, and writes the synchronization request into Redis according to the application data operation type. The synchronization proxy component of the present invention performs data synchronization through a pseudo slave node, which can achieve second-level switching, and different data centers can use the same set of codes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and in particular to a method, device and system for real-time synchronization of application data across data centers. Background Art

[0002] Since the existing technology has a master-slave synchronization relationship in the process of synchronizing multiple data centers, there are cumbersome confirmation steps for operation switching and long switching time for operation and maintenance. Once a single computer room is unavailable or the network delay is too high, the unavailability time of the entire system becomes longer, and it is impossible to achieve second-level synchronization of long-distance application data. In addition, since different data centers do not use the same set of codes, they cannot support data synchronization across firewalls and thousands of kilometers, so the normal operation of applications will be affected by network delays. Summary of the invention

[0003] In view of this, an object of the embodiments of the present invention is to provide a method, device and system for real-time synchronization of application data across data centers, which can be used to achieve second-level synchronization of long-distance application data.

[0004] To achieve the above-mentioned object, in a first aspect, an embodiment of the present invention provides a method for real-time synchronization of application data across data centers, which is applied to a sending end data center, and the method includes:

[0005] When data to be synchronized is written, receiving a synchronization request for the data to be synchronized;

[0006] Writing the synchronization request into the corresponding Redis according to the application operation data type, wherein the application operation data type includes Redis data and database data;

[0007] According to the synchronization request, a pseudo slave node is used to simulate a Redis slave node to obtain Redis operation instructions from the corresponding Redis; the Redis operation instructions are filtered accordingly according to the application operation data type, the filtering result is obtained, and the filtering result is sent to the receiving end data center to be synchronized.

[0008] In some possible implementations, writing the synchronization request into the corresponding Redis according to the application operation data type specifically includes:

[0009] When the application operation data type is Redis data, directly write the synchronization request into the Redis cache;

[0010] When the application operation data type is database data, data is read from the database through a custom JDBC driver, and triggered by transaction submission, the transaction is written into the Redis local time series queue as a single message.

[0011] In some possible implementations, the filtering of the Redis operation instruction according to the application operation data type, obtaining the filtering result, and sending the filtering result to the receiving end data center to be synchronized specifically includes:

[0012] The Redis operation instructions obtained from the Redis cache are filtered through the pseudo slave node, the Redis operation instructions that will not cause data circular replication are retained, and the retained Redis operation instructions are directly sent to the data center to be synchronized.

[0013] In some possible implementations, the filtering of the Redis operation instruction according to the application operation data type, obtaining the filtering result, and sending the filtering result to the receiving end data center to be synchronized specifically includes:

[0014] Filtering the Redis operation instructions obtained from the Redis local time series queue through the pseudo slave node, retaining the XADD instructions containing a specific prefix in the Redis operation instructions, and generating a continuous sequence number of the Redis local time series queue;

[0015] Packing the filtered Redis operation instructions and the continuous sequence numbers into a synchronization message;

[0016] The synchronization message is sent to the data center to be synchronized via a TCP connection.

[0017] In a second aspect, an embodiment of the present invention provides a method for real-time synchronization of application data across data centers, which is applied to a receiving end data center, and the method includes:

[0018] Receive the synchronization request sent by the sending data center;

[0019] Writing the received synchronization request into the corresponding Redis according to the synchronization request type, wherein the synchronization request type includes a Redis operation instruction and a synchronization message;

[0020] When the synchronization request type is a Redis operation instruction, the synchronization request is directly written into the Redis cache;

[0021] When the synchronization request type is a synchronization message, the messages of the synchronization request are reordered according to the consecutive sequence numbers in the synchronization message and then written into the Redis off-site timing queue.

[0022] In some possible implementations, reordering the synchronization requests according to the consecutive sequence numbers in the synchronization message and then writing them into the Redis remote timing queue specifically includes:

[0023] The synchronization request is written into the Redis cache timing queue through the Lua script of the remote data landing;

[0024] Establish a continuous sequence number index of the Redis cache timing queue according to the continuous sequence number;

[0025] The Lua script submitted through the remote data writes the synchronization request in the Redis cache timing queue into the Redis remote timing queue according to the continuous sequence number index.

[0026] In some possible implementations, the Lua script submitted through remote data writes the synchronization request in the Redis cache timing queue into the Redis remote timing queue according to the continuous sequence number index, specifically including:

[0027] Obtaining a message sequence number indexed by a continuous sequence number and a sequence number to be written locally, and comparing the message sequence number indexed by the continuous sequence number with the sequence number to be written locally;

[0028] Determine whether the minimum value of the message sequence number is greater than the sequence number that should be written locally. If the minimum value of the message sequence number is greater than the sequence number that should be written locally, continue to determine whether the timestamp corresponding to the continuous sequence number index plus the preset time threshold is greater than the current time;

[0029] If the timestamp corresponding to the continuous sequence number index plus the preset time threshold is greater than the current time, indicating that the message has expired, the message of the synchronization request is written into the failed timing queue and the continuous sequence number index is deleted;

[0030] If the timestamp corresponding to the continuous sequence number index plus the preset time threshold is not greater than the current time, indicating that the message is within the validity period, the submission is terminated and the sending end data center is waiting for resending;

[0031] If the minimum value of the message sequence number is not greater than the sequence number that should be written locally, then determining whether the minimum value of the message sequence number is less than the sequence number that should be written locally;

[0032] If the minimum value of the message sequence number is less than the sequence number that should be written locally, indicating that the message has expired, the synchronization request is written into the failed timing queue, and the continuous sequence number index is deleted;

[0033] If the minimum value of the message sequence number is not less than the sequence number to be written locally, indicating that it is the current message, the synchronization request is written into the remote timing queue, the continuous sequence number index is deleted, and the value of the sequence number to be written locally is updated.

[0034] In a third aspect, an embodiment of the present invention provides a device for real-time synchronization of application data across data centers, which is applied to a data center at a sending end, and the device includes:

[0035] A receiving unit, configured to receive a synchronization request for the data to be synchronized when the data to be synchronized is written;

[0036] A writing unit, used to write the synchronization request into the corresponding Redis according to the application operation data type, wherein the application operation data type includes Redis data and database data;

[0037] The synchronization proxy component is used to obtain Redis operation instructions from the corresponding Redis through a pseudo slave node to simulate the Redis slave node according to the synchronization request, perform corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtain the filtering processing result, and send the filtering processing result to the receiving end data center to be synchronized.

[0038] In a fourth aspect, an embodiment of the present invention provides a device for real-time synchronization of application data across data centers, which is applied to a receiving-end data center, and the device includes:

[0039] A synchronization proxy component is used to receive a synchronization request sent by a sending end data center; write the synchronization request into a corresponding Redis according to the type of the received synchronization request, wherein the synchronization request type includes a Redis operation instruction and a synchronization message;

[0040] A cache unit, used for writing the synchronization request directly into the Redis cache when the synchronization request type is a Redis operation instruction;

[0041] The timing queue storage unit is used to reorder the messages of the synchronization request according to the continuous sequence numbers in the synchronization messages and then write them into the Redis off-site timing queue when the synchronization request type is a synchronization message.

[0042] In a fifth aspect, an embodiment of the present invention provides a real-time synchronization system for heterogeneous data across data centers, the system comprising a sending end data center and a receiving end data center;

[0043] The sending-end data center is used to receive a synchronization request for the data to be synchronized when the data to be synchronized is written; write the synchronization request into the corresponding Redis according to the application operation data type, wherein the application operation data type includes Redis data and database data; obtain Redis operation instructions from the corresponding Redis through a pseudo slave node simulating a slave node of Redis according to the synchronization request, perform corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtain the filtering processing result, and send the filtering processing result to the receiving-end data center to be synchronized;

[0044] The receiving data center is used to receive the synchronization request sent by the sending data center; write the synchronization request into the corresponding Redis according to the type of the received synchronization request, and the synchronization request type includes Redis operation instructions and synchronization messages; when the synchronization request type is a Redis operation instruction, write the synchronization request directly into the Redis cache; when the synchronization request type is a synchronization message, reorder the synchronization request message according to the continuous sequence number in the synchronization message and write it into the Redis off-site timing queue.

[0045] In a sixth aspect, an embodiment of the present invention provides an electronic device, including:

[0046] one or more processors;

[0047] A storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement a real-time synchronization method for application data across data centers as described in any one of the first aspect or the second aspect.

[0048] In a seventh aspect, an embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements a method for real-time synchronization of application data across data centers as described in any one of the first aspect or the second aspect.

[0049] The above technical solution has the following beneficial effects:

[0050] The present invention provides a method, device and system for real-time synchronization of application data across data centers, the system comprising: after receiving a data synchronization request at a sending end data center, the synchronization request is written into a corresponding Redis according to the application operation data type; a synchronization proxy component obtains a Redis operation instruction from a corresponding Redis through a pseudo slave node according to the synchronization request, and processes the Redis operation instruction accordingly according to the application operation data type, obtains a processing result, and sends the processing result to a receiving end data center to be synchronized; a synchronization proxy component of a receiving end data center receives a synchronization request sent by a sending end data center, and writes the synchronization request into Redis according to the application data operation type; an embodiment of the present invention can be used for long-distance, second-level application data synchronization. In this embodiment, the synchronization proxy component of the data center synchronizes data from Redis through a pseudo slave node, and the pseudo slave node can more flexibly synchronize data between isomorphic application systems. Since there is no master-slave synchronization relationship, for operation and maintenance, there is no cumbersome confirmation step for operation switching, and switching can be achieved in seconds. At the same time, different data centers can use the same set of codes. This embodiment can support data synchronization across firewalls and across thousands of kilometers without affecting the operation of normal applications due to network delays. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. It is obvious that the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0052] Figure 1 It is a flow chart of a method for real-time synchronization of application data across data centers for a sending end data center according to an embodiment of the present invention;

[0053] Figure 2 It is a flow chart of a method for real-time synchronization of cross-data center application data applied to a receiving-end data center according to an embodiment of the present invention;

[0054] Figure 3 It is a flow chart of writing synchronization requests in a cache timing queue into a remote timing queue according to a continuous sequence number index according to an embodiment of the present invention;

[0055] Figure 4 It is a functional block diagram of a device for real-time synchronization of application data across data centers of a sending end data center according to an embodiment of the present invention;

[0056] Figure 5 It is a functional block diagram of a device for real-time synchronization of cross-data center application data applied to a receiving-end data center according to an embodiment of the present invention;

[0057] Figure 6 This is a data deployment diagram of a cross-data center application data real-time synchronization system according to an embodiment of the present invention;

[0058] Figure 7 It is a functional block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0059] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0060] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0061] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0062] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0063] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0064] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0065] Glossary:

[0066] Strong consistency: The requirement for data reliability requires that data writing must be confirmed by multiple nodes in a distributed system before it is considered complete. For example, in a certain city, there is a server as a node in computer room A and computer room B. When the application in computer room B is writing, the nodes in both computer rooms need to confirm that the writing has been successful before the writing is considered successful. If computer room A fails to write due to a fault, computer room B will also cancel the written data and feedback the write failure to the application. One of the main impacts brought about by this is that all write operations have to wait for the data to flow and be confirmed multiple times between the networks of the two computer rooms, which consumes much more time than the direct access and writing within a single computer room.

[0067] Eventual consistency: Data reliability requirements are lower than strong consistency. Successful writing to a single node returns success. Data synchronization of the remaining nodes can be done in the background. As long as the data is consistent after a period of time, it can be done. Doing so may result in the risk of data loss, but it brings high response efficiency and high throughput to the application. According to the requirements of the "JR / T 0209-2021 Financial Information System Multi-Active Technical Specification Application Strategy" document, only systems involving account types require strong consistency, and other systems can be eventually consistent.

[0068] Availability Zone: Alibaba Cloud's concept of treating different servers of the same application system in multiple computer rooms as being in the same local area network. Each computer room is responsible for a part of the system and interacts through the network. The application collection in each computer room is called an availability zone.

[0069] Redis Lua: Redis's built-in scripting language can be combined with certain business logic. Lua scripts are exclusive and can ensure atomicity, that is, the script content is either all successful or all failed, and the scripts can only be executed sequentially (only one script can be executed at the same time).

[0070] Stream: It is an advanced data structure in Redis, which can be regarded as an ordered message queue. Each message contains a unique ID and a set of key-value pairs.

[0071] XADD instruction: The XADD instruction is a stream addition or stream append instruction, which is used to insert a message or add a new entry to a stream.

[0072] JDBC driver: Java provides a set of standard database access interfaces. Database vendors generally implement the interfaces themselves to create their own drivers to adapt to their own database interaction protocols.

[0073] Database transaction: A key mechanism of the database. A set of instructions submitted is either completely successful or completely failed. At the code operation level, it starts with opening a transaction and ends with committing or rolling back the transaction. In specific implementation, the JDBC driver will cache the instructions first, and when receiving the commit transaction instruction, it will send all the cached instructions at once.

[0074] Redis master node and slave node: This is the core of Redis's high availability mechanism. External applications generally only access Redis's master node for read and write operations, and Redis's slave node is read-only. The two synchronize data through a protocol. It is generally believed that the data of the two are consistent in a macro sense. Therefore, when Redis's master node is unavailable, Redis's slave node can be changed to Redis's master node to replace the work of the master node. A master node can have multiple slave nodes.

[0075] Redis failover: When the Redis master node is unavailable, a certain mechanism is used to promote one of the slave nodes to the new master node, and the other slave nodes become slave nodes of the new master node. All clients are notified to restore services by accessing the new master node.

[0076] Pseudo slave node: simulates the slave node of Redis through application, and needs to support data synchronization instructions and failover instructions. In order to support failover instructions, it is necessary to implement the complete PSYNC2 instructions at the same time, support initiating synchronization instructions, support data synchronization instruction responses, support PING responses, support replication offset reporting, and a data port that supports info instructions from sentinels. At the same time, it cannot be selected as a candidate node for the master node.

[0077] PSYNC2 protocol: After Redis version 4.0, the protocol for data synchronization between Redis master and slave nodes is in the format of RESP message encoding. Its main steps include:

[0078] Step 1: The slave node sends the command REPLCONF listening-port to the master node, which is the slave node data port;

[0079] Step 2: After receiving the response information, the slave node sends the command PSYNC ? -1 to the master node. The question mark "?" means that the current synchronization session identifier is unknown, otherwise it is replaced by the synchronization session identifier; "-1" means that it is unknown where to start copying, otherwise it is replaced by the offset value currently recorded in the slave node.

[0080] Step 3: After receiving the PSYNC instruction, the master node determines whether it is legal. The synchronization session identifier is consistent with the currently used synchronization session identifier; the replication offset value is less than or equal to the current replication offset, and greater than the current replication offset minus the replication buffer size. If it is illegal, it will be processed as PSYNC ? -1.

[0081] Step 4: After receiving the PSYNC ? -1 instruction, the data in the current memory is compressed and packaged in binary format and sent to the slave node from the connection channel where the instruction is located. When the PSYNC instruction data is legal, the equivalent instruction of each change begins to be sent to the slave node, and the master node sends a PING instruction to the slave node according to the configuration (default 10 seconds). The slave node regularly reports the current replication offset to the master node. If it exceeds the configured time threshold (default 10 seconds) without reporting, the master node marks it as invalid. The unreported duration can be viewed by executing the replication information query command (info replication) in the Redis console, which is the delay (lag) value in each slave node information (slave0:xxx).

[0082] Redis Sentinel Mode: A high availability mechanism submitted by the Redis community version. Redis nodes running in Sentinel Mode do not store business data, but discover each other through the master node, build the topology between Redis nodes, and serve as the decision maker and executor of failover. There are several key points about the high availability mechanism of master-slave failover:

[0083] Sentinels discover each other through the master node and establish a Sentinel cluster for decision-making;

[0084] The sentinel obtains information about all slave nodes by executing the info command on the master node;

[0085] The sentinel obtains slave node information by executing the info command on all acquired slave nodes;

[0086] When a sentinel fails over, it only sends a failover instruction to the slave nodes it considers healthy, that is, it makes the healthy slave nodes become the slave nodes of the new master node.

[0087] The embodiment of the present invention provides a data middleware, which is mainly used for the scenario of second-level synchronization of application data across data centers (mainly due to the existence of firewalls, long communication distances, high network latency, etc., which makes it difficult to regard them as being in the same local area network).

[0088] Figure 1 is a flow chart of a method for real-time synchronization of cross-data center application data for a sending end data center according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0089] Step S11, when data to be synchronized is written, receiving a synchronization request for the data to be synchronized;

[0090] Step S12, writing the synchronization request into the corresponding Redis according to the application operation data type, wherein the application operation data type includes Redis data and database data;

[0091] Step S13, according to the synchronization request, the pseudo slave node simulates the Redis slave node to obtain the Redis operation instruction from the corresponding Redis; according to the application operation data type, the Redis operation instruction is correspondingly filtered and processed, and the filtering processing result is obtained, and the filtering processing result is sent to the receiving end data center to be synchronized.

[0092] Specifically, each data center is deployed with several synchronization proxy components, and pseudo slave node components are deployed on the synchronization proxy components. Pseudo slave nodes refer to slave nodes that simulate Redis through applications, and need to support data synchronization instructions and failover instructions. Several ports are opened on the synchronization proxy components in this embodiment (each master node that is monitored requires a corresponding slave node port), because pseudo slave nodes are used for sentinels to discover slave nodes. General open source projects often ignore this when doing slave node protocols, resulting in incomplete protocols. Only when the master node process is completely killed (server restart or kill) will it be connected through retries. If a port is opened and authenticated as a legitimate slave node by the sentinel protocol, it will receive a sentinel notification to connect to the new master node as soon as a failover occurs (a common situation is that the master node is voted offline by the sentinel due to disk failure or execution of some time-consuming instructions, and a failover occurs, but the old master node is always alive).

[0093] In this embodiment, the sending data center can send synchronization requests to multiple data centers at the same time, that is, send them to n data centers (n>=1) at the same time, 1 is a special case, that is, data center A can initiate synchronization to data centers B, C, D... at the same time. At the same time, data centers B, C, D... do not have to be the same system, but the data is synchronized at a certain stage. When application data is written to the sending data center, the data will be written to different Redis according to the application operation data type, such as Redis cache, Redis local time series queue, etc. The synchronization agent component connects the Redis cache and Redis local time series queue through a pseudo slave node, obtains Redis operation instructions from the Redis cache and Redis local time series queue respectively, and processes the Redis operation instructions received by different Redis separately, and sends the processing results to the data center to be synchronized.

[0094] The synchronization agent component of the data center in the embodiment of the present invention obtains synchronization instructions from Redis through a pseudo-slave node. The pseudo-slave node can more flexibly realize data synchronization between homogeneous application systems. Since there is no master-slave synchronization relationship, for operation and maintenance, there are no cumbersome confirmation steps for operation switching, and switching can be achieved in seconds. At the same time, different data centers can use the same set of codes. This embodiment can support data synchronization across firewalls and across thousands of kilometers without affecting the normal operation of applications due to network delays.

[0095] In some embodiments, writing the synchronization request into the corresponding Redis according to the application operation data type in step S12 specifically includes:

[0096] When the application operates Redis data, the application directly writes the synchronization request into the Redis cache;

[0097] When the application operates on database data, the application reads data from the database through a custom JDBC driver and writes the transaction as a single message to the Redis local time series queue when the transaction is committed.

[0098] In this embodiment, Redis includes Redis cache and Redis time series queue (time series queue includes local time series queue and remote time series queue). Redis cache and time series queue are two different groups of Redis. The application can directly access the Redis cache, while the Redis of the time series queue is accessed through a custom JDBC driver. Different application operation types are processed differently during subsequent synchronization. When writing data, if the application operation type is Redis data, the application can write the data directly to the Redis cache; but if the application operation type is database data, the application needs to read data from the database through a custom JDBC driver, and write the transaction as a single message to the Redis local time series queue triggered by transaction submission.

[0099] In some embodiments, step S13 performs corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtains the filtering processing results, and sends the filtering processing results to the receiving data center to be synchronized, specifically including: filtering the Redis operation instructions obtained from the Redis cache through the pseudo slave node, retaining the Redis operation instructions that will not cause data circular replication, and directly sending the retained Redis operation instructions to the data center to be synchronized.

[0100] Specifically, when the application operation data type is Redis data, it is necessary to use master-slave synchronization instructions that will not be repeatedly triggered by repeated writing in the data design. For example, when an instruction such as SET a1 123 is written multiple times, only the first time will trigger the synchronization instruction; while when an instruction such as INCR a2 is written multiple times, it will be triggered each time, which will cause data cyclic replication. At this time, the business system needs to redesign the data structure of a2 to break the cyclic replication. The pseudo-slave node on the synchronization agent component of the data center of the sending end is filtered by the instruction rule (white list), and the instructions that do not meet the requirements are directly discarded. After the instruction filtering, only the aforementioned data such as a1 is allowed to be synchronized, that is, the instructions that will not cause data cyclic replication can be synchronized, and then the Redis operation instructions are directly packaged and sent to the synchronization agent component of the data center of the end to be synchronized. The synchronization agent component of the end to be synchronized writes the Redis corresponding to the end according to the Redis operation instructions.

[0101] In this embodiment, the circular replication between two data centers can also be called data loopback, that is, assuming that a counter count is stored in the data, and the original value is 5; it performs an INCR operation in data center A (in Redis, INCR is a command for increasing the digital value stored in the key, which increases the digital value stored in the key by 1 and returns the increased value), and the value becomes 6; the synchronization instruction at this time is INCR count; after receiving the instruction, data center B executes this instruction to change its own count to 6, but at the same time generates a synchronization instruction INCR count and sends it to data center A; data center A cannot distinguish whether this is sent to data center B by itself, and will execute again, change the count value to 7, and generate a new INCR count instruction to send to data center B; when there are more than three data centers, circular replication will be triggered, that is, when data center A sends to data center B, the change instruction of data center B is sent to data center C, and then the synchronization instruction from data center C to data center A, because it passes through data center B, data center A cannot distinguish whether the instruction sent from data center C is sent to data center B by itself, and so on. Therefore, a design is needed to break this cycle.

[0102] In this embodiment, the following methods can be used to break the data cyclic replication. For example, a String (string type) data is changed to Stream data, the original SET instruction is changed to XADD instruction (adding MAXLEN ~ 1000 parameters to limit its size), and the last entry is read using Stream. Based on the characteristics of the Stream data structure, only data with EntryID (an identifier used to uniquely identify each data record) greater than the last entry can be written, which can break the data loop; of course, multiple changes can also be submitted in a transaction by using Lua scripts, and one of the operation values ​​(the value can use the STREAM data structure) is used as a check, and the failed one is not written, which can also break the data cyclic replication; as an example, in this embodiment, atomic processing can be performed by Lua scripts, first checking that count is 5, and then executing SET count 6. Then, even if the data is transmitted back, since count is 6, the generation instruction will not be triggered again. Of course, in a high-concurrency environment, SET cannot be used to replace INCR, because it is very likely that count will be 10 when SET count 6 comes back.

[0103] In some embodiments, step S13 performs corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtains the filtering processing results, and sends the filtering processing results to the receiving data center to be synchronized, specifically including: filtering the Redis operation instructions obtained from the Redis local timing queue through a pseudo slave node, retaining the XADD instructions containing a specific prefix in the Redis operation instructions, and generating a continuous sequence number for the Redis local timing queue (the continuous sequence number uses a Hash as a storage structure, the queue name as a field name, and the value of the continuous sequence number is a number. Each time the data is successfully landed, the value is +1, and the returned value is the current value corresponding to the queue); packaging the filtered Redis operation instructions and the continuous sequence number into a synchronization message; and sending the synchronization message to the data center to be synchronized via a TCP (Transmission Control Protocol) connection. The XADD instruction is used to add messages to a Stream. If the specified Stream does not exist, a Stream is created. The XADD syntax format is: XADD key ID field value [field value ...]; key is the queue name, which is created if it does not exist; ID is the message id. Using "*" indicates that it is generated by Redis and can be customized, but you must ensure the incrementality yourself; field value is the record.

[0104] Specifically, through a custom JDBC driver, write operations are cached locally, triggered by transaction submission, and the producer of the patented timing queue with the patent publication number CN113505012A and the name of a method, medium, device and system for processing message queues is executed, and the data transaction is written as a single message to the timing queue. In JDBC, it starts with calling the Connection.setAutoCommit(false) method and ends with calling the Connection.commit() / Connection.rollback() method. This embodiment uses the patented timing queue with the patent publication number CN113505012A to convert JDBC write operations (INSERT, UPDATE) into messages written to the message queue in units of transactions, and ensure the reliability of data and the order of writing to a single storage through timing.

[0105] The pseudo-slave node on the synchronization proxy component performs instruction filtering and receives the XADD instruction with a specific prefix (the specific prefix is ​​the key name of the operation disclosed in the patent publication number CN113505012A, which is prefixed with SerialQueue_). It generates a continuous sequence number for the queue. The continuous sequence number uses a Hash as the storage structure and the queue name as the field name. The continuous sequence number value is a number. Each time the data is successfully landed, the value increases by 1, and the returned value is the current value corresponding to the queue. The instruction and the continuous sequence number are packaged into a message and sent to the synchronization proxy component of data center B through a TCP connection. N copies can be sent to prevent loss.

[0106] In this embodiment, the continuous sequence number is used to sort the sent messages according to the order of instructions received by the pseudo-slave node, that is, it is obtained by operating the Redis hash field value increment (Hincrby) command. The continuous sequence number will be assembled in the message communicated by the sending data center to the data center to be synchronized and used as the basis for sorting.

[0107] Figure 2 is a flow chart of a method for real-time synchronization of cross-data center application data applied to a receiving end data center according to an embodiment of the present invention. Figure 2 As shown, the method is applied to a receiving end data center, and comprises the following steps:

[0108] Step S21, receiving a synchronization request sent by the sending end data center, and writing the synchronization request into the corresponding Redis according to the type of the received synchronization request, where the synchronization request type includes a Redis operation instruction and a synchronization message;

[0109] Step S22, when the synchronization request type is a Redis operation instruction, the synchronization request is directly written into the Redis cache;

[0110] Step S23, when the synchronization request type is a synchronization message, the synchronization request messages are reordered according to the consecutive sequence numbers in the synchronization messages and then written into the Redis remote timing queue.

[0111] Specifically, because the data sending end has different types of application operation data, the content of the synchronization request sent is different. When the application operation type is Redis data, the retained Redis operation instruction is sent; and when the application operation data type is database data, the continuous sequence number and the retained Redis operation instruction are packaged into a synchronization message. Therefore, in this embodiment, the types of synchronization requests received by the receiving end are also different. One is the directly received Redis operation instruction, and the other is a synchronization message (the synchronization message includes the Redis operation instruction and the continuous sequence number that retains the XADD instruction). After the synchronization proxy component receives the data synchronization request sent by the sending end data center, it will store the data in the Redis cache and the Redis off-site timing queue respectively for the received synchronization request type; when it needs to be stored in the Redis off-site timing queue, it is necessary to reorder the synchronization requests according to the continuous sequence number in the synchronization message and write them into the Redis off-site timing queue.

[0112] The synchronization agent component of this embodiment synchronizes the data in Redis across data centers through a pseudo-slave node, and ensures data synchronization and traceability through the consistency of the timing queue itself. When the queue name and message offset are the same, the data is consistent as long as the queue lengths in the two data centers are confirmed to be consistent; if there is an inconsistency, it is only necessary to compare the different offsets in the two queues.

[0113] In some embodiments, in step S23, when the synchronization request type is a synchronization message, the synchronization request messages are reordered according to the consecutive sequence numbers in the synchronization messages and then written into the Redis remote timing queue, specifically including:

[0114] Step S231, write the synchronization request into the Redis cache timing queue through the Lua script of the remote data landing;

[0115] Specifically, the Redis off-site time series queue executes the "off-site data landing" Lua script to store the data on the ground. At this time, the message is not written into the Redis off-site time series queue. Instead, the message content and the message stored in the sending data center, the continuous sequence number, the queue name and offset of the sending data center, and the local landing time are stored in a cache time series queue. The writing of the "off-site data landing" Lua script is a temporary queue defined by the reordering. As long as the writing is successful, it is off-site landing. In addition, before writing to the cache queue, the "off-site data landing" Lua script will search according to the characteristics of the message, such as the continuous sequence number, the queue name and offset of the sending data center, etc., to prevent duplication.

[0116] Step S232, establishing a continuous sequence number index of the Redis cache timing queue according to the continuous sequence number;

[0117] In this embodiment, the Lua script of "remote data landing" also needs to establish an index for the message with a continuous sequence number as the retrieval dimension, that is, a continuous sequence number index. The continuous sequence number index is stored in a ZSET, using the queue name and offset of the remote temporary queue as the value, and the sequence number as the index. Among them, ZSET is the abbreviation of SortedSet in Redis. An ordered set in Redis is a set with a score, and each element is sorted according to the score.

[0118] Step S233, the Lua script submitted by the remote data writes the synchronization request in the Redis cache timing queue into the Redis remote timing queue according to the continuous sequence number index.

[0119] Specifically, in this embodiment, after the data is landed through the Lua script of "remote data landing", the Lua script submitted by the remote data writes the synchronization request in the cache timing queue into the remote timing queue according to the continuous sequence number index. At this time, the data is truly written into the remote timing queue.

[0120] In some embodiments, in step S233, the Lua script submitted by the remote data writes the synchronization request in the Redis cache timing queue into the Redis remote timing queue according to the continuous sequence number index, specifically including:

[0121] Get the message sequence number of the continuous sequence number index and the sequence number to be written locally, compare the message sequence number of the continuous sequence number index with the sequence number to be written locally; determine whether the minimum value of the message sequence number is greater than the sequence number to be written locally. If the minimum value of the message sequence number is greater than the sequence number to be written locally, continue to determine whether the timestamp corresponding to the continuous sequence number index plus the preset time threshold is greater than the current time; if the timestamp corresponding to the continuous sequence number index plus the preset time threshold is greater than the current time, indicating that the message has expired, then write the message of the synchronization request into the failed timing queue and delete the continuous sequence number index; if the timestamp corresponding to the continuous sequence number index plus the preset time threshold is greater than the current time, indicating that the message has expired, then write the message of the synchronization request into the failed timing queue and delete the continuous sequence number index; If the time threshold is not greater than the current time, indicating that the message is within the validity period, the submission is terminated and the sending data center is waiting for reissue; if the minimum value of the message sequence number is not greater than the sequence number that should be written locally, it is determined whether the minimum value of the message sequence number is less than the sequence number that should be written locally; if the minimum value of the message sequence number is less than the sequence number that should be written locally, indicating that the message has expired, the synchronization request is written to the failed timing queue and the continuous sequence number index is deleted; if the minimum value of the message sequence number is not less than the sequence number that should be written locally, indicating that it is the current message, the synchronization request is written to the remote timing queue, the continuous sequence number index is deleted, and the value of the sequence number that should be written locally is updated.

[0122] Figure 3 Detailed description of the invention is a flowchart of writing synchronization requests in a cache timing queue into a remote timing queue according to a continuous sequence number index according to an embodiment of the present invention. Figure 3 As shown, in some embodiments, step S233 specifically includes:

[0123] S1, obtain the message sequence number indexed by the continuous sequence number and the sequence number to be written locally, and compare the message sequence number indexed by the continuous sequence number with the sequence number to be written locally;

[0124] S2, determine whether the minimum value of the message sequence number is greater than the sequence number that should be written locally;

[0125] S3, if the minimum value of the message sequence number is greater than the sequence number to be written locally, continue to determine whether the timestamp of the message sent corresponding to the continuous sequence number index plus the preset time threshold is greater than the current time;

[0126] In this embodiment, the preset time threshold can be set according to actual conditions. In this embodiment, the preset time threshold is set to 30s.

[0127] S4, if the timestamp of the message sent corresponding to the continuous sequence number index plus the preset time threshold is greater than the current time, indicating that the message has expired, the synchronization request message is written into the failed timing queue and the continuous sequence number index is deleted;

[0128] S5: If the timestamp of the message sent corresponding to the continuous sequence number index plus the preset time threshold is not greater than the current time, it means that the message is within the validity period, and the submission is terminated, waiting for the sending end data center to resend it.

[0129] S6: If the minimum value of the message sequence number is not greater than the sequence number that should be written locally, determine whether the minimum value of the message sequence number is less than the sequence number that should be written locally.

[0130] Specifically, if the minimum value of the message sequence number in the "continuous sequence number index" is greater than the "local sequence number to be written", it indicates that network transmission loss may have occurred. If its writing time (i.e. timestamp) has exceeded 30s (i.e. preset time threshold), that is, the timestamp plus the preset time threshold (30s) is greater than the current time, the write failure sequence queue is connected and its index is deleted; if it has not timed out, the submission is terminated directly and the sender is waiting for resending.

[0131] S7: If the minimum value of the message sequence number is less than the sequence number that should be written locally, it indicates that the message has expired, and the synchronization request is written to the failed timing queue, and the continuous sequence number index is deleted.

[0132] S8, if the minimum value of the message sequence number is not less than the sequence number that should be written locally, it indicates that it is the current message, the synchronization request is written into the remote timing queue, and the continuous sequence number index is deleted; at the same time, the value of the sequence number that should be written locally is updated.

[0133] Specifically, if the minimum value of the message sequence number in the "continuous sequence number index" is smaller than the "sequence number to be written locally", it indicates that the message has expired and can no longer be written to the time sequence queue. At this time, it is written to the failed time sequence queue, processed by the corresponding compensation mechanism, and its index is deleted. When the minimum value of the message sequence number is neither greater than the sequence number to be written locally nor less than the sequence number to be written locally, it indicates that the minimum value of the message sequence number is equal to the sequence number to be written locally. Only when the minimum value in the "continuous sequence number index" is equal to the "sequence number to be written locally", the message is written to the remote time sequence queue, its index is deleted, and the value of the "sequence number to be written locally" is updated to add 1.

[0134] In this embodiment, "remote data submission" is also implemented through Lua scripts. The script does not directly submit the message just written by the "remote data landing" script, that is, "remote data landing" is the producer of the temporary queue, and "remote data submission" is the consumer of the temporary queue, but the consumption order is not the order of the temporary queue itself, but the order of "continuous sequence number index". At the same time, remote data submission is also the producer of the "remote time series queue"; instead, it searches the "continuous sequence number index" from small to large, and compares its message sequence number with the pointer of "the sequence number to be written locally". This embodiment solves the problem of real-time data disorder caused by complex network environment during data synchronization through dual queues and such reordering.

[0135] In some embodiments, the method also includes setting a message submission number threshold for each submission by a Lua script for off-site data submission. When the number of synchronization request messages submitted each time by the Lua script for off-site data submission is equal to the message submission number threshold, there are still unsubmitted messages in the continuous sequence number index. The Lua script for off-site data submission is triggered by a timer to write the synchronization requests in the cache timing queue into the off-site timing queue according to the continuous sequence number index.

[0136] In this embodiment, due to the exclusivity of Lua scripts, Redis will lose response when it is executed. If too much data is processed and the time of losing response is too long, Redis itself will be abnormal. Therefore, in order to prevent blocking caused by too many messages, a threshold N of message submissions in a single script execution is set, that is, the script will end after processing a maximum of N messages. If there is still unprocessed data in the "continuous sequence number index" after processing N messages, a timer of s seconds is set to re-trigger the "remote data submission" script.

[0137] Figure 4 is a functional block diagram of a device for real-time synchronization of application data across data centers of a transmitting end data center according to an embodiment of the present invention, such as Figure 4 As shown, the device 100 includes:

[0138] The receiving unit 110 is used to receive a synchronization request of the data to be synchronized when the data to be synchronized is written;

[0139] A writing unit 120, configured to write the synchronization request into the corresponding Redis according to the application operation data type, wherein the application operation data type includes Redis data and database data;

[0140] The synchronization proxy component 130 is used to simulate the Redis slave node through the pseudo slave node to obtain Redis operation instructions from the corresponding Redis according to the synchronization request, perform corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtain the filtering processing results, and send the filtering processing results to the receiving end data center to be synchronized.

[0141] For details, refer to Figure 1 The method embodiment shown.

[0142] Figure 5 is a functional block diagram of a device for real-time synchronization of cross-data center application data applied to a receiving end data center according to an embodiment of the present invention. Figure 5 As shown, the device 200 includes:

[0143] The synchronization proxy component 210 receives the synchronization request sent by the sending end data center and writes the synchronization request to Redis according to the application data operation type;

[0144] The cache unit 220 is used to directly write the synchronization request into the Redis cache when the application data operation type is Redis data;

[0145] The timing queue storage unit 230 is used to reorder the synchronization request messages according to the continuous sequence numbers in the synchronization messages and then write them into the Redis off-site timing queue when the application data operation type is database data.

[0146] For details, refer to Figure 2 The method embodiment shown.

[0147] Figure 6 is a deployment diagram of a cross-data center application data real-time synchronization system according to an embodiment of the present invention, such as Figure 6 As shown in the figure, each data center is deployed with a synchronization proxy component, as well as Redis cache, Redis local time series queue, Redis remote time series queue and time series queue consumer. Any data center can send synchronization requests to multiple other data centers to be synchronized at the same time, that is, send to n data centers at the same time (n>=1), that is, data center A can initiate synchronization to data centers A, B, C, D, etc. At the same time, data centers A, B, C, D, etc. do not have to be the same system, but the data is synchronized at a certain stage.

[0148] When application data is written to the data center at the sending end, the data will be written to different Redis according to the application operation data type. Redis includes Redis cache or Redis local time series queue (time series queue includes local time series queue and remote time series queue). Redis cache and time series queue are two different groups of Redis. When the application operation data type is Redis data, the application can directly access the Redis cache. When the application operation data type is database, the Redis of the time series queue is accessed through a custom JDBC driver. The synchronization proxy component connects the Redis cache and the Redis local time series queue through a pseudo slave node, obtains Redis operation instructions from the Redis cache and the Redis local time series queue respectively, and processes the Redis operation instructions received by different Redis separately, and sends the processing results to the data center to be synchronized.

[0149] Because the data type of the sending end data center is different for different application operation data types, the content of the synchronization request sent is different. When the application operation data type is Redis data, the Redis operation instruction that is retained is sent; and when the application operation data type is database data, the continuous sequence number and the retained Redis operation instruction are packaged into a synchronization message. Therefore, in this embodiment, after receiving the data synchronization request sent by the sending end data center, the synchronization proxy component of the receiving end data center will store the data in the Redis cache and the Redis off-site timing queue for the received synchronization request type; when it needs to be stored in the Redis off-site timing queue, it is necessary to reorder the synchronization request according to the continuous sequence number in the synchronization message and write it to the Redis off-site timing queue. In this embodiment, after the Lua script submitted by the off-site data is executed, the data is written into the Redis off-site timing queue, and the message in the message queue is read by the timing queue consumer described in the patent publication number CN113505012A, and decoded into SQL (Structured Query Language) statements to execute database writing.

[0150] This embodiment adopts Figure 6 The architecture of the deployment diagram shown in the figure implements a data synchronization mechanism that can support 7,000 requests per second and 1.5 kB per request in the production environment. When an application in a single data center fails, the switch can be completed immediately, thus ensuring business continuity.

[0151] The embodiment of the present invention uses a time sequence queue to expand the processing of messages on the consumer side, and ensures the reliability of data and the order of writing into a single storage through time sequence.

[0152] The synchronization agent component of this embodiment synchronizes the data in Redis across data centers through a pseudo-slave node, and ensures data synchronization and traceability through the consistency of the timing queue itself. When the queue name and message offset are the same, the data is consistent as long as the queue lengths in the two data centers are confirmed to be consistent; if there is an inconsistency, it is only necessary to compare the different offsets in the two queues.

[0153] The synchronization agent component of the data center in the embodiment of the present invention obtains synchronization instructions from Redis through a pseudo-slave node. The pseudo-slave node can more flexibly realize data synchronization between homogeneous application systems. Since there is no master-slave synchronization relationship, for operation and maintenance, there are no cumbersome confirmation steps for operation switching, and switching can be achieved in seconds. At the same time, different data centers can use the same set of codes. This embodiment can support data synchronization across firewalls and across thousands of kilometers without affecting the normal operation of applications due to network delays.

[0154] The embodiment of the present invention performs cross-data center synchronization when writing data into a timing queue, and ensures data synchronization and traceability through the consistency of the timing queue itself. When the queue name and message offset are the same, the data is consistent as long as the queue lengths in the two data centers are confirmed to be consistent; if there is an inconsistency, it is only necessary to compare the different offsets in the two queues.

[0155] The embodiment of the present invention can more flexibly realize data synchronization between homogeneous application systems through custom JDBC drivers and pseudo-slave nodes. Since there is no master-slave synchronization relationship, for operation and maintenance, there are no cumbersome confirmation steps for operation switching, and switching can be achieved in seconds. At the same time, different data centers can use the same set of codes.

[0156] The embodiments of the present invention can support data synchronization across firewalls and over a distance of thousands of kilometers without affecting the operation of normal applications due to network delays.

[0157] Due to the existence of multi-active in seconds in the embodiment of the present invention, even if the application system is upgraded, it is possible to implement 7×24 hours of non-stop external services by switching data centers.

[0158] The embodiment of the present invention can be used in non-account systems and supports asynchronous data writing.

[0159] Reference below Figure 7 , which shows an electronic device suitable for implementing the embodiments of the present disclosure.

[0160] The terminal devices in the embodiments of the present disclosure may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., as well as fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0161] like Figure 7 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 into a random access memory (RAM) 303. In RAM 303, various programs and data required for the operation of the electronic device are also stored. The processing device 301, ROM 302, and RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.

[0162] Typically, the following devices may be connected to the I / O interface 305: input devices 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 308 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 309. The communication devices 309 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0163] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 309, or installed from the storage device 308, or installed from the ROM 302. When the computer program is executed by the processing device 301, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0164] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0165] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an adhoc network), as well as any currently known or future developed network.

[0166] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0167] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:

[0168] Receive the synchronization request of the data to be synchronized through the sending end data center; write the synchronization request into the corresponding Redis according to the application operation data type, wherein the application operation data type includes Redis data and database data; obtain Redis operation instructions from the corresponding Redis through the pseudo slave node simulating the slave node of Redis according to the synchronization request, perform corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtain the filtering processing result, and send the filtering processing result to the receiving end data center to be synchronized;

[0169] The synchronization request sent by the sending end data center is received by the receiving end data center; the synchronization request is written into the corresponding Redis according to the type of the received synchronization request, and the synchronization request type includes Redis operation instructions and synchronization messages; when the synchronization request type is a Redis operation instruction, the synchronization request is directly written into the Redis cache; when the synchronization request type is a synchronization message, the synchronization request message is reordered according to the continuous sequence number in the synchronization message and then written into the Redis off-site timing queue.

[0170] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk (an object-oriented programming language), C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate 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 a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0171] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0172] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.

[0173] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0174] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0175] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0176] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0177] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A method for real-time synchronization of application data across data centers, characterized in that: Applied to a data center at a sending end, the method includes: When data to be synchronized is written, receiving a synchronization request for the data to be synchronized; Writing the synchronization request into the corresponding Redis according to the application operation data type, wherein the application operation data type includes Redis data and database data; According to the synchronization request, the pseudo slave node simulates the slave node of Redis to obtain the Redis operation instruction from the corresponding Redis; according to the application operation data type, the Redis operation instruction is correspondingly filtered and processed, and the filtering processing result is obtained, and the filtering processing result is sent to the receiving end data center to be synchronized; The filtering process of the Redis operation instruction according to the application operation data type, obtaining the filtering process result, and sending the filtering process result to the receiving end data center to be synchronized specifically includes: The Redis operation instructions obtained from the Redis cache are filtered by the pseudo slave node, the Redis operation instructions that will not cause data circular replication are retained, and the retained Redis operation instructions are directly sent to the data center to be synchronized; or, The filtering process of the Redis operation instruction according to the application operation data type, obtaining the filtering process result, and sending the filtering process result to the receiving end data center to be synchronized specifically includes: Filtering the Redis operation instructions obtained from the Redis local time series queue through the pseudo slave node, retaining the XADD instruction in the Redis operation instruction, and generating a continuous sequence number of the Redis local time series queue; Packing the Redis operation instruction retaining the XADD instruction and the continuous sequence number into a synchronization message; The synchronization message is sent to the data center to be synchronized via a TCP connection.

2. The method according to claim 1, characterized in that The step of writing the synchronization request into the corresponding Redis according to the application operation data type specifically includes: When the application operation data type is Redis data, directly write the synchronization request into the Redis cache; When the application operation data type is database data, data is read from the database through a custom JDBC driver, and triggered by transaction submission, the transaction is written into the Redis local time series queue as a single message.

3. A method for real-time synchronization of application data across data centers, characterized in that: Applied to a receiving end data center, the method includes: Receive the synchronization request sent by the sending data center; Writing the received synchronization request into the corresponding Redis according to the synchronization request type, wherein the synchronization request type includes a Redis operation instruction and a synchronization message; When the synchronization request type is a Redis operation instruction, the synchronization request is directly written into the Redis cache; When the synchronization request type is a synchronization message, the synchronization request message is reordered according to the continuous sequence number in the synchronization message and then written into the Redis remote timing queue; the reordering of the synchronization request message according to the continuous sequence number in the synchronization message and then writing into the Redis remote timing queue specifically includes: The synchronization request is written into the Redis cache timing queue through the Lua script of the remote data landing; Establish a continuous sequence number index of the Redis cache timing queue according to the continuous sequence number; The Lua script submitted through the remote data writes the synchronization request in the Redis cache timing queue into the Redis remote timing queue according to the continuous sequence number index.

4. The method according to claim 3, characterized in that The Lua script submitted through remote data writes the synchronization request in the Redis cache timing queue into the Redis remote timing queue according to the continuous sequence number index, specifically including: Obtaining a message sequence number indexed by a continuous sequence number and a sequence number to be written locally, and comparing the message sequence number indexed by the continuous sequence number with the sequence number to be written locally; Determine whether the minimum value of the message sequence number is greater than the sequence number that should be written locally. If the minimum value of the message sequence number is greater than the sequence number that should be written locally, continue to determine whether the timestamp corresponding to the continuous sequence number index plus the preset time threshold is greater than the current time; If the timestamp corresponding to the continuous sequence number index plus the preset time threshold is greater than the current time, indicating that the message has expired, the message of the synchronization request is written into the failed timing queue and the continuous sequence number index is deleted; If the timestamp corresponding to the continuous sequence number index plus the preset time threshold is not greater than the current time, indicating that the message is within the validity period, the submission is terminated and the sending end data center is waiting for resending; If the minimum value of the message sequence number is not greater than the sequence number that should be written locally, then determining whether the minimum value of the message sequence number is less than the sequence number that should be written locally; If the minimum value of the message sequence number is less than the sequence number that should be written locally, indicating that the message has expired, the synchronization request is written into the failed timing queue, and the continuous sequence number index is deleted; If the minimum value of the message sequence number is not less than the sequence number to be written locally, indicating that it is the current message, the synchronization request is written into the remote timing queue, the continuous sequence number index is deleted, and the value of the sequence number to be written locally is updated.

5. A device for real-time synchronization of application data across data centers, characterized in that: Applied to a data center at a transmitting end, the device comprises: A receiving unit, configured to receive a synchronization request for the data to be synchronized when the data to be synchronized is written; A writing unit, used to write the synchronization request into the corresponding Redis according to the application operation data type, wherein the application operation data type includes Redis data and database data; A synchronization proxy component, used to obtain Redis operation instructions from the corresponding Redis through a pseudo slave node simulating a Redis slave node according to the synchronization request, perform corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtain the filtering processing result, and send the filtering processing result to the receiving end data center to be synchronized; The synchronization proxy component is specifically used to: filter the Redis operation instructions obtained from the Redis cache through the pseudo slave node, retain the Redis operation instructions that will not cause data circular replication, and directly send the retained Redis operation instructions to the data center to be synchronized; or, The synchronization proxy component is specifically used for: filtering the Redis operation instructions obtained from the Redis local timing queue through the pseudo slave node, retaining the XADD instruction in the Redis operation instructions, and generating a continuous sequence number for the Redis local timing queue; packaging the Redis operation instructions retaining the XADD instruction and the continuous sequence number into a synchronization message; and sending the synchronization message to the data center to be synchronized through a TCP connection.

6. A device for real-time synchronization of application data across data centers, characterized in that: Applied to a receiving end data center, the device comprises: A synchronization proxy component is used to receive a synchronization request sent by a sending end data center; write the synchronization request into a corresponding Redis according to the type of the received synchronization request, wherein the synchronization request type includes a Redis operation instruction and a synchronization message; A cache unit, used for writing the synchronization request directly into the Redis cache when the synchronization request type is a Redis operation instruction; A timing queue storage unit, used for reordering the synchronization request message according to the continuous sequence number in the synchronization message and writing it into the Redis remote timing queue when the synchronization request type is a synchronization message; wherein, The timing queue storage unit is specifically used to: write the synchronization request into the Redis cache timing queue through the Lua script of the remote data landing; establish a continuous sequence number index of the Redis cache timing queue according to the continuous sequence number; write the synchronization request in the Redis cache timing queue into the Redis remote timing queue according to the continuous sequence number index through the Lua script submitted by the remote data.

7. A real-time synchronization system for heterogeneous data across data centers, characterized in that: The system includes a sending end data center and a receiving end data center; The sending-end data center is used to receive a synchronization request for the data to be synchronized when there is data to be synchronized written; write the synchronization request into the corresponding Redis according to the application operation data type, wherein the application operation data type includes Redis data and database data; obtain Redis operation instructions from the corresponding Redis through a pseudo slave node simulating a Redis slave node according to the synchronization request, perform corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtain the filtering processing result, and send the filtering processing result to the receiving-end data center to be synchronized; wherein, the performing corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtaining the filtering processing result, and sending the filtering processing result to the receiving-end data center to be synchronized specifically includes: filtering the Redis operation instructions through the pseudo slave node Filter the Redis operation instructions obtained from the Redis cache, retain the Redis operation instructions that will not cause data cyclic replication, and directly send the retained Redis operation instructions to the data center to be synchronized; or, perform corresponding filtering processing on the Redis operation instructions according to the application operation data type, obtain the filtering processing result, and send the filtering processing result to the receiving end data center to be synchronized, specifically including: filtering the Redis operation instructions obtained from the Redis local timing queue through the pseudo slave node, retaining the XADD instruction in the Redis operation instructions, and generating a continuous sequence number of the Redis local timing queue; packaging the Redis operation instructions with the XADD instruction retained and the continuous sequence number into a synchronization message; sending the synchronization message to the data center to be synchronized through a TCP connection; The receiving-end data center is used to receive the synchronization request sent by the sending-end data center; write the synchronization request into the corresponding Redis according to the type of the received synchronization request, wherein the synchronization request type includes a Redis operation instruction and a synchronization message; when the synchronization request type is a Redis operation instruction, directly write the synchronization request into the Redis cache; when the synchronization request type is a synchronization message, reorder the synchronization request message according to the continuous sequence number in the synchronization message and write it into the Redis off-site timing queue; Among them, the reordering of the synchronization request messages according to the continuous sequence numbers in the synchronization messages and then writing them into the Redis off-site timing queue specifically includes: writing the synchronization request into the Redis cache timing queue through a Lua script where the off-site data is landed; establishing a continuous sequence number index of the Redis cache timing queue according to the continuous sequence number; and writing the synchronization request in the Redis cache timing queue into the Redis off-site timing queue according to the continuous sequence number index through a Lua script submitted by the off-site data.