Rapid capacity expansion method of Redis cluster based on Proxy architecture

Through the method based on Proxy architecture, the problems of low expansion efficiency and data loss of Redis cluster are solved, efficient, smooth and imperceptible dynamic expansion is achieved, ensuring business continuity and data integrity.

CN118656362AActive Publication Date: 2024-09-17CHINA TELECOM CLOUD TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410863311.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-29
Publication Date
2024-09-17
Estimated Expiration
2044-06-29

AI Technical Summary

Technical Problem

The existing technology is inefficient during the expansion process of the Redis cluster, is prone to data loss, and is business-aware, and cannot achieve fast, smooth, and imperceptible horizontal expansion.

Method used

Adopt a method based on Proxy architecture to achieve dynamic expansion and ensure data integrity through steps such as precondition determination, execution plan formulation, parallel control, execution backup, RDB file transfer, full data loading, write prohibition commands, and incremental data loading. and business continuity.

Benefits of technology

It achieves efficient, smooth, and imperceptible dynamic expansion of the Redis cluster, reduces data migration time, ensures business continuity and data integrity, and avoids data loss and business impact.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656362A
    Figure CN118656362A
Patent Text Reader

Abstract

The invention discloses a rapid expansion method of a Redis cluster based on a Proxy architecture. The method comprises the following steps: judging a precondition; making an execution plan; executing backup; transmitting an RDB file; detecting the RDB file; full data loading is carried out; forbidding writing by the source node: starting a forbidding writing command by the source node to ensure that the data is not increased any more; incremental data loading: the Proxy-Server analyzes an aof file of a source node, and backtracks a redis command; updating the slot position relationship; according to the steps S4 to S10, the remaining plan is executed to complete cluster capacity expansion; and cleaning source node data. According to the method, dynamic expansion, logistics file migration and rapid transfer of total data are carried out based on an existing cluster, only incremental data need to parse an aof playback write command, services are normally provided in the migration process, and the services are not affected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cloud computing, and in particular to a method for rapidly expanding a Redis cluster based on a Proxy architecture. Background Art

[0002] When the business develops rapidly or a business bug occurs, the Redis capacity and traffic are prone to overload. The business party often hopes to perform fast, smooth, lossless, and imperceptible horizontal expansion without changing the IP link address.

[0003] In many cases, the business will adopt the following approach: open a new cluster, use the Redis Shake tool to migrate data, and then replace the IP link address to complete the "capacity expansion" (new change) of the cluster. However, this method not only has a greater business perception (IP link address needs to be replaced), but also has a high probability of data loss, resulting in business damage.

[0004] In response to the current problems of Proxy-Redis clusters: low expansion efficiency, data loss, and expansion awareness, this patent provides a high-efficiency, smooth, and imperceptible dynamic expansion method to solve the above problems. Summary of the invention

[0005] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.

[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0007] A rapid capacity expansion method for a Redis cluster based on a Proxy architecture, comprising:

[0008] S1. Precondition determination: whether resources are in place;

[0009] S2. Formulate an execution plan: confirm the split source node and target node, and reallocate the slots;

[0010] S3, parallel control: apply distributed locks to ensure the seriality of capacity expansion;

[0011] S4. Execute backup: flush the memory data to disk, regenerate the rdb file, perform data backup, and reduce the data in memory;

[0012] S5, RDB file transfer: transfer the RDB file from the source node to each target node;

[0013] S6, RDB file detection: compare the MD5 values ​​of the files of the source node and the target node;

[0014] S7, full data loading: Start the target node and load the required data from the RDB into the memory according to the allocated slots;

[0015] S8, source node write prohibition: The source node starts the write prohibition command to ensure that the data does not increase;

[0016] S9, incremental data loading: Proxy-Server parses the source node aof file and traces back the redis command;

[0017] S10, updating slot relationship;

[0018] S11. According to steps S4 to S10, execute the remaining plan to complete cluster expansion;

