Redis cluster multi-activity system and method based on multiple Kubernetes
By deploying multi-directional synchronization components and health management components among multiple Kubernetes nodes, a multi-active system of the Redis cluster is realized, which solves the intrusive problems and data synchronization switching difficulties caused by Redis transformation in the existing technology, and ensures the high performance of Redis. Availability and business continuity availability.
Patent Information
- Application Number
- CN202410597313.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-14
- Publication Date
- 2024-08-23
AI Technical Summary
The existing technology requires the development and transformation of Redis, which is highly intrusive and affects the normal use of Redis. Especially in the case of multi-active, each request needs to be judged, causing a serious burden and failing to achieve effective multi-active and data synchronization. switch.
Adopt a Redis cluster system based on multi-Kubernetes, use multi-directional synchronization components to perform real-time data synchronization between multiple Redis master nodes, and use health management components to detect node failures and automatically switch business traffic to transferable nodes to avoid the transformation of native Redis. , ensuring data consistency and high availability.
It achieves the normal use and high availability of Redis, avoids the problem of data loop replication, reduces redundant communication, ensures the continuous availability of the business in the event of node failure, and realizes data migration and traffic switching through Kubernetes network communication.
Smart Images

Figure CN118540333A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a multi-Kubernetes-based Redis cluster multi-active system and method. Background Art
[0002] In computer science and information technology, multi-activity usually refers to high availability or redundant configuration in system design, ensuring that the system can continue to operate and provide uninterrupted services even if some components fail.
[0003] Currently, active-active data synchronization is mainly performed by writing files to disk or disguising from the processor. Specifically, the Redis code is modified to change the Redis append only file (AOF) log to a data log. The AOF log needs to be rewritten, or the original sync command of Redis itself needs to be changed to increase the id.
[0004] However, using this active-active data synchronization method requires the development and transformation of Redis itself, which will be highly invasive to Redis. When applied to multi-active situations, it will place a huge burden on Redis itself. Each request needs to be judged, which will have a serious impact on the normal use of Redis. Summary of the invention
[0005] In view of this, the present application provides a multi-Kubernetes-based Redis cluster multi-active system and method, the main purpose of which is to improve the current existing technology that requires the development and transformation of Redis itself, which will lead to high invasiveness to Redis. When applied to multi-active situations, it will cause a great burden on Redis itself. Each request needs to be judged, which will seriously affect the normal use of Redis. Technical problems.
[0006] In a first aspect, the present application provides a multi-Kubernetes-based Redis cluster multi-active system, including: a Kubernetes master node and multiple Kubernetes slave nodes;
[0007] The Kubernetes slave node includes a Redis cluster, and the Redis cluster includes multiple multi-directional synchronization components and multiple Redis master nodes;
[0008] The multi-directional synchronization component is used to synchronize the incremental data to other Redis master nodes except the target Redis master node after the incremental data is written to the target Redis master node among the multiple Redis master nodes;
[0009] The Kubernetes master node includes a health management component, which is used to determine a transferable Kubernetes slave node among the multiple Kubernetes slave nodes after detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes has a fault, and switch the business traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
[0010] Optionally, the Kubernetes slave node includes: Submariner;
[0011] In the case that the other Redis master node and the target Redis master node are not in the same Kubernetes slave node, the Submariner is used to encrypt the incremental data and synchronize the encrypted incremental data to the other Redis master node.
[0012] Optionally, the Submariner includes: an IPSec tunnel and a network security gateway;
[0013] The network security gateway is used for the target multi-directional synchronization component corresponding to the target Redis master node to transmit the incremental data to the IPSec tunnel through the network security gateway;
[0014] The IPSec tunnel is used to transmit the incremental data to other multidirectional synchronization components except the target multidirectional synchronization component through the network security gateway, and the other multidirectional synchronization components are used to synchronize the incremental data to the other Redis master nodes.
[0015] Optionally, the target multi-directional synchronization component is used to parse the received incremental data when the target synchronization component is the receiving end during the incremental data synchronization process, and if it is determined that the target Redis master node does not contain the received incremental data, synchronize the received incremental data to the target Redis master node;
[0016] The target multi-directional synchronization component is also used to generate a flag variable corresponding to the target multi-directional synchronization component when the target synchronization component is the sending end during the incremental data synchronization process, mark the transmission protocol used to send incremental data based on the flag variable, and send the incremental data to the other multi-directional synchronization components according to the marked transmission protocol.
[0017] Optionally, the Redis cluster further includes: a plurality of Redis standby nodes;
[0018] The Redis standby node is used to receive the incremental data sent by the target multi-directional synchronization component when the corresponding target Redis master node fails.
[0019] Optionally, the health management component is used to determine the service flow information of other Kubernetes slave nodes except the target Kubernetes slave node when a failure of the target Kubernetes slave node is detected;
[0020] Obtain the average concurrency and the total memory used of the target Kubernetes slave node, and determine the candidate transfer nodes among the other Kubernetes slave nodes except the target Kubernetes slave node based on the average concurrency and the total memory used;
[0021] The candidate transfer nodes are selected according to a preset central processing unit CPU impact factor coefficient and a preset memory impact factor coefficient, a transferable Kubernetes slave node among the candidate transfer nodes is determined, and the business traffic of the target Redis cluster is switched from the target Kubernetes slave node to the transferable Kubernetes slave node.
[0022] Optionally, the health management component is used to switch the service traffic of the target Redis cluster from the transferable Kubernetes slave node to the target Kubernetes slave node when detecting that the target Kubernetes slave node is restarted after a failure;
[0023] The health management component is also used to control multiple multi-directional synchronization components included in the target Kubernetes slave node to perform synchronization processing of full data;
[0024] After detecting that the data contained in the multiple Redis master nodes corresponding to the multiple multi-directional synchronization components meets the preset incremental synchronization conditions, the multiple multi-directional synchronization components are controlled to perform synchronization processing of the incremental data.
[0025] In the second aspect, the present application provides a multi-active Redis cluster method based on multiple Kubernetes, including:
[0026] Identify multiple Redis master nodes and multiple multi-directional synchronization components contained in multiple Kubernetes slave nodes;
[0027] Control the multiple multi-directional synchronization components to perform incremental data synchronization processing on the incremental data written into the multiple Redis master nodes;
[0028] In response to a health management component in the Kubernetes master node detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes is faulty, determining a transferable Kubernetes slave node among the multiple Kubernetes slave nodes;
[0029] Switch the service traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
[0030] In a third aspect, the present application provides a multi-Kubernetes-based Redis cluster multi-active device, including:
[0031] A determination module is configured to determine a plurality of Redis master nodes and a plurality of multi-directional synchronization components included in a plurality of Kubernetes slave nodes;
[0032] A processing module is configured to control the multiple multi-directional synchronization components to perform incremental data synchronization processing on the incremental data written into the multiple Redis master nodes;
[0033] The determination module is further configured to determine a transferable Kubernetes slave node among the multiple Kubernetes slave nodes in response to a health management component in the Kubernetes master node detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes has a fault;
[0034] The switching module is configured to switch the service traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
[0035] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the multi-Kubernetes-based Redis cluster multi-active method of the second aspect.
[0036] In a fifth aspect, the present application provides an electronic device, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor. When the processor executes the computer program, the multi-Kubernetes-based Redis cluster multi-active method of the second aspect is implemented.
[0037] In a sixth aspect, the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the multi-Kubernetes-based Redis cluster multi-active method of the second aspect.
[0038] By means of the above technical scheme, the present application provides a multi-Kubernetes-based Redis cluster multi-active system and method, wherein the system includes: a Kubernetes master node and multiple Kubernetes slave nodes; the Kubernetes slave node includes a Redis cluster, and the Redis cluster includes multiple multi-directional synchronization components and multiple Redis master nodes; the multi-directional synchronization component is used to synchronize the incremental data to other Redis master nodes except the target Redis master node after the target Redis master node among the multiple Redis master nodes writes incremental data; the Kubernetes master node includes a health management component, and the health management component is used to determine a transferable Kubernetes slave node among the multiple Kubernetes slave nodes after detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes has a fault, and switch the business traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node. Compared with the current existing technology, this application deploys multiple Redis clusters in multiple Kubernetes nodes and uses multi-directional data synchronization components for real-time multi-directional synchronization. There is no need to develop and transform the native Redis, which can ensure the normal use of Redis and adapt to the master-slave high availability of Redis itself to perform data synchronization switching. At the same time, it can ensure the eventual consistency of the data, overcome the impact of time delays, and avoid the problem of multi-directional synchronization data circular replication; through the health management component, the Kubernetes nodes are tested in real time for health. When a Kubernetes node fails, the business traffic of the failed Kubernetes node can be switched to other Kubernetes nodes to ensure that the business failure is not interrupted and the business is not affected by the Kubernetes node failure. Relying on Kubernetes' network communication, data migration and traffic switching after the availability zone failure are realized to ensure the continuous availability of the business.
[0039] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0041] In order to more clearly illustrate the embodiments of the present application 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. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0042] Figure 1 A schematic diagram of the structure of a multi-Kubernetes-based Redis cluster multi-active system provided in an embodiment of the present disclosure is shown;
[0043] Figure 1 middle:
[0044] 1-Kubernetes master node, 11-health management component;
[0045] 2-Kubernetes slave node, 21-multidirectional synchronization component, 22-Redis master node, 23-Redis backup node;
[0046] Figure 2 A schematic diagram of an example structure provided by an embodiment of the present disclosure is shown;
[0047] Figure 3 A schematic diagram showing an example provided by an embodiment of the present disclosure;
[0048] Figure 4 A schematic diagram of an example structure provided by an embodiment of the present disclosure is shown;
[0049] Figure 5 A schematic diagram showing an example provided by an embodiment of the present disclosure;
[0050] Figure 6 A schematic diagram of an example process provided by an embodiment of the present disclosure is shown;
[0051] Figure 7 A schematic diagram showing an example provided by an embodiment of the present disclosure;
[0052] Figure 8 A schematic diagram showing an example provided by an embodiment of the present disclosure;
[0053] Fig. 9 A schematic diagram of an example process provided by an embodiment of the present disclosure is shown;
[0054] Fig.10 A schematic diagram of a multi-Kubernetes-based Redis cluster multi-active method provided in an embodiment of the present disclosure is shown;
[0055] Fig.11A structural schematic diagram of a multi-Kubernetes-based Redis cluster multi-active device provided in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0056] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0057] Combine the following Figure 1 Describe a multi-Kubernetes-based Redis cluster multi-active system according to some embodiments of the present application.
[0058] The present application provides a signal conditioning system, such as Figure 1 As shown, it includes: Kubernetes master node 1 and multiple Kubernetes slave nodes 2;
[0059] The Kubernetes slave node 2 includes a Redis cluster, which includes multiple multi-directional synchronization components 21 and multiple Redis master nodes 22;
[0060] The multi-directional synchronization component 21 is used to synchronize the incremental data to other Redis master nodes except the target Redis master node after the incremental data is written to the target Redis master node among the multiple Redis master nodes 22;
[0061] The Kubernetes master node 1 includes a health management component 11, which is used to determine a transferable Kubernetes slave node among the multiple Kubernetes slave nodes 2 after detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes 2 has a fault, and switch the business traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
[0062] In the embodiment of the present application, in the Kubernetes (K8s for short) cluster, the master node plays the role of the brain, responsible for managing and controlling the operating status of the entire cluster. The master node is the control center of the Kubernetes cluster, responsible for cluster decision-making and global view. To ensure high availability, the master node in the production environment is often deployed as multiple nodes and managed by HA (high availability) solutions such as Kubernetes' Controller Manager.
[0063] Correspondingly, in a Kubernetes (K8s) cluster, a Worker Node or Minion Node is where the actual workload is executed, responsible for running the Pods of containerized applications. Each slave node contains the following core components to ensure coordination with the master node and effective execution of tasks. The slave node is the labor of the Kubernetes cluster, responsible for handling computing, storage, and network requirements, ensuring the operation of applications and the availability of data. For high reliability and expansion, multiple slave nodes are usually run in the cluster, and may be dynamically adjusted according to the load.
[0064] In some examples, the Redis cluster is a Redis Cluster cluster. Redis Cluster is a distributed solution for Redis that allows data to be distributed across multiple nodes and provides automatic data partitioning (sharding), high availability, and horizontal scalability.
[0065] For this embodiment, the name of the multi-directional synchronization component may be mslave. The multi-directional synchronization component is a self-developed multi-directional synchronization component. As a multi-directional synchronization between multiple clusters, it ensures data synchronization between clusters. The name of the multi-directional synchronization component is not specifically limited here.
[0066] In some examples, the name of the health management component 11 may be Manager for multi az, which is a self-developed health detection component that can switch business traffic in real time after a failure occurs in an availability zone to ensure continuous availability of the business. The name of the health management component is not specifically limited here.
[0067] Optionally, the Kubernetes slave node includes: Submariner; when other Redis master nodes and the target Redis master node are not in the same Kubernetes slave node, Submariner is used to encrypt the incremental data and synchronize the encrypted incremental data to the other Redis master nodes.
[0068] In the embodiment of the present application, Submariner is an open source Kubernetes multi-cluster network connection solution, which allows the establishment of secure network connections between multiple Kubernetes clusters, so that Pods can communicate directly across clusters. Submariner is committed to solving the interconnection problem between multiple clusters and realizing cross-cluster service discovery and network access, which is crucial for building large-scale, distributed, multi-regional Kubernetes deployments.
[0069] Optionally, Submariner includes: an IPSec tunnel and a network security gateway; the network security gateway is used for the target multi-directional synchronization component corresponding to the target Redis master node to transmit the incremental data to the IPSec tunnel through the network security gateway; the IPSec tunnel is used to transmit the incremental data to other multi-directional synchronization components except the target multi-directional synchronization component through the network security gateway, and the other multi-directional synchronization components are used to synchronize the incremental data to other Redis master nodes.
[0070] In the embodiments of the present application, Figure 2 As shown in the figure, Submariner can realize network communication between different Kubernetes clusters, mainly through Broker, Endpoint, Cluster, Gateway Engine and Service Discovery. Broker is CRD (Endpoint and Cluster) used to exchange cluster information. You need to select a cluster as the Broker cluster. Other clusters connect to the API Server of the Broker cluster to exchange cluster information. Specifically, Broker cluster refers to a distributed system formed by multiple Broker nodes in the message middleware system, which is responsible for receiving, storing, forwarding and managing messages. Different message middleware products.
[0071] Furthermore, Endpoint contains the information that Gateway Engine needs to establish inter-cluster connections, such as private IP addresses (Private IP) and public IP addresses (Public IP), NAT ports, and so on. Cluster contains static information about the original cluster, such as its Service and Pod CIDR. Gateway Engine manages tunnels connected to other clusters. Service Discovery: Provides cross-cluster DNS service discovery. Specifically, Service Discovery is a key technology in microservice architecture and distributed systems. It allows service consumers to automatically find and connect to service providers without hard-coding service addresses or knowing the specific location of service deployment in advance.
[0072] It should be noted that K8S clusters themselves cannot communicate with each other. After connecting multiple K8S clusters through Submariner, the networks between multiple K8S are opened up, so that each shard of multiple Redis clusters can communicate with each other, so that the corresponding shards can communicate with each other, which serves as the basis for multi-directional synchronization. At the same time, IPSec tunnels are used to achieve encrypted network connections.
[0073] Further, such as Figure 3 As shown in the figure, IPsec VPN protects point-to-point communication. Through IPsec VPN, a secure tunnel connection can be established between Redis shards in K8S, between Redis shards and network security gateways, or between network security gateways (such as routers and firewalls). Its protocol mainly works at the IP layer, encrypting and verifying data packets at the IP layer, which is very suitable for shard-to-shard network communication such as Redis.
[0074] Specifically, IPSec (Internet Protocol Security) tunnel is a network security technology that establishes a secure communication tunnel between two network nodes through encryption and authentication mechanisms to ensure the privacy and integrity of data transmitted across the public network. IPSec tunnel is mainly used in virtual private networks (VPNs), allowing remote users or branches to securely access corporate internal network resources through the public Internet.
[0075] Accordingly, IPsec VPN (Internet Protocol Security Virtual Private Network) is a secure tunnel technology based on the IP protocol, which is used to establish a secure private network connection on the public Internet or other untrusted networks. The IPsec protocol family provides security measures such as data encryption, data source verification, anti-replay attack and network layer integrity verification for data transmission, making data transmission in the public network as secure as transmission in a private network.
[0076] Optionally, the target multi-directional synchronization component is used to parse the received incremental data when the target synchronization component is the receiving end during the incremental data synchronization process. If it is determined that the target Redis master node does not contain the received incremental data, the received incremental data is synchronized to the target Redis master node. The target multi-directional synchronization component is also used to generate a flag variable corresponding to the target multi-directional synchronization component when the target synchronization component is the sending end during the incremental data synchronization process, mark the transmission protocol used to send the incremental data based on the flag variable, and send the incremental data to other multi-directional synchronization components according to the marked transmission protocol.
[0077] For example, Figure 4 As shown in the figure, it is a working diagram of the self-developed Redis data synchronization component. Figure 5As shown in the figure, when multiple different areas are communicating, there will be a problem of circular replication. To address this problem, when mslave synchronizes data, it will mark itself. For example, when mslave1 receives the data synchronization instructions async and bsync from mslave2 and mslave3, after data synchronization is established, the data synchronized from mslave2 will add a flag variable a to the data, and the data synchronized from mslave3 will add a flag variable b to the data. This variable is the header source information added in the redis transmission protocol. If the native redis protocol transmits the SET key value command, it is parsed as *3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n. After the transmission protocol is modified, it is parsed as #a*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n. Use pipeline to batch synchronize to redis After the master is established, the data will not be stored in redis with variables. If the master synchronizes the data to the mslave again, the mslave will compare whether the data in the current cache contains this data. If the data is the same, it will be discarded. If the data is different, it will be compared. Since the local mslave is real-time and the data synchronized from the remote mslave has a delay, if there is inconsistency, the data generated by the local master will overwrite the data synchronized from the remote mslave, and the new data will be synchronized in multiple directions. The high-availability component slave is not affected by the variables and all data is synchronized normally, thus solving the problem of circular replication.
[0078] Furthermore, for the redundant synchronization of data, variables are also used to distinguish data sources to avoid redundant multiple synchronization of data and ensure that each data is synchronized only once. As shown in the figure below, each multi-directional synchronous mslave performs incremental data synchronization through Rumor-Mongering. If the data generated by the master itself, such as the data generated by mslave1 is the c variable, then after multiple transmissions, mslave2 will filter out the data of the c variable when transmitting it to mslave1 to avoid filtering after transmission and waste of communication bandwidth. The difference from Rumor-Mongering is that the verification is changed from after transmission to before transmission.
[0079] In an embodiment of the present application, in Redis, Pipeline can be used for batch synchronization operations, by putting multiple commands into a batch queue and sending them to the Redis server at one time, and then receiving the execution results of all commands at one time, thereby reducing network IO overhead and improving data synchronization efficiency.
[0080] In the embodiment of the present application, when data is synchronized between multi-directional synchronous mslave components, there is a data consistency problem. The idea of the final consistency algorithm gossip is introduced into the multi-directional synchronous component mslave, and Rumor-Mongering is used. The core data synchronization actions include: Push is for mslave1 that initiates data exchange to randomly select and contact mslaven and send its own data to it. After receiving the data, mslaven updates data that is newer than itself. Only the node with new data will serve as the initiating node. Pull is for mslave1 that initiates data exchange to randomly select and contact mslaven and obtain data from the other party. Only the node with new data will serve as the initiating node. Push&Pull is for the node mslave1 that initiates data exchange to send information to the selected mslaven and obtain data from the other party at the same time to update its own local data.
[0081] Specifically, when using Rumor-Mongering, only incremental data synchronization is performed to avoid large amounts of bandwidth interaction in cross-regional communications. When a mslave has new data, it will periodically contact other mslave to send new data to them until all mslave are synchronized to the latest data. Because mslave only exchange new data, the communication burden is greatly reduced.
[0082] Optionally, the Redis cluster further includes: a plurality of Redis standby nodes; the Redis standby node is used to receive incremental data sent by the target multi-directional synchronization component when its corresponding target Redis master node fails.
[0083] In the embodiment of the present application, a Redis replica node refers to a Redis server responsible for replicating the master node data in a Redis master-slave replication configuration. Redis replica nodes are designed to enhance system reliability, scalability, and performance, ensuring that data and services are not lost and applications continue to operate even in the event of a single point of failure. Through reasonable configuration and management, the replica node is a key link in the stability of the Redis cluster.
[0084] For example, Figure 6As shown in the figure, the multi-directional synchronization mslave will act as a redis slave to synchronize the data of the redis master in real time. In order to prevent it from being mistaken for a high-availability node for master-slave switching, the slave's switching priority will be set to less than 1000. The lower the slave's priority (weight) is set, the higher the priority. The mslave will set its own switching priority to 9999 by default, that is, it will never be used as a high-availability switch. After the redis master recognizes the standby node, it only uses psync for data synchronization. When the fault is converted, the mslave will detect in real time that the redis master has failed. After the master and slave switch, it will automatically switch to the new redis master for data synchronization.
[0085] In the embodiment of the present application, psync is a protocol used by Redis slave nodes (slave) and master nodes (master) for data synchronization. The full name is Partial Resynchronization Sync, which means partial resynchronization. Compared with the early full synchronization (sync) method of Redis, psync provides a more efficient data synchronization mechanism.
[0086] Optionally, the health management component is used to determine the business traffic information of other Kubernetes slave nodes except the target Kubernetes slave node when a failure of the target Kubernetes slave node is detected; obtain the average concurrency and the total memory used of the target Kubernetes slave node, and determine the candidate transfer nodes among the other Kubernetes slave nodes except the target Kubernetes slave node based on the average concurrency and the total memory used; select the candidate transfer nodes according to the preset CPU impact factor coefficient and the preset memory impact factor coefficient, determine the transferable Kubernetes slave node among the candidate transfer nodes, and switch the business traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
[0087] In the embodiments of the present application, when discussing the "average concurrency of a node" in a distributed system, database or network application, it usually refers to the number of requests or transactions that a node (such as a server, database instance or service endpoint) can process simultaneously per unit time. This indicator is crucial for evaluating system performance, planning resources, optimizing load balancing and ensuring service response time.
[0088] Correspondingly, the total memory used can be the total amount of memory currently occupied by processes, services or systems on a computing node. This includes running applications, system caches, caches, buffers and other memory usage.
[0089] It should be noted that business traffic information may include the number of nodes in each availability zone, the average concurrent request volume in the availability zone (proportional to the business volume), the network latency with other availability zones, the number of remaining CPU cores of each node in the availability zone, and the remaining memory.
[0090] Furthermore, Inter-Availability Zone Network Latency can be the time delay required for network transmission of data or requests between different availability zones in a cloud computing platform or distributed system. Availability zones are isolated infrastructure areas provided by cloud service providers, usually located in the same geographic region but physically independent, in order to improve the high availability and fault tolerance of services.
[0091] For example, Figure 7The figure shows the schematic diagram of health detection of the availability zone, automatic fault calculation and selection of switching business traffic. Taking three availability zones as an example, three K8S nodes K8S 01NODE, K8S 02NODE, and K8S 03NODE each deploy a set of redis clusters with the same specifications. Multiple K8S nodes are deployed in different availability zones, such as Beijing, Shanghai, and Shenzhen. Network communication between K8S clusters is achieved through Submariner. Each shard of the redis cluster has a slave as a single machine failure in the availability zone. The high availability mechanism of redis itself is used for master-slave switching. Another mslave is a self-developed multi-directional synchronization component, which serves as multi-directional synchronization between multiple clusters to ensure data synchronization between clusters. Manager for multi az is a self-developed health detection component. After a certain availability zone fails, it can switch business traffic in real time to ensure the continuous availability of the business. Among them, the business traffic in Shanghai will automatically select the Redis cluster bound to K8S 01NODE in Shanghai through the business program. When K8S 01NODE fails at the availability zone level, the traffic will be switched to the best other availability zone. The best availability zone is obtained through dynamic calculation. Each availability zone will set indicators based on its own resources. Among them, the number of K8S NODE nodes in each availability zone is M, the average concurrent request volume of the availability zone is S (proportional to the business volume), and the network delay with other availability zones is L. The number of remaining CPU cores of each node in the availability zone is Cn (unit core), and the remaining memory is Mn (unit M).
[0092] First, the average concurrency of the current faulty availability zone S1 and the total memory used A1 are used to calculate whether the remaining average concurrency of other availability zones can be carried, as shown in the following formula 1. If both conditions are met, proceed to the next step.
[0093]
[0094] After eliminating the above-mentioned availability zones that do not meet the requirements and whose weights are less than 0, the availability selection evaluation O is performed through normalization processing and CPU impact factor 0.2 and memory impact factor 0.8, as shown in the following formula 2. The availability zone with the largest weight O is automatically selected for traffic migration. At the same time, the Redis cluster is dynamically expanded in real time for this availability zone, so that the cluster scale can reach the total traffic load of the migrated traffic and the existing traffic.
[0095]
[0096] For example, Figure 8As shown in the figure, after the failure of K8S 01NODE, it is calculated that K8S02NODE continues to migrate traffic to the optimal migration zone, and the schematic diagram after the Redis cluster scale is expanded. At this time, the original K82 01NODE traffic will be switched to K8S 02NODE.
[0097] Optionally, the health management component is used to switch the business traffic of the target Redis cluster from the transferable Kubernetes slave node to the target Kubernetes slave node when it is detected that the target Kubernetes slave node is restarting after a failure; the health management component is also used to control multiple multi-directional synchronization components contained in the target Kubernetes slave node to perform synchronization processing of the full data; the health management component is also used to control multiple multi-directional synchronization components to perform synchronization processing of incremental data after detecting that the data contained in multiple Redis master nodes corresponding to the multiple multi-directional synchronization components meet the preset incremental synchronization conditions.
[0098] For example, Fig. 9 As shown, in an embodiment of the present application, after a node failure, the manager for multi az component will select an optimal availability zone to transmit a full data snapshot for full synchronization. After the data is synchronized to be basically consistent, the multi-directional synchronization mslave will be started for incremental synchronization. Specifically, after the availability zone fails and restarts, full synchronization will be performed first through the management component. After the data is basically consistent, it will switch to incremental data synchronization.
[0099] It should be noted that the existing technical solutions mainly synchronize active-active data by dropping files to disk or by disguising them from a processor. The file dropping method mainly uses the native Redis data dropping method, AOF. The most common method in the industry is to transform AOF, such as transforming AOF log to data log formats such as binlog or wal, and adding Redis instance ID to the log to solve cyclic synchronization. Among them, each data log contains a globally unique ID (similar to the GTID in MySQL's binlog). The ID contains two parts, one is the Redis instance ID, which is used to solve the problem of cyclic synchronization, and the second part is an increasing number to ensure order and uniqueness. The data log contains logical clock information. When Redis on the target side performs a merge, the data synchronization problem is solved by using a conflict-free replication data strategy. This method solves cyclic synchronization and can achieve final data synchronization.
[0100] Correspondingly, the slave processor disguises the active-active data synchronization mainly through the Redis native data synchronization device to synchronize the data of the standby node through the psync command. Therefore, another common method is to disguise the data synchronization tool as a slave for processing, such as set kv, disguising the data synchronization tool as a slave. Since Redis provides APIs in multiple languages, the data synchronization tool suitable for disguise in this way can be almost any existing general data synchronization tool. The disguised data synchronization tool slave is responsible for receiving the incremental data sent by the master, and then encapsulating the data in a new SYNC command in the Redis format. The command will be marked with the ID of the cluster and synchronized to another cluster. After receiving the new SYNC command, the Redis server of the other cluster parses the above incremental data synchronization data set kv and executes it, so that the cached data is synchronized. At the same time, the Redis server of the other cluster pushes the new SYNC command to the data synchronization tool slaves within the cluster. Here, the first cluster is defined as cluster A, and the other cluster is defined as cluster B. The data synchronization tool slave principle of cluster B is the same as that of cluster A, and is also encapsulated by the data synchronization tool through the Redis protocol. After receiving the replication request, the data synchronization tool slave in cluster B parses and judges the request: if it is a new SYNC command, it parses whether its cluster A ID is consistent with the target cluster ID to be synchronized. If they are consistent, it does not need to be synchronized to the target cluster, thus avoiding an infinite loop. At the same time, a timestamp is added to each data to solve the problem of data inconsistency.
[0101] However, the method of performing active-active data synchronization by dropping files to disk requires major changes to the existing redis code. Redis's AOF log needs to be changed to a data log, and the AOF log needs to be rewritten, which requires a huge development workload. In addition, when synchronizing data to the peer, the data needs to be sent to the peer first, and the peer determines whether it is loop data, which takes up a lot of network bandwidth and thread processing resources. The method of performing active-active data synchronization by disguising from the processor only considers the active-active method, and the original sync command of redis itself needs to be changed to increase the id, which cannot be adapted to the open source native Redis. It synchronizes the command to master A through data synchronization tool B, and then synchronizes master A to data synchronization tool A again, and then determines whether to synchronize to master A. The native redis needs to be changed, resulting in code modification and intrusion. At the same time, solving data consistency through timestamps is risky. If there is a long delay in data synchronization, the cycle will cause system paralysis.
[0102] In the embodiments of the present application, the above schemes all need to develop and transform Redis itself, which is highly invasive. If the Redis version is upgraded in the future, it is necessary to transform and develop Redis, and it is necessary to design a non-invasive solution for the existing Redis. When the first scheme needs to synchronize data to the other end, the data needs to be sent to the other end first, and the other end determines whether it is loop data, which occupies a large amount of network bandwidth and thread processing resources. The network bandwidth consumption in multiple available intervals is large, and redundant communication needs to be reduced as much as possible. The second scheme does not consider the implementation of multi-active. If it is forced to be applied to multi-active, it will cause a great burden on Redis itself. Each request needs to be judged, which will have a serious impact on the normal use of Redis. It is necessary to design a complete multi-active implementation method. The above schemes only consider data synchronization itself, and do not implement a complete high-availability solution under the multi-active solution. It is necessary to design a high-availability solution for real-time automatic fault switching of traffic in a multi-active mode. Network communication is an important part of realizing multi-active. The network communication method and delay affect the above schemes, which need to be fully considered in the scheme design.
[0103] Compared with the current existing technology, this embodiment deploys multiple Redis clusters in multiple K8S nodes, realizes encrypted communication between clusters through Submariner, and performs real-time multi-directional synchronization through multi-directional data synchronization components. There is no need to develop and transform the native Redis, and it can adapt to the master-slave high availability of Redis itself to perform data synchronization switching. At the same time, it can ensure the final consistency of data, overcome the impact of time delay, and avoid the problem of data circular replication in multi-directional synchronization; the health management component performs real-time health detection on the K8S node. When the K8S node fails, it can calculate the optimal flow rate based on multiple factors and switch the business flow of the failed K8S node to other K8S nodes to ensure that the business failure is not interrupted and the business is not affected after the K8S node fails. Relying on the network communication of K8S, data migration and flow switching after the availability zone failure are realized to ensure the continuous availability of the business.
[0104] In order to improve the current existing technology, it is necessary to develop and transform Redis itself, which will lead to high invasiveness to Redis. When applied to multi-active, it will cause a great burden on Redis itself. Each request needs to be judged, which will seriously affect the normal use of Redis. This embodiment provides a multi-active method for Redis clusters based on multiple Kubernetes, such as Fig.10 As shown, the method includes:
[0105] Step 201: Determine multiple Redis master nodes and multiple multi-directional synchronization components included in multiple Kubernetes slave nodes.
[0106] In the embodiment of the present application, each Kubernetes slave node contains a Redis cluster, each Redis cluster contains multiple Redis shards, and each Redis shard contains a Redis master node and a multi-directional synchronization component.
[0107] Step 202: Control multiple multi-directional synchronization components to perform incremental data synchronization processing on incremental data written to multiple Redis master nodes.
[0108] For example, if there are Redis master node 1, Redis master node 2, Redis master node 3 and Redis master node 4, when incremental data A is written in Redis master node 1, Redis master node 1 will send incremental data A to the multi-directional synchronization component 1 corresponding to Redis master node 1. After receiving the incremental data, the multi-directional synchronization component 1 will send the incremental data to the multi-directional data synchronization component 2 corresponding to Redis master node 2, the multi-directional data synchronization component 3 corresponding to Redis master node 3 and the multi-directional data synchronization component 4 corresponding to Redis master node 4.
[0109] Furthermore, the multi-directional data synchronization component 2 will synchronize the received incremental data to the Redis master node 2; the multi-directional data synchronization component 3 will synchronize the received incremental data to the Redis master node 3; the multi-directional data synchronization component 4 will synchronize the received incremental data to the Redis master node 4, thereby completing the synchronization of the incremental data.
[0110] Step 203: In response to the health management component in the Kubernetes master node detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes fails, determine a transferable Kubernetes slave node among the multiple Kubernetes slave nodes.
[0111] In some examples, if there are Kubernetes slave node 1, Kubernetes slave node 2, Kubernetes slave node 3 and Kubernetes slave node 4, and the health management component detects that Kubernetes slave node 1 has a failure, it is necessary to determine a transferable Kubernetes slave node among Kubernetes slave node 2, Kubernetes slave node 3 and Kubernetes slave node 4.
[0112] Step 204: Switch the service traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
[0113] Exemplarily, based on step 204, if it is determined that the transferable Kubernetes slave node is Kubernetes slave node 4, the business traffic of Kubernetes slave node 1 is transferred to Kubernetes slave node 4.
[0114] Compared with the current existing technology, this embodiment deploys multiple Redis clusters in multiple K8S nodes, and uses multi-directional data synchronization components for real-time multi-directional synchronization. There is no need to develop and transform the native Redis, which can ensure the normal use of Redis, adapt to the master-slave high availability of Redis itself, and perform data synchronization switching. At the same time, it can ensure the final consistency of the data, overcome the impact of time delays, and avoid the problem of multi-directional synchronization data circular replication; the K8S node is subjected to real-time health detection through the health management component. When the K8S node fails, the business traffic of the failed K8S node can be switched to other K8S nodes to ensure that the business failure is not interrupted and the business is not affected after the K8S node fails. Relying on the network communication of K8S, data migration and traffic switching after the availability zone failure are realized to ensure the continuous availability of the business.
[0115] Further, as Fig.10 The specific implementation of the method shown in the embodiment provides a multi-active Redis cluster device based on multiple Kubernetes, such as Fig.11 As shown, the device includes: a determination module 31, a processing module 32, and a switching module 33.
[0116] A determination module 31 is configured to determine a plurality of Redis master nodes and a plurality of multi-directional synchronization components included in a plurality of Kubernetes slave nodes;
[0117] The processing module 32 is configured to control the multiple multi-directional synchronization components to perform incremental data synchronization processing on the incremental data written into the multiple Redis master nodes;
[0118] The determination module 31 is further configured to determine a transferable Kubernetes slave node among the multiple Kubernetes slave nodes in response to a health management component in the Kubernetes master node detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes has a fault;
[0119] The switching module 33 is configured to switch the service traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
[0120] It should be noted that for other corresponding descriptions of the functional units involved in the multi-Kubernetes-based Redis cluster multi-active method provided in this embodiment, please refer to Fig.10 The corresponding description in will not be repeated here.
[0121] Based on the above Fig.10 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Fig.10 The method shown.
[0122] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0123] Based on the above Fig.10 The method shown, and Fig.11 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device, such as a personal computer, a server, a laptop computer, a smart phone, an intelligent robot or other intelligent terminal, which includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Fig.10 The method shown.
[0124] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0125] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0126] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0127] Based on the above Fig.10 The present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned Fig.10 The method shown, the method implemented when the computer program is executed by the processor can refer to the various embodiments of the present application, and will not be described in detail here.
[0128] Through the description of the above implementation methods, the technicians in this field can clearly understand that the present application can be implemented by means of software plus necessary general hardware platforms, or by hardware. Compared with the current prior art, this embodiment deploys multiple Redis clusters in multiple K8S nodes, uses multi-directional data synchronization components for real-time multi-directional synchronization, and does not need to develop and transform the native Redis, which can ensure the normal use of Redis, can adapt to the high availability of the main and standby of Redis itself, and perform data synchronization switching. At the same time, it can ensure the final consistency of the data, overcome the influence caused by time delay, and avoid the problem of multi-directional synchronous data cyclic replication; the K8S node is tested in real time by the health management component. When the K8S node fails, the business traffic of the failed K8S node can be switched to other K8S nodes to ensure that the business failure is not interrupted, and the business is not affected after the K8S node fails. Relying on the network communication of K8S, data migration and traffic switching after the available zone failure are realized to ensure the continuous availability of the business.
[0129] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0130] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.
Claims
1. A multi-Kubernetes-based Redis cluster multi-active system, characterized in that: include: Kubernetes master node and multiple Kubernetes slave nodes; The Kubernetes slave node includes a Redis cluster, and the Redis cluster includes multiple multi-directional synchronization components and multiple Redis master nodes; The multi-directional synchronization component is used to synchronize the incremental data to other Redis master nodes except the target Redis master node after the incremental data is written to the target Redis master node among the multiple Redis master nodes; The Kubernetes master node includes a health management component, which is used to determine a transferable Kubernetes slave node among the multiple Kubernetes slave nodes after detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes has a fault, and switch the business traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
2. The system according to claim 1, characterized in that The Kubernetes slave nodes include: Submariner; In the case that the other Redis master node and the target Redis master node are not in the same Kubernetes slave node, the Submariner is used to encrypt the incremental data and synchronize the encrypted incremental data to the other Redis master node.
3. The system of claim 2, wherein: The Submariner includes: an IPSec tunnel and a network security gateway; The network security gateway is used for the target multi-directional synchronization component corresponding to the target Redis master node to transmit the incremental data to the IPSec tunnel through the network security gateway; The IPSec tunnel is used to transmit the incremental data to other multidirectional synchronization components except the target multidirectional synchronization component through the network security gateway, and the other multidirectional synchronization components are used to synchronize the incremental data to the other Redis master nodes.
4. The system according to claim 1, characterized in that The target multi-directional synchronization component is used to parse the received incremental data when the target synchronization component is the receiving end during the incremental data synchronization process, and if it is determined that the target Redis master node does not contain the received incremental data, synchronize the received incremental data to the target Redis master node; The target multi-directional synchronization component is also used to generate a flag variable corresponding to the target multi-directional synchronization component when the target synchronization component is the sending end during the incremental data synchronization process, mark the transmission protocol used to send incremental data based on the flag variable, and send the incremental data to the other multi-directional synchronization components according to the marked transmission protocol.
5. The system according to claim 4, characterized in that The Redis cluster also includes: multiple Redis standby nodes; The Redis standby node is used to receive the incremental data sent by the target multi-directional synchronization component when the corresponding target Redis master node fails.
6. The system according to claim 1, characterized in that The health management component is used to determine the service flow information of other Kubernetes slave nodes except the target Kubernetes slave node when a failure of the target Kubernetes slave node is detected; Obtain the average concurrency and the total memory used of the target Kubernetes slave node, and determine the candidate transfer nodes among the other Kubernetes slave nodes except the target Kubernetes slave node based on the average concurrency and the total memory used; The candidate transfer nodes are selected according to a preset central processing unit CPU impact factor coefficient and a preset memory impact factor coefficient, a transferable Kubernetes slave node among the candidate transfer nodes is determined, and the business traffic of the target Redis cluster is switched from the target Kubernetes slave node to the transferable Kubernetes slave node.
7. The system according to claim 1, characterized in that The health management component is used to switch the service traffic of the target Redis cluster from the transferable Kubernetes slave node to the target Kubernetes slave node when detecting that the target Kubernetes slave node is restarting after a failure; The health management component is also used to control multiple multi-directional synchronization components included in the target Kubernetes slave node to perform synchronization processing of full data; After detecting that the data contained in the multiple Redis master nodes corresponding to the multiple multi-directional synchronization components meets the preset incremental synchronization conditions, the multiple multi-directional synchronization components are controlled to perform synchronization processing of the incremental data.
8. A multi-active Redis cluster method based on multiple Kubernetes, characterized in that: include: Identify multiple Redis master nodes and multiple multi-directional synchronization components contained in multiple Kubernetes slave nodes; Control the multiple multi-directional synchronization components to perform incremental data synchronization processing on the incremental data written into the multiple Redis master nodes; In response to a health management component in the Kubernetes master node detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes is faulty, determining a transferable Kubernetes slave node among the multiple Kubernetes slave nodes; Switch the service traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
9. A multi-Kubernetes-based Redis cluster multi-active device, characterized in that: include: A determination module is configured to determine a plurality of Redis master nodes and a plurality of multi-directional synchronization components included in a plurality of Kubernetes slave nodes; A processing module is configured to control the multiple multi-directional synchronization components to perform incremental data synchronization processing on the incremental data written into the multiple Redis master nodes; The determination module is further configured to determine a transferable Kubernetes slave node among the multiple Kubernetes slave nodes in response to a health management component in the Kubernetes master node detecting that a target Kubernetes slave node among the multiple Kubernetes slave nodes has a fault; The switching module is configured to switch the service traffic of the target Redis cluster from the target Kubernetes slave node to the transferable Kubernetes slave node.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to claim 8 is implemented.
11. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to claim 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that: When the computer program is executed by a processor, the method according to claim 8 is implemented.
Citation Information
Cited By
Application active system, application disaster recovery management method, and computer device
WO2026103837A1
