Redis cluster routing method, device, equipment, storage medium and program product
By introducing an intermediate proxy layer between the Redis client and the caller, and distributing Redis call requests based on the routing mapping table, the capacity limit problem of Redis cluster during the upper limit of capacity expansion is solved, and efficient request routing and cluster expansion across clusters are achieved.
Patent Information
- Application Number
- CN202211390014.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-08
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2042-11-08
AI Technical Summary
When the existing Redis cluster is expanded at the upper limit of capacity, the node recovery time increases, resulting in the service recovery time being extended, and a single cluster has capacity limitations, so it is impossible to effectively handle Redis call requests across clusters.
By introducing an intermediate proxy layer between the Redis client and the caller, Redis call request information is obtained, and the target cluster identification information and route status identification information are determined based on the routing mapping table, so that the Redis call request is distributed to the corresponding target cluster.
Redis call request routing across clusters is implemented, breaking through the limit of capacity bottleneck of a single cluster, and improving the scalability and scalability of the Redis cluster.
Smart Images

Figure CN115866064B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of cloud computing technology, specifically to the field of distributed storage technology, and more specifically to a routing method, device, equipment, storage medium and program product of a Redis cluster. Background Art
[0002] The Redis cluster built based on Redis-cluster technology can expand capacity by expanding nodes when encountering storage bottlenecks. In theory, it can have nearly unlimited capacity to support the development of services and businesses. However, when the capacity of a single node is too high, it will take too long for the node to recover, and the recovery time required for the node to provide external services will increase. Therefore, as the business develops, multiple Redis clusters are often required to jointly provide storage services. Therefore, a single Redis cluster has a capacity limitation problem. In addition, in the related technology, for Redis call requests initiated by the client, the same cluster nodes can only be divided based on the hash value of the key, that is, the routing between the same cluster nodes. It is impossible to divide the key independently so that different keys are distributed in different clusters.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] In view of the above problems, the present disclosure provides a routing method, apparatus, device, storage medium and program product for a Redis cluster that addresses the upper limit of Redis cluster expansion.
[0005] According to a first aspect of the present disclosure, a routing method for a Redis cluster is provided, the routing method comprising:
[0006] Responding to the Redis call request from the client, obtaining Redis call request information;
[0007] Determine the target cluster identification information and the routing state identification information according to the Redis call request information and the routing mapping table, wherein the routing mapping table is used to store the mapping relationship between the primary key type and the Redis cluster;
[0008] Determine the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information;
[0009] Distribute the Redis call request to the target cluster corresponding to the Redis call request.
[0010] According to an embodiment of the present disclosure, the Redis call request information includes primary key type information, and determining the target cluster identification information and the routing state identification information according to the Redis call request information and the routing mapping table includes:
[0011] The target cluster identification information and the routing state identification information are determined according to the primary key type information and the routing mapping table.
[0012] According to an embodiment of the present disclosure, determining the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information includes:
[0013] When it is determined that the routing state is not enabled, determining the default cluster as the target cluster corresponding to the Redis call request;
[0014] When it is determined that the routing state is enabled, the target cluster corresponding to the Redis call request is determined according to the target cluster identification information.
[0015] According to an embodiment of the present disclosure, determining the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information further includes:
[0016] When it is determined that the routing state is in migration, determining the migration state identification information corresponding to the Redis call request;
[0017] Performing a migration status check on the Redis call request according to the migration status identification information;
[0018] The target cluster corresponding to the Redis call request is determined according to the migration status verification result.
[0019] According to an embodiment of the present disclosure, it also includes:
[0020] The routing mapping table is configured according to the cluster configuration information table.
[0021] A second aspect of the present disclosure provides a routing device for a Redis cluster, the routing device comprising:
[0022] The acquisition module is used to respond to the Redis call request of the client and obtain the Redis call request information;
[0023] A first determination module, used to determine the target cluster identification information and the routing state identification information according to the Redis call request information and the routing mapping table, wherein the routing mapping table is used to store the mapping relationship between the primary key type and the Redis cluster;
[0024] A second determination module is used to determine the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information;
[0025] The sending module is used to distribute the Redis call request to the target cluster corresponding to the Redis call request.
[0026] According to an embodiment of the present disclosure, the first determination module includes:
[0027] The third determination submodule is used to determine the target cluster identification information and the routing state identification information according to the primary key type information and the routing mapping table.
[0028] According to an embodiment of the present disclosure, the second determination module includes:
[0029] A first determination submodule is used to determine, when the routing state is determined to be disabled, a default cluster as a target cluster corresponding to the Redis call request;
[0030] The second determination submodule is used to determine the target cluster corresponding to the Redis call request according to the target cluster identification information when the routing state is determined to be enabled.
[0031] According to an embodiment of the present disclosure, the second determining module further includes:
[0032] A fourth determination submodule is used to determine the migration state identification information corresponding to the Redis call request when the routing state is determined to be in migration;
[0033] A verification submodule, used to perform a migration status verification on the Redis call request according to the migration status identification information;
[0034] The fifth determination submodule is used to determine the target cluster corresponding to the Redis call request according to the migration status verification result.
[0035] According to an embodiment of the present disclosure, it also includes:
[0036] A configuration module is used to configure the routing mapping table according to the cluster configuration information table.
[0037] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above method.
[0038] The fourth aspect of the present disclosure also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above method.
[0039] The fifth aspect of the present disclosure also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0040] A routing method for a Redis cluster provided by an embodiment of the present disclosure adds an intermediate proxy layer to the Redis client and the caller, obtains Redis call request information when receiving a Redis call request from the client; determines the target cluster identification information and the routing status identification information according to the Redis call request information and the routing mapping table, determines the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing status identification information; distributes the Redis call request to the target cluster corresponding to the Redis call request, thereby realizing cross-cluster routing of the call request. This breaks through the limitation in the related art that routing can only be performed in the same cluster, thereby breaking through the limitation of the capacity bottleneck of a single cluster. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0042] Figure 1 The flowchart of the original Redis service call is schematically shown;
[0043] Figure 2 The application scenario diagram of the routing method, apparatus, device, medium and program product of the Redis cluster according to the embodiment of the present disclosure is schematically shown;
[0044] Figure 3 A system architecture diagram of a Redis cluster routing method provided according to an embodiment of the present disclosure is schematically shown;
[0045] Figure 4 A flowchart of a Redis cluster routing method provided according to an embodiment of the present disclosure is schematically shown;
[0046] Figure 5 A flowchart schematically shows a method for determining target cluster identification information and routing state identification information provided according to an embodiment of the present disclosure;
[0047] Figure 6 A flowchart schematically illustrates a method for determining a target cluster according to an embodiment of the present disclosure;
[0048] Figure 7 A structural block diagram of a routing device of a Redis cluster according to an embodiment of the present disclosure is schematically shown;
[0049] Figure 8A block diagram of an electronic device suitable for implementing a routing method for a Redis cluster according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0050] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0051] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0052] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0053] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0054] In order to better understand the technical problems of the present disclosure, Figure 1 Explain and illustrate technical issues in related technologies. Figure 1 The flowchart of the original Redis service call is schematically shown.
[0055] like Figure 1As shown, when the caller needs to use the Redis storage service to read and write data, it sends a request for the Redis key to the Redis client. In the related technology, sharding is performed based on the hash value of the key to achieve the division of the same cluster node for routing. Although the Redis cluster built based on the Redis-cluster technology can complete capacity expansion by expanding nodes when encountering storage bottlenecks, this is bound to bring certain problems. For example, when the capacity of a single node is too high, it will take too long for the node to recover, and the recovery time required for the node to provide external services will increase. At the same time, a single network card has a traffic bottleneck, which may be full of network cards, causing other service networks on the same equipment rack to be affected, affecting the normal service of other services. The number of nodes in a single cluster needs to be controlled. In the existing open source Redis rich client mode, the client locally caches all node information, thereby reducing the number of network requests and improving efficiency. However, on this basis, if the number of nodes in the Redis cluster is large, when some master nodes in the cluster are abnormal, it will take longer for the client to re-cache all node information locally. During this process, the client has already accessed the abnormal node, resulting in amplification of network requests and increased bandwidth pressure. Therefore, a single Redis cluster actually has capacity limitations. For some Redis usage scenarios where data is persisted, the storage limit may be triggered, causing service exceptions.
[0056] Based on the above technical problems, an embodiment of the present disclosure provides a routing method for a Redis cluster, the routing method comprising: in response to a Redis call request from a client, obtaining Redis call request information; determining target cluster identification information and routing status identification information according to the Redis call request information and a routing mapping table, wherein the routing mapping table is used to store a mapping relationship between a primary key type and a Redis cluster; determining a target cluster corresponding to the Redis call request according to the target cluster identification information and the routing status identification information; and distributing the Redis call request to the target cluster corresponding to the Redis call request.
[0057] Figure 2 The application scenario diagram of the routing method, apparatus, device, medium and program product of the Redis cluster according to the embodiment of the present disclosure is schematically shown.
[0058] like Figure 2 As shown, the application scenario 100 according to this embodiment may include a service call scenario. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0059] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0060] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0061] Server 105 can be a cluster node server that provides distributed storage services and routes the data read and write service requests received from the service caller through the application server to the target cluster. For example, in response to a redis key call request initiated by the caller, the cluster node server determines the corresponding target cluster based on the key type and the routing mapping table, and routes the request to the target cluster, which then completes the subsequent data read and write operations.
[0062] It should be noted that the routing method of the Redis cluster provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the routing device of the Redis cluster provided in the embodiment of the present disclosure can generally be set in the server 105. The routing method of the Redis cluster provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the routing device of the Redis cluster provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0063] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0064] It should be noted that the routing method and device of the Redis cluster determined in the embodiments of the present disclosure can be used in the field of cloud computing technology, the field of financial technology, and any field other than the financial field. The application field of the routing method and device of the Redis cluster determined in the embodiments of the present disclosure is not limited.
[0065] Figure 3 The system architecture diagram of the routing method of the Redis cluster provided in accordance with the embodiment of the present disclosure is schematically shown. Figure 3The system architecture workflow of the embodiment of the present disclosure is described as follows: Figure 3 As shown, the embodiment of the present disclosure sets an intermediate layer between the caller and the Redis client, and the intermediate layer executes the routing method provided by the embodiment of the present disclosure to distribute the call request of the caller's Redis key to each Redis cluster cluster to realize data reading and writing. The routing method provided by the embodiment of the present disclosure is not sensitive to the caller, so that the Redis cluster can be expanded or reduced according to business needs, which is convenient for the splitting and expansion of the Redis cluster. The processing logic of distributing the Redis key call request to the corresponding Redis cluster is the same as that in the prior art, that is, a hash operation is performed according to the key and routed to a specific shard.
[0066] The following will be based on Figure 2 The scene described and Figure 3 The system architecture is Figure 4 The routing method of the Redis cluster in the embodiment of the present disclosure is described in detail.
[0067] Figure 4 The flowchart of a routing method of a Redis cluster provided according to an embodiment of the present disclosure is schematically shown. Figure 4 As shown, the routing method of the Redis cluster of this embodiment includes operations S210 to S240, which can be performed by a server or other computing device. When some redis usage scenarios are persistent data, as the business grows, the number of requests for data reading and writing also grows, which may trigger the storage limit and cause service abnormalities. Therefore, according to the routing method provided in the embodiment of the present disclosure, routing is performed at the upper layer to realize data routing between multiple clusters, thereby avoiding the capacity limitation problem that may occur in a single cluster.
[0068] In the embodiment of the present disclosure, two redis clusters C1 and C2 are taken as an example for description, but the routing method of the embodiment of the present disclosure is also applicable to cross-cluster routing between multiple clusters.
[0069] In operation S210, in response to a Redis call request from a client, Redis call request information is obtained.
[0070] In operation S220, target cluster identification information and routing state identification information are determined according to the Redis call request information and the routing mapping table.
[0071] According to an embodiment of the present disclosure, the routing mapping table is used to store a mapping relationship between a primary key type and a Redis cluster.
[0072] In one example, a middle layer is added between the caller and the redis client to execute the routing method of the embodiment of the present disclosure, and complete the routing operation of the corresponding redis key according to specific rules. The specific rules are generally divided into two categories: write rules and read rules. Specifically, they include routing verification rules, routing status verification rules, dual-write status verification rules, and asynchronous processing rules. When a redis call request from the caller is received, the call request can be to read data or write data. The middle layer performs routing verification on the requested key to determine whether routing rules are configured. If the current type is configured with routing rules, the target cluster is determined according to the routing rules; if the current type is not configured with routing rules, the request is sent to the default cluster and the data is written to the default cluster. According to the Redis call request information obtained in operation S210, the redis data structure is parsed to determine the type of the requested primary key key, and the target cluster identification information and routing status identification information corresponding to the current request are determined according to the pre-configured routing mapping table, wherein the routing mapping table stores the mapping relationship between the primary key type (redis type), cluster identification (cluster name) and routing status identification (Status). For the specific determination process, please refer to Figure 5 Operation S221 is not described in detail here.
[0073] In operation S230, a target cluster corresponding to the Redis call request is determined according to the target cluster identification information and the routing state identification information.
[0074] In operation S240, the Redis call request is distributed to a target cluster corresponding to the Redis call request.
[0075] In one example, the target cluster corresponding to the Redis call request is determined according to the target cluster identification information and the routing state identification information. For a specific method of determining the target cluster, see Figure 6 Operation S231 and operation S232 shown are not described in detail here. The Redis call request is distributed to the target cluster corresponding to the Redis call request, and the target cluster continues to perform data shard routing and read and write operations.
[0076] A routing method for a Redis cluster provided by an embodiment of the present disclosure adds an intermediate proxy layer to the Redis client and the caller, determines the target cluster identification information and the routing state identification information according to the Redis call request information and the routing mapping table, determines the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information; distributes the Redis call request to the target cluster corresponding to the Redis call request, thereby realizing cross-cluster routing of the call request. This breaks through the limitation of the capacity bottleneck of a single cluster and is conducive to the splitting and expansion of the Redis cluster.
[0077] Figure 5 The flowchart of the method for determining the target cluster identification information and the routing state identification information provided by the embodiment of the present disclosure is schematically shown. Figure 5 As shown, operation S220 includes operation S221.
[0078] In operation S221, target cluster identification information and routing state identification information are determined according to the primary key type information and the routing mapping table.
[0079] In an example, a sample of the routing mapping table is shown in Table 1 below. As shown in Table 1, the routing mapping table stores the mapping relationship between the primary key type (redis type), the cluster identifier (cluster name) and the routing status identifier (Status). The routing status is used to characterize the validity of the current routing rules. According to business needs, it can be specifically divided into enabled state, disabled state, migrating state, dual read-write state and abandoned state. The enabled state indicates that the currently configured routing rules are valid, and the disabled state and abandoned state indicate that the currently configured routing rules are invalid. The migrating state indicates that this type of data is being migrated. At this time, it is necessary to further determine whether dual reading or dual writing is required based on the dual read-write status identifier, that is, to perform a dual write status verification rule verification.
[0080] Table 1 Route mapping table
[0081]
[0082] Figure 6 The flowchart of the method for determining the target cluster provided by the embodiment of the present disclosure is schematically shown. Figure 6 As shown, operation S230 includes operations S231 to S232.
[0083] In operation S231, when it is determined that the routing state is not enabled, the default cluster is determined to be the target cluster corresponding to the Redis call request.
[0084] In operation S232, when it is determined that the routing state is enabled, a target cluster corresponding to the Redis call request is determined according to the target cluster identification information.
[0085] According to an embodiment of the present disclosure, when it is determined that the routing status is in migration, the migration status identification information corresponding to the Redis call request is determined; the migration status of the Redis call request is verified according to the migration status identification information; and the target cluster corresponding to the Redis call request is determined according to the migration status verification result.
[0086] In an example, as shown in Table 1 above, redis type represents the redis type in a certain business scenario, cluster name is the cluster name, and Status is the routing status. When redis type is TI type, it is determined that the routing status is not enabled, then the target cluster corresponding to T1 is determined to be the default cluster, and all redis keys of type T1 will be placed in the default cluster. When redis type is T2 type, it is determined that the routing status is enabled, then the target cluster corresponding to T2 is determined to be C2, and all redis keys of type T2 will be placed in the C2 cluster. When redis type is T3 type, it is determined that the routing status is migrating, then it is further determined whether it is dual-read and dual-write based on the migration status identification information. If dual-read or dual-write is determined, then the target cluster corresponding to T3 is determined to be C1 and the default cluster. This difference is related to the specific business and can be configured by yourself.
[0087] According to an embodiment of the present disclosure, the routing mapping table can be pre-configured according to the cluster configuration information table. The cluster configuration information table includes the cluster name, the IP address corresponding to the cluster, the cluster username and password, and the routing status information. There will be multiple types of redis keys in the system, which are configured according to the type and persisted in the database to ensure that the same type of redis keys are placed in the same redis cluster, so as to achieve routing of different clusters according to the key type.
[0088] Based on the above-mentioned Redis cluster routing method, the present disclosure also provides a Redis cluster routing device. Figure 7 The device is described in detail.
[0089] Figure 7 The structural block diagram of a routing device of a Redis cluster according to an embodiment of the present disclosure is schematically shown.
[0090] like Figure 7 As shown, the routing device 600 of the Redis cluster of this embodiment includes an acquisition module 610 , a first determination module 620 , a second determination module 630 and a sending module 640 .
[0091] The acquisition module 610 is used to respond to the Redis call request of the client and acquire the Redis call request information. In one embodiment, the acquisition module 610 can be used to perform the operation S210 described above, which will not be described in detail here.
[0092] The first determination module 620 is used to determine the target cluster identification information and the routing state identification information according to the Redis call request information and the routing mapping table, wherein the routing mapping table is used to store the mapping relationship between the primary key type and the Redis cluster. In one embodiment, the first determination module 620 can be used to perform the operation S220 described above, which is not repeated here.
[0093] The second determination module 630 is used to determine the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information. In one embodiment, the second determination module 630 can be used to perform the operation S230 described above, which will not be repeated here.
[0094] The sending module 640 is used to distribute the Redis call request to the target cluster corresponding to the Redis call request. In one embodiment, the sending module 640 can be used to perform the operation S240 described above, which will not be repeated here.
[0095] According to an embodiment of the present disclosure, the first determination module 620 includes: a third determination submodule.
[0096] The third determination submodule is used to determine the target cluster identification information and the routing state identification information according to the primary key type information and the routing mapping table. In one embodiment, the third determination submodule can be used to perform the operation S221 described above, which will not be described in detail here.
[0097] According to an embodiment of the present disclosure, the second determination module 630 includes: a first determination submodule and a second determination submodule.
[0098] The first determination submodule is used to determine the default cluster as the target cluster corresponding to the Redis call request when the routing state is determined to be not enabled; in one embodiment, the first determination submodule can be used to perform the operation S231 described above, which will not be repeated here.
[0099] The second determination submodule is used to determine the target cluster corresponding to the Redis call request according to the target cluster identification information when the routing state is determined to be enabled. In one embodiment, the second determination submodule can be used to perform the operation S232 described above, which will not be repeated here.
[0100] According to an embodiment of the present disclosure, the second determination module 630 further includes: a fourth determination submodule, a verification submodule and a fifth determination submodule.
[0101] The fourth determination submodule is used to determine the migration state identification information corresponding to the Redis call request when it is determined that the routing state is migrating.
[0102] The verification submodule is used to perform a migration status verification on the Redis call request according to the migration status identification information.
[0103] The fifth determination submodule is used to determine the target cluster corresponding to the Redis call request according to the migration status verification result.
[0104] According to an embodiment of the present disclosure, it also includes:
[0105] A configuration module is used to configure the routing mapping table according to the cluster configuration information table.
[0106] According to an embodiment of the present disclosure, any multiple modules of the acquisition module 610, the first determination module 620, the second determination module 630 and the sending module 640 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the acquisition module 610, the first determination module 620, the second determination module 630 and the sending module 640 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in a suitable combination of any of them. Alternatively, at least one of the acquisition module 610 , the first determination module 620 , the second determination module 630 , and the sending module 640 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.
[0107] Figure 8 A block diagram of an electronic device suitable for implementing a routing method for a Redis cluster according to an embodiment of the present disclosure is schematically shown.
[0108] like Figure 8As shown, the electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0109] In RAM 903, various programs and data required for the operation of electronic device 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other via bus 904. Processor 901 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0110] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The electronic device 900 may further include one or more of the following components connected to the I / O interface 905: an input portion 906 including a keyboard, a mouse, etc.; an output portion 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 908 including a hard disk, etc.; and a communication portion 909 including a network interface card such as a LAN card, a modem, etc. The communication portion 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage portion 908 as needed.
[0111] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the routing method of the Redis cluster according to the embodiment of the present disclosure is implemented.
[0112] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.
[0113] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program includes a program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the Redis cluster routing method provided by the embodiment of the present disclosure.
[0114] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 901. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0115] In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of a signal on a network medium, and downloaded and installed through the communication part 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0116] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0117] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0118] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0119] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0120] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A routing method for a Redis cluster, characterized in that: The routing method comprises: Responding to the Redis call request from the client, obtaining Redis call request information; Determine the target cluster identification information and the routing state identification information according to the Redis call request information and the routing mapping table, wherein the routing mapping table is used to store the mapping relationship between the primary key type and the Redis cluster; Determine the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information; Distribute the Redis call request to the target cluster corresponding to the Redis call request, Determining the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information includes: When it is determined that the routing state is not enabled, determining the default cluster as the target cluster corresponding to the Redis call request; When it is determined that the routing state is enabled, the target cluster corresponding to the Redis call request is determined according to the target cluster identification information.
2. The routing method according to claim 1, characterized in that: The Redis call request information includes primary key type information, and the determining of target cluster identification information and routing state identification information according to the Redis call request information and the routing mapping table includes: The target cluster identification information and the routing state identification information are determined according to the primary key type information and the routing mapping table.
3. The routing method according to claim 2, characterized in that: The determining the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information further includes: When it is determined that the routing state is in migration, determining the migration state identification information corresponding to the Redis call request; Performing a migration status check on the Redis call request according to the migration status identification information; The target cluster corresponding to the Redis call request is determined according to the migration status verification result.
4. The routing method according to any one of claims 1 to 3, characterized in that: Also includes: The routing mapping table is configured according to the cluster configuration information table.
5. A routing device for a Redis cluster, characterized in that: The routing device comprises: The acquisition module is used to respond to the Redis call request of the client and obtain the Redis call request information; A first determination module, used to determine the target cluster identification information and the routing state identification information according to the Redis call request information and the routing mapping table, wherein the routing mapping table is used to store the mapping relationship between the primary key type and the Redis cluster; A second determination module is used to determine the target cluster corresponding to the Redis call request according to the target cluster identification information and the routing state identification information; A sending module is used to distribute the Redis call request to the target cluster corresponding to the Redis call request, The second determining module comprises: A first determination submodule is used to determine, when the routing state is determined to be disabled, a default cluster as a target cluster corresponding to the Redis call request; The second determination submodule is used to determine the target cluster corresponding to the Redis call request according to the target cluster identification information when the routing state is determined to be enabled.
6. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors execute the routing method according to any one of claims 1 to 4.
7. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the routing method according to any one of claims 1 to 4.
8. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the routing method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Cluster service calling method and device, electronic equipment, storage medium and product
CN113111123A