[0019] S12. Clean source node data.

[0020] As a preferred solution of the method for rapid expansion of a Redis cluster based on a Proxy architecture described in the present invention, the precondition in S1 includes the resources necessary for the expansion of Redis-Server and Proxy-Server.

[0021] As a preferred solution of the rapid expansion method of a Redis cluster based on a Proxy architecture described in the present invention, the principles that need to be followed in the execution plan in S2 include: a. maintaining the existing cluster; b. using the node splitting mode for horizontal expansion; c. storing the slot information in zk.

[0022] As a preferred solution of the method for rapid expansion of a Redis cluster based on a Proxy architecture described in the present invention, wherein: maintaining the existing cluster is specifically dynamically expanding the existing cluster horizontally, and the total number of shards after expansion must be m times the current number of shards, m>=1.

[0023] As a preferred solution of the rapid expansion method of a Redis cluster based on a Proxy architecture described in the present invention, the horizontal expansion using the node splitting mode is specifically that the number of nodes is changed to n times, then a single node needs to migrate out the data of (n-1) / n slots, and only retains the data of 1 / n slots.

[0024] As a preferred solution of the method for rapid expansion of a Redis cluster based on a Proxy architecture described in the present invention, wherein: S4 performs backup by flushing the data in the Redis memory to the disk using the bgsave command.

[0025] As a preferred solution of the rapid expansion method of a Redis cluster based on a Proxy architecture described in the present invention, wherein: S5 uses the RDB persistence function of Redis to export the full amount of data in the form of an RDB file, and then transfers the RDB file to a new Redis server.

[0026] As a preferred solution of the rapid expansion method of a Redis cluster based on a Proxy architecture described in the present invention, the write-disable command in S8 adopts a self-developed redis command.

[0027] As a preferred solution of the method for rapid expansion of a Redis cluster based on a Proxy architecture described in the present invention, the updating of the slot relationship in S10 specifically includes updating the slot relationship in zk and removing the write-forbidden restriction on the source node.

[0028] As a preferred solution of the rapid expansion method of a Redis cluster based on a Proxy architecture described in the present invention, wherein: the cleaning of source node data in S12 is specifically processed by a Proxy-server program to filter out the data corresponding to the slots migrated out of the memory.

[0029] Beneficial effects of the present invention:

[0030] Dynamic expansion based on existing clusters, rather than completely new ones. This means that during the expansion process, new Redis servers can be gradually added instead of replacing all servers at once. This ensures that the business side will not feel any impact when using Redis services. Data migration is more simplified: migration is performed on-site, without the need to open a new machine for replacement; migration speed is fast: logistics file migration, fast transfer of full data, only incremental data needs to parse aof playback write commands; smooth and imperceptible: during the migration process, the business provides services normally, and there is no impact on the business. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:

[0032] Figure 1 The present invention provides a flowchart of a method for rapidly expanding a Redis cluster based on a Proxy architecture. DETAILED DESCRIPTION

[0033] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.

[0034] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0035] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0036] Example 1

[0037] Reference Figure 1 The present invention provides a rapid capacity expansion method for a Redis cluster based on a Proxy architecture, comprising:

[0038] S1. Precondition determination: whether resources are in place;

[0039] S2. Formulate an execution plan: confirm the split source node and target node, and reallocate the slots;

[0040] S3, parallel control: apply distributed locks to ensure the seriality of capacity expansion, which can be achieved by ZK, DB, etc.

[0041] S4. Execute backup: flush the memory data to disk, regenerate the rdb file, perform data backup, and reduce the data in memory;

[0042] S5, RDB file transfer: transfer the RDB file from the source node to each target node;

[0043] S6, RDB file detection: Compare the MD5 values ​​of the files on the source node and the target node to ensure that the files are sent and received normally and the data is complete;

[0044] S7, full data loading: Start the target node, load the required data from the RDB into the memory according to the allocated slot, and use the self-developed redis command or program control;

