Data transmission method, apparatus and system
By introducing flow identification and multi-channel connection pooling technology into the Redis cluster, the problems of connection pool overlimits and head of queue blocking in large-scale clusters are solved, and more efficient data transmission and throughput are achieved.
Patent Information
- Application Number
- PCT/CN2024/120923
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-12
- Filing Date
- 2024-09-25
- Publication Date
- 2025-06-19
AI Technical Summary
In large-scale Redis clusters, connection pools are prone to risk of over-limit, resulting in head-of-line blocking and affecting database throughput, especially when there are too many data transmissions or frequent stateful commands.
By introducing flow identifiers into the proxy server, the proxy server is allowed to return packets in an out-of-order based on the flow identifiers in the received packets, avoiding forwarding in dependence on the order of messages in the connection pool. At the same time, a multi-channel connection pool for the proxy server is implemented, allowing stateful commands to enter the connection pool without blocking the queue.
It improves the forwarding efficiency of the proxy server, avoids queue blocking, improves the system throughput of the database, and improves the utilization rate of proxy resources.
Smart Images

Figure CN2024120923_19062025_PF_FP_ABST
Abstract
Description
Data transmission method, device and system
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on December 14, 2023, with application number 202311718229.4 and application name “A request forwarding method, device and computing device cluster”, all of which are incorporated by reference into this application, and claims priority to the Chinese patent application filed with the State Intellectual Property Office on March 12, 2024, with application number 202410284757.1 and application name “A data transmission method, device and system”, all of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of databases, and in particular to a data transmission method, device, and system. Background Art
[0003] The remote dictionary server (Redis) is an open-source, high-performance key-value database that supports a variety of data types to meet diverse business needs. To ensure scalability and ease of use, Redis databases are often offered in a proxy cluster configuration.
[0004] The proxy acts as a bridge between the client and the cluster shards. Its main function is to forward requests. To avoid amplifying the number of connections and improve IO efficiency, the proxy uses a fixed-size connection pool to forward requests between the proxy and the shards. Typically, the standard RESP protocol is used between the proxy and the Redis shards. This is a request / response protocol that supports pipeline transmission, meaning that the proxy forwards received requests or responses based on a first-in-first-out (FIFO) mechanism. However, in large-scale clusters, the connection pool is at risk of overflow, and when there is too much data or commands to be forwarded, head-of-line blocking can occur.
[0005] Summary of the Invention
[0006] The present application provides a data transmission method, device, and system for improving data forwarding efficiency in a database and increasing system throughput.
[0007] In view of this, in a first aspect, the present application provides a data transmission method, which is applied to a remote dictionary service Redis database system, wherein the database system includes a Redis data server and a proxy server, the proxy server is connected to the data server, and the proxy server is also connected to the client; the method includes: the proxy server receives at least one first request message sent by the client, each first request message carries a flow identifier, which is the identifier of the flow transmitted between the client and the proxy server, and the flow can also be understood as a message queue transmitted between the client and the proxy server; then the proxy server forwards the information carried in each first request message to the Redis data server; the Redis data server sends at least one first response message to the proxy server, the at least one first response message corresponds to the at least one first request message, that is, the at least one first response message is a response to the aforementioned at least one first request message, each first response message carries the flow identifier in the corresponding first request message, the proxy server determines the corresponding client based on the flow identifier carried in each first response message, and forwards the information carried in the at least one first response message to the client.
[0008] In the embodiments of the present application, when forwarding a message, the proxy can determine the information of the receiving end of the message to be forwarded based on the flow identifier carried in the received message, thereby eliminating the need to forward messages in the order in which the messages enter the connection pool. This can achieve out-of-order packet return, improve the forwarding efficiency of the proxy, avoid queue blocking, and increase the throughput of the database. Furthermore, in the embodiments of the present application, a multi-channel connection pool of the proxy can be implemented, so that stateful commands can also be placed in the connection pool without blocking the queue, thereby achieving the forwarding of stateful commands using existing proxy resources, improving the utilization of proxy resources, and improving the database throughput.
[0009] In a possible implementation, the aforementioned proxy server forwards information carried in each first request message to the Redis data server, including: when the first protocol and the second protocol are the same, the proxy server forwards at least one first request message to the Redis data server, the first protocol is the message protocol transmitted between the client and the proxy server, and the second protocol is the message protocol transmitted between the proxy server and the Redis data server; or, when the first protocol and the second protocol are different, the proxy server generates at least one second request message based on the second protocol and the information carried in each first request message, and sends the at least one second request message to the Redis data server; wherein, at least one of the first protocol or the second protocol is a binary protocol.
[0010] In the implementation manner of the present application, a binary protocol can be used for data transmission between the client and the proxy, and / or between the proxy and the Redis data server. It can be understood that the situation in which the proxy forwards messages may include multiple situations. One is that the protocol used for communication between the sender and the proxy is the same as the protocol used for communication between the proxy and the receiver. In this case, direct forwarding is possible without processing. Another situation is that different protocols are used for transmission. In this case, the proxy needs to perform protocol conversion on the received message before forwarding. Therefore, in the implementation manner of the present application, it can adapt to multiple situations. Messages can be transmitted between the client and the proxy server and / or between the proxy servers based on a binary protocol, so that an identifier can be transmitted in the message, so that the intermediate device proxy can identify the destination address corresponding to the message to be forwarded based on the flow identifier carried in the received message. There is no need to return packets in a fixed order, and out-of-order packet return can be achieved, thereby improving the throughput of the database.
[0011] In a possible implementation, the aforementioned proxy server forwards information carried in at least one first response message to the client, including: when the first protocol and the second protocol are the same, the proxy server forwards at least one first response message to the client; or, when the first protocol and the second protocol are different, the proxy server generates at least one second response message based on the first protocol and the information carried in each first response message, and sends the at least one second response message to the client; at least one of the first protocol or the second protocol is a binary protocol.
[0012] In the implementation manner of the present application, the method of forwarding the information carried in the first response message is similar to the method of forwarding the information carried in the aforementioned first request message. Messages can be transmitted between the client and the proxy server and / or between proxy servers based on a binary protocol, so that identifiers can be transmitted in the messages, so that the intermediate device proxy can identify the destination address corresponding to the message to be forwarded based on the flow identifier carried in the received message. There is no need to return packets in a fixed order, and out-of-order packet return can be achieved, thereby improving the throughput of the database.
[0013] In one possible implementation, each of the aforementioned first request messages or each of the aforementioned first response messages further includes a first length, the first length including the length of the payload carried in the message, and the first length is used by the proxy server to determine the message boundary. After receiving the data, the proxy can identify the message in the stream based on the stream identifier in the data, and identify the message boundary based on the length, thereby determining the message from the data. Therefore, the proxy can determine the message boundary without parsing the data, reducing the proxy's parsing process, improving the proxy's work efficiency, and thus the overall operating efficiency of the database.
[0014] In one possible implementation, each of the aforementioned first request messages and each first response message further carries a request identifier, which is used to indicate the request corresponding to each message. In the implementation of the present application, the first request message may further carry a request identifier, which may be generated by the client, thereby enabling the client to request the required data processing operation from the data server, and the data server may provide the required service to the client based on the request identifier.
[0015] In one possible embodiment, the at least one first request message includes at least one of a blocking command (blocking cmd) or a subscription command (subscribe cmd), the blocking command is a message sent by the client to the Redis data server and waiting for a response, and the subscription command is a message that the client requests to subscribe to the Redis data server. In the embodiment of the present application, the message to be forwarded by the proxy may also include a stateful command. The embodiment of the present application may implement multiple processing channels, thereby reducing blocking, improving the data processing efficiency of the database, and improving the data throughput of the database. That is, blocking cmd and subscribe cmd can be forwarded through the proxy's connection pool, without the need to separately allocate resources for transmission, thereby improving the working efficiency of the proxy.
[0016] In one possible embodiment, when at least one first request message includes a subscription command, the aforementioned proxy server forwards the information carried in each first request message to the Redis data server, including: sending the information carried in the subscription command to the data server according to the flow identifier carried by the subscription command; the aforementioned proxy server forwards the information carried in at least one first response message to the client, including: the proxy server receives the publishing message corresponding to the subscription command sent by the Redis data server; the proxy server sends the information carried in at least one first response message to the client corresponding to the subscription command. The method provided in this application can be applied to the scenario of subscription commands, and subscription commands can also enter the proxy's connection pool, without the need to separately allocate resources to transmit subscription commands, thereby improving the working efficiency of the proxy.
[0017] In one possible implementation, when at least one first request message includes a blocking command, the aforementioned proxy server sends at least one second request message to the Redis data server, including: the proxy server sends a blocking command to the server according to the flow identifier carried by the blocking command; the aforementioned proxy server forwards the information carried in at least one first response message to the client, including: waiting to receive a response message corresponding to the blocking command; after receiving the first response message corresponding to the blocking command, sending the information carried in at least one first response message to the client corresponding to the blocking command.
[0018] In a second aspect, the present application provides a data transmission method, which is applied to a remote dictionary service Redis database system. The database system includes a Redis data server and a proxy server. The proxy server is connected to the data server, and the proxy server is also connected to the client. The method provided in the embodiment of the present application can be applied to the proxy; the method includes: the proxy server receives at least one first request message sent by the client, each first request message carries a flow identifier, which is the identifier of the flow transmitted between the client and the proxy server. The flow can also be understood as a message queue transmitted between the client and the proxy server; then the proxy server forwards the information carried in each first request message to the Redis data server; the proxy server receives at least one first response message sent by the Redis data server, and the at least one first response message corresponds to the at least one first request message, that is, the at least one first response message is a response to the aforementioned at least one first request message, and each first response message carries the flow identifier in the corresponding first request message. The proxy server forwards the information carried in the at least one first response message to the client based on the flow identifier carried in each first response message.
[0019] In the embodiments of the present application, when forwarding a message, the proxy can determine the information of the receiving end of the message to be forwarded based on the flow identifier carried in the received message, thereby eliminating the need to forward messages in the order in which the messages enter the connection pool. This can achieve out-of-order packet return, improve the forwarding efficiency of the proxy, avoid queue blocking, and increase the throughput of the database. Furthermore, in the embodiments of the present application, a multi-channel connection pool of the proxy can be implemented, so that stateful commands can also be placed in the connection pool without blocking the queue, thereby achieving the forwarding of stateful commands using existing proxy resources, improving the utilization of proxy resources, and improving the database throughput.
[0020] In a possible implementation, the aforementioned proxy server forwards information carried in each first request message to the Redis data server, including: when the first protocol and the second protocol are the same, the proxy server forwards at least one first request message to the Redis data server, the first protocol is the message protocol transmitted between the client and the proxy server, and the second protocol is the message protocol transmitted between the proxy server and the Redis data server; or, when the first protocol and the second protocol are different, the proxy server generates at least one second request message based on the second protocol and the information carried in each first request message, and sends the at least one second request message to the Redis data server; wherein, at least one of the first protocol or the second protocol is a binary protocol.
[0021] In the implementation manner of the present application, a binary protocol can be used for data transmission between the client and the proxy, and / or between the proxy and the Redis data server. It can be understood that the situation in which the proxy forwards the message may include multiple situations. One is that the protocol used for communication between the sender and the proxy is the same as the protocol used for communication between the proxy and the receiver. In this case, direct forwarding is possible without processing. Another situation is that different protocols are used for transmission. In this case, the proxy needs to perform protocol conversion on the received message before forwarding. Therefore, in the implementation manner of the present application, it can adapt to multiple situations. Messages can be transmitted between the client and the proxy server and / or between the proxy servers based on a binary protocol, so that an identifier can be transmitted in the message, so that the intermediate device proxy can identify the destination address corresponding to the message to be forwarded based on the flow identifier carried in the received message. There is no need to return packets in a fixed order, and out-of-order packet return can be achieved, thereby improving the throughput of the database.
[0022] In a possible implementation, the aforementioned proxy server forwards information carried in at least one first response message to the client, including: when the first protocol and the second protocol are the same, the proxy server forwards at least one first response message to the client; or, when the first protocol and the second protocol are different, the proxy server generates at least one second response message based on the first protocol and the information carried in each first response message, and sends the at least one second response message to the client; at least one of the first protocol or the second protocol is a binary protocol.
[0023] In the implementation manner of the present application, the method of forwarding the information carried in the first response message is similar to the method of forwarding the information carried in the aforementioned first request message. Messages can be transmitted between the client and the proxy server and / or between proxy servers based on a binary protocol, so that identifiers can be transmitted in the messages, so that the intermediate device proxy can identify the destination address corresponding to the message to be forwarded based on the flow identifier carried in the received message. There is no need to return packets in a fixed order, and out-of-order packet return can be achieved, thereby improving the throughput of the database.
[0024] In one possible implementation, each of the aforementioned first request messages or each of the aforementioned first response messages further includes a first length, the first length including the length of the payload carried in the message, and the first length is used by the proxy server to determine the message boundary. After receiving the data, the proxy can identify the message in the stream based on the stream identifier in the data, and identify the message boundary based on the length, thereby determining the message from the data. Therefore, the proxy can determine the message boundary without parsing the data, reducing the proxy's parsing process, improving the proxy's work efficiency, and thus the overall operating efficiency of the database.
[0025] In one possible implementation, each of the aforementioned first request messages or each first response message further carries a request identifier, which is used to indicate the request corresponding to each message. In this implementation, the first request message may further carry a request identifier, which may be generated by the client, thereby enabling the client to request the required data processing operation from the Redis data server, and the Redis data server may provide the required service to the client based on the request identifier.
[0026] In one possible embodiment, the at least one first request message includes at least one of a blocking command (blocking cmd) or a subscription command (subscribe cmd), the blocking command is a message sent by the client to the Redis data server and waiting for a response, and the subscription command is a message that the client requests to subscribe to the Redis data server. In the embodiment of the present application, the message to be forwarded by the proxy may also include a stateful command. The embodiment of the present application may implement multiple processing channels, thereby reducing blocking, improving the data processing efficiency of the database, and improving the data throughput of the database. That is, blocking cmd and subscribe cmd can be forwarded through the proxy's connection pool, without the need to separately allocate resources for transmission, thereby improving the working efficiency of the proxy.
[0027] In one possible embodiment, when at least one first request message includes a subscription command, the aforementioned proxy server forwards the information carried in each first request message to the Redis data server, including: sending the information carried in the subscription command to the Redis data server according to the flow identifier carried in the subscription command; the aforementioned proxy server forwards the information carried in at least one first response message to the client, including: the proxy server receives the publishing message corresponding to the subscription command sent by the Redis data server; the proxy server sends the information carried in at least one first response message to the client corresponding to the subscription command. The method provided in this application can be applied to the scenario of subscription commands, and subscription commands can also enter the proxy's connection pool, without the need to separately allocate resources to transmit subscription commands, thereby improving the working efficiency of the proxy.
[0028] In one possible implementation, when at least one first request message includes a blocking command, the aforementioned proxy server sends at least one second request message to the Redis data server, including: the proxy server sends a blocking command to the server according to the flow identifier carried by the blocking command; the aforementioned proxy server forwards the information carried in at least one first response message to the client, including: waiting to receive a response message corresponding to the blocking command; after receiving the first response message corresponding to the blocking command, sending the information carried in at least one first response message to the client corresponding to the blocking command.
[0029] In a third aspect, the present application provides a data transmission method that can be applied to a client, including: first, obtaining at least one request message, each request message carrying a flow identifier; then sending at least one request message to a proxy server (proxy) so that the proxy server forwards each request message according to the flow identifier carried in each request message.
[0030] Therefore, in the implementation mode of the present application, the client can carry a flow identifier in the request message, so that the proxy can record the flow corresponding to the request message. After receiving the response message corresponding to the request message, the response message can be forwarded to the client based on the corresponding flow identifier, so that the proxy does not need to forward the response message in a fixed FIFO order, and can realize out-of-order packet return.
[0031] In a possible implementation, the aforementioned method may further include: receiving at least one response message, where the at least one response message corresponds to the at least one request message.
[0032] In a possible implementation, each of the aforementioned response messages also carries a first length, where the first length includes the length of the payload carried in each response message. The first length is used by the proxy server to determine the boundary of each response message.
[0033] Therefore, the proxy can determine the message boundary without parsing the data, which reduces the proxy's parsing process, improves the proxy's work efficiency, and thus improves the overall operating efficiency of the database.
[0034] In a possible implementation, the aforementioned at least one request message further carries a request identifier, and the request identifier is used to indicate the request corresponding to each request message.
[0035] In an implementation manner of the present application, the request message may also carry a request identifier, which may be generated by the client, so that the client may request the required data processing operation from the Redis data server, and the Redis data server may provide the required service to the client based on the request identifier.
[0036] In a possible implementation, the at least one request message includes at least one of a blocking command or a subscription command.
[0037] In a fourth aspect, the present application provides a data transmission method applied to a Redis data server, the method comprising: the Redis data server receives at least one request message, each request message carries a flow identifier; sends at least one response message, at least one response message corresponds to at least one request message, and each response message carries the flow identifier in the corresponding request message.
[0038] Therefore, in the embodiment of the present application, both the request message and the response message carry a flow identifier. When the proxy forwards a message, it can determine the information of the receiving end of the message to be forwarded based on the flow identifier carried in the received message. Therefore, there is no need to forward the message according to the order in which the message enters the connection pool. This can achieve out-of-order packet return, improve the forwarding efficiency of the proxy, avoid queue blocking, and improve the throughput of the database. In addition, in the embodiment of the present application, a multi-channel connection pool of the proxy can be implemented, so that stateful commands can also be placed in the connection pool without blocking the queue, thereby realizing the forwarding of stateful commands using existing proxy resources, improving the utilization rate of proxy resources, and improving the throughput of the database.
[0039] In one possible implementation, each of the aforementioned response messages also includes a first length, which includes the length of the payload carried in each response message. The first length is used by the proxy server to determine the boundaries of each response message. Therefore, the proxy can determine the message boundaries without having to parse the data, reducing the proxy's parsing process, improving the proxy's efficiency, and thereby improving the overall operational efficiency of the database.
[0040] In one possible implementation, at least one of the aforementioned request messages further carries a request identifier, which is used to indicate the request corresponding to each request message. In an implementation of the present application, the request message may further carry a request identifier, which may be generated by the client, thereby enabling the client to request the required data processing operation from the Redis data server, and the Redis data server may provide the required service to the client based on the request identifier.
[0041] In one possible implementation, the at least one request includes a stateful command. In the implementation of the present application, the stateful command can also be placed in the connection pool without blocking the queue, thereby utilizing existing proxy resources to forward the stateful command, improving the utilization of proxy resources and increasing database throughput.
[0042] In one possible implementation, the at least one request message includes at least one of a blocking command or a subscription command. Therefore, in the method provided herein, blocking cmd and subscribe cmd can be forwarded through the proxy's connection pool, eliminating the need to allocate separate resources for transmission, thereby improving the proxy's efficiency.
[0043] In a fifth aspect, the present application provides a Redis database system, including: a Redis data server and a proxy server;
[0044] The Redis data server can be used to perform the steps performed by the Redis data server in the first aspect or any optional implementation manner of the first aspect;
[0045] The proxy server can be used to execute the steps executed by the proxy server in the first aspect or any optional implementation manner of the first aspect.
[0046] In a possible implementation, the aforementioned system further includes: a client, which is the client in the first aspect or any optional implementation of the first aspect.
[0047] In a sixth aspect, the present application provides a proxy server, comprising:
[0048] a transceiver module, configured to receive at least one first request message sent by a client, each first request message carrying a flow identifier, which is an identifier of a flow transmitted between the client and the proxy server. The flow can also be understood as a message queue transmitted between the client and the proxy server;
[0049] The transceiver module is further configured to forward the information carried in each first request message to the Redis data server;
[0050] The transceiver module is further configured to receive at least one first response message sent by the Redis data server, where the at least one first response message corresponds to the at least one first request message, i.e., the at least one first response message is a response to the at least one first request message, and each first response message carries the flow identifier in the corresponding first request message;
[0051] The transceiver module is further configured to forward information carried in at least one first response message to the client based on the flow identifier carried in each first response message.
[0052] In one possible implementation, the transceiver module is specifically configured to: when a first protocol and a second protocol are the same, the proxy server forwards at least one first request message to the Redis data server, where the first protocol is a message protocol transmitted between the client and the proxy server, and the second protocol is a message protocol transmitted between the proxy server and the Redis data server; or, when the first protocol and the second protocol are different, the proxy server generates at least one second request message based on the second protocol and information carried in each first request message, and sends the at least one second request message to the Redis data server; wherein at least one of the first protocol or the second protocol is a binary protocol.
[0053] In one possible embodiment, the transceiver module is specifically configured to: when the first protocol and the second protocol are the same, the proxy server forwards at least one first response message to the client; or, when the first protocol and the second protocol are different, the proxy server generates at least one second response message based on the first protocol and information carried in each first response message, and sends the at least one second response message to the client; at least one of the first protocol or the second protocol is a binary protocol.
[0054] In one possible implementation, each of the aforementioned first request messages or each of the aforementioned first response messages further includes a first length, the first length including the length of the payload carried in the message, and the first length is used by the proxy server to determine the message boundary. After receiving the data, the proxy can identify the message in the stream based on the stream identifier in the data, and identify the message boundary based on the length, thereby determining the message from the data. Therefore, the proxy can determine the message boundary without parsing the data, reducing the proxy's parsing process, improving the proxy's work efficiency, and thus the overall operating efficiency of the database.
[0055] In one possible implementation, each of the aforementioned first request messages or first response messages further carries a request identifier, which is used to indicate the request corresponding to each message. In this implementation, the first request message may further carry a request identifier, which may be generated by the client, thereby enabling the client to request the required data processing operation from the Redis data server, and the Redis data server may provide the required service to the client based on the request identifier.
[0056] In one possible embodiment, the at least one first request message includes at least one of a blocking command (blocking cmd) or a subscription command (subscribe cmd), the blocking command is a message sent by the client to the Redis data server and waiting for a response, and the subscription command is a message that the client requests to subscribe to the Redis data server. In the embodiment of the present application, the message to be forwarded by the proxy may also include a stateful command. The embodiment of the present application may implement multiple processing channels, thereby reducing blocking, improving the data processing efficiency of the database, and improving the data throughput of the database. That is, blocking cmd and subscribe cmd can be forwarded through the proxy's connection pool, without the need to separately allocate resources for transmission, thereby improving the working efficiency of the proxy.
[0057] In one possible embodiment, when at least one first request message includes a subscription command, the aforementioned transceiver module is specifically configured to: send the information carried in the subscription command to the Redis data server based on the flow identifier carried in the subscription command; receive the publish message corresponding to the subscription command sent by the Redis data server; and the proxy server sends the information carried in at least one first response message to the client corresponding to the subscription command. The method provided in this application can be applied to the subscription command scenario, and the subscription command can also enter the proxy connection pool, eliminating the need to allocate resources separately to transmit the subscription command, thereby improving the proxy's work efficiency.
[0058] In one possible implementation, when at least one first request message includes a blocking command, the aforementioned transceiver module is specifically used to: send a blocking command to the server according to the flow identifier carried by the blocking command; wait for receiving a response message corresponding to the blocking command; and after receiving the first response message corresponding to the blocking command, send at least one information carried by the first response message to the client corresponding to the blocking command.
[0059] In the seventh aspect, an embodiment of the present application provides a computing device cluster, including at least one computing device, each computing device including a processor and a memory; the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method steps executed by the Redis data server in the first aspect and any implementation thereof.
[0060] In an eighth aspect, an embodiment of the present application provides a client, comprising: a processor and a memory, wherein the processor and the memory are interconnected via a circuit, and the processor invokes program code in the memory to execute the processing-related functions of any of the methods described in the third aspect. Optionally, the client may be a chip.
[0061] In the ninth aspect, an embodiment of the present application provides a computing device cluster, comprising at least one computing device, each computing device comprising a processor and a memory; the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method as in the fourth aspect and any implementation thereof.
[0062] In a tenth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed by a computing device cluster, enables the computing device cluster to execute a method as in any one of the implementations of the first, second, third or fourth aspects.
[0063] In the eleventh aspect, an embodiment of the present application provides a computer-readable storage medium comprising computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes a method as in any one of the implementations of the first aspect, the second aspect, the third aspect, or the fourth aspect.
[0064] In the twelfth aspect, an embodiment of the present application provides a chip comprising at least one processor and an interface; at least one processor obtains program instructions or data through the interface; and at least one processor is used to execute program line instructions to implement the method in any one of the implementation methods of the first aspect, the second aspect, and the third aspect.
[0065] It can be understood that the beneficial effects of the fifth to twelfth aspects can be found in the relevant descriptions of the first to fourth aspects, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] FIG1 is a schematic diagram of the architecture of a Redis database system provided by this application;
[0067] FIG2 is a schematic diagram of the architecture of another Redis database system provided by this application;
[0068] FIG3 is a schematic diagram of the architecture of another Redis database system provided by this application;
[0069] FIG4 is a flow chart of a data transmission method provided by the present application;
[0070] FIG5 is a schematic diagram of a message structure provided by this application;
[0071] FIG6 is a schematic diagram of another message structure provided by this application;
[0072] FIG7 is a schematic diagram of another message structure provided by this application;
[0073] FIG8 is a flow chart of another data transmission method provided by the present application;
[0074] FIG9 is a schematic diagram of a multi-channel structure of a connection pool provided by the present application;
[0075] FIG10 is a schematic diagram of an application scenario provided by this application;
[0076] FIG11 is a schematic diagram of the structure of a proxy server provided by this application;
[0077] FIG12 is a schematic diagram of the structure of a client provided by this application;
[0078] FIG13 is a schematic diagram of the structure of a Redis data server provided by the present application;
[0079] FIG14 is a schematic diagram of the architecture of another database system provided by the present application;
[0080] FIG15 is a schematic diagram of the structure of a computing device provided by the present application;
[0081] FIG16 is a schematic diagram of the structure of a computing device cluster provided by this application;
[0082] FIG17 is a schematic diagram of the structure of another computing device cluster provided in this application. DETAILED DESCRIPTION
[0083] The following will describe the technical solutions in the embodiments of this application in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0084] First of all, the methods, systems, or devices provided in the embodiments of the present application are related to databases. To facilitate understanding, some database-related terms or concepts involved in the embodiments of the present application are first introduced.
[0085] (1) Database (DB): An ordered collection of structured information or data, typically stored electronically in a computer system. It is typically controlled by a database management system (DBMS). Schematically, data, the DBMS, and associated applications are collectively referred to as a database system, often referred to simply as a database. A database typically consists of a client and a server. The database client provides an interface for data query services. The database server is used to perform database parsing queries and data communication processes.
[0086] (2) Cloud Database: A database deployed in a virtual computing environment that can achieve advantages such as pay-as-you-go, on-demand expansion, high availability, and storage integration. The virtual computing environment can refer to a cloud platform. Cloud platform is the abbreviation of cloud computing platform, which can provide computing, network, and storage capabilities based on services of hardware resources and software resources. Through the network "cloud", huge amounts of data are processed and analyzed remotely and then returned to users. It has the characteristics of large scale, distribution, virtualization, high availability, scalability, on-demand service, and security. The cloud platform can achieve the rapid issuance and release of configurable computing resources with a low management cost or low interaction complexity between users and service providers.
[0087] (3) Object Storage Service (OBS): This is an object-based mass storage service that provides users with massive, secure, and highly reliable data storage capabilities, including the ability to create, modify, and delete buckets, and upload, download, and delete objects. The basic components of OBS are buckets and objects. Buckets are containers for storing objects in OBS. Each bucket has its own storage category, access permissions, region, and other attributes. Users locate buckets on the Internet using their domain name. Objects are the basic unit of data storage in OBS. An object is actually a collection of file data and its related attribute information.
[0088] (4) Redis database
[0089] It is an open source, high-performance key-value database. Redis can support multiple data types, such as stream, string, list, set, zset (sorted set), and hash, so as to meet different business needs.
[0090] (5) Stream transmitted in Redis database
[0091] A stream is a data structure in the Redis database. A stream in a Redis database is essentially a component with publish / subscribe messaging capabilities, similar to a message queue (MQ). It can also be thought of as a linked list that strings together all messages, each with a unique ID and corresponding content.
[0092] A stream message queue consists of four main components: the message itself, the producer, the consumer, and the consumer group. The end that puts data into the message queue is the producer, and the end that retrieves data from the message queue is the consumer. A stream queue can correspond to multiple consumer groups, each of which contains multiple consumers. While there may be competition between consumers within a group, there is generally no competition between different consumer groups. For example, within a consumer group, once a consumer consumes a message, no other consumer in the same group will consume the same message again. Consumed messages are placed in the pending_ids column, which records messages that have been read but have not yet received an ACK. After each message is consumed, the consumer group's cursor advances one position, and consumers within the group continue to compete for the right to consume the next message. After processing is completed, the XACK command is typically executed to confirm the message's consumption. This is done by the consumer using the XACK command to notify Streams that the message has been processed. Therefore, the consumer acknowledgment mechanism increases message reliability.
[0093] Each message in a stream has a corresponding identification (ID), referred to as a streamID. Typically, a streamID can be generated by the Redis data server or by the client. For example, a streamID can be generated by the client and typically consists of multiple parts, such as a timestamp and a sequence number. The timestamp is a timestamp in milliseconds that indicates the time the message was added to the stream. This timestamp ensures the global ordering of messages, and older messages typically have smaller timestamps. In a highly concurrent environment, multiple messages may be added to a stream within the same millisecond. In this case, a sequence number is needed to distinguish between different messages within the same millisecond. The sequence number is typically a number that increments within the same millisecond to distinguish different messages within the same timestamp. When multiple messages are added to a stream within the same millisecond, the sequence number ensures that each message has a unique ID. The sequence number starts at 0 and increments for each new message with the same timestamp. For example, a possible ID is 1638426953435-8, where 1638426953435 is the timestamp portion and 8 is the sequence number portion.
[0094] The stream identifier mentioned in the following implementation manners of this application may include StreamID.
[0095] In addition, from the perspective of data transmission between the client and the Redis data server, the client can send a request message to the Redis data server, which can carry the StreamID corresponding to the request message. Correspondingly, when the Redis data server responds to the request message, it can also carry the corresponding StreamID in the response message, so that the proxy can determine the client receiving the message based on the StreamID carried in the response message, so that the client can obtain the response message to the request message.
[0096] (6) Redis serialization protocol (RESP)
[0097] The RESP protocol was introduced in Redis 1.2 and became the standard way to communicate with Redis servers in Redis 2.0. It is the protocol that Redis clients must follow. RESP is a text-based protocol that describes different types of data structures in Redis. The design of the RESP protocol enables Redis clients and servers to communicate efficiently. Both clients and servers based on the RESP protocol can handle multiple requests and responses at once without establishing a new connection for each request / response. This design enables Redis to maintain high performance and low latency when processing large amounts of data.
[0098] Another feature of the RESP protocol is its ability to process streaming data, meaning that clients and servers can begin processing data while it's being sent or received, without having to wait for all the data to be sent or received. This is very useful for processing large amounts of data or large clusters. And although RESP is a text-based protocol, it can handle binary data. For example, you can store an image or video file in Redis and then use the RESP protocol to retrieve or modify it.
[0099] (7) Binary protocol
[0100] The binary protocol processes information into data composed of 0 and 1, which can be binary data. Of course, the binary data in the embodiment of the present application can also include binary-based data representations such as octal or hexadecimal.
[0101] (8) Redis serial protocol over binary protocol (RESP over binary protocol)
[0102] In the embodiment of the present application, when transmitting data between the client and the server, the binary-based RESP protocol can be used for transmission. The binary-based RESP protocol used in the embodiment of the present application processes information as binary data instead of text in traditional RESP.
[0103] Secondly, the present application provides a database system, which may also be referred to as a data transmission system or database in this application. The system may include a Redis data server, a proxy server, and one or more clients. The database system provided by this application is introduced below.
[0104] FIG1 is a schematic diagram showing the structure of a database system provided by this application.
[0105] As shown in FIG1 , the database system 10 may include a Redis data server cluster 11 , a proxy server 12 , and one or more clients 13 .
[0106] The Redis data server cluster 11 has storage and processing functions, and is used to store relevant data information, update the stored data information according to received information, or return corresponding information according to received information. The Redis data server cluster 11 may include one or more Redis data servers, each of which can store data fragments.
[0107] The client 13 may include a user handheld terminal. In an embodiment of the present application, the client 13 may send a request message to the Redis data server cluster 11 to request corresponding services or data from the Redis data server cluster, and receive a response message fed back by the server cluster 11.
[0108] The proxy server 12 has the function of receiving and forwarding data. The proxy server 12 acts as a hub between the client 13 and the Redis data server cluster 11, and can forward data between the client 13 and the Redis data server cluster 11. In the embodiment of the present application, when the client 13 and the Redis data server cluster 11 use different protocols when transmitting data, the proxy server 12 can also perform protocol conversion to enable communication between the client using the protocol and the Redis data server cluster.
[0109] The number of proxy servers can be one or more. In the implementation manner of this application, only the steps executed by one of the proxies are introduced.
[0110] The following further introduces the Redis data server cluster 11.
[0111] The aforementioned Redis data server cluster 11 can be a centralized server or a distributed server. When the Redis data server cluster is a distributed server, FIG1 takes the Redis data server cluster as an example for introduction, and data can be distributedly stored in the distributed server.
[0112] For example, taking the distributed database MongoDB as an example, the structure of a distributed server cluster may be as shown in FIG2 . The Redis data server cluster may include one or more configuration servers 111 and one or more shard servers 112 .
[0113] The configuration server 111 may be used to store configuration information of the server cluster and provide external cluster configuration services.
[0114] The Shard server 112 can be used to provide external data storage and access.
[0115] Shard servers 112 can be added or deleted by configuring the server 111. After the Shard service is enabled, data can be stored in different Shard servers, and parallel processing of multiple Shard servers can be achieved, thereby achieving higher data storage and processing capabilities.
[0116] In the following implementation manners of the present application, the Redis data server mentioned may be any one of the Redis data servers in the Redis data server cluster, which will not be described in detail below.
[0117] The following is a further introduction to proxy.
[0118] The proxy serves as a bridge between the client and the cluster shards. Its main function is to forward requests. In order to avoid amplifying the number of connections and to improve IO efficiency, the proxy uses a connection pool to forward requests between the proxy and the shards.
[0119] In the existing solution, the standard RESP protocol is used between Proxy and Redis shards, which supports pipeline transmission.
[0120] The proxy-side connection pool prevents the number of connections carried by a Redis shard from being multiplied, leading to the phenomenon of "the number of connections on the proxy is within the limit, but the connection pool on the shard is exceeded" and thus reducing the shard's network I / O efficiency. Using a connection pool allows for batch sending and receiving of requests in a pipelined manner, significantly improving efficiency.
[0121] Typically, in large-scale clusters, the connection pool is at risk of overrunning. The original FIFO connection pool processing mechanism will cause head-of-line blocking, and non-stateless commands such as blocking and subscription cannot go through the connection pool.
[0122] For example, pipeline sending and receiving can cause head-of-line blocking. A slow request can slow down multiple requests, severely impacting P99 latency. Furthermore, blocking and subscribe commands cannot be processed through the connection pool because they are stateful commands that must be executed before the next command can proceed. A connection can only execute one command of this type at a time, requiring exclusive connections for these commands. This can easily lead to excessive connections on Redis shard nodes, or even premature exhaustion, impacting availability.
[0123] In the database provided by this application, as shown in Figure 3, a shared connection pool is established between the proxy and the Shard to forward requests or responses transmitted in the database. In an embodiment of the present application, multiple channels can be formed in the shared connection pool, i.e., multiple shard conns as shown in Figure 3, and the connection pool prioritizes throughput. Therefore, in an embodiment of the present application, multiplexed connection channels can be supported, greatly improving the data transmission efficiency of the database, and improving the database's forwarding efficiency for requests and the efficiency of responding to requests.
[0124] The following describes the method flow provided in this application in conjunction with the architecture of the aforementioned database system.
[0125] Referring to FIG4 , a flow chart of another data transmission method provided by the present application is described as follows.
[0126] 401. The client sends a request message to the proxy server, and each request message carries a flow identifier.
[0127] First, the client may generate one or more request messages, which are referred to as first request messages for ease of distinction.
[0128] Each first request message carries a stream ID, which is the ID of the first request message in its corresponding stream. The first request message can be understood as a message in one of the streams. The stream ID of the first request message can be found in the aforementioned streamID description and will not be repeated here.
[0129] In one possible implementation, the request message may also carry a request identifier, which may include an identifier that the client requests the data server to process. Generally, different request operations may correspond to different identifiers. The specific operation that the client requests from the data server may include, but is not limited to, read, write, delete, update, or modify operations. Reading is a request to read data from the data server, writing is a request to write data to the data server, deleting is a request to delete data from the data server, updating is a request to update data stored in the data server, and modifying is a request to modify data stored in the data server. The request identifier can be used to identify the specific operation that the client requests from the data server.
[0130] In one possible implementation, the request message may also carry a first length, or may also be called a payload length. The first length may be used to represent the length of the payload in the request message, so that the proxy may determine the length of the payload in the request message based on the first length, thereby identifying the boundary of the request message, thereby reducing the workload of the proxy in parsing the request message.
[0131] Of course, the request message may also carry a message length indicating the length of the request message, so that the proxy can also identify the boundary of the request message based on the message length, thereby reducing the workload of the proxy in parsing the request message.
[0132] In addition, the request message may also carry a payload, which may include data corresponding to the operation requested by the client. For example, when the client requests a read operation from the Redis data server, the payload may include a description of the data to be read. For example, in a product query scenario, the payload may carry information such as the name, ID, or product number of the product to be queried. When the client requests a write operation from the Redis data server, the payload may include the data to be written. For example, in a product information entry scenario, the payload may carry specific information about the product to be written. When the client requests a delete operation from the Redis data server, the payload may include information about the data to be deleted. For example, in a product deletion scenario, the payload may carry information such as the name and product number of the product to be deleted. When the client requests an update operation from the Redis data server, the payload may include specific data to be updated. For example, in a product information update scenario, the payload may carry specific updated information about the product, such as updating the product's color or image. When the client requests a modify operation from the Redis data server, the payload may include specific data to be modified. For example, in a product information modification scenario, the payload may carry specific updated information about the product to be modified, such as updating the product's name or product number.
[0133] For example, the structure of a request message can be shown in Figure 5. The request message can include steamID, reqID (i.e., request identifier) and Redis payload (i.e., payload). Among them, the length of steamID can be 32 bits, the length of reqID is 32 bits, steamID and reqID occupy 8 bytes, and the length of Redis payload can be determined according to the actual application scenario. The structure of the request message carrying the payload length can be shown in Figure 6. Compared with the structure shown in Figure 5, the payload length is added to indicate the length of the Redis payload.
[0134] Typically, the text-based Redis RESP protocol does not carry identifiers, making it impossible to associate out-of-order responses with requests. Therefore, messages can only be forwarded in a fixed order, which can easily lead to queue congestion. However, in the method provided in the embodiments of the present application, messages can carry flow identifiers, and proxies can forward or reply packets based on the flow identifiers carried in the messages, thus achieving out-of-order packet returns and improving database throughput.
[0135] Furthermore, the text-based Redis RESP protocol lacks a message length identifier. A typical proxy needs to interpret each byte of the message to determine the message boundaries. This consumes excessive proxy CPU when the query result set contains too many elements. However, in the implementation of this application, the payload length can be added to the message. This allows the proxy to determine the message boundaries from subsequent data after parsing the payload length, without having to parse the Redis payload, thus avoiding excessive proxy CPU consumption.
[0136] The above describes the structure of the request message. In addition, the request message may also include messages corresponding to stateful commands such as blocking messages or subscription messages. A blocking command is a message that a client sends to a Redis data server and then waits for a response, and a subscription command is a message that a client sends to a Redis data server requesting a subscription. Therefore, in the embodiment of the present application, stateful messages such as blocking messages or subscription messages can also be forwarded through the proxy's connection pool, so the proxy does not need to call separate resources to transmit stateful messages, thereby improving the utilization of proxy resources.
[0137] 402. The proxy server forwards the information carried in the request message to the Redis data server.
[0138] After receiving the request message sent by the client, the proxy can forward the information carried in the request message to the Redis data server.
[0139] Specifically, the specific way in which the proxy server forwards information carried in at least one request message to the Redis data server may include multiple scenarios. For example, if the protocol used by the client to generate the request message is the same as the protocol that the Redis data server can recognize, the proxy server can directly forward the request message to the proxy server; if the protocol used by the client to generate the request message is different from the protocol that the Redis data server can recognize, the proxy server can generate a message with a protocol that the Redis data server can recognize based on the information carried in the request message, and send it to the Redis data server.
[0140] In one possible implementation, when the first protocol and the second protocol are the same, the proxy server forwards at least one first request message to the Redis data server, where the first protocol is a message protocol transmitted between the client and the proxy server, and the second protocol is a message protocol transmitted between the proxy server and the Redis data server; or, when the first protocol and the second protocol are different, the proxy server generates at least one second request message based on the second protocol and information carried in each first request message, and sends the at least one second request message to the Redis data server; wherein at least one of the first protocol or the second protocol is a binary protocol.
[0141] For example, in one possible scenario, the proxy and the client communicate through the plain text RESP protocol, that is, the request message sent by the client received by the proxy is a RESP protocol message, and the proxy and the Redis data server communicate through RESP based on the binary protocol. After receiving the request message sent by the client, the proxy can perform structural conversion on the request message to obtain a RESP message based on the binary protocol, or generate a new request message according to the RESP protocol based on the binary protocol based on the information carried in the request message, and send the new request message to the Redis data server.
[0142] For example, in one possible scenario, the client can generate a request message and the Redis data server can generate a response message using the RESP protocol based on the binary protocol. That is, the proxy can directly forward the request message to the Redis data server and directly forward the response message to the client.
[0143] Of course, in one possible scenario, the proxy and the server can communicate via the plain text RESP protocol. That is, the response message sent by the Redis data server received by the proxy is a RESP protocol message, and the proxy and the client communicate via RESP based on the binary protocol. Then, after receiving the request message sent by the client, the proxy converts the request message into a plain text RESP protocol request message, or generates a new request message according to the plain text RESP protocol based on the information carried in the request message, and forwards the new request message to the Redis data server.
[0144] 403. The Redis data server sends a response message to the proxy server. The response message carries the flow identifier in the corresponding request message.
[0145] After receiving the request message, the Redis data server can process it based on the information carried in the request message and generate a response message after executing the processing. The response message can specifically carry the processing result after the Redis data server executes the processing, as well as the flow identifier. The flow identifier can be the flow identifier carried in the request message, so that the proxy can identify the response message as a response to the request message based on the flow identifier.
[0146] Specifically, the request message may carry a request identifier and / or a payload. The Redis data server may identify the processing operation to be performed based on the request identifier and / or the payload, and generate a corresponding response message after executing the processing operation. The response message may contain the processing result obtained after executing the processing operation, which is carried in the payload of the response message. For example, the processing result may specifically include the data read, whether the data was written successfully, the specific data written, whether the data was deleted successfully, whether the data was modified successfully, the modified data, whether the data was updated successfully, or the specific data updated, etc., to notify the client of the execution result of the requested operation.
[0147] When a request message carries a request identifier and a payload, the request identifier can be used to indicate the corresponding request operation, such as read, write, delete, update, or modify. The payload can include information about the data to be operated on. The Redis data server can combine the request identifier and the payload to perform data processing, such as reading, writing, deleting, updating, or modifying data. For example, in a scenario where the Redis data server stores product information, the client can request the Redis data server to read, write, delete, update, or modify product information. The request identifier can identify the read, write, delete, update, or modify operation, and the payload can carry specific information about the product to be read, written, deleted, updated, or modified, such as the product name to be read, the product description to be written, the product identifier to be deleted, the updated product information to be updated, or the product information to be modified.
[0148] In some possible scenarios, the request message may only carry a request identifier. In this scenario, the request identifier can be used to indicate an operation that does not require data adjustment. For example, the request identifier can be a heartbeat maintenance identifier, or the request representation can also be a pre-set identifier indicating a specific operation.
[0149] Furthermore, in some possible scenarios, a request message may only carry a payload, meaning it may not carry a request identifier. For example, a client may include a payload in a request message, and the Redis data server and client may pre-agreed on data processing operations. Upon receiving the payload in the request message, the Redis data server may then perform data processing according to the pre-agreed data processing operations. For example, a Redis data server may provide a data write function for the client. Upon receiving the payload in the request message, the Redis data server may then perform a write operation on the payload carried in the request message.
[0150] For example, the structure of a response message (Response) can be shown in Figure 7. The response message can specifically include steamID, reqID (i.e., request identifier), payload length (payload length), and Redis payload (i.e., payload). Among them, the length of steamID can be 32 bits, the length of reqID is 32 bits, and the steamID and reqID occupy 8 bytes. The payload length (payload length) can be used to indicate the length of the Redis payload, which can be determined according to the actual application scenario.
[0151] In this embodiment, the Response includes the steamID. The proxy can forward or reply packets based on the stream ID carried in the message, thereby achieving out-of-order packet returns and improving database throughput. Furthermore, the Response includes a payload length field, allowing the proxy to determine the message boundaries from subsequent data after parsing the payload length, without having to parse the Redis payload, thus avoiding excessive proxy CPU consumption.
[0152] 404. The proxy server forwards the information contained in the response message to the client.
[0153] After receiving the response message sent by the Redis data server, the proxy server can forward the information carried in the response message to the client.
[0154] In one possible scenario, the proxy and client communicate using the plaintext RESP protocol. That is, the client's request message received by the proxy is a RESP message, while the proxy and the Redis data server communicate using RESP, which is a binary protocol. In this scenario, after receiving the binary-based RESP response message from the Redis data server, the proxy can convert the response message to obtain a plaintext RESP response message, or generate a new plaintext RESP response message based on the information carried in the response message and send the new response message to the client.
[0155] In one possible implementation, when the first protocol and the second protocol are the same, the proxy server forwards at least one first response message to the client; or, when the first protocol and the second protocol are different, the proxy server generates at least one second response message based on the first protocol and information carried in each first response message, and sends the at least one second response message to the client; at least one of the first protocol or the second protocol is a binary protocol.
[0156] For example, in one possible scenario, the client can generate a request message and the Redis data server can generate a response message using the binary-based RESP protocol, that is, the proxy can directly forward the request message to the Redis data server and directly forward the response message to the client.
[0157] For example, in one possible scenario, the proxy and the server can communicate using the plain text RESP protocol. That is, the response message sent by the Redis data server received by the proxy is a RESP protocol message, while the proxy and the client communicate using RESP based on the binary protocol. After receiving the response message sent by the server, the proxy converts the response message into a binary RESP protocol response message, or generates a binary RESP protocol response message based on the information carried in the response message, and sends a new response message to the client.
[0158] Therefore, in the embodiment of the present application, when the proxy forwards a message, it can determine the information of the receiving end of the message to be forwarded based on the flow identifier carried in the received message, thereby eliminating the need to forward messages in the order in which the messages enter the connection pool. This can achieve out-of-order packet return, improve the forwarding efficiency of the proxy, avoid queue blocking, and increase the throughput of the database. Furthermore, in the embodiment of the present application, a multi-channel connection pool of the proxy can be implemented, so that stateful commands can also be placed in the connection pool without blocking the queue, thereby realizing the forwarding of stateful commands using existing proxy resources, improving the utilization of proxy resources, and improving the database throughput.
[0159] The following describes the effects achieved by the method provided in this application in conjunction with specific application scenarios.
[0160] First, the method provided in the embodiment of the present application can support out-of-order reply packets from the proxy.
[0161] In existing databases based on the plain text RESP protocol, the process of returning packets needs to be carried out in the forwarding order. However, in the method provided by this application, as shown in Figure 8, multiplexing can be implemented between the proxy and the Redis data server. For response messages, the Redis data server can reply to the processed packets first, thereby eliminating the effect of head-of-line blocking.
[0162] The binary protocol is used in the shared connection pool between the proxy and the Redis server. Its out-of-order packet return feature eliminates the drawbacks of shared connections. Stateful commands such as blocking cmds and subscribe cmds can also be transmitted through the shared connection pool.
[0163] For example, as shown in Figure 9, for blocking cmd, since the proxy's shared connection pool can include multiple shard conns, even if one channel is blocked, other channels can continue to transmit, thereby avoiding the inability to transmit messages due to queue blocking.
[0164] For another example, based on the method provided in the embodiment of the present application, as shown in Figure 10, a shared connection pool based on a binary protocol can support any number of streams. This shared connection pool with a fixed number of connections can carry a large number of message subscription clients without worrying about the amplification of the number of connections within the cluster, thereby eliminating the drawbacks of traditional shared connection pools.
[0165] The above describes the process of the method provided in this application. The following describes the device structure for executing the above method.
[0166] Referring to FIG11 , a schematic diagram of the structure of a proxy server provided by the present application includes:
[0167] The transceiver module 1101 is configured to receive at least one first request message sent by a client, where each first request message carries a flow identifier, which is an identifier of a flow transmitted between the client and the proxy server. The flow can also be understood as a message queue transmitted between the client and the proxy server.
[0168] The transceiver module 1101 is further configured to forward the information carried in each first request message to the Redis data server;
[0169] The transceiver module 1101 is further configured to receive at least one first response message sent by the Redis data server, where the at least one first response message corresponds to the at least one first request message, i.e., the at least one first response message is a response to the at least one first request message, and each first response message carries the flow identifier in the corresponding first request message;
[0170] The transceiver module is further configured to forward information carried in at least one first response message to the client based on the flow identifier carried in each first response message.
[0171] In one possible embodiment, when at least one first request message includes a subscription command, the aforementioned transceiver module 1101 is specifically configured to: send information carried in the subscription command to a Redis data server based on a stream identifier carried in the subscription command; receive a publish message corresponding to the subscription command sent by the Redis data server; and have the proxy server send information carried in at least one first response message to the client corresponding to the subscription command. The method provided in this application can be applied to subscription command scenarios, and subscription commands can also enter the proxy's connection pool, eliminating the need to allocate resources separately to transmit subscription commands, thereby improving the proxy's efficiency.
[0172] In one possible implementation, when at least one first request message includes a blocking command, the aforementioned transceiver module 1101 is specifically used to: send a blocking command to the server according to the flow identifier carried by the blocking command; wait for receiving a response message corresponding to the blocking command; and after receiving the first response message corresponding to the blocking command, send at least one information carried by the first response message to the client corresponding to the blocking command.
[0173] Referring to FIG12 , a schematic diagram of the structure of a client provided by the present application includes:
[0174] The processing module 1201 is configured to obtain at least one request message, each request message carrying a flow identifier;
[0175] The transceiver module 1202 is configured to send at least one request message to the proxy server, so that the proxy server forwards each request message according to a flow identifier carried in each request message.
[0176] In a possible implementation, the aforementioned transceiver module 1202 is further configured to receive at least one response message, where the at least one response message corresponds to the at least one request message.
[0177] In a possible implementation, each of the aforementioned response messages also carries a first length, where the first length includes the length of the payload carried in each response message. The first length is used by the proxy server to determine the boundary of each response message.
[0178] In a possible implementation, the aforementioned at least one request message further carries a request identifier, and the request identifier is used to indicate the request corresponding to each request message.
[0179] In a possible implementation, the at least one request message includes at least one of a blocking command or a subscription command.
[0180] Referring to FIG13 , a schematic diagram of the structure of a data server provided by the present application includes:
[0181] The transceiver module 1301 is configured to receive at least one request message, each request message carrying a flow identifier;
[0182] The transceiver module 1301 is further configured to send at least one response message, where the at least one response message corresponds to at least one request message, and each response message carries the flow identifier in the corresponding request message.
[0183] In a possible implementation, each of the aforementioned response messages further includes a first length, where the first length includes the length of the payload carried in each response message, and the first length is used by the proxy server to determine the boundary of each response message.
[0184] In a possible implementation, the aforementioned at least one request message further carries a request identifier, and the request identifier is used to indicate the request corresponding to each request message.
[0185] In a possible implementation, the aforementioned at least one request includes a stateful command.
[0186] In a possible implementation, the at least one request message includes at least one of a blocking command or a subscription command.
[0187] The aforementioned transceiver module or processing module can be implemented by software or hardware. For example, the implementation of the processing module is described by taking the processing module as an example, and the implementation of the transceiver module can also refer to the implementation of the processing module.
[0188] As an example of a software functional unit, a processing module may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the processing module may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Typically, a region may include multiple AZs.
[0189] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same virtual private cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.
[0190] As an example of a hardware functional unit, a processing module may include at least one computing device, such as a server. Alternatively, the processing module may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0191] The multiple computing devices included in the processing module can be distributed in the same region or in different regions. The multiple computing devices included in the processing module can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the processing module can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, and other computing devices.
[0192] It should be noted that in other embodiments, the processing module can be used to execute any processing steps in the method provided in this application, and the transceiver module can be used to execute any transceiver steps in the method provided in this application. The steps that the processing module and the transceiver module are responsible for implementing can be specified as needed. The processing module and the transceiver module respectively implement different steps in the aforementioned method to realize all the functions of the proxy, Redis data server or client.
[0193] The present application also provides a Redis database system, as shown in FIG14 , which includes:
[0194] A proxy server, configured to execute the steps performed by the proxy in Figures 4 to 10 above;
[0195] The Redis data server is used to execute the steps performed by the Redis data server mentioned in Figures 4 to 10 above.
[0196] The system may also include:
[0197] The client is used to execute the steps performed by the client mentioned in Figures 4 to 10 above.
[0198] The proxy server, Redis data server, and client can all be implemented by software or hardware. For example, the implementation of the proxy server is described below. Similarly, the implementation of the Redis data server and client can refer to the implementation of the proxy server device.
[0199] As an example of a software functional unit, a proxy server may include code running on a computing instance. The computing instance may be at least one of a physical host (computing device), a virtual machine, a container, and other computing devices. Furthermore, the computing device may be one or more. For example, a proxy server may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the application may be distributed in the same region or in different regions. The multiple hosts / virtual machines / containers used to run the code may be distributed in the same AZ or in different AZs, and each AZ includes one data center or multiple geographically close data centers. Typically, a region may include multiple AZs.
[0200] Similarly, the multiple hosts / virtual machines / containers running the code can be distributed within the same VPC or across multiple VPCs. Typically, a VPC is located within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.
[0201] As an example of a hardware functional unit, a proxy server may include at least one computing device, such as a server. Alternatively, the proxy server may be implemented using an ASIC or a PLD. The PLD may be implemented using a CPLD, FPGA, GAL, or any combination thereof.
[0202] The multiple computing devices included in the proxy server can be distributed in the same region or in different regions. The multiple computing devices included in the proxy server can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the proxy server can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, and other computing devices.
[0203] This application also provides a computing device 100. As shown in FIG15 , computing device 100 includes a bus 102, a processor 104, a memory 106, and a communication interface 108. Processor 104, memory 106, and communication interface 108 communicate with each other via bus 102. Computing device 100 may be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computing device 100.
[0204] Bus 102 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG15 shows only one line, but this does not imply a single bus or type of bus. Bus 104 may include a path for transmitting information between various components of computing device 100 (e.g., memory 106, processor 104, and communication interface 108).
[0205] The processor 104 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0206] The memory 106 may include volatile memory, such as random access memory (RAM). The processor 104 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0207] The memory 106 stores executable program code, and the processor 104 executes the executable program code to implement the functions of the transceiver module and the processing module mentioned in Figures 12 to 14, thereby implementing the method provided by the present application. In other words, the memory 106 stores instructions for executing the method provided by the present application.
[0208] The communication interface 103 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 100 and other devices or a communication network.
[0209] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0210] As shown in Figure 16, the computing device cluster includes at least one computing device 100. The memory 106 in one or more computing devices 100 in the computing device cluster may store the same instructions for executing the method provided by the present application.
[0211] In some possible implementations, the memory 106 of one or more computing devices 100 in the computing device cluster may also store some instructions for executing the method provided in the present application. In other words, the combination of one or more computing devices 100 can jointly execute the instructions for executing the method provided in the present application.
[0212] It should be noted that the memory 106 in different computing devices 100 in the computing device cluster can store different instructions, each for executing a portion of the functions of the joint testing apparatus. In other words, the instructions stored in the memory 106 in different computing devices 100 can implement the functions of one or more of the aforementioned transceiver module or processing module.
[0213] In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network. The network may be a wide area network (WAN) or a local area network (LAN), etc. FIG17 illustrates a possible implementation. As shown in FIG17 , two computing devices 100A and 100B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 106 in the computing device 100A stores instructions for executing the functions of the transceiver module and the processing module. Simultaneously, the memory 106 in the computing device 100B stores instructions for executing the functions of the transceiver module and the processing module.
[0214] It should be understood that the functions of the computing device 100A shown in FIG17 may also be completed by multiple computing devices 100. Similarly, the functions of the computing device 100B may also be completed by multiple computing devices 100.
[0215] The present application also provides another computing device cluster. The connection relationship between the computing devices in this computing device cluster can be similar to the connection method of the computing device cluster described in Figures 16 and 17. However, the memory 106 in one or more computing devices 100 in this computing device cluster can store the same instructions for executing the method provided in this application.
[0216] The present application also provides a computer program product comprising instructions. The computer program product may be software or a program product comprising instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the method provided in the present application.
[0217] The present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the method provided in the present application.
[0218] Finally, 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 aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A data transmission method, characterized in that: Applied to a remote dictionary service Redis database system, the database system includes a Redis data server and a proxy server, the proxy server is connected to the data server, and the proxy server is also connected to a client; the method includes: The proxy server receives at least one first request message sent by the client, each first request message carrying a flow identifier; The proxy server forwards the information carried in each first request message to the Redis data server; The Redis data server sends at least one first response message to the proxy server, where the at least one first response message corresponds to the at least one first request message, and each first response message carries the flow identifier in the corresponding first request message; The proxy server forwards the information carried in the at least one first response message to the client according to the flow identifier carried in each first response message.
2. The method according to claim 1, characterized in that The proxy server forwards the information carried in each first request message to the Redis data server, including: In the case where the first protocol and the second protocol are the same, the proxy server forwards the at least one first request message to the Redis data server, the first protocol is a message protocol transmitted between the client and the proxy server, and the second protocol is a message protocol transmitted between the proxy server and the Redis data server; Alternatively, when the first protocol is different from the second protocol, the proxy server generates at least one second request message based on the second protocol and the information carried in each first request message, and sends the at least one second request message to the Redis data server; At least one of the first protocol or the second protocol is a binary protocol.
3. The method according to claim 2, characterized in that The proxy server forwards the information carried in the at least one first response message to the client according to the flow identifier carried in each first response message, including: In a case where the first protocol is the same as the second protocol, the proxy server forwards the at least one first response message to the client according to the flow identifier carried in each first response message; Alternatively, when the first protocol is different from the second protocol, the proxy server generates at least one second response message based on the first protocol and the information carried by each first response message, and sends the at least one second response message to the client according to the flow identifier carried in each first response message.
4. The method according to any one of claims 1 to 3, characterized in that Each first request message or each first response message also includes a first length, where the first length includes the length of the payload carried in the message, and the first length is used by the proxy server to determine the message boundary.
5. The method according to any one of claims 1 to 4, characterized in that Each of the first messages also carries a request identifier, and the request identifier is used to indicate the request corresponding to each of the first messages.
6. The method according to any one of claims 1 to 5, characterized in that The at least one first request message includes at least one of a blocking command or a subscription command, the blocking command is a message sent by the client to the Redis data server and then waiting for a response, and the subscription command is a message for the client to request a subscription to the Redis data server.
7. The method according to claim 6, characterized in that In the case where the at least one first request message includes the subscription command, The proxy server forwards the information carried in each first request message to the Redis data server, including: Sending the information carried in the subscription command to the data server according to the stream identifier carried in the subscription command; The proxy server forwards the at least one first response message to the client according to the flow identifier carried in each first response message. The information carried in the response message includes: The proxy server receives a publishing message corresponding to the subscription command sent by the Redis data server; The proxy server sends the information carried in the at least one first response message to the client corresponding to the subscription command according to the flow identifier corresponding to the publishing message.
8. The method according to claim 6 or 7, characterized in that: In the case where the at least one first request message includes the blocking command, The proxy server sends at least one second request message to the Redis data server, including: The proxy server sends the blocking command to the server according to the flow identifier carried in the blocking command; The proxy server forwards the information carried in the at least one first response message to the client according to the flow identifier carried in each first response message, including: The proxy server waits to receive a response message corresponding to the blocking command; After the proxy server receives the first response message corresponding to the blocking command, the proxy server sends the information carried in the at least one first response message to the client corresponding to the blocking command according to the flow identifier carried in the first response message.
9. A database system, characterized in that: include: Computing device clusters and proxy servers; The computing device cluster is used to execute the steps performed by the Redis data server in the method according to any one of claims 1 to 8; The proxy server is used to execute the steps performed by the proxy server in the method according to any one of claims 1-8.
10. The system according to claim 9, characterized in that The system further comprises: a client; The client is used to execute the steps performed by the client according to any one of claims 1-8.
11. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the steps performed by the Redis data server in the method according to any one of claims 1 to 8.
12. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the steps performed by the proxy server in the method according to any one of claims 1 to 8.
13. A computer-readable storage medium, characterized in that: The method comprises computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 8.
14. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster is caused to perform the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Data processing method and equipment based on redis
CN107395559A
Data Storage System Based on Redis Cluster
CN109407980A
Expressway portal system capable of quickly processing and transmitting data
CN110928937A
Tenant data processing method, agent component, electronic equipment and storage medium
CN116320017A
High-throughput data integrity via trusted computing
US20190268308A1