A device and method for synchronizing distributed cache clusters across computer rooms
Patent Information
- Application Number
- CN201911125859.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-18
- Publication Date
- 2024-08-30
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing cross-computer room distributed cache system has problems such as one-way synchronization limitations, high network environment requirements, poor timeliness, difficulty in ensuring data consistency, high business system transformation costs, and the inability to achieve two-way synchronization between multiple computer rooms during data synchronization. .
A cross-computer room synchronization distributed cache cluster device and method is designed, including ordinary nodes, working nodes, parsing modules, synchronization modules and coordination modules. Bidirectional synchronization between multiple computer rooms is achieved by dynamically expanding working nodes, using memory and disk mixing. Queuing strategies ensure data reliability and achieve data consistency and timeliness through filter chains.
It achieves two-way synchronization between multiple computer rooms, reduces network environment requirements, reduces business system transformation costs, ensures data consistency and timeliness, and improves system reliability and compatibility.
Smart Images

Figure CN110990432B8
Abstract
Description
Technical Field
[0001] This invention relates to the field of distributed database technology, and in particular to an apparatus and method for a cross-data center synchronous distributed cache cluster. Background Technology
[0002] In the context of big data, distributed databases have become a crucial means to address big data bottlenecks, and achieving high availability is paramount for their applicability. With the advent of the "Internet+" era, the amount of data the internet industry needs to process is increasing daily, and concurrent user access is also growing rapidly. To ensure online service, service providers often prioritize deploying the same system in different data centers to distribute traffic when a large number of users access the system concurrently. Traditional cross-data center distributed database systems establish data centers in different regions, setting up independent database server clusters, storing and managing user data only within their respective regions. When a database server cluster in one data center fails, power outages are required for maintenance, and data storage and access services can only resume after the fault is resolved. Traditional cross-data center distributed database systems suffer from low reliability in data read and write operations. In recent years, with the rapid development of information technology, the demand for service quality has also increased significantly. The reliability of a single data center can never be guaranteed. Incidents such as fiber optic cables being cut or power outages frequently occur. Application services and data often need to be deployed in multiple data centers, such as dual data centers in the same city or three data centers in the same city and different locations, to ensure that reliable services can still be provided even if one data center fails.
[0003] As is well known, distributed caching is indispensable in a distributed environment, and Redis is the first choice for most companies. Faced with the new challenges of multi-datacenter environments, there are very few industry cases of Redis cross-datacenter synchronization. How to achieve a cross-datacenter distributed caching cluster is the core technology of this invention.
[0004] The demand for cross-datacenter distributed caching clusters is very strong, and the basic solutions in the industry are as follows:
[0005] Option 1 only handles intranet synchronization and does not consider multi-datacenter solutions. Current technical solutions, such as Codis and Redis Cluster, are intranet synchronization and do not support cross-datacenter synchronization scenarios. Therefore, we manually build an intranet environment by interconnecting the two datacenter environments through the network, and then use the intranet environment to synchronize data.
[0006] Option 2: Implement cross-datacenter synchronization using the MySQL database layer, bypassing the Redis synchronization solution. The application layer then transfers the database data to a Redis cache. This requires significant modifications to the application system.
[0007] Option 3, which uses application system interfaces, requires calling data synchronization interfaces from multiple data centers to update, delete, or modify Redis data, resulting in heavy coupling with the business system.
[0008] The first problem is that the application scenarios of Solution 1 are relatively limited. The master / slave mode can only meet one-way synchronization scenarios, such as data from data center A to data center B. It cannot achieve bidirectional synchronization, let alone synchronization between multiple data centers.
[0009] The second problem is that Option 1 has very high requirements for the network environment; it must be an internal network environment built through VPN or VPC.
[0010] The third problem is that Solution 2 relies on MySQL data synchronization, which cannot meet the timeliness requirements. For example, after the data is synchronized from the database in data center A to the data in data center B, when will it be flushed to the Redis cache? In addition to relying on an asynchronous task, it cannot achieve real-time results, making it difficult to guarantee data consistency.
[0011] The fourth problem is that Solution 3 heavily relies on business systems, making the transformation cost very high. Without Redis synchronization, the business side needs to make a lot of modifications to achieve multi-datacenter deployment, which is difficult to promote.
[0012] The fifth problem is poor timeliness. For example, solutions two and three cannot meet the needs of scenarios where Redis cache automatically expires and then notifies other data centers. Therefore, they are unacceptable for scenarios with high timeliness requirements.
[0013] The sixth problem is that we cannot guarantee that orders will not be lost. After all, it involves cross-data center API calls, which will inevitably increase the failure rate. When a call fails, we need to have a mechanism for retrying, which seriously affects the operating efficiency of the business system.
[0014] The seventh problem is data consistency. The same record operation may occur in multiple data centers, and the conflict cannot be resolved when conflicting data occurs. Summary of the Invention
[0015] This invention aims to at least partially solve the technical problems in related technologies. Therefore, one objective of this invention is to provide an apparatus and method for synchronizing distributed cache clusters across data centers, thereby solving the problem of data synchronization across distributed caches, reducing the manpower and time costs of using distributed caches in multi-data center scenarios, and achieving multi-data center synchronization using existing access processes with virtually no intrusion into business systems.
[0016] To achieve the above objectives, an apparatus for a cross-data center synchronous distributed cache cluster according to a first aspect of the present invention includes: a regular node; a working node, wherein the working node further includes a parsing module and a synchronization module; a coordination module; and a management module.
[0017] In addition, the apparatus of the present invention applied to a cross-data center synchronous distributed cache cluster may also have the following additional technical features:
[0018] In one embodiment of the present invention, the ordinary node is set as a Redis node, and the Redis master node is selected as the synchronization source and synchronization target.
[0019] In one embodiment of the present invention, the Rotter-Node is responsible for synchronizing source Redis data to target Redis, reporting monitoring data and synchronization status.
[0020] The parsing module is configured to parse the RDB and AOF of the Redis node; RDB is a relational database, and AOF is an append-only file, which is a log file for appending data.
[0021] In one embodiment of the present invention, the synchronization module is configured to perform synchronization processing according to a synchronization strategy;
[0022] In one embodiment of the present invention, the coordination module is configured to elect and coordinate the work of worker nodes.
[0023] In one embodiment of the present invention, the management module manages synchronization sources and targets and synchronization strategies, performs overall role allocation, assigns tasks to work nodes, collects synchronization status and monitors it.
[0024] In one embodiment of the present invention, the device for a cross-data center synchronous distributed cache cluster is set up in n data centers. When n=1, unidirectional synchronization can be performed; when n=2, bidirectional synchronization is formed; when n>2, m working nodes are dynamically expanded according to n, where m=n.
[0025] When n≥2, the ordinary node of the first computer room is connected to the synchronization module of the second computer room, the ordinary node of the second computer room is connected to the synchronization module of the third computer room, and so on, until the ordinary node of the nth computer room is connected to the synchronization module of the first computer room.
[0026] The second objective of this invention is to provide a method for synchronizing distributed cache clusters across data centers, thereby solving the problem of data synchronization across distributed caches, reducing the manpower and time costs of using distributed caches in situations involving multiple data centers, and enabling synchronization across multiple data centers using existing access processes with virtually no intrusion into business systems.
[0027] To achieve the above objectives, a method for cross-data center synchronous distributed cache cluster according to a second aspect embodiment of the present invention includes the following steps:
[0028] S1: Start the service. After the worker node starts, it reports its own status.
[0029] S2: The coordination module receives node information from the working nodes and registers the information;
[0030] S3: The management module monitors the status changes of worker nodes and determines whether a worker node has started based on the status changes;
[0031] S4: The management module checks if there are any idle pipeline synchronization tasks;
[0032] S5: After confirming the existence of an idle pipeline synchronization task, the storage management module pushes configuration information;
[0033] S6: If there are any idle pipeline tasks, assign a pipeline task to the worker node, bind the pipeline task to the worker node, and write it into the coordination module.
[0034] S7: The worker node listens for the pipeline tasks assigned to it by the management module;
[0035] S8: Initialize configuration, initialize the source, target and other configuration information of ordinary nodes, find the position of the last successful synchronization through the synchronization ID (master_replid) and offset (master_repl_offset) of the source of ordinary nodes - to prevent data loss, and prevent duplicate synchronization through the offset (target_offset) of the target of ordinary nodes.
[0036] S9: Connects the source and target of a normal node. It starts connecting the Redis source and Redis target. If the connection fails, it will retry. If the connection succeeds, it will perform synchronization.
[0037] S10: Select a synchronization strategy, which includes: a) performing Redis dump data synchronization; or b) performing incremental synchronization;
[0038] S11: Determine whether to select synchronization strategy a. If yes, further select a synchronization strategy. Specifically, select a strategy based on business characteristics, such as selecting a partial important dump synchronization strategy or a full dump synchronization strategy. Then execute the subsequent steps. If no, directly execute the subsequent steps.
[0039] S12: Perform filtration, which is carried out through a filter chain consisting of a series of filters;
[0040] S13: Filtering complete, perform synchronization, data from the source ordinary node is synchronized to the target ordinary node.
[0041] In one embodiment of the present invention, the filter chain in step S12 has two forms: FilterChain and DumpFilterChain; the series of filters included in FilterChain are: ParseEventFilter, DBFilter, KeyFilter, CircleSyncFilter, MultiThreadFilter, OvertimeFilter, DeleteKeyFilter, RateLimitFilter, SendTargetFilter, MonitorFilter, and ComputeRateFilter; the series of filters included in DumpFilterChain are: ParseEventFilter, DumpFilter, DBFilter, KeyFilter, RateLimitFilter, SendTargetFilter, and ComputeRateFilter.
[0042] The ParseEventFilter: Transforms Redis replicator events.
[0043] The Redis DB filter is used to select the Redis database, and can conveniently and flexibly support multiple DBs.
[0044] The key filter allows for fine-grained management, reaching every key in Redis, including strategies for ignoring certain keys and specifying certain keys.
[0045] The CircleSyncFilter, a filter that introduces loop keys, aims to prevent infinite loops during synchronization. During data synchronization, a copy_key is added for each command, and this key is synchronized to the target Redis. When the target Redis performs reverse synchronization, it first checks if the copy_key exists for the key to be synchronized. If it does, the key is not synchronized, and the copy_key is deleted.
[0046] The key_copy_filter effectively ensures data consistency by filtering synchronized data to avoid duplicate synchronization.
[0047] The OvertimeFilter needs to determine whether it is still valid before sending it to the target.
[0048] The DeleteKeyFilter's delete key protection time is as follows: 1. Data center A performs a delete key operation in Redis; 2. Rotter synchronizes the delete key to data center B and simultaneously writes a record to Redis in data center B, recording the delete key with a two-minute expiration time; 3. Data center B reads data from its database that Rotter has not yet synchronized and writes it to Redis; 4. Rotter determines that the Redis key in data center B was just deleted and will not synchronize it to data center A; 5. Data center A reads new data from its database and writes it to Redis, and Rotter synchronizes the Redis key to data center B. After the above operations, Redis in data center A, the database in data center A, and Redis in data center B all contain new and correct data.
[0049] RateLimitFilter: The rate and bandwidth used when processing synchronized data.
[0050] The MonitorFilter monitors which keys are being synchronized. Currently, it only logs the changes, but it may report them to the management system later.
[0051] The DumpFilter has the following full dump policy: 0 - no dump; 1 - partial key dump; 2 - full dump.
[0052] The MultiThreadFilter allows you to specify a thread during synchronization.
[0053] The third objective of this invention is to provide an apparatus and method for synchronizing distributed cache clusters across data centers, thereby solving the problem of data synchronization across distributed caches, reducing the manpower and time costs of using distributed caches in situations involving multiple data centers, and enabling synchronization across multiple data centers using existing access processes with virtually no intrusion into business systems.
[0054] The data reliability of the device and method for cross-data center synchronous distributed cache clusters of the present invention is achieved through a hybrid queue strategy of memory and disk.
[0055] 1. Memory Queue
[0056] 1) Default memory queue length: 100;
[0057] 2) Use ArrayBlockingQueue as a container for the memory queue.
[0058] 2. The disk design includes two types of files: data files and index files.
[0059] Data file: includes multiple data items; Index file: includes redisOffset, dataOffset, and dataLength. redisOffset is the offset value from the Redis master node to the worker nodes during synchronization; dataOffset is the offset value of the synchronization command stored in the disk file; and dataLength is the length of the command.
[0060] 3. DiskMode attribute: First, it determines whether it is in disk mode. Only in disk mode will synchronization commands enter the disk queue.
[0061] The fourth objective of this invention is to provide an apparatus and method for synchronizing distributed cache clusters across data centers, thereby solving the problem of data synchronization across distributed caches, reducing the manpower and time costs of using distributed caches in situations involving multiple data centers, and enabling synchronization across multiple data centers using existing access processes with virtually no intrusion into business systems.
[0062] The beneficial effects of this invention are: First, it not only solves the problem of bidirectional synchronization between two computer rooms, but also realizes mutual synchronization between multiple computer rooms;
[0063] Second, it lowers the requirements for the network environment, no longer limited to the intranet mode, and is also suitable for the public network environment and the leased line mode;
[0064] Third, it can operate independently without relying on cross-datacenter synchronization such as databases, and it does not require scheduled tasks to flush data from the database to Redis, thus reducing cumbersome steps.
[0065] Fourth, it requires almost no modification to the business system, and the access method is the same as that of ordinary Redis, which greatly reduces the access cost.
[0066] Fifth, it has good compatibility, implementing all Redis events and following the native Redis events, including events such as automatic expiration of Redis cache.
[0067] Sixth: It ensures no order loss, and the architecture implements retransmission upon failure, which will not affect the operating efficiency and performance of the business system;
[0068] Seventh: It solves the data consistency problem. The same record operation may occur in multiple data centers. When conflicting data occurs, it provides different strategies to resolve the conflict based on the business scenario. Attached Figure Description
[0069] Figure 1 This is a schematic diagram of an apparatus for a cross-data center synchronous distributed cache cluster according to an embodiment of the present invention;
[0070] Figure 2 This is a flowchart of a method for cross-data center synchronous distributed cache cluster according to an embodiment of the present invention;
[0071] Figure 3 This is a flowchart illustrating the task allocation to worker nodes in a method for cross-data center synchronous distributed cache cluster according to an embodiment of the present invention.
[0072] Figure 4 This is a flowchart of monitoring in a method for cross-data center synchronous distributed cache cluster according to an embodiment of the present invention. Detailed Implementation
[0073] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0074] The apparatus and method for cross-data center synchronous distributed cache clusters according to embodiments of the present invention are described below with reference to the accompanying drawings.
[0075] Figure 1 This is a schematic diagram of an apparatus for a cross-data center synchronous distributed cache cluster according to an embodiment of the present invention. Figure 1As shown, the system includes: This invention aims to at least partially solve the technical problems in related technologies. Therefore, one objective of this invention is to provide an apparatus and method for synchronizing distributed cache clusters across data centers, thereby solving the problem of data synchronization across distributed caches, reducing the manpower and time costs of using distributed caches in multi-data center scenarios, and achieving multi-data center synchronization using existing access processes with virtually no intrusion into business systems.
[0076] To achieve the above objectives, an apparatus for a cross-data center synchronous distributed cache cluster according to a first aspect of the present invention includes: a regular node; a working node, wherein the working node further includes a parsing module and a synchronization module; a coordination module; and a management module.
[0077] Furthermore, in one embodiment of the present invention, the ordinary node is set as a Redis node, and the Redis master node is selected as the synchronization source and synchronization target.
[0078] In one embodiment of the present invention, the Rotter-Node is responsible for synchronizing source Redis data to target Redis, reporting monitoring data and synchronization status.
[0079] The parsing module is configured to parse the RDB and AOF of the Redis node; RDB is a relational database, and AOF is an append-only file, which is a log file for appending data.
[0080] In one embodiment of the present invention, the synchronization module is configured to perform synchronization processing according to a synchronization strategy;
[0081] In one embodiment of the present invention, the coordination module is configured to elect and coordinate the work of worker nodes.
[0082] In one embodiment of the present invention, the management module manages synchronization sources and targets and synchronization strategies, performs overall role allocation, assigns tasks to work nodes, collects synchronization status and monitors it.
[0083] In one embodiment of the present invention, the device for a cross-data center synchronous distributed cache cluster is set up in n data centers. When n=1, unidirectional synchronization can be performed; when n=2, bidirectional synchronization is formed; when n>2, m working nodes are dynamically expanded according to n, where m=n.
[0084] When n≥2, the ordinary node of the first computer room is connected to the synchronization module of the second computer room, the ordinary node of the second computer room is connected to the synchronization module of the third computer room, and so on, until the ordinary node of the nth computer room is connected to the synchronization module of the first computer room.
[0085] Figure 2 This is a flowchart of a method for cross-datacenter synchronous distributed cache clustering according to an embodiment of the present invention. Figure 2 As shown, the second objective of this invention is to provide a method for synchronizing distributed cache clusters across data centers, thereby solving the problem of data synchronization across distributed caches, reducing the manpower and time costs of using distributed caches in situations involving multiple data centers, and enabling synchronization across multiple data centers using existing access processes with virtually no intrusion into business systems.
[0086] To achieve the above objectives, a method for cross-data center synchronous distributed cache cluster according to a second aspect embodiment of the present invention includes the following steps:
[0087] S1: Start the service. After the worker node starts, it reports its own status.
[0088] S2: The coordination module receives node information from the working nodes and registers the information;
[0089] S3: The management module monitors the status changes of worker nodes and determines whether a worker node has started based on the status changes;
[0090] S4: The management module checks if there are any idle pipeline synchronization tasks;
[0091] S5: After confirming the existence of an idle pipeline synchronization task, the storage management module pushes configuration information;
[0092] S6: If there are any idle pipeline tasks, assign a pipeline task to the worker node, bind the pipeline task to the worker node, and write it into the coordination module.
[0093] S7: The worker node listens for the pipeline tasks assigned to it by the management module;
[0094] S8: Initialize configuration, initialize the source, target and other configuration information of ordinary nodes, find the position of the last successful synchronization through the synchronization ID (master_replid) and offset (master_repl_offset) of the source of ordinary nodes - to prevent data loss, and prevent duplicate synchronization through the offset (target_offset) of the target of ordinary nodes.
[0095] S9: Connects the source and target of a normal node. It starts connecting the Redis source and Redis target. If the connection fails, it will retry. If the connection succeeds, it will perform synchronization.
[0096] S10: Select a synchronization strategy, which includes: a) performing Redis dump data synchronization; or b) performing incremental synchronization;
[0097] S11: Determine whether to select synchronization strategy a. If yes, further select a synchronization strategy. Specifically, select a strategy based on business characteristics, such as selecting a partial important dump synchronization strategy or a full dump synchronization strategy. Then execute the subsequent steps. If no, directly execute the subsequent steps.
[0098] S12: Perform filtration, which is carried out through a filter chain consisting of a series of filters;
[0099] S13: Filtering complete, perform synchronization, data from the source ordinary node is synchronized to the target ordinary node.
[0100] In one embodiment of the present invention, the filter chain in step S12 has two forms: FilterChain and DumpFilterChain; the series of filters included in FilterChain are: ParseEventFilter, DBFilter, KeyFilter, CircleSyncFilter, MultiThreadFilter, OvertimeFilter, DeleteKeyFilter, RateLimitFilter, SendTargetFilter, MonitorFilter, and ComputeRateFilter; the series of filters included in DumpFilterChain are: ParseEventFilter, DumpFilter, DBFilter, KeyFilter, RateLimitFilter, SendTargetFilter, and ComputeRateFilter.
[0101] The ParseEventFilter: Transforms Redis replicator events.
[0102] The Redis DB filter is used to select a Redis database and can conveniently and flexibly support multiple DBs.
[0103] The key filter facilitates fine-grained management, reaching every key in Redis, including strategies for ignoring certain keys and specifying certain keys.
[0104] The purpose of introducing the CircleSyncFilter (a filter for loop keys) is to prevent infinite loops during synchronization. When synchronizing data, a copy_key is added for each instruction, and this key is synchronized to the target Redis. When the target Redis performs reverse synchronization, it first checks whether the key to be synchronized exists as a copy_key. If it exists, the key is not synchronized, and the copy_key is deleted.
[0105] The key_copy_filter effectively ensures data consistency by filtering synchronized data to avoid duplicate synchronization.
[0106] The OvertimeFilter needs to determine whether it is still valid before sending it to the target.
[0107] The DeleteKeyFilter's delete key protection time is as follows: 1. Data center A performs a delete key operation in Redis; 2. Rotter synchronizes the delete key to data center B and simultaneously writes a record to Redis in data center B, recording the delete key with a two-minute expiration time; 3. Data center B reads data from its database that Rotter has not yet synchronized and writes it to Redis; 4. Rotter determines that the Redis key in data center B was just deleted and will not synchronize it to data center A; 5. Data center A reads new data from its database and writes it to Redis, and Rotter synchronizes the Redis key to data center B. After the above operations, Redis in data center A, the database in data center A, and Redis in data center B all contain new and correct data.
[0108] RateLimitFilter: The rate and bandwidth used when processing synchronized data.
[0109] The MonitorFilter monitors which keys are being synchronized. Currently, it only prints logs, but it may report to the management system in the future.
[0110] The DumpFilter has the following full dump policy: 0 - no dump; 1 - partial key dump; 2 - full dump.
[0111] The MultiThreadFilter allows you to specify a thread during synchronization.
[0112] The third objective of this invention is to provide an apparatus and method for synchronizing distributed cache clusters across data centers, thereby solving the problem of data synchronization across distributed caches, reducing the manpower and time costs of using distributed caches in situations involving multiple data centers, and enabling synchronization across multiple data centers using existing access processes with virtually no intrusion into business systems.
[0113] The data reliability of the device and method for cross-data center synchronous distributed cache clusters of the present invention is achieved through a hybrid queue strategy of memory and disk.
[0114] 1. Memory Queue
[0115] 1) Default memory queue length: 100;
[0116] 2) Use ArrayBlockingQueue as a container for the memory queue.
[0117] 2. The disk design includes two types of files: data files and index files.
[0118] Data file: includes multiple data items; Index file: includes redisOffset, dataOffset, and dataLength. redisOffset is the offset value from the Redis master node to the worker nodes during synchronization; dataOffset is the offset value of the synchronization command stored in the disk file; and dataLength is the length of the command.
[0119] 3. DiskMode attribute: First, it determines whether it is in disk mode. Only in disk mode will synchronization commands enter the disk queue.
[0120] Figure 3 This is a flowchart illustrating the task allocation to worker nodes in a method for cross-data center synchronous distributed cache cluster according to an embodiment of the present invention.
[0121] Rules for assigning rotter nodes:
[0122] 1. Find an idle rotter node
[0123] The first priority is to use the current rotter-node. For example, if some policies are modified for a running rotter-node, it will be selected to continue working after restarting. This greatly reduces the cost of data exchange and improves real-time performance, and can be said to take effect in seconds.
[0124] The second priority uses the last node – the current synchronization task has stopped, and restarting it will select the third priority, searching for an available node in the current data center.
[0125] 2. Next, find the rotter-node with a smaller queue backlog to make full use of server resources.
[0126] 3. Finally, find the rotter node that synchronizes no more than 3 pipeline tasks, and try to ensure that each rotter node can run smoothly.
[0127] 4. If no rotter-node is selected to be executed, an alert will be issued indicating that the number of rotter-nodes needs to be increased.
[0128] Figure 4 This is a flowchart illustrating the monitoring process in a method for cross-data center synchronous distributed cache cluster according to an embodiment of the present invention.
[0129] 01: Rotter-node will synchronize any state to ZooKeeper, because ZooKeeper has very good data consistency guarantees and allows rotter-manager to listen quickly.
[0130] 02: The rotter-manager will be aware of the status of the rotter-node in ZooKeeper. Once it detects an anomaly in the rotter-node, it will perform a secondary health check to confirm whether the rotter-node has actually failed.
[0131] 03: If the rotter-node really fails, kick it out and reassign the rotter-node.
[0132] 04: The rotter-node reports information such as synchronization time, synchronization location, synchronization rate, and queue backlog.
[0133] 05: The rotter-manager receives information such as step time, synchronization position, synchronization rate, and queue backlog.
[0134] 06: When the network is interrupted or data processing fails, the rotter-node will immediately report the failure information in addition to retrying synchronization, and the rotter-manager will immediately issue an alarm upon receiving the failure information.
[0135] This invention solves the problem of cross-data center distributed cache data synchronization, reducing the manpower and time costs of using distributed cache in multi-data center scenarios. It can achieve multi-data center synchronization by utilizing the existing Redis access process, with almost no intrusion into the business system, just like using Redis distributed cache in a single data center.
[0136] The beneficial effects of this invention are: First, it not only solves the problem of bidirectional synchronization between two computer rooms, but also realizes mutual synchronization between multiple computer rooms;
[0137] Second, it lowers the requirements for the network environment, no longer limited to the intranet mode, and is also suitable for the public network environment and the leased line mode;
[0138] Third, it can operate independently without relying on cross-datacenter synchronization such as databases, and it does not require scheduled tasks to flush data from the database to Redis, thus reducing cumbersome steps.
[0139] Fourth, it requires almost no modification to the business system, and the access method is the same as that of ordinary Redis, which greatly reduces the access cost.
[0140] Fifth, it has good compatibility, implementing all Redis events and following the native Redis events, including events such as automatic expiration of Redis cache.
[0141] Sixth: It ensures no order loss, and the architecture implements retransmission upon failure, which will not affect the operating efficiency and performance of the business system;
[0142] Seventh: It solves the data consistency problem. The same record operation may occur in multiple data centers. When conflicting data occurs, it provides different strategies to resolve the conflict based on the business scenario.
[0143] Although the present invention has been described with reference to preferred embodiments, various modifications can be made and components can be replaced with equivalents without departing from the scope of the invention. In particular, the technical features mentioned in the various embodiments can be combined in any manner as long as there is no structural conflict. The above descriptions only illustrate several embodiments of the present invention and are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention.
Claims
1. An apparatus for a cross-data center synchronous distributed cache cluster, characterized in that, include: Ordinary node; worker node, wherein the worker node further includes a parsing module and a synchronization module; Coordination module; Management module.
2. The apparatus for a cross-data center synchronous distributed cache cluster as described in claim 1, characterized in that, The ordinary nodes are configured as Redis nodes, selecting the Redis master node as both the synchronization source and target. The worker nodes (Rotter-Nodes) are responsible for synchronizing source Redis data to the target Redis, reporting monitoring data, and reporting synchronization status. The parsing module is configured to parse the Redis node's RDB and AOF; RDB is a relational database, and AOF is an append-only file. The synchronization module is configured to perform synchronization processing according to the synchronization strategy. The coordination module is configured to elect and coordinate worker nodes. The management module manages the synchronization source and target, the synchronization strategy, and performs overall role allocation, distributing tasks to worker nodes, collecting synchronization status, and monitoring.
3. The apparatus for a cross-data center synchronous distributed cache cluster as described in claim 1, characterized in that, The device for a cross-data center synchronous distributed cache cluster is set up in n data centers; when n=1, one-way synchronization can be performed; when n=2, two-way synchronization is formed; when n>2, m working nodes are dynamically expanded according to n, where m=n.
4. The apparatus for a cross-data center synchronous distributed cache cluster as described in claim 1, characterized in that, When n≥2, the ordinary node of the first computer room is connected to the synchronization module of the second computer room, the ordinary node of the second computer room is connected to the synchronization module of the third computer room, and so on, until the ordinary node of the nth computer room is connected to the synchronization module of the first computer room.
5. A method for cross-data center synchronous distributed cache clusters, characterized in that, Includes the following steps: S1: Start the service. After the worker node starts, it reports its own status. S2: The coordination module receives node information from the working nodes and registers the information; S3: The management module monitors the status changes of worker nodes and determines whether a worker node has started based on the status changes; S4: The management module checks if there are any idle pipeline synchronization tasks; S5: After confirming the existence of an idle pipeline synchronization task, the storage management module pushes configuration information; S6: If there are any idle pipeline tasks, assign a pipeline task to the worker node, bind the pipeline task to the worker node, and write it into the coordination module. S7: The worker node listens for the pipeline tasks assigned to it by the management module; S8: Initialize configuration, initialize the source, target and other configuration information of ordinary nodes, find the position of the last successful synchronization through the synchronization ID (master_replid) and offset (master_repl_offset) of the source of ordinary nodes - to prevent data loss, and prevent duplicate synchronization through the offset (target_offset) of the target of ordinary nodes. S9: Connects the source and target of a normal node. It starts connecting the Redis source and Redis target. If the connection fails, it will retry. If the connection succeeds, it will perform synchronization. S10: Select a synchronization strategy, which includes: a) performing Redis dump data synchronization; or b) performing incremental synchronization; S11: Determine whether to select synchronization strategy a. If yes, further select a synchronization strategy. Specifically, select a strategy based on business characteristics, such as selecting a partial important dump synchronization strategy or a full dump synchronization strategy. Then execute the subsequent steps. If no, directly execute the subsequent steps. S12: Perform filtration, which is carried out through a filter chain consisting of a series of filters; S13: Filtering complete, execute synchronization, and synchronize the data from the source ordinary node to the target ordinary node.
6. The method for cross-data center synchronous distributed cache cluster as described in claim 5, characterized in that, In step S12, the filter chain is in the form of FilterChain; the series of filters included in FilterChain are: ParseEventFilter, DBFilter, KeyFilter, CircleSyncFilter, MultiThreadFilter, OvertimeFilter, DeleteKeyFilter, RateLimitFilter, SendTargetFilter, MonitorFilter, and ComputeRateFilter.
7. The method for cross-data center synchronous distributed cache cluster as described in claim 5, characterized in that, In step S12, the filter chain is in the form of DumpFilterChain; the series of filters included in DumpFilterChain are: ParseEventFilter, DumpFilter, DBFilter, KeyFilter, RateLimitFilter, SendTargetFilter, and ComputeRateFilter.
8. A method for cross-data center synchronous distributed cache clusters as described in any one of claims 6-7, characterized in that, The ParseEventFilter: converts Redis replicator events; The Redis DB filter is used to select a Redis database, and can conveniently and flexibly support multiple DBs; The key filter facilitates fine-grained management, reaching every key in Redis, including strategies for ignoring certain keys and specifying certain keys. The purpose of introducing the loop key filter, CircleSyncFilter, is to prevent infinite loops during synchronization. When synchronizing data, a copy_key is added for each instruction, and this key is synchronized to the target Redis. When the target Redis performs reverse synchronization, it first checks whether the key to be synchronized has a copy_key. If it does, the key will not be synchronized and the copy_key will be deleted. The key_copy_filter filter, in order to avoid duplicate synchronization, filters out synchronized data, effectively ensuring data consistency; The OvertimeFilter needs to determine whether it is still valid before sending it to the target. The DeleteKeyFilter: Delete key protection time; The RateLimitFilter specifies the rate and bandwidth for processing synchronous data. The MonitorFilter monitors which keys are being synchronized. Currently, it only prints logs, but it may report to the management terminal in the future. The DumpFilter has the following full dump policy: 0 - no dump; 1 - partial key dump; 2 - full dump. The MultiThreadFilter allows you to specify a thread during synchronization.
9. The method for cross-data center synchronous distributed cache cluster as described in claim 8, characterized in that, The specific steps of the DeleteKeyFilter are as follows: 1) The Redis instance in data center A performs a delete key operation; 2) The rotter synchronizes the deleted key to data center B, and simultaneously writes a record to the Redis instance in data center B, recording the deleted key with an expiration time of two minutes; 3) Data center B reads the data that the rotter has not yet synchronized from the database and writes it to Redis; 4) The rotter determines that the Redis key in data center B has just been deleted and will not synchronize it to data center A; 5) Data center A reads the new data from the database and writes it to Redis, and the rotter synchronizes the Redis key to data center B. After the above operations, the Redis instance in data center A, the database in data center A, and the Redis instance in data center B all contain new and correct data.
Citation Information
Patent Citations
Across-room multiple-active distributed database management system and across-room multiple-active distributed database management method
CN106341454A
Apparatus and method for managing cache in cache distributed environment
US20150248350A1
