Connection establishment method, device, equipment and storage medium based on RDMA
By creating virtual links on RDMA links, the sharing of multiple virtual connections is solved, and the problem of slow RDMA connection building speed is improved, and data transmission efficiency is improved, especially under the demand for multi-links, the overall connection building speed is significantly improved.
Patent Information
- Application Number
- CN202211211865.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-09-30
AI Technical Summary
RDMA technology has a slow connection building speed in application scenarios where links are repeatedly created and disconnected, which affects data transmission efficiency.
Abstracting virtual links on RDMA links allows multiple virtual connections to be created between the client and the server. Multiple virtual links share resources of the same RDMA link, thereby realizing multiple data transmission, reducing the number of RDMA links, and improving the speed of building connections .
Through the reuse and sharing of virtual links, the establishment speed of RDMA links is significantly improved. Especially when multiple links are needed, the problem of slow RDMA link building speed is solved and the overall data transmission efficiency is improved.
Smart Images

Figure CN115623057B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of RDMA technology, and in particular to a connection establishment method, device, equipment and storage medium based on RDMA. Background Art
[0002] The Remote Direct Memory Access (RDMA) protocol, with its kernel bypass feature, allows direct data reading and writing between applications and network cards. It can transfer data directly from the memory of one computer to another computer without the intervention of the operating systems of both parties, circumventing the limitations of the Transmission Control Protocol / Internet Protocol (TCP / IP) protocol, and can effectively reduce communication latency and CPU occupancy. It is widely used in in-memory databases, distributed storage, high-performance computing and other fields.
[0003] However, compared with the speed of RDMA data transmission, RDMA has the problem of slow connection establishment, especially in application scenarios where RDMA links are repeatedly created and disconnected, the problem of slow RDMA connection establishment is particularly prominent. Summary of the invention
[0004] Multiple aspects of the present application provide a connection establishment method, apparatus, device and storage medium based on RDMA, so as to solve the problem of slow RDMA connection establishment speed and further improve the data transmission speed based on RDMA link.
[0005] An embodiment of the present application provides an RDMA-based connection establishment method, which is applied to a client, wherein a first application is running on the client side, including: receiving a first connection establishment request initiated by the first application to a second application on a server side, wherein the first connection establishment request is any one of multiple connection establishment requests initiated by the first application to the second application; according to the first connection establishment request, obtaining a first RDMA link between the client and the server that can be reused by the first application; creating a first virtual link corresponding to the first connection establishment request on the first RDMA link, so that the first application and the second application perform one-way data transmission through the first virtual connection carried on the first RDMA link; wherein, in the case of creating multiple virtual links on the first RDMA link, the multiple virtual links share resources of the first RDMA link, so that the first application and the second application perform multi-way data transmission through the multiple virtual connections carried on the first RDMA link.
[0006] An embodiment of the present application also provides an RDMA-based connection establishment method, comprising: receiving a first channel identifier sent by a client through a first RDMA link between the client and a server, the first channel identifier being a channel identifier in an idle state selected from multiple channel identifiers supported by the first RDMA link, and the first RDMA link being an RDMA link between the client and the server that can be reused by a first application on the client; returning a response message to the client based on the first RDMA link, the response message at least including a message indicating that the first channel identifier has been received, so as to create a first virtual link corresponding to the first channel identifier on the first RDMA link, the first virtual link being used by the first application to transmit data to a second application on the server side through the first RDMA link.
[0007] An embodiment of the present application also provides an RDMA-based connection device, including: a receiving module, used to receive a first connection request initiated by a first application on a client side to a second application on a server side, wherein the first connection request is any one of multiple connection requests initiated by the first application to the second application; an acquisition module, used to acquire, based on the first connection request, a first RDMA link between the client and the server that can be reused by the first application; a connection module, used to create a first virtual link corresponding to the first connection request on the first RDMA link, so that the first application and the second application perform one-way data transmission through the first virtual connection carried on the first RDMA link; wherein, in the case of creating multiple virtual links on the first RDMA link, the multiple virtual links share resources of the first RDMA link, so that the first application and the second application perform multiple-way data transmission through the multiple virtual connections carried on the first RDMA link.
[0008] An embodiment of the present application also provides an RDMA-based connection establishment device, including: a receiving module, used to receive a first channel identifier sent by a client through a first RDMA link between the client and a server, the first channel identifier is a channel identifier in an idle state selected from multiple channel identifiers supported by the first RDMA link, and the first RDMA link is an RDMA link between the client and the server that can be reused by a first application on the client side; a sending module, used to return a response message to the client based on the first RDMA link, the response message at least including a message indicating that the first channel identifier is received, so as to create a first virtual link corresponding to the first channel identifier on the first RDMA link, and the first virtual link is used by the first application to transmit data to a second application on the server side through the first RDMA link.
[0009] An embodiment of the present application also provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor is coupled to the memory and is used to execute the computer program to implement the steps in any RDMA-based connection establishment method provided in the embodiment of the present application.
[0010] The embodiment of the present application further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor is enabled to implement the steps in any RDMA-based connection establishment method provided in the embodiment of the present application.
[0011] In an embodiment of the present application, a virtual link is abstracted on top of the RDMA link, allowing multiple virtual connections to be created on one RDMA link between the client and the server. The multiple virtual links share the resources of one RDMA link, so that the upper-layer applications on both sides can achieve multi-channel data transmission through multiple virtual links carried on the same RDMA link. This can not only solve the problem of requiring multiple communication links between the upper-layer applications on both sides, but also reduce the number of RDMA links because the same RDMA link will carry multiple virtual links. This avoids the problem of slow RDMA connection establishment to a certain extent, especially when a large number of links are required, and can significantly improve the overall connection establishment speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0013] Figure 1a A schematic diagram of a first application and a second application communicating via an RDMA link provided in an embodiment of the present application;
[0014] Figure 1b An internal architecture diagram of a client or server for implementing a connection provided in an embodiment of the present application;
[0015] Figure 1c Another internal architecture diagram of a client or server provided in an embodiment of the present application for implementing connection establishment;
[0016] Figure 2a A schematic diagram of an RDMA-based connection interaction process provided in an embodiment of the present application;
[0017] Figure 2b Another RDMA-based connection interaction process diagram provided in an embodiment of the present application;
[0018] Figure 2c A schematic diagram of a virtual connection and RDMA connection closing process provided in an embodiment of the present application;
[0019] Figure 3a A schematic diagram of a flow chart of a connection establishment method based on RDMA provided in an embodiment of the present application;
[0020] Figure 3b A schematic diagram of a process for obtaining a reusable RDMA link provided in an embodiment of the present application;
[0021] Figure 4 A flowchart of another RDMA-based connection establishment method provided in an embodiment of the present application;
[0022] Figure 5 A schematic diagram of the structure of an RDMA-based connection establishment device provided in an embodiment of the present application;
[0023] Figure 6 A schematic diagram of the structure of another RDMA-based connection establishment device provided in an embodiment of the present application;
[0024] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0026] In response to the technical problem of slow RDMA connection establishment, in some embodiments of the present application, a virtual link is abstracted on the RDMA link, allowing multiple virtual connections to be created on an RDMA link between the client and the server. The multiple virtual links share the resources of an RDMA link, and the upper-layer applications on both sides can perform multi-channel data transmission through the multiple virtual connections carried on the same RDMA link. This can not only solve the problem of requiring multiple communication links between the upper-layer applications on both sides, but also reduce the number of RDMA links because the same RDMA link will carry multiple virtual links. This avoids the problem of slow RDMA connection establishment to a certain extent, and can significantly improve the overall connection establishment speed when a large number of links are required.
[0027] In the embodiment of the present application, the client and the server are relative, and refer to the two ends that need to establish a communication link and transmit data based on the established communication link. In this embodiment, the roles between the client and the server are not limited. When one party needs to initiate a connection request to the other party, the party that initiates the connection request can be the client, and the other party can be the server. Therefore, the client and the server can also be called the first communication end and the second communication end, or can also be called the first host end or the second host end.
[0028] Whether it is a client or a server, it can run on various electronic devices, such as smart phones, tablet computers, personal computers, wearable devices, etc., or it can be a traditional server, cloud server or server cluster, etc. In this embodiment, the electronic device generally includes at least one processing unit and at least one memory. The number of processing units and memories depends on the configuration and type of the electronic device. The memory may include volatile, such as RAM, or non-volatile, such as read-only memory (ROM), flash memory, etc., or may include both types at the same time. The memory generally stores the program code of the operating system (OS), one or more application programs (also referred to as upper-layer applications), and may also store program data, etc. In addition to the processing unit and memory, the electronic device also includes an RDMA device, which refers to a network interface card that supports the RDMA transmission protocol, which can be referred to as RNIC.
[0029] In this embodiment, upper-layer applications are running on electronic devices on both the client and server sides. When the upper-layer application on the client side needs to communicate with the upper-layer application on the server side, a connection request can be initiated; the client establishes a communication link with the server based on the connection request of the upper-layer application, and provides data transmission services for the upper-layer application on the client side and the upper-layer application on the server side based on the communication link. In this embodiment, the communication link between the client and the server is a communication link in a broad sense, including both physical links and virtual links carried on physical links. The physical link can be a TCP link, a User Datagram Protocol (UDP) link, or an RDMA link. In each embodiment of the present application, the physical link mainly refers to the RDMA link.
[0030] In the embodiment of the present application, the client and the server have the ability to send and receive data through the RDMA device on the electronic device where they are located. Figure 1aAs shown, an RDMA link can be established between the client and the server, and the upper-layer applications on both sides can perform data transmission based on the RDMA link. Taking the process of the upper-layer application on the client side sending and receiving data through the RDMA device as an example, the upper-layer application writes WQE (Work Queue Element) to the sending queue (SQ) and receiving queue (RQ) of the RDMA device to notify the network card to send and receive data. After the task is completed, the RDMA device writes CQE (Completion Queue Element) to its completion queue (CQ) to notify the upper-layer application that the IO read and write task is completed. If a CQE for a sending operation is received, it indicates a write event; if a CQE for a receiving operation is received, it indicates a read event. It should be noted that the RDMA device and the network card can be integrated on the same network interface device, or they can be implemented as two independent devices but communicated with each other.
[0031] In this embodiment, the electronic device where the client and the server are located has an RDMA device, and the client and the server also have the ability to send and receive data through their RDMA devices, but the embodiment of the application does not limit the network protocol for data transmission that the upper-layer application relies on to develop. Any network protocol that can support the client and the server to send and receive data for its upper-layer application through its RDMA device is applicable to the embodiment of the application. For example, the network protocol that the upper-layer application relies on to develop includes but is not limited to: RDMA protocol, TCP / IP protocol, UDP / IP protocol, etc.
[0032] It is further explained that no matter which network protocol the upper-layer application relies on, when sending and receiving data through the RDMA device, it is necessary to create an RDMA link, and the problem of slow RDMA connection establishment will be faced, especially when multiple RDMA links need to be created. The problem of slow RDMA connection establishment will be more prominent. To this end, in an embodiment of the present application, a virtual link is abstracted on the RDMA link, allowing multiple virtual connections to be created in one RDMA link between the client and the server, and multiple virtual links share the resources of one RDMA link. The upper-layer applications on both sides perform multi-channel data transmission through multiple virtual links carried on the same RDMA link, which can solve the problem of multiple communication links required between the applications at both ends, and reduce the number of RDMA links because the same RDMA link can carry multiple virtual links at the same time, which avoids the problem of slow RDMA connection establishment to a certain extent, especially when the number of links required by the applications at both ends is large, and the overall connection establishment speed can be significantly improved.
[0033] In the embodiment of the present application, the virtual link is an abstract communication link on top of the RDMA link, which is a simulation of the physical link. Although multiple virtual links can share the resources of the same RDMA link, the data in different virtual links can be distinguished and isolated from each other. The virtual links will be slightly different depending on the network protocols relied on by the upper-layer applications to be developed, mainly because the physical links simulated by the virtual connections are different. The following is an exemplary description of two application scenarios.
[0034] In some application scenarios, the upper layer application is developed based on the RDMA protocol. In this application scenario, according to the traditional solution, when data is transmitted between the client and the upper layer application on the server side, an RDMA link needs to be created between the client and the server, which faces the problem of slow RDMA link establishment, especially when multi-process communication is required between the upper layer applications on both sides, which means that multiple RDMA links need to be created between the client and the server. In this case, the problem of slow RDMA connection establishment will be more prominent. In the embodiment of the present application, Figure 1b The internal software architecture of the client or server shown in the figure includes a connection establishment interface (such as an RDMA connection establishment interface), a virtual link layer, and an RDMA link layer provided for upper-layer applications. The connection establishment interface (such as an RDMA connection establishment interface) is used by upper-layer applications developed based on the RDMA protocol to call to initiate a connection establishment request, the RDMA link layer is used to create an RDMA link, and the virtual link layer is used to create a virtual link on the RDMA link. Figure 1b The software architecture shown in the figure abstracts virtual links on top of RDMA links, simulates RDMA links through virtual links, allows one RDMA link to bind multiple virtual connections, and multiple virtual links share the resources of one RDMA link. Multiple virtual links carried on the same RDMA link are used to transmit multiple data between upper-layer applications on both sides, which can not only meet the multi-process communication requirements between upper-layer applications on both sides, but also reduce the number of RDMA links actually created, thus avoiding the problem of slow RDMA connection establishment to a certain extent. In this application scenario, virtual links are simulations of RDMA links, which are used to replace RDMA links to play the role of RDMA links.
[0035] In other application scenarios, the upper layer application is developed based on the TCP / IP protocol. In this application scenario, a TCP link needs to be established between the upper layer applications on both sides. However, in order to allow the upper layer applications to enjoy the benefits of RDMA's fast data transmission speed, the RDMA link and the TCP link are usually replaced 1:1, that is, the RDMA link is used as a TCP link. This also faces the problem of slow RDMA link establishment, especially when multi-process communication is required between the upper layer applications on both sides, which means that multiple RDMA links need to be created between the client and the server to replace multiple TCP links. In this case, the problem of slow RDMA connection establishment will be more prominent. In the embodiment of the present application, if Figure 1c The internal software architecture of the client or server shown in the figure includes a connection interface (such as a socket interface), a virtual link layer, and an RDMA link layer provided for upper-layer applications. The connection interface (such as a socket interface) is used by upper-layer applications developed based on the TCP / IP protocol to call to initiate a connection request, the RDMA link layer is used to create an RDMA link, and the virtual link layer is used to create a virtual link on the RDMA link. Figure 1c The software architecture shown in the figure abstracts virtual links on top of RDMA links, simulates TCP links through virtual links, allows one RDMA link to bind multiple virtual connections, and multiple virtual links share the resources of one RDMA link. Multiple virtual links carried on the same RDMA link are used to transmit multiple data between upper-layer applications on both sides, which can not only meet the multi-process communication requirements between upper-layer applications on both sides, but also reduce the number of created RDMA links, thus avoiding the problem of slow RDMA connection establishment to a certain extent. In this application scenario, virtual links are simulations of TCP links, which are used to replace TCP links to play the role of TCP links.
[0036] like Figure 1b and Figure 1cAs shown, there are multiple upper-layer applications running on the client or server side, and application 1-application N is used as an example for illustration, where N is a positive integer ≥ 2. The client or server can create an RDMA link for each upper-layer application, and create multiple virtual links required by the upper-layer application on the created RDMA link; the RDMA links used by different upper-layer applications are independent. In this embodiment, when any upper-layer application on the client side needs to communicate with any upper-layer application on the server side, the client and the server can cooperate with each other to create a virtual link for the upper-layer applications on both sides, so that the upper-layer applications on both sides can transmit data through the RDMA link based on the created virtual link. It should be noted that for any pair of upper-layer applications with communication requirements at both ends, the process of creating a communication link for them by the client and the server is the same or similar. Therefore, in the following embodiments, taking the first application on the client side needing to communicate with the second application on the server side as an example, the process of creating a virtual link between the client and the server for the first application and the second application is described. The first application can be any upper-layer application on the client, and the second application can be any upper-layer application on the server.
[0037] The following, in conjunction with the accompanying drawings, describes in detail the technical solution of the embodiment of the present application from the process of establishing or disconnecting the interaction between the client and the server.
[0038] Figure 2a The following is a schematic diagram of the interactive process of an RDMA-based connection establishment method provided in an embodiment of the present application. Figure 2a As shown, the method includes:
[0039] 21a. The client requests the server to create an RDMA link.
[0040] 22a. The server and the client interact to complete the creation of the RDMA link;
[0041] 23a. The client requests the server to create a virtual link on the created RDMA link.
[0042] 24a. The server and the client interact to complete the creation of the virtual link on the created RDMA link;
[0043] 25a. The client again requests the server to create another virtual link on the created RDMA link.
[0044] 26a. The server and the client interact again to complete the creation of another virtual link on the created RDMA link.
[0045] In this embodiment, when the first application needs to communicate with the second application, the first application can initiate a connection request to the second application. According to the first connection request initiated by the first application, the client determines that a virtual link needs to be created with the second application on the server. Therefore, an RDMA link is first established between the client and the server, and the RDMA link establishment process is relatively slow. It should be noted that the RDMA link establishment process is not limited to Figure 2a The two steps shown only indicate that the establishment of an RDMA link can be completed through interaction between the client and the server. The present application does not limit the creation process of the RDMA link. Each embodiment of the present application multiplexes the RDMA link by creating a virtual connection on the created RDMA link.
[0046] Regardless of the process used to create the RDMA link, based on the existence of the RDMA link between the client and the server, a virtual link can be created on the RDMA link according to the communication requirements between the first application and the second application, and multiple virtual links can be created on the RDMA link. Among them, the virtual link created on the RDMA link forms a binding relationship with the RDMA link, and the data of each virtual link will be transmitted through the RDMA link bound to it, and will be distinguished from the data of other virtual links bound to the RDMA link. Figure 2a In the illustrated embodiment, two virtual links are created on the same RDMA link as an example, but the invention is not limited thereto. Figure 2a The two steps shown only represent that the virtual link can be established through interaction between the client and the server.
[0047] exist Figure 2a In the illustrated embodiment, from the perspective of the client, an example of creating an RDMA link for the first application is used for illustration, but it is not limited to this. Multiple RDMA links can be created for the first application. When there are multiple RDMA links, the multiple RDMA links used by the first application can be managed by means of an RDMA link pool. The RDMA connection pools for different upper-layer applications can be distinguished and marked by the IP address and / or port number of the upper-layer application, which is not limited to this. Among them, each RDMA link can carry multiple virtual links and be reused by multiple virtual links.
[0048] In each embodiment of the present application, the maximum number of virtual links that each RDMA link can carry is not limited. The maximum number of virtual links that each RDMA link can support is limited by various resources (SQ, RQ) on the client and server, the number of existing RDMA links, the maximum number of RDMA links allowed to be established, etc. The maximum number of virtual connections that each RDMA link can support can be determined by negotiation between the client and the server. Optionally, the two can negotiate the maximum number of virtual links that the RDMA link can support during the creation of the RDMA link. Specifically, during the creation of the RDMA link, the client and the server can carry the number of virtual connections supported by each other in the custom field of the relevant interactive message to complete the negotiation of the maximum number of virtual links. The detailed process can be found in the subsequent embodiments, which will not be described in detail here. The maximum number of virtual links supported by different RDMA links can be the same or different. For example, the maximum number of virtual links supported by an RDMA link with an earlier creation time can be greater than the maximum number of virtual links supported by an RDMA link with a later creation time. Of course, the maximum number of virtual links supported by an RDMA link with an earlier creation time can also be less than the maximum number of virtual links supported by an RDMA link with a later creation time.
[0049] Compared with the creation of RDMA links, the creation speed of virtual links is much faster. With the help of multiple virtual links to reuse RDMA links, when multiple communication links are required between the first application and the second application, the method of this embodiment can quickly create multiple virtual links on a small number of RDMA links, which can not only meet the multi-channel communication requirements between the applications at both ends, but also reduce the number of RDMA links, thus overcoming the problem of slow RDMA connection establishment speed to a certain extent.
[0050] It is explained here that since the creation of a virtual link depends on the RDMA link, when a virtual link needs to be created and there is no reusable RDMA link between the client and the server, it is necessary to create an RDMA link and then create a virtual link based on the RDMA link. The time consumption of this connection process is greater than the time consumption of directly creating an RDMA link. In order to further reduce the time consumption of connection establishment, another RDMA-based connection establishment method provided in the embodiment of the present application is as follows: Figure 2b As shown, the interactive process of the connection establishment method includes the following steps:
[0051] 21b. The client requests the server to create an RDMA link, and at the same time carries the information required to create the first virtual link;
[0052] 22b. The server interacts with the client to complete the creation of the RDMA link, and at the same time carries the information required to create the first virtual link, and completes the creation of the first virtual link;
[0053] 23b. The client requests the server to create another virtual link on the created RDMA link.
[0054] 24b. The server and the client interact to complete the creation of another virtual link on the created RDMA link.
[0055] In this embodiment, when the first application needs to communicate with the second application, the first application can initiate a connection request to the second application. Based on the first connection request initiated by the first application, the client determines that a virtual link needs to be created with the second application on the server. When a new virtual link needs to be created, but there is no reusable RDMA link between the client and the server, the information required to create the first virtual link can be included in the process of creating the RDMA link. That is, when the RDMA link is created, the creation of the first virtual link bound to the RDMA link is also completed. Figure 2a In the embodiment shown, the cost of creating an additional first virtual link can be omitted.
[0056] Further, as shown in step 23b and step 24b, when the RDMA link and the first virtual link are created, when it is necessary to create other virtual links on the RDMA link, the client can interact with the server to complete the creation of other virtual links on the created RDMA link. This process is the same as Figure 2a It should be noted that step 23b and step 24b are optional steps, and in actual applications, only one virtual link may be required between the first application and the second application.
[0057] As the communication needs between the first application and the second application disappear, the problem of closing the virtual link and the RDMA link (referred to as the disconnection problem) will arise. In an embodiment of the present application, when the virtual link is closed, the RDMA link bound to the virtual link will not be closed immediately, but the RDMA link will be closed only when certain conditions are met. Compared with the closing of the virtual link, there will be a certain delay in closing the RDMA link. In this way, before the RDMA link is closed, if the first application and the second application have new communication needs again, a new virtual link can be created directly on this RDMA link without creating an RDMA link first, which can further solve the problem of slow RDMA connection establishment. Among them, Figure 2c The flowchart of closing a virtual connection and an RDMA connection is shown, which includes the following steps:
[0058] 21c. The client and the server interact to complete the creation of the RDMA link;
[0059] 22c. The client and the server interact to complete the creation of the virtual link A1 on the created RDMA link.
[0060] 23c. After a period of time, the client and the server interact to close the virtual link A1, but the RDMA link is not closed at this time.
[0061] 24c. After a period of time, the client and the server interact to complete the creation of virtual link A2 on the created RDMA link;
[0062] 25c. After a period of time, the client and the server interact to close the virtual link A2, but the RDMA link is not closed at this time.
[0063] 26c. When the conditions for closing the RDMA link are met, the client and the server interact to complete the closing of the RDMA link.
[0064] In step 23c, the virtual link is closed, but the RDMA link is not closed. After a period of time, when a new virtual link A2 needs to be created, the new virtual link A2 can be directly created on the RDMA link that has not been closed, which is conducive to improving the creation speed of the virtual link A2.
[0065] There is no limitation on the conditions that need to be met to close an RDMA link, which can be divided into necessary conditions and optional conditions. The optional conditions can be flexibly set according to application requirements. The necessary conditions that need to be met to close an RDMA link include, but are not limited to: the RDMA link no longer carries any virtual links. The optional conditions that need to be met to close an RDMA link include, but are not limited to: for the first application or the second application, a specified number of RDMA links are required between the client and the server; or, a reusable RDMA link is required between the client and the server. A reusable RDMA link refers to an RDMA link that currently carries less virtual links than the maximum number of virtual links supported by the RDMA link.
[0066] In the above embodiment, the connection establishment scheme provided by the embodiment of the present application is briefly described through the interaction process between the client and the server. Below, still taking the communication between the first application and the second application as an example, the RDMA-based connection establishment process and the link closing process provided by the embodiment of the present application are further described in detail from the perspectives of the client and the server.
[0067] Figure 3a A flowchart of a method for establishing a connection based on RDMA provided in an embodiment of the present application is provided. The method is described from the perspective of a client, where a first application is running on the client side, such as Figure 3a As shown, the method includes:
[0068] 31. Receive a first connection establishment request initiated by a first application to a second application on a server side, where the first connection establishment request is any one of multiple connection establishment requests initiated by the first application to the second application.
[0069] 32. According to the first connection establishment request, obtain a first RDMA link between the client and the server that can be reused by the first application.
[0070] 33. Create a first virtual link corresponding to the first connection establishment request on the first RDMA link, so that the first application and the second application perform one-way data transmission through the first virtual link carried on the first RDMA link;
[0071] When multiple virtual links are created on the first RDMA link, the multiple virtual links share resources of the first RDMA link, so that the first application and the second application perform multi-channel data transmission through the multiple virtual links carried on the first RDMA link.
[0072] The method provided in this embodiment can be executed by the client. Optionally, the client can be a dynamic library implanted in the electronic device where the first application is located to execute the RDMA-based connection establishment method provided in this embodiment. The dynamic library can provide a connection establishment interface to the upper-layer application (such as the first application). The upper-layer application (such as the first application) initiates a connection establishment request by calling the connection establishment interface provided by the dynamic library. It should be noted that the connection establishment interface provided by the dynamic library is adapted to the network protocol used by the upper-layer application (such as the first application). For example, if the first application is developed using the TCP / IP protocol or the UDP / IP protocol, then Figure 1c As shown, the connection interface may be a socket interface, and accordingly, the first connection request is a socket connection request; if the first application is developed using the RDMA protocol, then Figure 1b As shown, the connection interface can be an RDMA connection interface, and accordingly, the first connection request is an RDMA connection request. The library function in the dynamic library is used to respond to the call of the connection interface, obtain the connection request initiated by the first application to the second application, and execute other steps to complete the creation of a virtual link on the RDMA link that can be reused by the first application. It should be noted that, in terms of implementation, in addition to the dynamic library implanted in the electronic device where the first application is located, the client can also be an API, plug-in, SDK, APP or client program that can implement the RDMA-based connection method provided in the embodiment of the present application. Of course, in addition to implementing it in software, a hardware module that can implement the RDMA-based connection method provided in the embodiment of the present application can also be added to the electronic device where the first application is located, and there is no limitation on this.
[0073] In this embodiment, when the first application needs to communicate with the second application, a connection request can be initiated by, but not limited to, calling a connection interface. In a high-concurrency scenario or a scenario where multi-process communication is required, the first application can initiate multiple connection requests to the second application to request the creation of multiple virtual links with the second application. For each connection request, the process of the client creating a virtual link for the first application is the same or similar. In this embodiment, the process of creating a virtual link is described by taking any connection request as an example, and any connection request is referred to as a first connection request.
[0074] When receiving a first connection establishment request initiated by the first application to the second application, a first RDMA link between the client and the server that can be reused by the first application is obtained. There may be multiple RDMA links between the client and the server, and these RDMA links may serve different upper-layer applications. It is necessary to select an RDMA link that can serve the first application; of course, there may not be an RDMA link between the client and the server that can serve the first application.
[0075] Based on the above, if Figure 3b As shown, a method for obtaining a first RDMA link between a client and a server that can be reused by a first application includes:
[0076] 321. According to the first connection establishment request, determine whether there is an RDMA link created for the first application between the client and the server; if the determination result is yes, that is, there is at least one RDMA link created for the first application between the client and the server, execute step 322; if not, that is, there is no RDMA link created for the first application between the client and the server, execute step 324;
[0077] 322. According to the number of virtual links currently carried by each RDMA link, identify whether there is a candidate RDMA link in at least one RDMA link whose number of virtual links currently carried is less than the maximum number of virtual links corresponding to each link; if the identification result is yes, that is, if there is a candidate RDMA link, execute step 323; if not, that is, if there is no candidate RDMA link, execute step 324;
[0078] 323. Select an RDMA link from the candidate RDMA links as the first RDMA link.
[0079] 324. Create a first RDMA link for the first application between the client and the server, and during the creation of the first RDMA link, negotiate a maximum number of virtual links that the first RDMA link can support, so that the first RDMA link can be reused.
[0080] The "RDMA link created for the first application" mentioned above refers to the RDMA link that has been created to provide data transmission services for the first application. For the first application, if there is an RDMA link that has been created between the client and the server and can serve the first application, the number of virtual links currently carried by each RDMA link is used to determine whether it contains a candidate RDMA link that can be reused by the first application. The candidate RDMA link refers to an RDMA link that currently carries less virtual links than its corresponding maximum number of virtual links; if the number of virtual links currently carried by an RDMA link has reached the maximum number of virtual links it supports, the RDMA link will no longer be able to carry virtual links and is already full, and cannot be reused by new virtual links.
[0081] The candidate RDMA link may be one or more. When there is one candidate RDMA link, the candidate RDMA link is directly used as the first RDMA link; when there are multiple candidate RDMA links, one RDMA link may be selected from the multiple candidate RDMA links as the first RDMA link. The selection method may be, but is not limited to, the following:
[0082] An RDMA link may be randomly selected from multiple candidate RDMA links as the first RDMA link;
[0083] An RDMA link with the smallest number of virtual links currently carried may be selected from multiple candidate RDMA links as the first RDMA link;
[0084] An RDMA link that currently carries the largest number of virtual links may be selected from multiple candidate RDMA links as the first RDMA link;
[0085] An RDMA link with the largest resource amount (SQ, RQ) may be selected from multiple candidate RDMA links as the first RDMA link;
[0086] An RDMA link that supports the largest maximum number of virtual links may be selected from multiple candidate RDMA links as the first RDMA link.
[0087] If there is no created RDMA link between the client and the server that can serve the first application, or there is an created RDMA link between the client and the server that can serve the first application but there is no candidate RDMA link that can be reused by the first application, for example, these created RDMA links are all fully loaded, then it is necessary to create a new RDMA link for the first application between the client and the server, and give the new RDMA link reusability, and use the new reusable RDMA link as the first RDMA link. The process of giving the new RDMA link reusability is the process of negotiating the maximum number of virtual links supported by the RDMA link during the process of creating the RDMA link.
[0088] In an optional embodiment, the process of creating the first RDMA link includes: the client initiates an RDMA connection request (Request) message (abbreviated as REQ message), indicating that an RDMA link needs to be created. The message carries connection parameters, such as the QPN (Query Pair Number) of the QP (Queue Pair) to which this end is to connect, the starting PSN (Packet Sequence Number), the upper limit of the number of retransmissions, etc. QP is a combination of a sending work queue and a receiving work queue. The two queues are called SQ (Send Queue) and RQ (Receive Queue), respectively, and QPN is the unique number of QP. The starting PSN is the starting number value used to detect lost or duplicated data packets. In addition, the message can also carry some custom fields to meet the user's customized needs. In an embodiment of the present application, the custom field may include the first virtual connection number, which refers to the number of virtual links that can be carried by creating an RDMA link from the client side. The server is in a listening state before the client initiates a REQ message. When it listens to the REQ message, the CM layer will verify and record the connection parameters. Optionally, the information of the custom field can be sent to the user for verification. After the verification is passed, the server will send an RDMA connection reply (Reply) message (abbreviated as REP message) to indicate that it accepts the previous connection request, and carry its own connection parameters in the message - including QPN, starting PSN, etc. The REP message can also carry custom fields, such as the second virtual link number, which refers to the number of virtual links that can be carried by creating an RDMA link from the server side. After receiving the REP message, the client will verify and record the content, and then send a Ready To Use (RTU) message to indicate that it agrees with the connection parameters on the server side. At this point, the RDMA link between the client and the server is established. After that, the QP agreed by both parties can be used for data exchange.
[0089] In the above RDMA link creation process, for the client or the server, the maximum number of virtual links that the first RDMA link can support will be determined according to the first virtual link number and the second virtual link number. Among them, the client and the server will pre-agree on the method of determining the maximum number of virtual links, and both ends ensure the same maximum number of virtual links determined for the first RDMA link according to the same determination method. In an optional manner, the number of links with a smaller number of the first virtual link number and the second virtual link number can be selected as the maximum number of virtual links that the first RDMA link can support; in another optional manner, the number of links with a larger number of the first virtual link number and the second virtual link number can also be selected as the maximum number of virtual links that the first RDMA link can support; in another optional manner, the mean of the first virtual link number and the second virtual link number can be calculated, and the mean is used as the maximum number of virtual links that the first RDMA link can support. Of course, in addition to using the mean calculation, other numerical calculation methods can also be used, and the result of the numerical calculation of the first virtual link number and the second virtual link number is used as the maximum number of virtual links that the first RDMA link can support.
[0090] After determining the maximum number of virtual links that the first RDMA link can support, the client can maintain available channel identifiers for the first RDMA link based on the maximum number of virtual links, and the maximum number of virtual links is used to limit the number of channel identifiers used by the first RDMA link. Each channel identifier is used to identify a virtual link carried on the first RDMA link. The channel identifier has two states, namely, an idle state and a used state. The idle state means that the channel identifier has not been assigned to a virtual link for use, and the used state means that the channel identifier is assigned to a certain created virtual link for use.
[0091] It should be noted that the above describes the process of creating the first RDMA link, but is not limited thereto. The process of creating any RDMA link may refer to the above embodiment, which will not be described in detail here.
[0092] After obtaining the first RDMA link that can be reused by the first application, a first virtual link corresponding to the first connection request can be created on the first RDMA link, that is, a virtual link is created between the first application and the second application, and the virtual link is carried on the first RDMA link. In this way, the first application and the second application can perform one-way data transmission through the first virtual link carried on the first RDMA link. The process of the first application and the second application performing data transmission through the virtual link carried on the first RDMA link can be referred to the subsequent embodiments, which will not be described in detail here.
[0093] The process of creating a first virtual link on the first RDMA link includes: selecting a first channel identifier in an idle state from a plurality of channel identifiers supported by the first RDMA link, wherein each channel identifier is used to identify a virtual link created on the first RDMA link; based on the first RDMA link, negotiating between the client and the server for the first channel identifier; if the negotiation is successful, creating a first virtual link object corresponding to the first connection request, and establishing a corresponding relationship between the first virtual link object and the first channel identifier to obtain the first virtual link. The first virtual link object corresponds to the first connection request and is a bridge between the first application and the first virtual link, and is used to associate the first application with the first virtual link, so that the first application knows which data is transmitted through which virtual link. Further, a corresponding relationship between the first virtual link object and the first channel identifier is established. Since the first channel identifier comes from the first RDMA link, and at the same time, the first channel identifier is used to identify the first virtual link, the corresponding relationship can bind the first virtual link to the first RDMA link through the first virtual link object. Optionally, the first virtual link object also includes some data processing actions corresponding to the first connection request, which are used to process data from the second application.
[0094] It should be noted that in the above method, by establishing a first virtual link object, an association relationship between the first channel identifier, the first virtual link, and the first RDMA link is established through the first virtual link object, thereby completing the creation of the first virtual link, but it is not limited to this. Any connection establishment method that can associate the first channel identifier, the first virtual link, and the first RDMA link is applicable to the embodiment of the present application. For example, a unique virtual link identifier can be assigned to each virtual link, and each virtual link identifier is associated with a corresponding connection establishment request. For the first connection establishment request, a correspondence relationship between the first channel identifier, the virtual link identifier of the first virtual link, and the first RDMA link can be directly established, thereby completing the creation of the first virtual link.
[0095] Among them, the negotiation between the client and the server for the first channel identifier is mainly a process in which the client informs the server of the first channel identifier used by the first virtual link, so that the server creates the first virtual link on its own side according to the first channel identifier. Optionally, during the negotiation process, the server may also perform availability verification on the first channel identifier. The availability verification mainly verifies whether the first channel identifier can be allocated to the first virtual link for use according to the set verification strategy or conditions. If it cannot be allocated to the first virtual link for use, it indicates that the availability verification has not passed. If it can be allocated to the first virtual link for use, it indicates that the availability verification has passed.
[0096] In an optional embodiment, the server maintains each virtual link created on the first RDMA link and the channel identifier occupied by each virtual link. Based on this, an optional method of availability verification includes: the server determines whether the first channel identifier has been occupied by an existing virtual link. If it has been occupied, it cannot be allocated to the first virtual link for use, that is, it fails the availability verification; if it has not been occupied, it can be allocated to the first virtual link for use, that is, it passes the availability verification.
[0097] Based on the above, an implementation method for negotiating the first channel identifier between the client and the server includes: based on the first RDMA link, sending the first channel identifier to the server, and upon receiving a response message returned by the server confirming receipt of the first channel identifier, determining that the negotiation for the first channel identifier is successful. Alternatively, another implementation method for negotiating the first channel identifier between the client and the server includes: based on the first RDMA link, sending the first channel identifier to the server for the server to verify the availability of the first channel identifier; upon receiving a response message returned by the server indicating that the first channel identifier has passed the availability verification, determining that the negotiation for the first channel identifier is successful. In the latter implementation method, in addition to indicating that the first channel identifier has passed the availability verification, the response message also indicates that the server confirms receipt of the first channel identifier.
[0098] It is explained here that if the first RDMA link is selected from the created RDMA links, the above-mentioned process of negotiating the first channel identifier between the client and the server will be independent of the process of creating the first RDMA link, and the first channel identifier can be negotiated between the client and the server through a separate interactive process after the first RDMA link is selected. If the first RDMA link is created in real time when there is no created RDMA link or no candidate RDMA link that can be reused by the first application, the above-mentioned process of negotiating the first channel identifier between the client and the server can be completed synchronously during the process of creating the first RDMA link.
[0099] Specifically, taking the process of creating the first RDMA link mentioned above as an example, during the process of creating the first RDMA link, the client selects the first channel identifier and adds the first channel identifier to the RDMA connection request message and sends it to the server, so that the server can verify the availability of the first channel identifier; the server can carry the information of whether the first channel identifier has passed the availability verification in the RDMA connection response message and return it to the client; if the information that the first channel identifier has passed the availability verification is obtained from the RDMA connection response message returned by the server, it is determined that the negotiation for the first channel identifier is successful. Of course, after the client and the server have negotiated the maximum number of virtual links that can be supported by the first RDMA link through the first virtual link number carried in the RDMA connection request message and the second virtual link number carried in the RDMA connection response message, the client adds the first channel identifier to the RTU message and sends it to the server, so that the server can verify the availability of the first channel identifier, and receive the response message returned by the server for the RTU message, when the information that the first channel identifier has passed the availability verification is obtained from the response message returned by the server for the RTU message, it is determined that the negotiation for the first channel identifier is successful.
[0100] Alternatively, in an optional method in which the availability check of the first channel identifier is not performed, during the first RDMA link creation process, the client selects the first channel identifier and adds the first channel identifier to the RDMA connection establishment request message and sends it to the server. When the server receives the RDMA connection establishment response message returned by the server, it indicates that the server has received the first channel identifier, and therefore it can be determined that the negotiation for the first channel identifier is successful.
[0101] If the first channel identifier negotiation is successful, a first virtual link corresponding to the first connection establishment request may be created according to the first channel identifier. The creation process of the first virtual link can be found in the above text and will not be described in detail here.
[0102] As the number of connection establishment requests initiated by the first application to the second application increases, multiple virtual links can be created on the first RDMA link, and the multiple virtual links share the resources of the first RDMA link, such as SQ, RQ, etc. For the first application and the second application, multiple virtual connections carried on the first RDMA link can be used to perform multi-channel data transmission to achieve parallel data transmission or multi-process data transmission. For the first application and the second application, the process of data transmission through any virtual link is the same or similar. The following is an explanation of the process of data transmission between the first application and the second application through the first virtual link carried on the first RDMA link.
[0103] The data transmission process between the first application and the second application through the first virtual link carried on the first RDMA link includes: the process of the first application sending the first data to the second application through the first virtual link carried on the first RDMA link, and the process of the first application receiving the second data sent by the second application through the first virtual link carried on the first RDMA link. In the process of the first application sending the first data to the second application through the first virtual link carried on the first RDMA link, according to the correspondence between the first virtual link object and the first channel identifier, the first channel identifier is added to the first data; the first data with the first channel identifier added is sent to the server through the first RDMA link, so that the server sends the first data to the second application according to the first channel identifier. In the case where the first application receives the second data sent by the second application through the first virtual connection carried on the first RDMA link, the second data including the first channel identifier sent by the server through the first RDMA link is received; according to the first channel identifier contained in the second data and the correspondence between the first virtual link object and the first channel identifier, the first virtual link object is determined, the second data is processed according to the data processing action in the first virtual link object, and the processed second data is sent to the first application.
[0104] Specifically, when the first application needs to send the first data to the second application through the first virtual link carried on the first RDMA link, the first application can submit a data sending task to the client through an interface call, and the data sending task includes the first data. The client adds the first channel identifier to the first data according to the correspondence between the first virtual link object and the first channel identifier; writes the first data after adding the first channel identifier into the memory cache as the data to be sent, and writes WQE in the sending queue SQ, the WQE contains a pointer to the data to be sent (i.e., the first data after adding the first channel identifier), notifies the network card to send the first data after adding the first channel identifier to the server through the first RDMA link, so that the server sends the first data to the second application according to the first channel identifier; after completing the data sending task, writes CQE to the completion queue CQ to notify the first application that the data sending is completed. Optionally, the client can provide an interface for data transmission to the first application, and the first application provides the first data to the client by calling the interface for data transmission.
[0105] When the first application receives the second data sent by the second application through the first virtual link carried on the first RDMA link, the first application can submit a data receiving task to the client through an interface call, the data receiving task includes address information of a memory cache area for storing the second data, the client writes a WQE in the receiving queue RQ, the WQE includes information about the memory cache area for storing the second data, the network card receives the second data including the first channel identifier sent by the server through the first RDMA link, and writes it into the memory cache area pointed to by the WQE; after completing the data receiving task, the CQE is written to the completion queue CQ, the second data including the first channel identifier is read from the memory cache area pointed to by the WQE, the second data is parsed to obtain the first channel identifier, the first virtual link object is determined according to the first channel identifier included in the second data, and the correspondence between the first virtual link object and the first channel identifier, the second data is processed according to the data processing action in the first virtual link object, and the processed second data is reported to the first application.
[0106] Further, in an optional embodiment, during the negotiation between the client and the server for the first channel identifier, the first data that the first application needs to send to the second application through the first virtual link can also be sent to the server, so that the server sends it to the second application. Taking the first application as the client of an instant messaging application as an example, and the second application is the server of an instant messaging application, the first data can be the first session message sent by the client and the server to the server when the connection is established, or a new session creation request message, or a message shared externally, etc. In this way, there is no need to wait for the first virtual link to be created, and the first data can be sent during the creation of the first virtual link, which is conducive to improving the efficiency of data transmission. Further, if the first channel identifier is negotiated during the creation of the RDMA link, the first data that the first application needs to send to the second application through the first virtual link does not even need to wait for the first RDMA link to be created, and can be sent during the synchronous creation of the first RDMA link and the first virtual link, which is conducive to improving the efficiency of data transmission.
[0107] As the data transmission process between the first application and the second application ends, the first virtual link may need to be closed. In this embodiment, when the client and the server perceive that the first virtual link needs to be closed, either party may actively initiate a request to close the first virtual link.
[0108] The client actively initiates a virtual link closing operation: when it is necessary to close the first virtual connection, the client can send a first link closing request message to the server to request to close the first virtual link; after receiving the first link closing request message, the server returns a first link closing response message to the client on the one hand, and performs a resource release operation on the first virtual link on the other hand to set the first channel identifier corresponding to the first virtual link to an idle state; when the client receives the first link closing response message returned by the server, it believes that the server already knows that the first virtual link is to be closed, so it performs a resource release operation on the first virtual link to set the first channel identifier corresponding to the first virtual link to an idle state.
[0109] The server actively initiates a virtual link closing operation: when it is necessary to close the first virtual connection, the server can send a second link closing request message to the client to request the closing of the first virtual link; after receiving the second link closing request message, the client returns a second link closing response message to the server on the one hand, and performs a resource release operation on the first virtual link on the other hand to set the first channel identifier corresponding to the first virtual link to an idle state; when the server receives the first link closing response message returned by the server, it believes that the client already knows that the first virtual link is to be closed, so it performs a resource release operation on the first virtual link to set the first channel identifier corresponding to the first virtual link to an idle state.
[0110] The resource release operation performed on the first virtual link mainly refers to setting the first channel identifier corresponding to the first virtual link to an idle state to release the channel identifier resource, but is not limited to the channel identifier resource. All objects related to the first virtual link will be released.
[0111] In an embodiment of the present application, when the first virtual link is closed, the first RDMA link will not be closed immediately; optionally, it can be determined whether the first virtual link is the last virtual link carried by the first RDMA link. If so, after the first virtual link is closed, the first RDMA link is in an idle state. At this time, after the resource release is completed for the first virtual link, a set time can be waited, and after the set time is over, the first RDMA link is closed. That is to say, after the last virtual link carried by the first RDMA link completes the resource release, a set time is waited; after the set time is over, the first RDMA link is closed. Among them, the process of closing the first RDMA link is mainly a process of releasing various resources occupied by the first RDMA link, such as SQ, RQ, etc.
[0112] Further optionally, in order to ensure that a virtual link is created between the first application and the second application in a timely manner, it may be required that a specified number of RDMA links exist between the client and the server, and the specified number may be 1, 2, or 3 RDMA links, etc., without limitation. Based on this, before closing the first RDMA link, it is necessary to determine whether there are a specified number of RDMA links in the RDMA link pool corresponding to the first application in addition to the first RDMA link; if so, the first RDMA link is closed; if not, the first RDMA link is prohibited from being closed.
[0113] Alternatively, in order to ensure that a virtual link is created for the first application and the second application in a timely manner, it may be required that the client and the server can currently carry an RDMA link with a number of virtual links less than the corresponding maximum number of virtual links, so that the first application can reuse the existing RDMA link at any time when a virtual link is needed. Based on this, before closing the first RDMA link, it is required to determine whether there is an RDMA link in the RDMA link pool corresponding to the first application with a number of virtual links less than the corresponding maximum number of virtual links in addition to the first RDMA link; if so, the first RDMA link relationship is closed; if not, the first RDMA link is prohibited from being closed.
[0114] Here, the above description is based on the closing process of the first virtual link and the first RDMA link as an example, and the closing process of other virtual links and RDMA links is the same or similar, and will not be repeated. In addition, in the above link closing process, some judgment conditions about the first RDMA link are examples and are not limited to this.
[0115] Figure 4 A flowchart of another RDMA-based connection establishment method provided in an embodiment of the present application. This method is described from the perspective of the server, such as Figure 4 As shown, the method includes:
[0116] 41. Receive a first channel identifier sent by the client through a first RDMA link between the client and the server, where the first channel identifier is a channel identifier in an idle state selected from a plurality of channel identifiers supported by the first RDMA link, and the first RDMA link is an RDMA link between the client and the server that can be reused by a first application on the client side;
[0117] 42. Return a response message to the client based on the first RDMA link, where the response message at least includes a message indicating that the first channel identifier has been received, so that the client can create a first virtual link corresponding to the first channel identifier on the first RDMA link, and the first virtual link is used for the first application to transmit data to the second application on the server side through the first RDMA link.
[0118] In an optional embodiment, the method further includes: creating a first virtual link corresponding to the first channel identifier on the first RDMA link. Further, creating the first virtual link corresponding to the first channel identifier on the first RDMA link includes: creating a first virtual link object corresponding to the first connection establishment request, and establishing a corresponding relationship between the first virtual link object and the first channel identifier to obtain the first virtual link.
[0119] In an optional embodiment, returning a response message to the client based on the first RDMA link includes: performing an availability check on the first channel identifier, and if the first channel identifier passes the availability check, returning a response message indicating that the first channel identifier passes the availability check to the client based on the first RDMA link.
[0120] In an optional embodiment, the method also includes: during the first RDMA link creation process, receiving an RDMA connection request message sent by the client, the RDMA connection request message includes at least the first virtual link number supported by the client; returning an RDMA connection response message to the client, the RDMA connection response message includes at least the second virtual link number supported by the server; and determining the maximum number of virtual links that the first RDMA link can support based on the first virtual link number and the second virtual link number.
[0121] In an optional embodiment, the method also includes: when it is necessary to close the first virtual connection, sending a second link close request message to the client to request closing the first virtual link; when receiving the second link close response message returned by the client, performing a resource release operation on the first virtual link; or, when receiving the first link close request message sent by the client, returning the first link close response message to the client and performing a resource release operation on the first virtual link.
[0122] Further optionally, the method further includes: if the last virtual link carried by the first RDMA link completes resource release, waiting for a set time; after the set time expires, closing the first RDMA link.
[0123] Further optionally, before closing the first RDMA link, the method further includes: determining whether, in addition to the first RDMA link, there are a specified number of RDMA links in the RDMA link pool corresponding to the first application; if so, closing the first RDMA link; or, determining whether, in addition to the first RDMA link, there are RDMA links in the RDMA link pool corresponding to the first application whose number of virtual links currently carried is less than the corresponding maximum number of virtual links; if so, closing the first RDMA link relationship.
[0124] For detailed description of the above method embodiment, please refer to the aforementioned embodiment, which will not be repeated here.
[0125] It should be noted that in some of the processes described in the above embodiments and the accompanying drawings, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel, and the sequence numbers of the operations, such as 41, 42, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.
[0126] Figure 5 The present invention provides a schematic diagram of a structure of an RDMA-based connection device. The device can be applied to the client to complete the connection function based on the RDMA link. Figure 5 As shown, the device comprises:
[0127] A receiving module 51, configured to receive a first connection establishment request initiated by a first application on a client side to a second application on a server side, wherein the first connection establishment request is any one of a plurality of connection establishment requests initiated by the first application to the second application;
[0128] An acquisition module 52 is used to acquire, according to the first connection establishment request, a first RDMA link between the client and the server that can be reused by the first application;
[0129] A connection establishment module 53, configured to create a first virtual link corresponding to the first connection establishment request on the first RDMA link, so that the first application and the second application perform one-way data transmission through the first virtual connection carried on the first RDMA link;
[0130] When multiple virtual links are created on the first RDMA link, the multiple virtual links share resources of the first RDMA link, so that the first application and the second application perform multi-channel data transmission through the multiple virtual connections carried on the first RDMA link.
[0131] In an optional embodiment, the connection establishment module 53 is specifically used to: select a first channel identifier in an idle state from multiple channel identifiers supported by the first RDMA link, wherein each channel identifier is used to identify a virtual link created on the first RDMA link; based on the first RDMA link, negotiate the first channel identifier between the client and the server; if the negotiation is successful, create a first virtual link object corresponding to the first connection establishment request, and establish a corresponding relationship between the first virtual link object and the first channel identifier to obtain the first virtual link.
[0132] In an optional embodiment, when the connection establishment module 53 negotiates the first channel identifier between the client and the server, it is specifically used to: send the first channel identifier to the server based on the first RDMA link, so that the server can verify the availability of the first channel identifier; when receiving a response message returned by the server indicating that the first channel identifier has passed the availability verification, determine that the negotiation for the first channel identifier is successful; or, based on the first RDMA link, send the first channel identifier to the server, and when receiving a response message returned by the server confirming that the first channel identifier has been received, determine that the negotiation for the first channel identifier is successful.
[0133] In an optional embodiment, the acquisition module 52 is specifically used to: determine whether there is an RDMA link created for the first application between the client and the server based on the first connection establishment request; in the case that there is at least one RDMA link created for the first application between the client and the server, identify whether there is a candidate RDMA link in the at least one RDMA link whose number of virtual links currently carried is less than the corresponding maximum number of virtual links based on the number of virtual links currently carried by each RDMA link; if there is a candidate RDMA link, select an RDMA link from the candidate RDMA links as the first RDMA link.
[0134] In an optional embodiment, the acquisition module 52 is also used to: when there is no RDMA link created for the first application between the client and the server or there is no candidate RDMA link, create a first RDMA link for the first application between the client and the server, and during the creation of the first RDMA link, negotiate the maximum number of virtual links that the first RDMA link can support so that the first RDMA link can be reused; wherein the maximum number of virtual links is used to limit the number of channel identifiers used by the first RDMA link.
[0135] Based on the above, when the acquisition module 52 negotiates the maximum number of virtual links that the first RDMA link can support, it is specifically used to: send an RDMA connection request message to the server, the RDMA connection request message at least includes the first number of virtual links supported by the client; receive an RDMA connection response message returned by the server for the RDMA connection request message, the RDMA connection response message at least includes the second number of virtual links supported by the server; determine the maximum number of virtual links that the first RDMA link can support based on the first number of virtual links and the second number of virtual links.
[0136] In an optional embodiment, when the connection module 53 negotiates the first channel identifier between the client and the server, it is specifically used to: during the first RDMA link creation process, add the first channel identifier to the RDMA connection request message and send it to the server, so that the server can verify the availability of the first channel identifier; if information that the first channel identifier passes the availability verification is obtained from the RDMA connection response message returned by the server, it is determined that the negotiation for the first channel identifier is successful; or, during the first RDMA link creation process, add the first channel identifier to the RDMA connection request message and send it to the server, and when the RDMA connection response message returned by the server is received, it is determined that the negotiation for the first channel identifier is successful.
[0137] In an optional embodiment, the connection establishment module 53 is also used to: during the negotiation between the client and the server regarding the first channel identifier based on the first RDMA link, send the first data that the first application needs to send to the second application through the first virtual link to the server, so that the server sends it to the second application.
[0138] In an optional embodiment, the connection establishment module 53 is also used for: when the first application sends the first data to the second application through the first virtual link carried on the first RDMA link, adding the first channel identifier to the first data according to the correspondence between the first virtual link object and the first channel identifier; sending the first data after adding the first channel identifier to the server through the first RDMA link, so that the server sends the first data to the second application according to the first channel identifier; and / or, when the first application receives the second data sent by the second application through the first virtual connection carried on the first RDMA link, receiving the second data containing the first channel identifier sent by the server through the first RDMA link; determining the first virtual link object according to the correspondence between the first virtual link object and the first channel identifier, and processing the second data according to the data processing action in the first virtual link object.
[0139] In an alternative embodiment, if Figure 5 As shown, the device also includes: a disconnection module 54. The disconnection module 54 is used to send a first link closing request message to the server to request closing the first virtual link when the first virtual connection needs to be closed; when receiving a first link closing response message returned by the server, perform a resource release operation on the first virtual link to set the first channel identifier corresponding to the first virtual link to an idle state; or, when receiving a second link closing request message sent by the server, return a second link closing response message to the server, and perform a resource release operation on the first virtual link to set the first channel identifier corresponding to the first virtual link to an idle state.
[0140] Further optionally, the disconnection module 54 is further configured to: wait for a set time after the last virtual link carried by the first RDMA link completes resource release; and close the first RDMA link after the set time expires.
[0141] Further optionally, the disconnection module 54 is also used to: before closing the first RDMA link, determine whether there are a specified number of RDMA links in the RDMA link pool corresponding to the first application in addition to the first RDMA link; if so, close the first RDMA link; or, determine whether there are RDMA links in the RDMA link pool corresponding to the first application in addition to the first RDMA link, whose number of virtual links currently carried is less than the corresponding maximum number of virtual links; if so, disconnect the first RDMA link relationship.
[0142] In an optional embodiment, the first application is an application developed based on the RDMA protocol, and the first connection request is an RDMA connection request; or, the first application is an application developed based on the TCP / IP protocol, and the first connection request is a socket connection request.
[0143] Figure 6 This is a schematic diagram of the structure of another RDMA-based connection device provided in an embodiment of the present application. The device can be applied to the server to implement the RDMA-based connection function. Figure 6 As shown, the device comprises:
[0144] A receiving module 61 is configured to receive a first channel identifier sent by a client through a first RDMA link between the client and the server, where the first channel identifier is a channel identifier in an idle state selected from a plurality of channel identifiers supported by the first RDMA link, and the first RDMA link is an RDMA link between the client and the server that can be reused by a first application on the client side;
[0145] The sending module 62 is used to return a response message to the client based on the first RDMA link, and the response message at least includes a message indicating that the first channel identifier is received, so that the client can create a first virtual link corresponding to the first channel identifier on the first RDMA link, and the first virtual link is used for the first application to transmit data to the second application on the server side through the first RDMA link.
[0146] Further, if Figure 6 As shown, the device also includes a connection module 63 and a disconnection module 64. The connection module 63 is used to create a first virtual link corresponding to the first channel identifier on the first RDMA link according to the first channel identifier. The connection module 63 is specifically used to: create a first virtual link object corresponding to the first connection request, and establish a corresponding relationship between the first virtual link object and the first channel identifier to obtain the first virtual link.
[0147] The disconnection module 64 is used to: when it is necessary to close the first virtual connection, send a second link closing request message to the client to request to close the first virtual link; when receiving the second link closing response message returned by the client, perform a resource release operation on the first virtual link; or, when receiving the first link closing request message sent by the client, return the first link closing response message to the client and perform a resource release operation on the first virtual link.
[0148] In an optional embodiment, when the sending module 62 returns a response message to the client based on the first RDMA link, it is specifically used to: perform an availability check on the first channel identifier, and when the first channel identifier passes the availability check, return a response message indicating that the first channel identifier passes the availability check to the client based on the first RDMA link.
[0149] In an optional embodiment, the receiving module 61 is also used to: receive an RDMA connection request message sent by the client during the first RDMA link creation process, and the RDMA connection request message includes at least the first virtual link number supported by the client. Correspondingly, the sending module 62 is also used to: return an RDMA connection response message to the client, and the RDMA connection response message includes at least the second virtual link number supported by the server. Correspondingly, the device also includes a determination module, which is used to determine the maximum number of virtual links that the first RDMA link can support based on the first virtual link number and the second virtual link number.
[0150] The functional modules in the above-mentioned device embodiments can be used to perform the corresponding operations in the above-mentioned method embodiments. For detailed functional descriptions, please refer to the above-mentioned method embodiments, which will not be repeated here.
[0151] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device can be implemented as the electronic device where the above-mentioned client is located, and a first application is also running on the electronic device, such as Figure 7 As shown, the electronic device includes: a memory 71, a processor 72 and an RDMA device 73.
[0152] The memory 71 is used to store computer programs and can be configured to store various other data to support operations on the electronic device. Examples of such data include instructions, messages, pictures, videos, etc. for any application or method operating on the electronic device.
[0153] The processor 72 is coupled to the memory 71 and is used to execute the computer program in the memory 71 to implement the functions of the above-mentioned client, specifically including: receiving a first connection establishment request initiated by the first application to the second application on the server side, the first connection establishment request being any one of multiple connection establishment requests initiated by the first application to the second application; obtaining a first RDMA link between the client and the server that can be reused by the first application according to the first connection establishment request; creating a first virtual link corresponding to the first connection establishment request on the first RDMA link, so that the first application and the second application perform one-way data transmission through the first virtual connection carried on the first RDMA link; wherein, when multiple virtual links are created on the first RDMA link, the multiple virtual links share resources of the first RDMA link, so that the first application and the second application perform multiple-way data transmission through the multiple virtual connections carried on the first RDMA link.
[0154] In an optional embodiment, when the processor 72 creates a first virtual link corresponding to the first connection establishment request on the first RDMA link, it is specifically used to: select a first channel identifier in an idle state from multiple channel identifiers supported by the first RDMA link, wherein each channel identifier is used to identify a virtual link created on the first RDMA link; based on the first RDMA link, negotiate the first channel identifier between the client and the server; if the negotiation is successful, create a first virtual link object corresponding to the first connection establishment request, and establish a corresponding relationship between the first virtual link object and the first channel identifier to obtain the first virtual link.
[0155] In an optional embodiment, when the processor 72 negotiates the first channel identifier between the client and the server, it is specifically configured to:
[0156] Based on the first RDMA link, the first channel identifier is sent to the server, so that the server can verify the availability of the first channel identifier; when a response message returned by the server indicating that the first channel identifier has passed the availability verification is received, it is determined that the negotiation for the first channel identifier is successful;
[0157] or
[0158] Based on the first RDMA link, the first channel identifier is sent to the server, and when a response message returned by the server confirming receipt of the first channel identifier is received, it is determined that the negotiation for the first channel identifier is successful.
[0159] In an optional embodiment, the processor 72 is specifically used to: determine whether there is an RDMA link created for the first application between the client and the server based on the first connection establishment request; in the case that there is at least one RDMA link created for the first application between the client and the server, identify whether there is a candidate RDMA link in the at least one RDMA link whose number of virtual links currently carried is less than the corresponding maximum number of virtual links based on the number of virtual links currently carried by each RDMA link; if there is a candidate RDMA link, select an RDMA link from the candidate RDMA links as the first RDMA link.
[0160] In an optional embodiment, the processor 72 is further used to: create a first RDMA link for the first application between the client and the server when there is no RDMA link created for the first application or no candidate RDMA link exists between the client and the server, and during the creation of the first RDMA link, negotiate the maximum number of virtual links that the first RDMA link can support so that the first RDMA link can be reused; wherein the maximum number of virtual links is used to limit the number of channel identifiers used by the first RDMA link.
[0161] Based on the above, when negotiating the maximum number of virtual links that the first RDMA link can support, the processor 72 is specifically used to: send an RDMA connection request message to the server, where the RDMA connection request message includes at least the first number of virtual links supported by the client; receive an RDMA connection response message returned by the server in response to the RDMA connection request message, where the RDMA connection response message includes at least the second number of virtual links supported by the server; and determine the maximum number of virtual links that the first RDMA link can support based on the first number of virtual links and the second number of virtual links.
[0162] In an optional embodiment, when the processor 72 negotiates the first channel identifier between the client and the server, it is specifically used to: during the first RDMA link creation process, add the first channel identifier to the RDMA connection request message and send it to the server, so that the server can verify the availability of the first channel identifier; if information that the first channel identifier passes the availability verification is obtained from the RDMA connection response message returned by the server, it is determined that the negotiation for the first channel identifier is successful; or, during the first RDMA link creation process, add the first channel identifier to the RDMA connection request message and send it to the server, and when the RDMA connection response message returned by the server is received, it is determined that the negotiation for the first channel identifier is successful.
[0163] In an optional embodiment, the processor 72 is also used to: during the negotiation between the client and the server regarding the first channel identifier based on the first RDMA link, send the first data that the first application needs to send to the second application through the first virtual link to the server, so that the server sends it to the second application.
[0164] In an optional embodiment, the processor 72 is further used for: when the first application sends the first data to the second application through the first virtual link carried on the first RDMA link, adding the first channel identifier to the first data according to the correspondence between the first virtual link object and the first channel identifier; sending the first data after adding the first channel identifier to the server through the first RDMA link, so that the server sends the first data to the second application according to the first channel identifier; and / or, when the first application receives the second data sent by the second application through the first virtual connection carried on the first RDMA link, receiving the second data including the first channel identifier sent by the server through the first RDMA link; determining the first virtual link object according to the correspondence between the first virtual link object and the first channel identifier, and processing the second data according to the data processing action in the first virtual link object.
[0165] In an optional embodiment, the processor 72 is also used to: when it is necessary to close the first virtual connection, send a first link close request message to the server to request to close the first virtual link; when receiving the first link close response message returned by the server, perform a resource release operation on the first virtual link to set the first channel identifier corresponding to the first virtual link to an idle state; or, when receiving a second link close request message sent by the server, return a second link close response message to the server, and perform a resource release operation on the first virtual link to set the first channel identifier corresponding to the first virtual link to an idle state.
[0166] Further optionally, the processor 72 is further configured to: wait for a set time after the last virtual link carried by the first RDMA link completes resource release; and close the first RDMA link after the set time expires.
[0167] Further optionally, the processor 72 is also used to: before closing the first RDMA link, determine whether there are a specified number of RDMA links in the RDMA link pool corresponding to the first application in addition to the first RDMA link; if so, close the first RDMA link; or, determine whether there are RDMA links in the RDMA link pool corresponding to the first application in addition to the first RDMA link, whose number of virtual links currently carried is less than the corresponding maximum number of virtual links; if so, close the first RDMA link relationship.
[0168] In an optional embodiment, the first application is an application developed based on the RDMA protocol, and the first connection request is an RDMA connection request; or, the first application is an application developed based on the TCP / IP protocol, and the first connection request is a socket connection request.
[0169] Further, if Figure 7 As shown, the electronic device also includes: a communication component 74, a display 75, a power component 76, an audio component 77 and other components. Figure 7 Only some components are shown schematically, which does not mean that the electronic device only includes Figure 7 In addition, Figure 7 The components shown in the dashed box may depend on the specific implementation form of the electronic device. When the electronic device is implemented as a terminal device such as a mobile phone, a laptop computer, or a tablet computer, the components in the dashed box may be included; when the electronic device is implemented as a server, a cloud server, a server cluster, or other server-side device, the components in the dashed box are usually not included.
[0170] In addition to the above electronic device, the embodiment of the present application also provides an electronic device, the electronic device and Figure 7 The electronic devices shown have the same or similar structures, so they are not shown in the figure again. Figure 7 The difference between the electronic devices shown is that the functions implemented by the processor executing the computer program stored in the memory are different. The electronic device of this embodiment can be used as the electronic device where the server in the above embodiment is located, and a second application is running on the electronic device, and its processor executes the computer program stored in the memory to implement the functions of the above server, specifically including: receiving a first channel identifier sent by the client through the first RDMA link between it and the server, the first channel identifier is a channel identifier in an idle state selected from multiple channel identifiers supported by the first RDMA link, and the first RDMA link is an RDMA link between the client and the server that can be reused by the first application on the client; based on the first RDMA link, a response message is returned to the client, and the response message at least includes a message indicating that the first channel identifier is received, so as to create a first virtual link corresponding to the first channel identifier on the first RDMA link, and the first virtual link is used for the first application to transmit data to the second application on the server through the first RDMA link.
[0171] In an optional embodiment, when the processor returns a response message to the client based on the first RDMA link, it is specifically used to: perform an availability check on the first channel identifier, and if the first channel identifier passes the availability check, return a response message indicating that the first channel identifier passes the availability check to the client based on the first RDMA link.
[0172] In an optional embodiment, the processor is also used to: during the first RDMA link creation process, receive an RDMA connection request message sent by the client, the RDMA connection request message includes at least the first virtual link number supported by the client; return an RDMA connection response message to the client, the RDMA connection response message includes at least the second virtual link number supported by the server; and determine the maximum number of virtual links that the first RDMA link can support based on the first virtual link number and the second virtual link number.
[0173] For detailed descriptions of the functions executed by the processors in the above-mentioned electronic devices, please refer to the aforementioned method embodiments, which will not be repeated here.
[0174] Accordingly, an embodiment of the present application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor is enabled to implement each step in any of the above method embodiments.
[0175] The memory in the above embodiments can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0176] The communication component in the above-mentioned embodiment is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0177] The display in the above-mentioned embodiment includes a screen, and the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
[0178] The power supply assembly in the above embodiments provides power to various components of the device where the power supply assembly is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device where the power supply assembly is located.
[0179] The audio component in the above embodiments may be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal may be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting an audio signal.
[0180] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0181] The present application is described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, and the combination of the process and / or box in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and / or one box or multiple boxes in the block diagram.
[0182] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0183] These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0184] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0185] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0186] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0187] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0188] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A connection establishment method based on RDMA, applied to a client, wherein a first application is running on the client side, characterized in that: The method comprises: Receiving a first connection establishment request initiated by a first application to a second application on a server side, wherein the first connection establishment request is any one of a plurality of connection establishment requests initiated by the first application to the second application; Acquire, according to the first connection establishment request, a first RDMA link between the client and the server that can be reused by the first application; Creating a first virtual link corresponding to the first connection establishment request on the first RDMA link, so that the first application and the second application perform one-way data transmission through the first virtual link carried on the first RDMA link; When multiple virtual links are created on the first RDMA link, the multiple virtual links share resources of the first RDMA link, so that the first application and the second application perform multi-channel data transmission through the multiple virtual connections carried on the first RDMA link.
2. The method according to claim 1, characterized in that Creating a first virtual link corresponding to the first connection establishment request on the first RDMA link includes: Selecting a first channel identifier in an idle state from a plurality of channel identifiers supported by the first RDMA link, wherein each channel identifier is used to identify a virtual link created on the first RDMA link; Based on the first RDMA link, negotiating the first channel identifier between the client and the server; If the negotiation is successful, a first virtual link object corresponding to the first connection establishment request is created, and a corresponding relationship between the first virtual link object and the first channel identifier is established to obtain the first virtual link.
3. The method according to claim 2, characterized in that Based on the first RDMA link, negotiating the first channel identifier between the client and the server includes: Based on the first RDMA link, the first channel identifier is sent to the server, so that the server can verify the availability of the first channel identifier; when a response message indicating that the first channel identifier has passed the availability verification is received from the server, it is determined that the negotiation for the first channel identifier is successful; or Based on the first RDMA link, the first channel identifier is sent to the server, and when a response message returned by the server confirming receipt of the first channel identifier is received, it is determined that the negotiation for the first channel identifier is successful.
4. The method according to claim 1, characterized in that: Acquiring, according to the first connection establishment request, a first RDMA link between the client and the server that can be reused by the first application, including: According to the first connection establishment request, determining whether there is an RDMA link created for the first application between the client and the server; In a case where at least one RDMA link created for the first application exists between the client and the server, identifying, according to the number of virtual links currently carried by each RDMA link, whether there is a candidate RDMA link in the at least one RDMA link whose number of virtual links currently carried is less than the maximum number of virtual links corresponding to each of the candidate RDMA links; If there are candidate RDMA links, an RDMA link is selected from the candidate RDMA links as the first RDMA link.
5. The method according to claim 4, characterized in that Also includes: In a case where there is no RDMA link created for the first application between the client and the server or there is no candidate RDMA link, creating a first RDMA link for the first application between the client and the server, and in the process of creating the first RDMA link, negotiating a maximum number of virtual links that can be supported by the first RDMA link so that the first RDMA link can be reused; The maximum number of virtual links is used to limit the number of channel identifiers used by the first RDMA link.
6. The method according to claim 5, characterized in that During the process of creating the first RDMA link, negotiating a maximum number of virtual links that the first RDMA link can support includes: Sending an RDMA connection establishment request message to the server, wherein the RDMA connection establishment request message includes at least a first virtual link number supported by the client; Receiving an RDMA connection establishment response message returned by the server in response to the RDMA connection establishment request message, wherein the RDMA connection establishment response message includes at least the number of second virtual links supported by the server; A maximum number of virtual links that can be supported by the first RDMA link is determined according to the first number of virtual links and the second number of virtual links.
7. The method according to claim 5, characterized in that Creating a first virtual link corresponding to the first connection establishment request on the first RDMA link includes: during the process of creating the first RDMA link, simultaneously creating the first virtual link corresponding to the first connection establishment request.
8. The method according to any one of claims 2 to 3, characterized in that: Also includes: During negotiation between the client and the server regarding the first channel identifier based on the first RDMA link, the first data that the first application needs to send to the second application through the first virtual link is sent to the server, so that the server sends it to the second application.
9. The method according to any one of claims 2-3, characterized in that: Also includes: In the case where the first application sends first data to the second application through the first virtual link carried on the first RDMA link, according to the correspondence between the first virtual link object and the first channel identifier, the first channel identifier is added to the first data; and the first data after the first channel identifier is added is sent to the server through the first RDMA link, so that the server sends the first data to the second application according to the first channel identifier; and / or In the case where the first application receives second data sent by the second application through the first virtual connection carried on the first RDMA link, the second data including the first channel identifier is received and sent by the server through the first RDMA link; the first virtual link object is determined according to the correspondence between the first virtual link object and the first channel identifier, and the second data is processed according to the data processing action in the first virtual link object.
10. The method according to any one of claims 1 to 7, characterized in that: Also includes: When the first virtual connection needs to be closed, sending a first link closing request message to the server to request closing the first virtual connection; When receiving the first link closing response message returned by the server, performing a resource release operation on the first virtual link to set the first channel identifier corresponding to the first virtual link to an idle state; or When receiving the second link closing request message sent by the server, a second link closing response message is returned to the server, and a resource release operation is performed on the first virtual link to set the first channel identifier corresponding to the first virtual link to an idle state.
11. The method according to claim 10, characterized in that Also includes: If the last virtual link carried by the first RDMA link completes resource release, wait for a set time; After the set time expires, the first RDMA link is closed.
12. A connection establishment method based on RDMA, characterized in that: include: Receiving a first channel identifier sent by a client through a first RDMA link between the client and a server, where the first channel identifier is a channel identifier in an idle state selected from a plurality of channel identifiers supported by the first RDMA link, and the first RDMA link is an RDMA link between the client and the server that can be multiplexed by a first application on the client; A response message is returned to the client based on the first RDMA link, the response message at least including a message indicating that the first channel identifier is received, so as to create a first virtual link corresponding to the first channel identifier on the first RDMA link, the first virtual link being used by the first application to transmit data to the second application on the server through the first RDMA link.
13. An electronic device, characterized in that: include: Memory and processor; The memory is used to store a computer program, and the processor is coupled to the memory and is used to execute the computer program to implement the steps in the method of any one of claims 1 to 11 or claim 12.
14. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is enabled to implement the steps of the method according to any one of claims 1 to 11 or claim 12.
Citation Information
Patent Citations
Virtual desktop connection method, agent device, system, equipment and storage medium
CN110719309A
RDMA-based data transmission method and distributed shared memory system
CN111277616A
Cited By
RDMA-based link establishment method and apparatus, and device and storage medium
EP4597986A1
RDMA-based link establishment method and apparatus, and device and storage medium
WO2024067529A1