[0045] S8, source node write prohibition: The source node starts the write prohibition command to ensure that the data does not increase;

[0046] S9, incremental data loading: Proxy-Server parses the source node aof file and traces back the redis command; connects to the target node, executes the corresponding command on the target node according to the allocated slot, and completes the incremental data loading;

[0047] S10, updating the slot relationship; at this point, the current source node has completed the split, and the source node and the target node begin to provide services;

[0048] S11. According to steps S4 to S10, execute the remaining plan to complete cluster expansion;

[0049] S12. Clean the source node data and filter out redundant information.

[0050] Among them, the prerequisites in S1 include the resources required for the expansion of Redis-Server and Proxy-Server, specifically servers, jar packages, scripts, etc.

[0051] Furthermore, the principles that need to be followed in the execution plan in S2 include: a. Maintaining the existing cluster; b. Using the node splitting mode for horizontal expansion; c. The slot information is stored in zk.

[0052] Furthermore, maintaining the existing cluster specifically involves dynamically expanding the existing cluster horizontally, and the total number of shards after the expansion must be m times the current number of shards, where m>=1.

[0053] Furthermore, if the node splitting mode is used for horizontal expansion, specifically the number of nodes is changed to n times, then a single node needs to migrate out the data of (n-1) / n slots, and only retains the data of 1 / n slots.

[0054] Furthermore, S4 performs backup by flushing the data in Redis memory to disk using the bgsave command, which ensures that data will not be lost even if the Redis server fails during the expansion process. At the same time, the flushing operation can reduce the pressure of synchronizing subsequent incremental data.

[0055] Furthermore, S5 uses the RDB persistence function of Redis to export all data in the form of RDB files, and then transfers the RDB files to the new Redis server and loads them according to the slots through self-developed loading commands or programs. This ensures that the new Redis server can quickly obtain all data.

[0056] Furthermore, the write-forbidden command in S8 uses a self-developed redis command to ensure that data does not increase.

[0057] Furthermore, updating the slot relationship in S10 specifically includes updating the slot relationship in zk and removing the write-forbidden restriction of the source node.

[0058] Furthermore, the source node data cleaning in S12 is specifically processed by the Proxy-server program to filter out the data corresponding to the slots migrated out of the memory.

[0059] Before executing the plan, use the bgsave command to flush the data in Redis memory to disk. This ensures that data will not be lost even if the Redis server fails during the expansion process. At the same time, the flushing operation can reduce the pressure of synchronizing subsequent incremental data.

[0060] Use the RDB persistence function of Redis to export all data in the form of an RDB file. Then, transfer the RDB file to the new Redis server and load it according to the slot using a self-developed loading command or program. This ensures that the new Redis server can quickly obtain all data.

[0061] Before synchronizing incremental data, use the Redis write-disable command or function to ensure that no data is lost during the data synchronization process.

[0062] Dynamic expansion is performed based on the existing cluster, rather than replacing all new ones. This means that during the expansion process, new Redis servers can be added gradually, rather than replacing all servers at once. This ensures that the business side will not feel any impact when using the Redis service.

[0063] Example 2

[0064] Reference Figure 1 , which is the second embodiment of the present invention, and this embodiment is different from the first embodiment in that, in order to verify its beneficial effects. The specific steps are as follows:

[0065] Step 1: Before executing the expansion plan, first perform a bgsave operation on the source node to back up data to ensure data security and reduce the amount of data in the aof file, making the subsequent synchronization process faster;

[0066] Step 2, the present invention completes the transmission of the full amount of data by synchronizing the RDB file. After the target node loads the RDB file, it can quickly import the data into the memory, thereby entering a normal working state;

[0067] Step 3: After starting the target node process, use the self-developed slot-based loading command or program to load the RDB file according to the predetermined slot, so that only the required data is entered into the memory, avoiding data redundancy and waste of computing resources;

