A connection multiplexing method, device, electronic device and storage medium
By performing connection multiplexing, grouping and multiplexing TCP connections on the proxy server, the problem of complex information processing on the back-end server is solved, the connection efficiency between the proxy server and the back-end server is improved, and the development and maintenance of the back-end service is facilitated.
Patent Information
- Application Number
- CN202110721982.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-28
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-06-28
AI Technical Summary
When the existing proxy server handles multiple client requests, the information processing of the back-end server is too complicated, resulting in inconvenience in development and maintenance.
By implementing the connection multiplexing method on the proxy server, the client request message is obtained, grouped based on the preset grouping rules, and the available TCP connections are determined based on the grouping attributes, and the connection is multiplexed to send the request message to the back-end server. , maintain the TCP connection to reduce the number of connection establishment times.
It effectively reduces the number of TCP connections maintained by the proxy server, improves the efficiency of the back-end server in processing requests, and facilitates the development, maintenance, and upgrade of back-end services.
Smart Images

Figure CN113472875B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of communications, and in particular, to a connection multiplexing method, device, electronic device, and storage medium. Background Art
[0002] Currently, proxy servers can support connection reuse with clients, but the existing connection reuse method is relatively simple. For multiple requests sent by one or more clients, as long as there is a TCP connection between the proxy server and a back-end server, the back-end server will process the above multiple requests, which makes the information processed by the back-end server very complicated, which is not conducive to the development of the back-end server. Summary of the invention
[0003] In order to solve the above technical problems, the embodiments of the present application provide a connection multiplexing method, device, electronic device and storage medium.
[0004] The embodiment of the present application provides a connection multiplexing method, which is applied to a proxy server, and the method includes:
[0005] Obtaining a request message sent by at least one client to a destination server;
[0006] The request messages are grouped based on a preset grouping rule, and a grouping attribute of each group of request messages is determined;
[0007] Determine, according to the grouping attributes of each group of request messages, an available established TCP connection corresponding to each grouping attribute, wherein each established TCP connection corresponds to one grouping attribute;
[0008] Based on connection multiplexing of the available established TCP connections, request messages of various grouping attributes are sent to corresponding back-end servers that can implement part of the functions of the destination server.
[0009] In an optional implementation manner of the present application, determining, according to the grouping attributes of each group of request messages, an available established TCP connection corresponding to each grouping attribute includes:
[0010] According to the grouping attributes of each group of request messages, determining whether a TCP connection corresponding to each grouping attribute has been saved in the connection pool;
[0011] If the corresponding TCP connection has been saved in the connection pool, an available established TCP connection is obtained from the connection pool.
[0012] In an optional implementation manner of the present application, if the corresponding TCP connection has been saved in the connection pool, obtaining an available established TCP connection from the connection pool includes:
[0013] If the corresponding TCP connection has been saved in the connection pool, determine whether the bandwidth of the TCP connection does not exceed the bandwidth threshold;
[0014] If the bandwidth threshold is not exceeded, an available established TCP connection is obtained from the connection pool.
[0015] In an optional implementation manner of the present application, the method further includes:
[0016] If an available established TCP connection corresponding to the grouping attribute cannot be determined, a TCP connection is established with the corresponding backend server.
[0017] In an optional implementation manner of the present application, the method further includes:
[0018] The correspondence between the client and the request message is recorded to ensure that the corresponding client can be determined when the back-end server response information is received.
[0019] In an optional implementation manner of the present application, the method further includes:
[0020] When the connection with the client is disconnected, the TCP connection with each backend server is maintained.
[0021] In an optional implementation manner of the present application, the communication protocol between the proxy server and the client, and between the proxy server and the backend server is HTTP2.
[0022] The embodiment of the present application also provides a connection multiplexing device, which is applied to a proxy server, and the device includes:
[0023] An acquisition unit, used to acquire a request message sent by at least one client to a destination server;
[0024] A grouping unit, used to group the request messages based on a preset grouping rule and determine a grouping attribute of each group of request messages;
[0025] A determining unit, configured to determine, according to the grouping attributes of each group of request messages, an available established TCP connection corresponding to each grouping attribute, wherein each established TCP connection corresponds to one grouping attribute;
[0026] The sending unit is used to send the request message of each group attribute to the corresponding back-end server that can realize part of the function of the destination server based on the connection multiplexing of the available established TCP connection.
[0027] In an optional implementation of the present application, the determination unit is specifically used to: determine whether TCP connections corresponding to each grouping attribute have been saved in the connection pool based on the grouping attributes of each group of request messages; if the corresponding TCP connection has been saved in the connection pool, obtain an available established TCP connection from the connection pool.
[0028] In an optional implementation of the present application, the determination unit is specifically used to: if the corresponding TCP connection has been saved in the connection pool, determine whether the bandwidth of the TCP connection does not exceed the bandwidth threshold; if it does not exceed the bandwidth threshold, obtain an available established TCP connection from the connection pool.
[0029] In an optional implementation manner of the present application, the device further includes:
[0030] The connection unit is used to establish a TCP connection with a corresponding backend server if an available established TCP connection corresponding to the grouping attribute cannot be determined.
[0031] In an optional implementation manner of the present application, the device further includes:
[0032] The recording unit is used to record the corresponding relationship between the client and the request message to ensure that the corresponding client can be determined when the back-end server response information is received.
[0033] In an optional implementation manner of the present application, the device further includes:
[0034] The maintaining unit is used to maintain the TCP connection with each backend server when the connection with the client is disconnected.
[0035] In an optional implementation manner of the present application, the communication protocol between the proxy server and the client, and between the proxy server and the backend server is HTTP2.
[0036] An embodiment of the present application further provides an electronic device, comprising: a memory and a processor, wherein the memory stores computer executable instructions, and when the processor runs the computer executable instructions on the memory, the connection multiplexing method described in the above embodiment can be implemented.
[0037] An embodiment of the present application further provides a computer storage medium, on which executable instructions are stored. When the executable instructions are executed by a processor, the connection multiplexing method described in the above embodiment is implemented.
[0038] The technical solution of the embodiment of the present application is that the proxy server obtains the request message sent by at least one client to the destination server; based on the preset grouping rules, the request message is grouped to determine the grouping attributes of each group of request messages; according to the grouping attributes of each group of request messages, the available established TCP connections corresponding to each grouping attribute are determined, wherein each established TCP connection corresponds to one grouping attribute; based on the connection multiplexing of the available established TCP connections, the request messages of each grouping attribute are sent to the corresponding back-end server that can realize part of the functions of the destination server. The technical solution of the embodiment of the present application, on the one hand, ensures the number of connections between the proxy server and the back-end server, avoiding the proxy server from maintaining a large number of TCP connections; on the other hand, it can ensure that the request messages sent to each back-end server for processing are of one type or only achieve one purpose, thereby facilitating the development, maintenance and upgrading of back-end services. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 A schematic diagram of a flow chart of a connection multiplexing method provided in an embodiment of the present application;
[0040] Figure 2 A schematic diagram of a combination method of a request message provided in an embodiment of the present application;
[0041] Figure 3 A schematic diagram of information interaction between a proxy server, a client, and a backend server provided in an embodiment of the present application;
[0042] Figure 4 A schematic diagram of the structure of a connection multiplexing device provided in an embodiment of the present application;
[0043] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0044] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.
[0045] The following is an explanation of key terms related to the embodiments of the present application:
[0046] HTTP2 (HyperText Transfer Protocol 2.0): Hypertext Transfer Protocol version 2, originally named HTTP 2.0, abbreviated as h2 (encrypted connection based on Transport Layer Security (TLS) 1.2 or above) or h2c (non-encrypted connection), is the second major version of the HTTP protocol and is used on the World Wide Web.
[0047] HTTP2 multiplexing: A feature of the HTTP2 protocol, which means that when the client sends a message to the server, it does not need to wait for the response to the previous request message before sending the next request message. The client can send multiple request messages to the back-end server at the same time. There is no dependency between the request messages, and there is no dependency between the response information.
[0048] Figure 1 A flow chart of a connection multiplexing method provided in an embodiment of the present application is shown as follows: Figure 1 As shown, the connection multiplexing method provided in the embodiment of the present application includes the following steps:
[0049] Step 101: Obtain a request message sent by at least one client to a destination server.
[0050] In the embodiments of the present application, the client is also called the user end, which refers to a program corresponding to the back-end server that provides local services to customers. In addition to some applications that only run locally, they are generally installed on ordinary client computers and need to cooperate with the back-end server to run. In Internet technology, more commonly used clients include web browsers such as those used for the World Wide Web, email clients for sending and receiving emails, and client software for instant messaging. For various types of client applications, there needs to be corresponding back-end servers and service programs in the network to provide corresponding services, such as database services, email services, etc., and a specific communication connection needs to be established between the client and the back-end server to ensure the normal operation of the client application.
[0051] The destination server includes one or more backend servers. Backend servers are a type of computer that runs faster, has a higher load, and is more expensive than ordinary computers. Backend servers provide computing or application services for other clients (such as PCs, smart phones, ATMs and other terminals, and even large devices such as train systems) in the network. Backend servers have high-speed CPU computing power, long-term reliable operation, strong I / O external data throughput capabilities, and better scalability. According to the services provided by the backend servers, generally speaking, the backend servers have the ability to respond to service requests, provide services, and guarantee services.
[0052] The proxy server is an intermediate device that connects the client and the back-end server and is responsible for forwarding request messages and response information between the client and the back-end server.
[0053] In an embodiment of the present application, the proxy server can simultaneously accept multiple request messages sent by multiple clients, wherein the number of request messages sent by each client is one or more.
[0054] like Figure 2 As shown, the proxy server can simultaneously receive request messages A1, A2, A3 sent by client 1, request messages B1, B2, B3 sent by client 2, and request messages C1, C2, C3 sent by client 3.
[0055] The request message sent by each of the multiple clients may include multiple types, for example, Figure 2 As shown, client 1 sends three request messages A1, A2, and A3, wherein request messages A1 and A2 are requests for sending emails, and request message A3 is a request for image processing.
[0056] Step 102: Group the request messages based on a preset grouping rule, and determine a grouping attribute of each group of request messages.
[0057] In the embodiment of the present application, the preset rule is specifically a rule based on which multiple request messages are grouped. The preset rule can be selected in multiple forms. After the request messages are grouped according to the preset rule, the grouping attributes corresponding to the request messages in the same group of request messages are the same. Depending on the preset rule, the specific attributes included in the grouping attribute are also different.
[0058] In one embodiment, the preset rule is specifically to group multiple request messages according to the type of resources of the request messages sent by the client, for example, to group the request messages of the type of sending and receiving emails sent by each client into one group, and to group the request messages of the type of image processing sent by each client into one group. In this case, the grouping attribute is specifically the type of resource requested.
[0059] Here, if the group attribute is specifically the resource type of the request, the TCP connection corresponding to the group attribute can be understood as the backend server corresponding to the group attribute. For example, a group of request messages belonging to the type of sending and receiving emails can be sent to a backend server dedicated to processing the task of sending and receiving emails, and a group of request messages belonging to the type of image processing can be sent to a backend server dedicated to the task of image processing.
[0060] In another embodiment, the preset rule is specifically to group multiple request messages according to the priority level corresponding to the request message sent by the client, for example, the request messages belonging to the first priority sent by each client are grouped into one group, and the request messages belonging to the second priority sent by each client are grouped into one group, wherein the first priority is higher than the second priority. In this case, the grouping attribute is specifically the priority type of the request. Here, if the grouping attribute is specifically the priority type of the request, the TCP connection corresponding to the grouping attribute can be understood as the back-end server corresponding to the grouping attribute. For example, the proxy server can send a group of request messages belonging to the first priority to the first back-end server, and send a group of request messages belonging to the second priority to the second back-end server, where the processing speed of the first back-end server is greater than the processing speed of the second back-end server.
[0061] In addition, the preset rule can also be to group the request messages according to different types of clients, in which case the grouping attribute is specifically the type of client; or the preset rule is to group the request messages according to the security level of the request messages, etc. In this case, the grouping attribute is specifically the security level type of the request. The embodiments of the present application do not specifically limit the preset rules and grouping attributes. The above preset rules and corresponding grouping attributes are several specific rules listed in the embodiments of the present application and the grouping attributes corresponding to the specific rules. It can be understood that the preset rules and grouping attributes in the embodiments of the present application can also be in other forms.
[0062] Figure 2 In the example, after receiving the request messages A1, A2, A3, B1, B2, B3, C1, C2 and C3 sent by the client 1, the client 2 and the client 3, the proxy server groups the above 9 requests according to the preset rules, and obtains the first group of request messages consisting of A1, B2, C3 and A2, and the second group of request messages consisting of C1, A3, B1, B3 and C2. Among them, each request message in the first group of request messages corresponds to group attribute 1, and the second group of request messages corresponds to group attribute 2. According to the above two group attributes determined, the TCP connections corresponding to the above two group attributes can be determined, and it can also be understood that the three back-end servers corresponding to each group of request messages are determined according to the above two group attributes determined.
[0063] Step 103: Determine the available established TCP connections corresponding to each group attribute according to the group attribute of each group of request messages, wherein each established TCP connection corresponds to one group attribute.
[0064] In an embodiment of the present application, the grouping attributes corresponding to each request message included in the same group of request messages are the same. The same grouping attributes can be understood as each request message in the same group of request messages corresponding to the same TCP connection, and can also be understood as each message in the same group of request messages corresponding to the same backend server.
[0065] In an optional implementation manner of the present application, the above step 103 can be specifically implemented by the following process:
[0066] Step 3-1): According to the grouping attributes of each group of request messages, determine whether the TCP connections corresponding to each grouping attribute have been saved in the connection pool;
[0067] Step 3-2): If the corresponding TCP connection has been saved in the connection pool, an available established TCP connection is obtained from the connection pool.
[0068] In order to reduce the number of times the proxy server establishes connections with the back-end server, it can maintain a connection pool. When the connection between the client and the back-end server is disconnected, the corresponding connection between the proxy server and the back-end server will not be disconnected, but will be placed in a connection pool maintained by the proxy server. When a new request message from a qualified client is dispatched to the same back-end server, the proxy server can take out the connection between it and the back-end server from the maintained connection pool to process the request message.
[0069] For each group of request messages corresponding to the determined grouping attributes, the proxy server first determines from the connection pool it maintains whether there is a TCP connection corresponding to the grouping attributes of the group of request messages. If so, the existing TCP connection corresponding to the grouping attributes can be directly used to send the group of request messages.
[0070] In an optional implementation manner of the present application, the above step 3-2) can be specifically implemented by the following steps:
[0071] Step 3-2-1): If the corresponding TCP connection has been saved in the connection pool, determine whether the bandwidth of the TCP connection does not exceed the bandwidth threshold;
[0072] Step 3-2-2): If the bandwidth threshold is not exceeded, an available established TCP connection is obtained from the connection pool.
[0073] After the proxy server determines that there is a TCP connection corresponding to the grouping attributes of each group of request messages from the connection pool it maintains, it also needs to determine whether the bandwidth of the TCP connection corresponding to each group of request messages exceeds the bandwidth threshold. This step is to achieve load balancing and avoid affecting the processing speed of request messages or causing the loss of request messages or response information due to excessive load between the proxy server and the corresponding back-end server.
[0074] In an optional implementation manner of the present application, if an available established TCP connection corresponding to the grouping attribute cannot be determined, a TCP connection is established with the corresponding backend server.
[0075] For the grouping attributes corresponding to each group of request messages, if the proxy server cannot determine the available established TCP connection corresponding to the grouping attributes, or, it can be understood that if the proxy server determines that no TCP connection has been established with the back-end server corresponding to the grouping attributes, the proxy server needs to first execute the operation of establishing a TCP connection with the back-end server corresponding to the grouping attributes.
[0076] like Figure 2 As shown, before the proxy server sends the first group of request messages to server 1, it needs to confirm whether a TCP connection is established between it and server 1. If not, it needs to establish a TCP connection with server 1 before sending the first group of request messages. Similarly, before the proxy server sends the second group of request messages to server 2, it needs to confirm whether a TCP connection is established between it and server 2. If not, it needs to establish a communication connection with server 2 before sending the second group of request messages.
[0077] Step 104: Based on connection multiplexing of the available established TCP connections, the request message of each grouping attribute is sent to the corresponding back-end server that can realize part of the functions of the destination server.
[0078] In an embodiment of the present application, for each group of request messages, each group of request messages needs to be encapsulated according to the communication protocol between the proxy server and the back-end server, and then each encapsulated group of request messages needs to be sent to the back-end server corresponding to the grouping attributes of the group of request messages.
[0079] In an optional implementation manner of the present application, the communication protocol between the proxy server and the client, and between the proxy server and the backend server is HTTP2.
[0080] In an embodiment of the present application, the HTTP2 communication protocol between the proxy server client and the backend server supports parallel processing of multiple request messages and multiple response messages, and there is no dependency between the request messages and no dependency between the response messages.
[0081] In an optional implementation of the present application, the proxy server records the correspondence between the client and the request message to ensure that the corresponding client can be determined when the back-end server response information is received.
[0082] In addition to sending the request message of each group attribute to the corresponding back-end server based on the established TCP connection, the proxy server also records the connection information between each request message and the client. The connection information can be specifically understood as the correspondence between the request message and the client. Alternatively, the proxy server records the connection information between the request message, the client and the back-end server. At this time, the connection information can be specifically understood as the correspondence between "request message-client-back-end server".
[0083] After receiving each request message, the backend server can generate a corresponding response based on the specific content of the request message. Based on the record of connection information, after receiving the response information sent by the backend server, the proxy server first determines the request message corresponding to the response information, and then determines to which client the response information needs to be sent based on the recorded connection information.
[0084] For example, after receiving the response information sent by the back-end server 1 or the back-end server 2, the proxy server can determine which request message the response information corresponds to. For example, after the proxy server receives the response information A11 sent by the back-end server 1, it determines that the response information A11 is the response information corresponding to the request message A1. Furthermore, based on the recorded client corresponding to the request message A1, the proxy server can determine that the response information A11 needs to be sent to the client 1.
[0085] In an optional implementation of the present application, the proxy server encapsulates each response information received corresponding to each request message according to the transmission protocol between the proxy server and the client, and sends each response information to the corresponding client.
[0086] In an optional implementation of the present application, when the connection between the proxy server and the client is disconnected, the proxy server maintains a TCP connection with each backend server.
[0087] by Figure 2 Taking the client 1 as an example, after the request messages A1, A2, and A3 sent by the client 1 all receive corresponding response information, the client 1 will disconnect from the proxy server, but the TCP connection between the proxy server and the backend server 1 and the backend server 2 will not be disconnected, and the proxy server still maintains the TCP connection between the backend server 1 and the backend server 2 in the connection pool. When the client 1 sends a request message to the backend server 1 or the backend server 2 again, the proxy server can directly take out the connection with the backend server 1 or the backend server 2 from the connection pool for use.
[0088] The technical solution of the embodiment of the present application can enable the same connection between the proxy server and the back-end server to be used by multiple clients, realize the processing of multiple request messages sent by multiple clients, and realize the many-to-many connection multiplexing effect between multiple clients and multiple back-end servers when there are multiple clients and multiple back-end servers at the same time. It can significantly improve the utilization rate of the connection between the proxy server and the server, and improve the response speed to the request messages sent by multiple clients.
[0089] The technical solution of the embodiment of the present application, on the one hand, ensures the number of connections between the proxy server and the back-end server, avoiding the proxy server from maintaining a large number of TCP connections, and on the other hand, can ensure that the request message sent to a certain back-end server for processing is of one type or only achieves one purpose, thereby facilitating the development, maintenance and upgrading of back-end services.
[0090] Figure 3 The following is a schematic diagram of information interaction between the proxy server, the client, and the back-end server provided in the embodiment of the present application. Figure 3 Take the following as an example to explain the specific processing process of the proxy server for the request message sent by the client and the response information returned by the back-end server.
[0091] S301: The client sends multiple requests to the proxy server in parallel.
[0092] The same client can send multiple requests to the proxy server at the same time, and different clients can also send multiple requests to the proxy server at the same time.
[0093] S302: The proxy server analyzes multiple requests, groups the multiple requests according to preset rules, and determines a grouping attribute corresponding to each group of requests.
[0094] After receiving multiple request messages, the proxy server determines the grouping attributes corresponding to each request according to preset rules (such as the requested resource type, security level, priority level, etc.), or understands it as the corresponding backend server.
[0095] S303: Check whether a TCP connection corresponding to each grouping attribute exists. If so, use it directly. If not, establish a TCP connection with a backend server corresponding to the grouping attribute.
[0096] When the proxy server sends a request message to the target backend server, it determines whether a TCP connection is established with the backend server. If no TCP connection is established, it first performs an operation of establishing a TCP connection with the backend server.
[0097] S304: Establish a connection with the backend server.
[0098] The proxy server sends a connection request to the backend server, requesting to establish a communication connection with the backend server.
[0099] S305: Establish a connection with the proxy server.
[0100] After receiving the connection request sent by the proxy server, the backend server establishes a TCP connection with the proxy server.
[0101] S306: Record the connection information between the client and the backend server corresponding to each request.
[0102] After determining the backend server corresponding to each request message, the proxy server can record the connection information between the request message and the corresponding client and the corresponding backend server.
[0103] S307: Rewrite / encapsulate the original request to generate a new request.
[0104] For the received request message, the proxy server encapsulates the request message according to the transmission protocol between the proxy server and the backend server, so that the format of the request message complies with the transmission protocol between the proxy server and the backend server.
[0105] S308: Send a request to the backend server.
[0106] After encapsulating the request message, the proxy server sends the encapsulated request message to the corresponding backend server.
[0107] S309: The backend server receives the request and responds.
[0108] After receiving the request message forwarded by the proxy server, the back-end server responds to the request message according to the specific content of the request message and generates response information corresponding to the request message.
[0109] S310: Receive a response from the backend server.
[0110] The proxy server receives the response information corresponding to the request message.
[0111] S311: Determine the client corresponding to the response based on the recorded connection information.
[0112] After receiving the response information, the proxy server determines to which request message the response information specifically corresponds, and based on the original client corresponding to the request message, determines to which client the response information needs to be forwarded.
[0113] S312: Re-encapsulate the response information and send it to the client.
[0114] After determining the client corresponding to the response information, the proxy server encapsulates the response information according to the transmission protocol between the proxy server and the client and sends it to the client.
[0115] S313: Send response information to the client.
[0116] The proxy server sends the encapsulated response information to the client.
[0117] S314: After the client confirms the responses to all requests, it disconnects from the proxy server.
[0118] The client determines whether all request messages sent by the client have received corresponding responses according to the received response information, and disconnects the connection with the proxy server after confirming that all request messages have been responded.
[0119] S315: The client disconnects from the proxy server.
[0120] The client disconnects from the proxy server after confirming that all request messages have been answered.
[0121] S316: Disconnect from the client, but still maintain the connection with the backend server.
[0122] After the proxy server disconnects from the client, it still maintains the connection with the back-end server and keeps the connection information in the connection pool of the proxy server. When the client sends a request message to the back-end server again, the proxy server can directly use the communication connection with the back-end server to send the request message and receive the response information.
[0123] Figure 4 A schematic diagram of the structure of a connection multiplexing device provided in an embodiment of the present application, wherein the connection multiplexing device is applied to a proxy server, such as Figure 4 As shown, the connection multiplexing device provided in the embodiment of the present application includes:
[0124] The acquisition unit 401 is used to acquire a request message sent by at least one client to a destination server;
[0125] A grouping unit 402, configured to group the request messages based on a preset grouping rule and determine a grouping attribute of each group of request messages;
[0126] The determining unit 403 is used to determine, according to the grouping attributes of each group of request messages, the available established TCP connections corresponding to each grouping attribute, wherein each established TCP connection corresponds to one grouping attribute;
[0127] The sending unit 404 is used to send the request message of each group attribute to the corresponding backend server that can realize part of the function of the destination server based on the connection multiplexing of the available established TCP connection.
[0128] In an optional implementation of the present application, the determination unit 403 is specifically used to: determine whether TCP connections corresponding to each grouping attribute have been saved in the connection pool based on the grouping attributes of each group of request messages; if the corresponding TCP connection has been saved in the connection pool, obtain an available established TCP connection from the connection pool.
[0129] In an optional implementation of the present application, the determination unit 403 is specifically used to: if the corresponding TCP connection has been saved in the connection pool, determine whether the bandwidth of the TCP connection does not exceed the bandwidth threshold; if it does not exceed the bandwidth threshold, obtain an available established TCP connection from the connection pool.
[0130] In an optional implementation manner of the present application, the device further includes:
[0131] The connection unit 405 is configured to establish a TCP connection with a corresponding backend server if an available established TCP connection corresponding to the group attribute cannot be determined.
[0132] In an optional implementation manner of the present application, the device further includes:
[0133] The recording unit 406 is used to record the correspondence between the client and the request message to ensure that the corresponding client can be determined when the back-end server response information is received.
[0134] In an optional implementation manner of the present application, the device further includes:
[0135] The maintaining unit 407 is used to maintain the TCP connection with each backend server when the connection with the client is disconnected.
[0136] In an optional implementation manner of the present application, the communication protocol between the proxy server and the client, and between the proxy server and the backend server is HTTP2.
[0137] Those skilled in the art should understand that Figure 4 The implementation functions of each unit in the connection multiplexing device shown can be understood by referring to the relevant description of the aforementioned connection multiplexing method. Figure 4 The functions of each unit in the connection multiplexing device shown can be implemented by a program running on a processor, or by a specific logic circuit.
[0138] An embodiment of the present application also provides an electronic device. Figure 5Schematic diagram of the hardware structure of the electronic device of the embodiment of the present application, such as Figure 5 As shown, the electronic device includes: a communication component 503 for data transmission, at least one processor 501 and a memory 502 for storing a computer program that can be run on the processor 501. The various components in the terminal are coupled together through a bus system 504. It can be understood that the bus system 504 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 504 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 5 Various buses are labeled as bus system 504 .
[0139] Wherein, when the processor 501 executes the computer program, at least Figure 1 The steps of the method are shown.
[0140] It can be understood that the memory 502 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 502 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memories.
[0141] The method disclosed in the above embodiment of the present application can be applied to the processor 501, or implemented by the processor 501. The processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 501 or an instruction in the form of software. The above processor 501 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 501 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 502, and the processor 501 reads the information in the memory 502 and completes the steps of the above method in combination with its hardware.
[0142] In an exemplary embodiment, the electronic device may be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), FPGA, general purpose processor, controller, MCU, microprocessor, or other electronic components to execute the aforementioned method of proceeding.
[0143] The present application also provides a computer-readable storage medium having a computer program stored thereon, wherein the program is at least used to execute when executed by a processor Figure 1 The computer readable storage medium may be a memory. The memory may be Figure 5 Memory 502 is shown.
[0144] The technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.
[0145] In the several embodiments provided in the present application, it should be understood that the disclosed methods and intelligent devices can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0146] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0147] In addition, all functional units in the embodiments of the present application may be integrated into a second processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0148] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A connection multiplexing method, characterized in that: Applied to a proxy server, the method comprises: Obtaining a request message sent by at least one client to a destination server; the destination server includes one or more backend servers; the request message includes multiple types; The request messages are grouped based on a preset grouping rule, and a grouping attribute of each group of request messages is determined; Determine, according to the grouping attributes of each group of request messages, an available established TCP connection corresponding to each grouping attribute, wherein each established TCP connection corresponds to a grouping attribute; the TCP connection corresponding to the grouping attribute is a backend server corresponding to the grouping attribute; the grouping attribute is specifically a requested resource type or a requested priority type or a client type or a requested security level type; Based on connection multiplexing of the available established TCP connections, the request message of each grouping attribute is sent to the corresponding back-end server that can realize part of the function of the destination server; Among them, after the proxy server disconnects from the client, it still maintains the connection with the back-end server and maintains the connection information in the connection pool of the proxy server. When the client sends a request message to the back-end server again, the proxy server can directly use the communication connection with the back-end server to send the request message.
2. The method according to claim 1, characterized in that The step of determining, according to the grouping attributes of each group of request messages, an available established TCP connection corresponding to each grouping attribute comprises: According to the grouping attributes of each group of request messages, determining whether a TCP connection corresponding to each grouping attribute has been saved in the connection pool; If the corresponding TCP connection has been saved in the connection pool, an available established TCP connection is obtained from the connection pool.
3. The method according to claim 2, characterized in that If the corresponding TCP connection has been saved in the connection pool, obtaining an available established TCP connection from the connection pool includes: If the corresponding TCP connection has been saved in the connection pool, determine whether the bandwidth of the TCP connection does not exceed the bandwidth threshold; If the bandwidth threshold is not exceeded, an available established TCP connection is obtained from the connection pool.
4. The method according to claim 1, characterized in that: The method further comprises: If an available established TCP connection corresponding to the grouping attribute cannot be determined, a TCP connection is established with the corresponding backend server.
5. The method according to claim 1, characterized in that The method further comprises: The correspondence between the client and the request message is recorded to ensure that the corresponding client can be determined when the back-end server response information is received.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: When the connection with the client is disconnected, the TCP connection with each backend server is maintained.
7. The method according to any one of claims 1 to 5, characterized in that The communication protocol between the proxy server and the client, and between the proxy server and the backend server is HTTP2.
8. A connection multiplexing device, characterized in that: Applied to a proxy server, the device comprises: An acquisition unit, configured to acquire a request message sent by at least one client to a destination server; the destination server includes one or more backend servers; the request message includes multiple types; A grouping unit, used to group the request messages based on a preset grouping rule and determine a grouping attribute of each group of request messages; A determination unit, configured to determine, according to the grouping attributes of each group of request messages, an available established TCP connection corresponding to each grouping attribute, wherein each established TCP connection corresponds to a grouping attribute; the TCP connection corresponding to the grouping attribute is a backend server corresponding to the grouping attribute; the grouping attribute is specifically a requested resource type or a requested priority type or a client type or a requested security level type; A sending unit, configured to send the request message of each grouping attribute to a corresponding back-end server that can realize part of the function of the destination server based on connection multiplexing of the available established TCP connection; Among them, after the proxy server disconnects from the client, it still maintains the connection with the back-end server and maintains the connection information in the connection pool of the proxy server. When the client sends a request message to the back-end server again, the proxy server can directly use the communication connection with the back-end server to send the request message.
9. An electronic device, characterized in that: The electronic device comprises: a memory and a processor, wherein the memory stores computer executable instructions, and the processor can implement any one of claims 1 to 7 when executing the computer executable instructions on the memory.
10. A computer storage medium, characterized in that: The storage medium stores executable instructions, which, when executed by a processor, implement the method according to any one of claims 1 to 7.