[0068] Step 4: Set a write-forbidden restriction on the source node Redis to ensure that data will not be continuously added, thus ensuring data consistency and stability (restrictions on write operations can be implemented by modifying the Redis kernel or proxy layer);

[0069] Step 5: When parsing the AOF file, the device can synchronize the data to the target node according to the slot setting, further improving the accuracy and efficiency of data synchronization.

[0070] At this point, the data has been synchronized and the node splitting process has been successfully completed. The present invention effectively improves the expansion efficiency and data consistency of the Proxy-Redis distributed cluster, while minimizing the impact on the business.

[0071] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A rapid expansion method for Redis cluster based on Proxy architecture. Features: include: S1. Precondition determination: whether resources are in place; S2. Formulate an execution plan: confirm the split source node and target node, and reallocate the slots; S3, parallel control: apply distributed locks to ensure the seriality of capacity expansion; S4. Execute backup: flush the memory data to disk, regenerate the rdb file, perform data backup, and reduce the data in memory; S5, RDB file transfer: transfer the RDB file from the source node to each target node; S6, RDB file detection: compare the MD5 values ​​of the files of the source node and the target node; S7, full data loading: Start the target node and load the required data from the RDB into the memory according to the allocated slots; S8, source node write prohibition: The source node starts the write prohibition command to ensure that the data does not increase; S9, incremental data loading: Proxy-Server parses the source node aof file and traces back the redis command; S10, updating slot relationship; S11. According to steps S4 to S10, execute the remaining plan to complete cluster expansion; S12. Clean source node data.

2. According to the method for rapidly expanding the Redis cluster based on the Proxy architecture described in claim 1, Features: The prerequisites in S1 include the resources necessary for the expansion of Redis-Server and Proxy-Server.

3. According to the method for rapidly expanding the Redis cluster based on the Proxy architecture described in claim 2, Features: The principles that need to be followed in the execution plan in S2 include: a. Maintaining the existing cluster; b. Using the node splitting mode for horizontal expansion; c. The slot information is stored in zk.

4. According to claim 3, a method for rapidly expanding a Redis cluster based on a Proxy architecture, Features: Maintaining the existing cluster specifically refers to dynamically expanding the existing cluster horizontally. The total number of shards after the expansion must be m times the current number of shards, where m>=1.

5. According to claim 4, a method for rapidly expanding a Redis cluster based on a Proxy architecture, Features: The horizontal expansion using the node splitting mode specifically means that the number of nodes is changed to n times, and a single node needs to migrate out the data of (n-1) / n slots, and only retains the data of 1 / n slots.

6. According to claim 5, a method for rapidly expanding a Redis cluster based on a Proxy architecture, Features: The S4 performs backup by flushing the data in the Redis memory to the disk using the bgsave command.

7. According to claim 6, a method for rapidly expanding a Redis cluster based on a Proxy architecture, Features: The S5 uses the RDB persistence function of Redis to export all data in the form of RDB files, and then transfers the RDB files to the new Redis server.

8. According to the method for rapidly expanding the capacity of a Redis cluster based on a Proxy architecture according to claim 7, Features: The write-forbidden command in the S8 adopts the self-developed redis command.

9. According to claim 8, a method for rapidly expanding a Redis cluster based on a Proxy architecture, Features: The updating of the slot relationship in S10 specifically includes updating the slot relationship in zk and removing the write prohibition restriction of the source node.

10. According to claim 9, a method for rapidly expanding a Redis cluster based on a Proxy architecture, Features: The source node data cleaning in S12 is specifically processed by the Proxy-server program to filter out the slot corresponding data moved out of the memory.

Citation Information

Patent Citations

  • Data migration method and device

    CN116340291A

  • Method and system for realizing dynamic capacity expansion and shrinkage of perceived redis access machine

    CN116346625A

  • Redis read-write separation system and method based on protocol proxy

    CN117827099A

  • Data backup method and apparatus, data recovery method and apparatus, and storage medium

    US20230325287A1