WO2023202241A1 - Communication method and related product - Google Patents

Communication method and related product Download PDF

Info

Publication number
WO2023202241A1
WO2023202241A1 PCT/CN2023/079651 CN2023079651W WO2023202241A1 WO 2023202241 A1 WO2023202241 A1 WO 2023202241A1 CN 2023079651 W CN2023079651 W CN 2023079651W WO 2023202241 A1 WO2023202241 A1 WO 2023202241A1
Authority
WO
WIPO (PCT)
Prior art keywords
network agent
service
channel
virtual channel
identifier
Prior art date
Application number
PCT/CN2023/079651
Other languages
French (fr)
Chinese (zh)
Inventor
张伟
张永明
黄毽
Original Assignee
华为云计算技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为云计算技术有限公司 filed Critical 华为云计算技术有限公司
Publication of WO2023202241A1 publication Critical patent/WO2023202241A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4641Virtual LANs, VLANs, e.g. virtual private networks [VPN]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/561Adding application-functional data or data for application control, e.g. adding metadata

Definitions

  • This application relates to the field of cloud computing technology, and in particular, to a communication method and related products.
  • the main methods currently used are: 1 Use a new application layer protocol between the client agent and the server agent, such as: Hypertext Transfer Protocol 2 (Hypertext Transfer Protocol 2) , HTTP2), low-latency Internet connection (quick user datagram protocol Internet connection) protocol and proxy protocol (proxyprotocol) based on user datagram protocol to proxy the default application layer protocol, that is, the client's application service and the server's application service
  • HTTP2 Hypertext Transfer Protocol 2
  • proxy protocol proxy protocol
  • the negotiated application layer protocol can reduce the number of transmission control protocol (TCP) connections established between the client's application service and the server's application service, thereby reducing the communication delay between the two.
  • TCP transmission control protocol
  • KCM kernel connection multiplexer
  • This application provides a communication method and related products, which can improve the communication efficiency between services.
  • this application provides a communication method, which method includes: a first network agent establishing a first virtual channel on a communication channel with a second network agent, wherein the first network agent is responsible for the first service Access, the second network agent is responsible for access to the second service, the first virtual channel is used to transmit communication messages between the first service and the second service, the communication message carries the identification of the first virtual channel, the current The identification of a virtual channel is the first identification.
  • the first network agent changes the identity of the first virtual channel from the first identity to a second identity, where the length of the second identity is less than the length of the first identity. In this way, the communication message transmitted through the first virtual channel can carry more business data, thereby improving the communication efficiency between the first service and the second service.
  • the second identification is an identification of a second virtual channel on the communication channel.
  • the first network agent when one or more of the following conditions are met, changes the identity of the first virtual channel from the first identity to the second identity: transmission on the first virtual channel
  • the priority of the service data is higher than the priority of the service data transmitted on the second virtual channel, and the efficiency of transmitting the service data on the first virtual channel is lower than the efficiency of transmitting the service data on the second virtual channel.
  • the second network proxy stores a first mapping relationship between the identifier of the first virtual channel and the identifier of the second service, where the first mapping relationship is used to indicate the second
  • the network proxy forwards the service data from the first virtual channel to the second service.
  • the second network agent receives the communication message from the first virtual channel, it can determine to forward the business data in the message to the second service based on the identification of the first virtual channel in the message. That is to say, The second network agent can forward the business data in the above message to the second service without parsing it, which improves the efficiency of sending business data, thereby improving the communication efficiency between the first service and the second service.
  • the first network proxy stores a second mapping relationship between the identifier of the first virtual channel and the identifier of the first service, where the second mapping relationship is used to indicate the first
  • the network agent forwards the service data from the first virtual channel to the first service.
  • the above-mentioned first network agent changes the identification of the first virtual channel from the first identification to the second identification, including: the first network agent changes the identification of the first virtual channel in the second mapping relationship from the first identification to the second identification. .
  • the first network agent receives the communication message from the first virtual channel, it can determine to forward the business data in the message to the first service based on the identification of the first virtual channel in the message. That is to say, The first network agent can forward the business data in the above message to the first service without parsing it, which improves the efficiency of sending business data, thereby improving the communication efficiency between the first service and the second service.
  • the above-mentioned first network agent changes the identity of the first virtual channel in the second mapping relationship from the first identity to the second identity, including: the first network agent changes the identity of the first virtual channel to the second identity.
  • the network agent sends an identity change request, where the identity change request is used to instruct the second network agent to change the identity of the first virtual channel in the first mapping relationship from the first identity to the second identity.
  • the first network agent changes the identifier carried in the communication message sent to the second network agent through the first virtual channel from the first identifier to the second identifier.
  • the first network agent receives the identity change response returned by the second network agent, and changes the identity used to forward the service data from the first virtual channel to the first service from the first identity to the second identity based on the identity change response.
  • the identity of the first virtual channel can be changed without affecting the use of the first virtual channel to transmit communication messages.
  • the communication channel is a TCP channel
  • the method further includes: first The network agent sends a TCP connection message to the second network agent to establish the above communication channel.
  • the above-mentioned communication channel is a TCP channel
  • the above-mentioned method further includes: A network agent establishes the communication channel based on the TCP connection message sent by the second network agent. In this way, the service (first service) in the public network can access the service (second service) in the private network.
  • the above-mentioned first network agent establishes a first virtual channel on the communication channel with the second network agent, including: in response to a message sent by the first service, the first network agent The agent establishes a first virtual channel, in which the message sent by the first service does not carry the business data sent by the first service to the second service.
  • the first service and the second service can communicate using an application layer protocol such as MySQL.
  • Such protocols require the second service (server) to push the first service (client) to send business data to it.
  • the above-mentioned first network agent establishes a first virtual channel on the communication channel with the second network agent, including: the first network agent sends a message to the second network through the above-mentioned communication channel.
  • the agent sends a virtual connection message, where the virtual connection message includes an identifier of the first virtual channel and an identifier of the second service, and the virtual connection message is used to instruct the second network agent to establish a communication channel with the second service.
  • the second network agent is automatically triggered to establish a communication channel with the second service.
  • this application provides a communication method, which is applied to a container system.
  • the container system includes a first container system.
  • the first container runs the first service;
  • the second container runs the second service;
  • the first network agent establishes a first virtual channel on the communication channel with the second network agent, wherein the first network agent is responsible for the first service
  • the second network agent is responsible for access to the second service.
  • the first virtual channel is used to transmit communication messages between the first service and the second service.
  • the communication message carries the identification of the first virtual channel.
  • the first virtual channel is used to transmit communication messages between the first service and the second service.
  • the identity of the virtual channel is a first identity; the first network agent changes the identity of the first virtual channel from the first identity to a second identity, where the length of the second identity is less than the length of the first identity.
  • the communication message transmitted through the first virtual channel can carry more business data, thereby improving the communication efficiency between the first service and the second service.
  • the communication channel is a TCP channel.
  • the method further includes: One network agent sends a TCP connection message to the second network agent to establish the above communication channel.
  • the communication channel is a TCP channel.
  • the method further includes: The second network agent sends a TCP connection message to the first network agent to establish the above communication channel.
  • the above-mentioned first network agent establishes a first virtual channel on the communication channel with the second network agent, including: in response to a message sent by the first service, the first network agent The agent establishes a first virtual channel, in which the message sent by the first service does not carry the business data sent by the first service to the second service.
  • the first service and the second service can communicate using an application layer protocol such as MySQL.
  • Such protocols require the second service (server) to push the first service (client) to send business data to it.
  • this application provides a first network agent.
  • the first network agent includes a service access module, a channel establishment module, and an identity change module.
  • the business access module is used for accessing the first service;
  • the channel establishment module is used for establishing a first virtual channel on the communication channel with the second network agent, wherein the second network agent is responsible for accessing the second service,
  • the first virtual channel is used to transmit communication messages between the first service and the second service.
  • the communication message carries the identifier of the first virtual channel.
  • this application provides a container system, which includes a first container, a second container, a first network agent and a second network agent described in any of the foregoing first aspects and any implementation of the first aspect.
  • Web proxy wherein, the first container is used to run the first service; the second container is used to run the second service; the second network agent is used to be responsible for access to the second service; the first network agent is used to be responsible for access to the first service, and in A first virtual channel is established on the communication channel with the second network agent, where the first virtual channel is used to transmit communication messages between the first service and the second service, and the communication messages carry the identification of the first virtual channel.
  • the current identifier of the first virtual channel is the first identifier
  • the identifier of the first virtual channel is changed from the first identifier to the second identifier, where the length of the second identifier is smaller than the length of the first identifier.
  • the present application provides a computing device.
  • the computing device includes a processor and a memory.
  • the processor executes the computer program code in the memory to implement the aforementioned first aspect and the part described in any implementation manner of the first aspect. Or all methods.
  • the present application provides a computer-readable storage medium.
  • the computer storage medium stores computer program code.
  • the computing device executes the aforementioned first aspect and any of the first aspects.
  • An implementation describes some or all of the methods.
  • Figure 1 is a schematic structural diagram of an adjustment system provided by an embodiment of the present application.
  • Figure 2 is a schematic structural diagram of a distributed storage system provided by an embodiment of the present application.
  • Figure 3 is a schematic structural diagram of a container system provided by an embodiment of the present application.
  • Figure 4 is a schematic structural diagram of another container system provided by an embodiment of the present application.
  • Figure 5 is a schematic structural diagram of yet another container system provided by an embodiment of the present application.
  • Figure 6 is a schematic structural diagram of a Kubernetes container system provided by an embodiment of the present application.
  • Figure 7 is a schematic flowchart of a method for establishing a communication channel provided by an embodiment of the present application.
  • Figure 8 is a schematic flowchart of a communication method provided by an embodiment of the present application.
  • FIG. 9 is a schematic flowchart of another communication method provided by an embodiment of the present application.
  • Figure 10 is a schematic flowchart of a method for changing the identity of a first virtual channel provided by an embodiment of the present application
  • Figure 11 is a schematic flow chart of communication before and after changing the identity of the first virtual channel provided by an embodiment of the present application
  • Figure 12 is a schematic structural diagram of a message transmitted based on the first virtual channel provided by an embodiment of the present application.
  • Figure 13 is a schematic structural diagram of a first network proxy provided by an embodiment of the present application.
  • Figure 14 is a schematic structural diagram of a computing device provided by an embodiment of the present application.
  • Figure 15 is a schematic structural diagram of a computing device system provided by an embodiment of the present application.
  • An application is a collection of computer programs written for a special application purpose of the user. Specifically, it can be a single application or a collection of multiple application programs. For example, an application can be an editor, etc. Applications can also be application software such as e-commerce systems and government and enterprise management systems.
  • Container technology is a kernel virtualization technology that can provide lightweight virtualization and facilitate the isolation of processes and resources.
  • container technology With the rapid development of container technology, the application's operating environment is isolated in units of containers, and the application's configuration information and operating environment are packaged and encapsulated together, and then orchestrated and managed through container cluster scheduling technology (such as Kubernetes) , has become a development trend, which can bring the deployment and life cycle management of large-scale applications, as well as the iterative development and online efficiency of applications to a new level. Therefore, more and more users choose to deploy their business on the cloud in the form of applications.
  • container cluster scheduling technology such as Kubernetes
  • microservice architecture such as Spring Cloud, Dubbo
  • microservices Each microservice is decoupled from each other and can be independently replaced, upgraded, and scaled. Therefore, using a microservice architecture not only helps developers update and maintain applications, but also allows other microservices to continue working when a single microservice fails, improving the stability of the application.
  • Service mesh technology is an application network technology based on the traditional Internet Protocol (IP) network.
  • agents also called sidecar processes
  • the non-functional service governance logic in application services is separated from the business process into the sidecar process, thereby providing connection, security, flow control, grayscale publishing and observation capabilities between application services in a non-invasive way, and achieving lightweight business and service governance basics Facilityization.
  • Istio implements communication between application services by using envoy as the sidecar of application services. Because envoy supports hot restart, dynamic configuration and plug-in structure, and also has complete service governance, flow control and observability capabilities, Istio is commonly used among application services to implement service governance.
  • a microservice architecture is used to split the application into multiple microservices, and multiple microservices are deployed on multiple containers.
  • Kubernetes is used to The above multiple containers are managed and orchestrated, and Istio is used to implement service governance between multiple microservices.
  • the above methods can not only simplify the deployment difficulty, maintenance and expansion difficulty of applications, but also improve the stability and reliability of applications. and usability to provide users with higher quality services.
  • resources on the physical host can be utilized more efficiently. Therefore, many users currently choose to deploy applications on the cloud using the above methods.
  • downstream agent and "upstream agent” can have different names.
  • different standards, different versions of the same standard, different manufacturers, and different application scenarios can have different names for "downstream agent” and "upstream agent”.
  • Different names for example, the term “downstream proxy” is sometimes also called “client proxy”, and “upstream proxy” is sometimes called “server proxy”.
  • a TCP channel between the client and the server needs to be established first.
  • the TCP channel between the client and the server consists of three sections: client The TCP channel with the downstream proxy, the TCP channel between the downstream proxy and the upstream proxy, and the TCP channel between the upstream proxy and the server, which causes the connection establishment time between the client and the server to be too long.
  • a TCP channel can only handle one service request at the same time, and after a service request is completed, the TCP channel used to transmit the service request often needs to be disconnected.
  • the communication delay between the two will gradually increase, causing a large number of business requests to fail due to response timeouts.
  • HTTP2 and proxyprotocol mentioned in method 1 do not support application layer protocols such as proxy MySQL, in which the server actively pushes data to the client after establishing a communication channel, nor do they support reverse connections (that is, initiated by the server to the client). connection) is established.
  • the utilization method 2 requires modification of the kernel protocol stack, and the client needs to use a new socket interface to establish a connection with the server, which results in the low versatility of this method.
  • this application provides a proxy protocol.
  • the proxy protocol includes the following content: in response to a message sent by the client (the message may or may not carry the business data that the client wants to send to the server), the downstream agent communicates with A virtual channel is established on the communication channel between the upstream agents, where the virtual channel is used to transmit communication messages between the client and the server. After the above virtual channel is established, the downstream agent stores the mapping relationship between the identifier of the virtual channel and the identifier of the client, and the upstream agent stores the mapping relationship between the identifier of the virtual channel and the identifier of the server.
  • the downstream agent when the downstream agent receives the business data (such as HTTP1 messages, MySQL messages) that the client wants to send to the server, the downstream agent can use the virtual channel identifier to encapsulate the above business data based on the locally stored mapping relationship, and then pass it through Send the encapsulated business data to the upstream agent through the virtual channel.
  • the upstream agent can also use the identification of the virtual channel to decapsulate the above-mentioned encapsulated business data based on the locally stored mapping relationship, and forward the decapsulated business data to the server.
  • the upstream agent and the downstream agent can send the above business data from the server to the client based on their respective stored mapping relationships. end.
  • the proxy protocol also supports: 1
  • the communication channel between the downstream proxy and the upstream proxy can be a TCP channel
  • the TCP channel can be a forward TCP channel or a reverse TCP channel.
  • the forward TCP channel refers to the TCP channel established by the downstream agent sending a TCP connection message to the upstream agent
  • the reverse TCP channel refers to the TCP channel established by the upstream agent sending a TCP connection message to the downstream agent.
  • Multiple communication channels can be established between the downstream agent and the upstream agent, and the virtual channel can be flexibly established on any of the above communication channels.
  • 3 Multiple virtual channels can be established on the communication channel between the downstream agent and the upstream agent, and the identifier of the virtual channel can be changed.
  • FIG. 3 exemplarily shows a schematic structural diagram of a container system.
  • the container system 100 includes a control node 110 and a plurality of computing nodes 120.
  • the various components of container system 100 are briefly described below.
  • the control node 110 may be a physical host or a virtual machine (VM).
  • the control node 110 is used to manage and control the scheduling of resources and the execution of tasks in the container system 100, for example, managing resources (including computing resources, storage resources and network resources) on multiple computing nodes 120; for example, based on each computing node
  • the resource usage on 120 allocates the application to the appropriate computing node 120 for running.
  • the computing node 120 may also be a physical host or a VM.
  • the computing node 120 includes one or more container groups 121, where the container group 121 is the smallest deployment unit in the container system 100.
  • Each container group 121 has a corresponding Internet Protocol (IP) address, and each container group 121 includes one or more containers 1211.
  • IP Internet Protocol
  • Each container 1211 can run one or more services.
  • the service here can be an application or an application service (such as a microservice) that constitutes an application.
  • the computing node 120 also includes a network agent 122.
  • the network agent 122 is responsible for accessing services in the node (hereinafter, this network agent responsible for accessing services in the computing node will be referred to as a node agent for short).
  • the network agent 122 is responsible for accessing external services.
  • the request is forwarded to the corresponding container and the local business response is forwarded.
  • the network agent 122 can be deployed on the computing node 120 in the form of a container, or can also be deployed on the computing node 120 in the form of a device.
  • the network agent 122 may be a software system, a hardware device, or a combination of a software system and a hardware device.
  • each container group 221 in the multiple computing nodes 220 includes not only one or more containers 2211, but also a network agent 2212, where , the network agent 2212 is responsible for accessing services in this container group (hereinafter, this network agent responsible for accessing services in the container group is referred to as a container group agent for short).
  • the network agents in some computing nodes 320 are node agents, that is, the network agents 322, and the network agents in some computing nodes 320 are container groups.
  • Agent i.e. network agent 3212.
  • the functions of the node 320, the container group 321, and the container 3211 are similar to the functions of the control node 110, the computing node 120, the container group 121, and the container 1211 in the container system 100 shown in Figure 3.
  • the embodiments of this application will not Describe similar sections as above.
  • Containers in the container system can be orchestrated using various tools such as Kubernetes, Docker swarm, Docker compose, or apache Mesos.
  • control node 110 is also called the master node, and the computing node 120 is also called the node node.
  • the container group 121 in the computing node 120 here refers to Pod.
  • control node 110 may include one or more of the following components: an application programming interface server (API server) 111, a control management component (controller manager) 112, a scheduling component (scheduler) 113, and a storage component (ETCD). ) 114, these components are used to manage and control the scheduling of resources and the execution of tasks in the container system 100.
  • API server application programming interface server
  • control management component control management component
  • scheduling component scheduling component
  • ETCD storage component
  • the application programming interface service component 111 is used to receive external requests and serve as a transfer station for other components to communicate with each other. It is also used to write various received information to the storage component 114; the control management component 112 is used to execute cluster-level Operations, for example, view the configuration information of the computing node 120, handle the failure of the computing node 120, manage and control the container 1211 on the computing node 120, etc.; the scheduling component 113 is responsible for the scheduling of the application, for example, scheduling the container with the application deployed to the appropriate location. running on the computing node 120; the storage component 114 is used to store all information on the container system 100, for example, information written by the application programming interface service component 111.
  • the computing node 120 may also include a Kubelet component 123 and a container runtime component 124.
  • the Kubelet component 123 is mainly responsible for interacting with the container running component 124 and the application programming interface service component 111 in the control node 110 to manage the container 1211 on this node, for example, sending the control node 110 to this node Allocate tasks to containers, or regularly report the usage of resources on this node to the control node 110.
  • the container running component 124 is used to download the image when the container 1211 is running, and control the running of the container 1211.
  • Figure 6 is only an exemplary display.
  • the container system 200 and the container system 300 can also use Kubernetes for container orchestration.
  • the container system involved in the embodiments of the present application can also use other tools for container orchestration, which is not limited by the embodiments of the present application, but for the sake of simplicity, the description will not be repeated here.
  • services can be run on the containers in the container system (including the container system shown in Figures 3 to 6), and there are communication requirements between different services.
  • the proxy protocol provided by this application can be used to reduce communication delay, thereby improving communication efficiency between services.
  • the following takes the communication between the first service and the second service running on the above-mentioned container system as an example, and describes in detail how the proxy protocol provided by this application realizes the communication between the first service and the second service in conjunction with Figures 7-12. communication.
  • the first service and the second service may be applications or application services constituting applications.
  • the first service and the second service may be different applications, or different application services that constitute the same application, or application services that constitute different applications; for another example, the first service is an application, and the second service is An application service that constitutes another application, or the second service is an application and the first service is an application service that constitutes another application.
  • the network agent responsible for access to the first service is different from the network agent responsible for access to the second service.
  • the container system includes two types of container groups: a first type container group having containers running a first service, and a second type container group having containers running a second service.
  • the first type of container group may include one or more containers running the first service
  • the second type container group may also include one or more containers running the second service.
  • the number of the first type of container group and the number of the second type of container group can be one or more.
  • the above-mentioned one or more first-type container groups may be located on one or more computing nodes in the container system, and the one or more second-type container groups may also be located on one or more computing nodes in the container system.
  • the first type of container group and the second type of container group may be located on the same computing node, or may be located on different computing nodes.
  • the network agent responsible for access to the first service may be located in the first class container group, and the network agent responsible for access to the second service may be located in the second class container group. In this way, it can be ensured that the network agent responsible for access to the first service is different from the network agent responsible for access to the second service.
  • the above-mentioned container system can be any of the container systems shown in Figures 3 to 6.
  • the first type of container group and the computing node where it is located the second type of container group and the computing node where it is located
  • the container running the first service and the container running the second service, the network agent responsible for access to the first service and the network agent responsible for access to the second service may be computing nodes, container groups, containers and network agents in the corresponding container system.
  • this application does not make specific limitations. In actual applications, adaptive adjustment and deployment can be made according to the resource usage and specific business requirements on the container system.
  • the first service wants to send business data D 1 to the second service.
  • the first service will act as the client and the second service will act as the server.
  • the communication process between the first service and the second service can be divided into the following two stages.
  • the first phase the establishment of the communication channel between the first service and the second service (shown in Figure 7)
  • the first service establishes a first communication channel with the first network agent.
  • the first service runs on a container in a first container group, and the first container group belongs to the first type of container group.
  • the first network agent ie, the downstream agent in the preceding article
  • the first network agent may be a container group agent (such as network agent 2212) or a node agent (such as network agent 122).
  • the first communication channel is a TCP channel
  • the first service establishes the first communication channel with the first network agent, including: the first service sends a first communication channel establishment request to the first network agent.
  • the first network agent returns a response confirming the establishment of the first communication channel to the first service.
  • the first service again sends a message confirming the establishment of the first communication channel to the first network agent, After the above three-way handshake, the first communication channel between the first container group and the first network agent is established.
  • S102 The first service sends the first message to the first network agent through the first communication channel.
  • the first message is used to instruct the first network agent to establish a communication channel with the second service.
  • the first message includes the service name of the second service, the IP address of the second service and the port of the second service (port A). At least one of them, port A is a port on the second container group used to send and receive messages related to the second service.
  • the first message may carry the service data D 1 , or may not carry the service data D 1 .
  • the business data D 1 refers to the message generated based on the application layer protocol between the first service and the second service. Since the first service and the second service can use multiple application layer protocols to implement communication, such as HTTP1 and MySQL, therefore The business data D 1 can be an HTTP1 message, a MySQL message, etc.
  • the first message may be a connection type message, that is, a message used to establish a communication channel, such as a TCP three-way handshake message.
  • the first network agent determines the second network agent based on the first message.
  • the first network agent determines the second service based on the first message, then determines the second container group based on the second service, and then determines the second network agent based on the second container group (i.e., as mentioned above the upstream agent).
  • the second container group belongs to the second type of container group, that is, the second container group includes containers running the second service, and the second network agent is used to be responsible for access to the business (including the second service) in the second container group.
  • the second network agent may be a container group agent (such as network agent 2212) or a node agent (such as network agent 122).
  • the first network agent determines the second container group based on the second service, including: the first network agent determines multiple second container groups based on the second service. class container group, and then use a load balancing algorithm to determine a second container group from the plurality of second class container groups.
  • the load balancing algorithm may include a polling algorithm, a random algorithm, a minimum connection algorithm, etc., which are not limited in the embodiments of this application.
  • the first network agent since the first message may carry the service data D 1 or not, compared with the first message not carrying the service data D 1 , when the first message carries the service data D 1 , the first network agent needs to The second network agent can only be determined by performing more processing on a message (that is, using an application layer protocol to decapsulate the service data D1 in the first message).
  • S104 The first network agent determines whether the second communication channel with the second network agent has been established. If the second communication channel is not established, S105-S110 is executed; if the second communication channel is established, S106-S110 is executed.
  • the second communication channel may be a TCP channel.
  • the second communication channel may be a forward TCP channel or a reverse TCP channel.
  • the forward TCP channel refers to the TCP channel established by the first network agent sending a TCP connection message to the second network agent.
  • the reverse TCP channel refers to the TCP channel established by the second network agent to the second network agent.
  • a TCP channel is established by sending a TCP connection message through a network agent. Please refer to the following description for the specific establishment process.
  • the second communication channel is a reverse TCP channel
  • the second communication channel has been established before the first network agent executes S104.
  • the second network agent sends the establishment request of the second communication channel to the first network agent.
  • the first network agent returns a response confirming the establishment of the second communication channel to the second network agent.
  • the second network agent sends a message confirming the establishment of the second communication channel to the first network agent again, thus completing the establishment of the second communication channel.
  • the first network agent also stores a mapping relationship between the identifier of the second network agent and the identifier of the second communication channel.
  • the identification of the second network agent may be an ID, number, etc.
  • the information of the second network agent or the identity of the second network agent can be flexibly set based on the type of the second network agent. For example, when the second network agent is a container group agent, the identity of the second network agent can be the second network agent.
  • the IP address of the second container group; when the second network agent is a node agent, the identifier of the second network agent may be the IP address of the computing node where the second network agent is located.
  • the identification of the second communication channel may be an ID, a number, or other information assigned to the second communication channel by the first network agent or the control node in the container system, which can be used to identify the second communication channel.
  • the first network agent determines whether the second communication channel with the second network agent has been established, including: when the first network agent stores an identifier of the second network agent and an identifier of the second communication channel. When the first network agent determines that the second communication channel has been established; when the first network agent does not store the mapping relationship between the identifier of the second network agent and the identifier of the second communication channel, the first network agent It is determined that the second communication channel is not established.
  • the first service may be a service running in a public network
  • the second service may be a service running in a private network (such as a virtual private cloud (VPC)).
  • VPC virtual private cloud
  • the second communication channel can be a reverse TCP channel
  • the proxy provided by this application supports services running in the public network to access services running in the private network.
  • the identifier of the second network proxy may include private network. The network identifier and the IP address of the private network.
  • the first network agent establishes a second communication channel with the second network agent.
  • the first network agent sends the establishment request of the second communication channel to the second network agent. After receiving the above request, the second network agent returns a response confirming the establishment of the second communication channel to the first network agent. After receiving the above response, the first network agent sends a message confirming the establishment of the second communication channel to the second network agent again, thus completing the establishment of the second communication channel.
  • the second communication channel is A network proxy can also establish a secure channel on the second communication channel, for example, a secure socket layer (SSL) connection or a transport layer security (TLS) connection.
  • SSL secure socket layer
  • TLS transport layer security
  • the first network proxy can use the following method to Establishing a secure channel on the second communication channel: First, the first network agent sends a secure channel establishment request (such as a client hello message) to the second network agent through the second communication channel. After receiving the above request, the second network agent sends the request to the second network agent through the second communication channel.
  • the second communication channel returns a corresponding response message (such as a server hello message) to the first network agent, where the above response message includes the public key in the key pair generated by the second network agent.
  • the first network agent generates a session key, uses the public key to encrypt the session key, and then sends the encrypted session key to the second network agent through the second communication channel.
  • the second network agent uses the private key to decrypt the encrypted session key to obtain the session key.
  • the first network agent and the second network agent can use the session key to encrypt the data to be transmitted, thereby completing the establishment of the SSL channel.
  • a secure channel in addition to establishing a secure channel on the second communication channel, a secure channel can also be established on the first communication channel mentioned above and the third communication channel mentioned below.
  • the specific establishment process can be found in The process of establishing a secure channel on the second communication channel will not be described here for simplicity.
  • the first network agent also stores a mapping relationship between the identifier of the second network agent and the identifier of the second communication channel.
  • the first network agent configures the second communication channel as a proxy channel.
  • the first network agent configures the second communication channel as a proxy channel, including: the first network agent sends a first negotiation request to the second network agent through the second communication channel, wherein the first negotiation request is used to Negotiate with the second network agent to configure the second communication channel as a proxy channel.
  • the proxy channel refers to a channel that transmits messages based on the proxy protocol.
  • the proxy channel supports multiplexing, that is, at least two services (including the first service and the first service) can be transmitted on the proxy channel. communication messages between the second service).
  • the second network agent configures the second communication channel as a proxy channel based on the first negotiation request, and returns a first negotiation response to the first network agent to inform the first network agent to confirm that the second communication channel will be used.
  • the channel is configured as a proxy channel.
  • both the first negotiation request and the first negotiation response include a negotiation identifier.
  • the negotiation identifier is used to indicate that the message is used to negotiate whether to configure a certain communication channel as a proxy channel.
  • the negotiation identifier can be a magic number or a calibration number. Verifier, etc.
  • the first negotiation request also includes an identification of the second communication channel.
  • the identifier of the second communication channel may also be the IP of the first network agent. address. It should be noted that when the identifier of the second communication channel is the IP address of the first network agent, after receiving the first negotiation request, the second network agent first determines the first network agent based on the identifier of the second communication channel, and then determines the first network agent based on the identifier of the second communication channel. The first network agent determines the second communication channel, and then uses the negotiation identifier in the first negotiation request to learn whether the first network agent wants to negotiate with it whether to configure the second communication channel as a proxy channel.
  • the first negotiation request also includes a connection timeout period, where the connection timeout period is used to inform the second network agent that after sending the first negotiation request, the first network agent expects to receive a heartbeat message returned by the second network agent. time, where the heartbeat message is used to indicate that the second communication channel is in a normal connection state.
  • the first network agent may disconnect the second communication channel if the first network agent does not receive the heartbeat message returned by the second network agent within the above-mentioned connection timeout period.
  • the second communication channel may be a reverse TCP channel
  • the connection timeout period is calculated from the time when the first network agent sends the first negotiation request, it can be guaranteed that the second communication channel will be established for a long time after Normal connection status can still be maintained when not in use.
  • the embodiment of the present application also proposes that the first network agent and the second network agent use the "drum-beating and flower-passing" mode to send heartbeat messages to each other, that is, the heartbeat message is not sent by one party and received by the other party. Both parties alternate sending and receiving.
  • the first negotiation response also includes information that can be used to indicate that the second network agent agrees to configure the second communication channel as a proxy channel, for example, characters preset by the user, etc.
  • the first network agent can also Full channel configures the second communication channel as a proxy channel.
  • the secure channel as an SSL channel as an example:
  • the first network agent sends a secure channel establishment request (such as a client hello message) to the second network agent.
  • a secure channel establishment request such as a client hello message
  • the second network agent may include identifiers of one or more protocols supported by the first network proxy, wherein the identifiers of the one or more protocols include identifiers of the above-mentioned proxy protocols.
  • the second network agent selects a protocol it supports (including a proxy protocol) from the above one or more protocols, and sends the identifier of the proxy protocol through a corresponding response message (such as a server hello message). Return to first network proxy.
  • the first network agent can send the first negotiation request to the second network agent through the SSL channel, and the second network agent can also return the first negotiation response to the first network agent through the SSL channel, thereby
  • the second communication channel is configured as a proxy channel.
  • the above process describes the establishment process of configuring the second communication channel as a proxy channel when the second network proxy supports the proxy protocol.
  • the second network agent does not support the proxy protocol.
  • embodiments of the present application propose that when the second network agent does not support the proxy protocol, the first network agent can disconnect the second communication. channel, or use other methods to continue to implement communication between the first service and the second service. For example, use any method mentioned in the prior art to implement communication between the first service and the second service.
  • the first network agent may determine that the second network agent does not support the proxy protocol in any of the following ways: (1) After the first network agent sends the first negotiation request, it does not receive it or does not receive it within the expected time. The first negotiation response returned by the second network proxy. (2) After the first network agent sends a secure channel establishment request (including a negotiation identifier), the response message returned by the second network agent does not include the negotiation identifier.
  • the first network agent configures the second communication channel as a proxy channel, including: the first network agent receives a second negotiation request sent by the second network agent through the second communication channel, and the first network agent receives After the second negotiation request, the second communication channel is configured as a proxy channel based on the second negotiation request, and a second negotiation response is returned to the second network agent, thereby configuring the second communication channel as a proxy channel.
  • the second negotiation request is similar to the first negotiation request.
  • the second negotiation request is used to negotiate with the first network agent to configure the second communication channel as a proxy channel.
  • the second negotiation request includes the above negotiation identifier. In addition, it also The identifier of the second communication channel and the connection timeout may be included.
  • the identifier of the second communication channel in the second negotiation request may also be the identifier of the second communication channel.
  • the second negotiation response is similar to the first negotiation response and is used to inform the second network agent to confirm that the second communication channel is configured as a proxy channel.
  • the second protocol response includes the above negotiation identifier. In addition, it may also include information that can be used to indicate Information that the first network agent agrees to configure the second communication channel as a proxy channel.
  • the first network agent stores the mapping relationship between the identifier of the second network agent and the identifier of the agent channel.
  • the identifier of the proxy channel may be an ID, a number, and other information assigned to the proxy channel by the first network proxy or the control node in the container system that can be used to identify the proxy channel.
  • the identifier of the proxy channel and the identifier of the second communication channel may be the same identifier, or they may be different identifiers.
  • the purpose of the first network agent storing the mapping relationship between the identifier of the second network agent and the identifier of the agent channel is: in subsequent communications, it can be determined that the second communication channel has been configured as a proxy channel, and the second communication channel has been configured as a proxy channel.
  • the purpose of a network agent storing the mapping relationship between the identifier of the second network agent and the identifier of the second communication channel is to determine that the second communication channel has been established in subsequent communications.
  • the embodiment of the present application proposes: the first network proxy can configure the second communication channel as a proxy channel Then store the mapping relationship between the second network agent and the identifier of the second communication channel (that is, the identifier of the agent channel).
  • the first network agent establishes the first virtual channel on the second communication channel and stores the identifier of the first virtual channel. Mapping relationship with the identity of the first service.
  • the first virtual channel is used to transmit communication messages between the first service and the second service.
  • the identification of the first virtual channel may be an ID, a number, or other information assigned to the first virtual channel by the first network agent or the control node in the container system, which can be used to identify the first virtual channel.
  • the proxy channel can support multiplexing, that is to say, the second communication channel can carry multiple virtual channels, and each virtual channel can be used to transmit communication messages between two services. Therefore, in a specific implementation, the identifier of the first virtual channel may be mainly used to identify the first virtual channel among the plurality of virtual channels, that is, the identifier of the first virtual channel remains unique among the identifiers of the plurality of virtual channels. Can.
  • the first network agent or control node can use multiple rules to allocate identifiers to the virtual channels (including the first virtual channel) on the second communication channel.
  • Several possible allocation rules are listed below:
  • each virtual channel Assign a number to each virtual channel as its identification in order from small to large or from large to small. For example, assuming that the first network agent successively establishes virtual channel 1, virtual channel 2, ..., virtual channel n (where n is an integer greater than 1) on the second communication channel, then the first network agent provides the above n virtual channels with The identification of channel allocation can be 1, 2,..., n-1; or m, m-1,..., m-n+2 (where m is an integer greater than or equal to n).
  • the identifier assigned to the virtual channel includes two fields: the first field and the second field, where the first field is a field indicating the length of the identifier, and the second field is a number set within the range that meets the above length requirements ( or ID) field.
  • the identifier of the virtual channel has three formats: 1 an identifier with a length of 4 bits (bit), 2 an identifier with a length of 8 bits, and 3 an identifier with a length of 16 bits.
  • the first field in the above three formats of identifiers can be set based on whether the length of the identifier is greater than 4 bits, and whether it is less than 16 bits. For example, when the length of the identifier is less than or equal to 4 bits, It is recorded as "0". When the length of the identifier is greater than 4 bits, it is recorded as "1". When the length of the identifier is less than 16 bits, it is recorded as "0".
  • the length of the identifier When the length of the identifier is greater than or equal to 16 bits, it is recorded as "1". Then, as shown in Table 1, for an identifier with a length of 4 bits, the first field is "0", occupying 1 bit; for an identifier with a length of 8 bits, the first field is "01", occupying 2 bits; For an identifier with a length of 16 bits, the first field is "11", occupying 2 bits. Further, for an identifier with a length of 4 bits, the second field can occupy 3 bits, and its representation range is 0-7; for an identifier with a length of 8 bits, the second field occupies 6 bits, and its representation range is 0-7.
  • format 1 can be used to identify 8 virtual channels
  • format 2 can be used to identify 64 virtual channels
  • the first field in the above three formats of identification can also be set in other forms.
  • other identifiers such as numbers and characters
  • the first field in the identification can also be flexibly set based on the number of virtual channels that can be carried on the second communication channel, the size of the data to be transmitted, and the communication quality. For example, Set to a different length of identifier, or set more lengths of identifiers.
  • the length of the virtual logo is generally preset, so method (1) or method
  • formula (2) is used to assign identifiers to virtual channels
  • the identifiers of different virtual channels have the same length.
  • using method (3) to assign identifiers to virtual channels can improve the transmission efficiency of business data. The reasons are as follows: For example, assume that method (2) is used to allocate identifiers to virtual channels.
  • the length of the identifier is set to 16 bits.
  • the identifier of virtual channel 8 is 0000000000000111, while using method (3) to assign identifiers to virtual channel 8 8
  • the identifier of virtual channel 8 is 0111; when using method (2) to allocate identifiers to virtual channel 72 in ascending order, the identifier of virtual channel 72 is 0000000001001000, and using method (3) to When the virtual channel 72 is assigned an identifier, the identifier of the virtual channel 72 is 10111111. It is not difficult to see that the identifier assigned to the virtual channel using method (3) can occupy fewer bytes.
  • the identification of the first service may be an ID, a number, or other information that can identify the first service assigned to the first service by the first network agent or the control node in the container system.
  • the identity of the first service can also be flexibly set based on the type of the first network proxy.
  • the identity of the first service can be the service name of the first service, the first The ID, number, etc. assigned by the container group to the first service;
  • the identification of the first service may include at least the IP address of the first container group and the port (port B) of the first service.
  • port B is a port on the first container group used to send and receive messages related to the first service.
  • the identification of the first service may also be information that can identify the first communication channel, such as an ID, a number, etc. assigned to the first communication channel by the first network agent or the control node in the container system.
  • the first network agent establishes the first virtual channel on the second communication channel, including: the first network agent sends a virtual connection message to the second network agent.
  • the virtual connection message includes an identifier of the first virtual channel.
  • the virtual connection message also includes the identification of the second service.
  • the identifier of the second service may be similar to the identifier of the first service: the identifier of the second service may be an ID, number, or other information that can identify the second service assigned by the first network agent or the control node in the container system to the second service.
  • the identity of the second service can also be flexibly set based on the type of the second network proxy. For example, when the second network proxy is a container group proxy, the identity of the second service can be the service name of the second service, the second container group The ID, number, etc. assigned to the second service; when the second network agent is a node agent, the identifier of the second service may include at least one of the IP address of the second container group and port A.
  • the identification of the second service may also be information that can identify the third communication channel, such as an ID, a number, etc. assigned by the first network agent or the control node in the container system to the third communication channel later.
  • the embodiment of the present application is not limited to the first network agent establishing the first virtual channel on the second communication channel and storing the mapping relationship between the identifier of the first virtual channel and the identifier of the first service.
  • the execution order of the steps, that is, the two steps can be executed at the same time or one after another.
  • the second network agent stores the mapping relationship between the identifier of the first virtual channel and the identifier of the second service based on the virtual connection message.
  • the second network agent after receiving the virtual connection message, obtains the identity of the first virtual channel and the identity of the second service based on the virtual connection message, and then stores the relationship between the identity of the first virtual channel and the identity of the second service. Mapping relations.
  • the second network agent establishes a third communication channel with the second service based on the virtual connection message.
  • the second network agent after receiving the virtual connection message, the second network agent obtains the identity of the second service based on the virtual connection message, and then establishes a third communication channel with the second service based on the identity of the second service.
  • the process of the second network agent establishing the third communication channel with the second service is the same as the process of the first service establishing the third communication channel with the first network agent in S101.
  • the process of the first communication channel between the two parties is similar and is established through a three-way handshake. Therefore, for the sake of simplicity, this process will not be described here.
  • the communication channel (including the first communication channel, the first virtual channel and the third communication channel) between the first service and the second service is established, and then the second phase is performed.
  • the first service and the second service communicate based on the above-mentioned established communication channel.
  • the communication between the first service and the second service is divided into the following two situations.
  • Case 1 The first service actively sends business data to the second service, that is, the first service and the second service communicate using an application layer protocol such as HTTP1. Then, the communication process between the first service and the second service can be seen in Figure 8.
  • the first service sends a second message to the first network agent through the first communication channel.
  • the second message includes the service data D 1 that the first service wants to send to the second service. It should be noted that when the first message in S102 above carries service data D 1 , the second message and the first message may be the same message.
  • the first network agent generates a data transmission message R 1 based on the second message, and sends the data transmission message R 1 to the second network agent through the first virtual channel.
  • the first network agent determines that the business data D 1 in the message needs to be sent to the second service by parsing the second message, thereby determining the second container group running the second service and being responsible for business access in the second container group. second network proxy. Afterwards, the first network agent determines the second network agent based on the locally stored mapping relationship between the identifier of the second network agent and the identifier of the second communication channel, and the mapping relationship between the identifier of the second network agent and the identifier of the agent channel. The communication channel is established and the second communication channel is the proxy channel. Then, the first network agent obtains the identity of the first virtual channel based on the second message from the first service and the mapping relationship between the locally stored identity of the first virtual channel and the identity of the first service.
  • the first network agent encapsulates the service data D 1 based on the identifier of the first virtual channel to obtain the data transmission message R 1 , and sends the data transmission message R 1 to the second network agent through the first virtual channel.
  • the data transmission message R 1 may also include the length of the service data D 1 .
  • S203 The second network agent forwards the service data D 1 to the second service through the third communication channel based on the data transmission message R 1 .
  • the second network agent after receiving the data transmission message R 1 , the second network agent obtains the identity of the first virtual channel and the service data D 1 based on the data transmission message R 1 , and then obtains the identity of the first virtual channel and the second service based on the locally stored identity of the first virtual channel.
  • the mapping relationship between the identifiers sends the business data D 1 to the second service through the third communication channel.
  • the second service may also return service data D 2 to the first service, where the service data D 1 is similar to the service data D 1 .
  • the business data D 2 refers to a message generated based on the application layer protocol between the first service and the second service. Therefore, the communication between the first service and the second service may also include the following S204-S206.
  • the second service generates a third message based on the service data D2 , and sends the third message to the second network agent through the third communication channel.
  • the third message includes the above-mentioned service data D 2 .
  • the second network agent generates the data transmission message R 2 based on the third message, and sends the data transmission message R 2 to the first network agent through the first virtual channel.
  • the second network agent determines by parsing the third message that the service data D2 in the message needs to be sent to the first service, that is, the message is a response to the second message, thereby obtaining the identity of the first virtual channel. Then, the second network agent encapsulates the service data D 2 based on the identification of the first virtual channel to obtain the data transmission message R 2 , and sends the data transmission message R 2 to the first network agent through the first virtual channel.
  • the data transmission message R 2 may also include the length of the service data D 2 .
  • the first network agent forwards the service data D2 to the first service through the first communication channel based on the data transmission message R2 .
  • the first network agent After receiving the data transmission message R 2 , the first network agent obtains the identity of the first virtual channel and the service data D 2 based on the data transmission message R 2 , and then obtains the identity of the first virtual channel and the first service based on the locally stored identity of the first virtual channel.
  • the mapping relationship between the identifiers forwards the service data D2 to the first service through the first communication channel.
  • Case 2 The second service pushes the first service to send business data to it (the first service sends business data to the second service only after the second service sends a message to the first service), that is, the first service and the second service use, for example, Application layer protocols such as MySQL communicate. Then, the communication process between the first service and the second service can be seen in Figure 9.
  • S301 The second service sends a fourth message to the second network agent through the third communication channel.
  • the fourth message includes instruction data used to instruct the first service to send service data to the second service.
  • the indication data refers to a message generated based on the application layer protocol between the first service and the second service (here it may be a MySQL message).
  • the second network agent generates the data transmission message R 3 based on the fourth message, and sends the data transmission message R 3 to the first network agent through the first virtual channel.
  • the data transmission message R 3 includes the identification of the first virtual channel and the above-mentioned indication data.
  • the first network agent forwards the above instruction data to the first service through the first communication channel based on the data transmission message R3 .
  • the first service After receiving the above indication data, the first service sends the service data D 1 to the second service.
  • the second service may also return the business data D 2 to the first service.
  • the above-mentioned process (S301-S303) of the second service sending the instruction data to the first service is similar to the above-mentioned process (S204-S206) of the second service sending the business data D2 to the first service. Therefore, for simplicity, This process will not be described here.
  • the second network agent when the second network agent receives the data transmission message R 1 sent from the first network agent, since the second network agent supports the agent protocol, the second network agent can use the identification pair of the first virtual channel.
  • the data transmission message R 1 is decapsulated to obtain service data D 1 .
  • the second network agent can also forward the business data D 1 to the second service based on the mapping relationship between the locally stored identity of the first virtual channel and the identity of the second service. In this process, the second network agent forwards the business data D 1 to the second service.
  • the second network agent can directly forward the service data D 1 to the second service without using the application layer protocol to decapsulate the service data D 1 , thus improving the transmission efficiency of the service data D 1 .
  • the proxy protocol since the proxy protocol is also used, the transmission efficiency of the service data D1 and the instruction data is also improved.
  • transport layer messages refer to messages transmitted on the second communication channel.
  • the transport layer message may be a TCP message.
  • the more bytes the identifier of the first virtual channel occupies the fewer bytes the service data occupies.
  • the fewer bytes the identifier of the first virtual channel occupies the less bytes the identifier of the first virtual channel occupies. Can carry more business data.
  • the embodiment of this application proposes that if the current identification of the first virtual channel (with When the identifier F 1 (hereinafter referred to as the identifier) cannot meet the communication requirements between the first service and the second service, the first network agent changes the identifier of the first virtual channel from the identifier F 1 to the identifier F 2 .
  • the length of the mark F 2 is smaller than the length of the mark F 1 .
  • the identification of the first virtual channel cannot meet the communication requirements between the first service and the second service: 1 The priority of the service data transmitted on the first virtual channel Higher than the first threshold; 2 The efficiency of transmitting service data on the first virtual channel is lower than the second threshold.
  • the first threshold may be a priority preset by the user, or may be dynamically adjusted by the first network agent based on the priority of business data transmitted by each virtual channel on the second communication channel and actual business requirements; the second threshold may be It is preset by the user, or may be dynamically adjusted by the first network agent based on the efficiency of transmitting business data of each of the above virtual channels and the actual business requirements.
  • the first network agent changes the identity of the first virtual channel from the identity F 1 to the identity F 2 , including the following steps:
  • the first network agent determines the identifier F 2 .
  • the identifier F 2 is the identifier of the second virtual channel on the second communication channel. Then, the first network agent determines the identifier F 2 , including: the first network agent determines the multiplexed number established on the second communication channel. virtual channels, wherein the plurality of virtual channels include a first virtual channel and a second virtual channel. Then, the first network agent determines at least one of a priority of the service data transmitted on each of the plurality of virtual channels and an efficiency of each virtual channel in transmitting the service data, wherein the efficiency of the virtual channel in transmitting the service data It refers to the proportion of business data in the messages transmitted through the channel within a unit time.
  • the first network agent determines the second virtual channel based on at least one of the priority of the service data transmitted on each virtual channel and the efficiency of each virtual channel in transmitting the service data, thereby determining the identifier F 2 , where the second The virtual channel is used to transmit business data when communicating with other services.
  • the second virtual channel satisfies one or more of the following conditions: the priority of the business data transmitted on the second virtual channel is lower than the priority of the business data transmitted on the first virtual channel. level, and the efficiency of transmitting service data on the second virtual channel is less than the efficiency of transmitting service data on the first virtual channel.
  • the first network agent can determine the data transmission efficiency of each virtual channel in the following manner: the first network agent determines the rate at which each virtual channel sends messages, the size of the message, and the size of the business data carried in the message, thereby calculating Obtain the efficiency of each virtual channel in transmitting business data.
  • the first network agent is set with a backup identifier set.
  • a backup identifier set For example, if the allocation rule (3) in S108 above is used to allocate identifiers to the virtual channel on the second communication channel, the partial length may be shorter.
  • the identifier (such as a 4-bit identifier) is added to the backup identifier set.
  • the identifiers in the standby identifier set can be used to be assigned to the virtual channel whose identifier needs to be changed, and the identifier F2 can be any one in the standby identifier set.
  • the first network agent sends a first identity change request to the second network agent through the second communication channel.
  • the first identification change request includes identification F 1 and identification F 2 .
  • the first network agent may send the first identity change request to the second network agent through the first virtual channel, or may send the first identity change request to the second network agent through the second virtual channel.
  • the first network agent changes the identity of the first virtual channel in the sending direction from the identity F 1 to the identity F 2 .
  • the identifier of the first virtual channel in the first network agent includes the following two functions: 1 When the first network agent sends a message through the first virtual channel, the identifier of the first virtual channel needs to be used to encapsulate the message to be processed. Transmitted business data; 2 When the first network agent receives a message from the first virtual channel, it needs to use the identifier of the first virtual channel to forward the business data in the above message to the first service.
  • the above identification of the first virtual channel in the sending direction refers to the identification used to implement function 1, that is, the message sent by the first network agent to the second network agent through the first virtual channel needs to carry the identification of the first virtual channel in the sending direction. .
  • the first network agent stores a mapping relationship between the identifier of the first virtual channel and the identifier of the first service.
  • the first network agent implements the above function 1 based on the mapping relationship. Therefore, the first network agent will sending direction Changing the identity of the first virtual channel from the identity F 1 to the identity F 2 includes: the first network agent changes the mapping relationship of the sending direction from the mapping relationship between the identity F 1 and the identity of the first service to the mapping relationship between the identity F 2 and the first service.
  • the mapping relationship between the identifiers of a service refers to the mapping relationship used to realize the above function 1.
  • the second network agent changes the identity of the first virtual channel from the identity F 1 to the identity F 2 based on the first identity change request.
  • the second network agent stores a mapping relationship between the identifier of the first virtual channel and the identifier of the second service, and the current identifier of the first virtual channel is the identifier F 1 . Therefore, the second network agent is based on The first identity change request changes the identity of the first virtual channel from the identity F 1 to the identity F 2 , including: the second network agent changes the mapping relationship between the identity F 1 and the identity of the second service based on the first identity change request. is the mapping relationship between the identifier F 2 and the identifier of the second service.
  • S405 The second network agent sends the first identity change response to the first network agent through the first virtual channel.
  • the first identification change response includes identification F 1 and identification F 2 .
  • the first network agent changes the identity of the first virtual channel in the receiving direction from the identity F 1 to the identity F 2 based on the first identity change response.
  • the identifier of the first virtual channel in the receiving direction refers to the identifier used to implement the above function 2, that is, the identifier used to forward the service data from the first virtual channel to the first service.
  • the first network agent can not only realize the above function 1 but also realize the above function 2 based on the mapping relationship between the identity of the first virtual channel and the identity of the first service. Therefore, the first network agent will receive the direction Changing the identity of the first virtual channel from the identity F 1 to the identity F 2 includes: the first network agent changes the mapping relationship in the receiving direction from the mapping relationship between the identity F 1 and the identity of the first service to the mapping relationship between the identity F 2 and the identity of the first service.
  • the mapping relationship between the identifiers of the first service refers to the mapping relationship used to realize the above function 2.
  • the identifier F2 is the identifier of the second virtual channel
  • the identity of the second virtual channel can be changed from the identity F 2 to the identity F 1 , or from the identity F 2 to the identity F 3 , where the identity F 3 is the first network agent or the control node in the container system.
  • the process of changing the identity of the second virtual channel is similar to the above-mentioned process of changing the identity of the first virtual channel, and therefore will not be described further.
  • the two should be performed simultaneously.
  • the first network agent sends an identity change request to the second network agent, it also sends a second identity change request to the second network agent to instruct the second network agent to change the identity of the second virtual channel; for another example, the first network agent sends an identity change request to the second network agent.
  • a network agent changes the identity of the first virtual channel in the receiving direction, it also changes the identity of the second virtual channel in the receiving direction.
  • the first identity change request may be configured to instruct the second network agent to exchange the identity F 1 and the identity F 2 (ie, change the identity of the first virtual channel from the identity F 1 to the identity F 2 , and An instruction to change the identification of the second virtual channel from identification F 2 to identification F 1 ).
  • the first network agent does not need to send the second identity change request to the second network agent.
  • the second network agent should also return the first identity change response and the second identity to the first network agent through the first virtual channel and the second virtual channel respectively. Change response.
  • the above method of changing the identifier of the first virtual channel will not interrupt the process of transmitting messages between the first virtual channel and the second virtual channel.
  • the above method can On the basis of not affecting the use of the first virtual channel and the second virtual channel to transmit messages, the identifier of the first virtual channel is changed. to pass the exchange mark Taking the method of identifying F 1 and identifying F 2 as an example to change the identity of the first virtual channel, as shown in Figure 11, assume that the second virtual channel is used to transmit communication messages between the third service and the second service:
  • the identity of the first virtual channel is the identity F 1 and the identity of the second virtual channel is the identity F 2 , therefore, the first network agent and The second network agent will use the identifier F1 to process the service data that needs to be transmitted through the first virtual channel, and use the identifier F2 to process the service data that needs to be transmitted through the second virtual channel.
  • the message sent by the first network agent (second network agent) to the second network agent (first network agent) through the first virtual channel will carry the identifier F 1 ; the first network agent (second network agent) receives When receiving a message from the first virtual channel, the identifier F 1 will be used to forward the business data in the message to the first service (second service); the first network agent (second network agent) sends the message through the second virtual channel.
  • the message to the second network agent (first network agent) will carry the identifier F 2 ; when the first network agent (second network agent) receives the message from the second virtual channel, it will use the identifier F 2 to convert the message.
  • the business data in is forwarded to the third service (fourth service).
  • the first network agent After the first network agent sends the first identity change request to the second network agent, it can be known from the above S403 that the first network agent will change the identity of the first virtual channel in the sending direction from the identity F 1 to the identity F 2 , and the identity of the second virtual channel in the sending direction is changed from the identity F 2 to the identity F 1 , so the message sent by the first network agent to the second network agent through the first virtual channel carries the identity F 1 .
  • the message sent by the second virtual channel to the second network agent carries the identifier F 2 .
  • the second network agent after receiving the first identity change request, the second network agent will change the identity of the first virtual channel from the identity F 1 to the identity F 2 based on the first identity change request, and change the identity of the second virtual channel to The identifier F 2 is changed to the identifier F 1 , so in the subsequent process, when the second network agent receives a message from the first virtual channel, it will use the identifier F 2 to forward the business data in the message to the second service. When the second network agent receives the message from the second virtual channel, it will use the identifier F1 to forward the service data in the message to the fourth service.
  • the second network agent After the second network agent returns the first identity change response and the second identity change response to the first network agent, since the second network agent has changed the identity of the first virtual channel from the identity F 1 to the identity F 2 , And the identity of the second virtual channel is changed from the identity F 2 to the identity F 1 , so in the subsequent process, the message sent by the second network agent to the first network agent through the first virtual channel carries the identity F 2 , through The message sent by the second virtual channel to the first network agent carries the identifier F 1 . It can be seen from the above S406 that after receiving the first identity change response, the first network agent will change the identity of the first virtual channel in the receiving direction from the identity F 1 to the identity F 2 based on the first identity change response.
  • the first network agent receives After receiving the second identity change response, the identity of the second virtual channel in the receiving direction is changed from the identity F 2 to the identity F 1 based on the second identity change response. Therefore, in the subsequent process, when the first network agent receives the message from the first virtual channel, it will use the identifier F2 to forward the business data in the message to the first service. The first network agent receives the message from the second virtual channel. When sending a message to the channel, the identifier F 1 will be used to forward the business data in the message to the third service.
  • the first network agent can select the communication channel that carries the smallest number of virtual channels from the plurality of communication channels, and then establish the first virtual channel on the communication channel. In this way, the first network agent or the control node of the container system can allocate a short-length identifier to the first virtual channel.
  • the first network agent may first determine the size of the service data to be transmitted. When the business data to be transmitted is large, the first network agent can select the communication channel with the smallest number of virtual channels and establish the first virtual channel on this channel, or the first network agent can establish a new connection. to the communication channel of the second network agent, and establish the first virtual channel on the new channel.
  • FIG. 7 to 10 describe the communication process between the first service and the second service when the first virtual channel is normal.
  • the situations that cause the first virtual channel to be disconnected include one or both of the following: disconnection of the first service and the first network agent. a first communication channel, and a third communication channel between the second service disconnect and the second network agent.
  • the following describes respectively the disconnection process of the communication between the first service and the second service in one or both of the above situations.
  • Scenario 1 The first service disconnects the first communication channel with the first network agent
  • the first service sends a notification message to the first network agent to disconnect the first communication channel.
  • the first network agent After receiving the notification message for disconnecting the first communication channel, the first network agent sends a first disconnect message to the second network agent, where the first disconnect message is used to indicate that the first network agent currently locally disconnects the first communication channel.
  • the virtual channel is set to a semi-closed state.
  • the semi-closed state includes that the first network agent can receive a specified message from the first virtual channel (such as the second disconnect message below), but cannot receive data from the first virtual channel. Transmission messages (such as data transmission message R 2 and data transmission message R 3 ).
  • the second network agent After receiving the first disconnection message, the second network agent returns the second disconnection message to the first network agent, and deletes the mapping relationship between the identifier of the first virtual channel and the identifier of the second service, wherein the second disconnection message
  • the open message is used to indicate that the second network agent currently sets the first virtual channel to a fully closed state locally.
  • the fully closed state includes that the second network agent does not receive all messages from the first virtual channel.
  • the first network agent After receiving the second disconnection message, the first network agent deletes the mapping relationship between the identifier of the first virtual channel and the identifier of the first service, and disconnects the first virtual channel. In this way, the identity of the first virtual channel is released, and the first network agent can allocate the identity to other virtual channels.
  • the first network agent after receiving the above-mentioned notification message for disconnecting the first communication channel, also receives a data transmission message (such as data transmission message R2 and data transmission message R2 ) sent by the second network agent through the first virtual channel. transmission message R 3 ), the first network agent discards the above-mentioned data transmission message.
  • a data transmission message such as data transmission message R2 and data transmission message R2
  • the first network agent receives the above-mentioned notification message of disconnecting the first communication channel and occurs when the first network agent sends the first identity to the second network agent.
  • the first network agent may not send the first identity change request to the second network agent.
  • the first virtual channel is disconnected after the identity of the first virtual channel is changed from the identity F 1 to the identity F 2 , that is, the first virtual channel is disconnected.
  • the occurrence does not interrupt the process of changing the identity of the first virtual channel.
  • the first network agent receives the above-mentioned notification message to disconnect the first communication channel (here the message carries the identifier F 1 )
  • the first network agent sends the first identifier change request to the second network agent, for
  • the second network agent will first receive the first identity change request, and then receive the first disconnect message.
  • the second network agent will first execute the above-mentioned S404-S405, and then execute: return the second disconnect message to the first network agent (here, the message carries the identifier F 2 ), and delete the identifier F 2 and the identifier of the second service. mapping relationship between them.
  • the first network agent will first execute the above-mentioned S406, and after receiving the above-mentioned second disconnection message, then execute: delete the mapping relationship between the identifier F 2 and the identifier of the first service, and disconnect the first virtual channel .
  • Scenario 2 The second service disconnects the third communication channel with the second network agent
  • the second service sends a notification message to the second network agent to disconnect the third communication channel.
  • the second network agent After receiving the notification message for disconnecting the third communication channel, the second network agent sends a second disconnect message to the first network agent, and deletes the mapping relationship between the identifier of the first virtual channel and the identifier of the second service.
  • the first network agent After receiving the second disconnection message, deletes the mapping relationship between the identifier of the first virtual channel and the identifier of the first service, and disconnects the first virtual channel.
  • the second network agent after receiving the notification message for disconnecting the third communication channel, also receives a data transmission message (such as data transmission message R 1 ) sent by the first network agent through the first virtual channel, Then the second network agent discards the above data transmission message.
  • a data transmission message such as data transmission message R 1
  • situation 2 occurs during the process of changing the identity of the first virtual channel, specifically:
  • the second network agent When the second network agent receives the notification message for disconnecting the third communication channel, it occurs after the first network agent sends the first identity change request to the second network agent (i.e. S402), and the second network agent receives Before the first identity change request, that is to say, the second network agent will first receive the notification message for disconnecting the third communication channel, and then receive the first identity change request. Therefore, the second network agent will first send a second disconnect message to the first network agent (here, the message carries the identifier F 1 ), and then delete the mapping relationship between the identifier F 1 and the identifier of the second service.
  • the first network agent will first execute the above-mentioned S401-S403; after receiving the above-mentioned second disconnection message, it will then execute: delete the identifier of the first virtual channel in the receiving direction (ie, the identifier F 1 ) and the identifier of the first service. deleting the mapping relationship between the identifier of the first virtual channel in the sending direction (ie, the identifier F 2 ) and the identifier of the first service, and disconnecting the first virtual channel.
  • the second network agent When the second network agent receives the notification message for disconnecting the third communication channel, it occurs before the second network agent receives the first identity change request. That is to say, the second network agent will first receive the first identification change request. The identification change request is received, and then the notification message for disconnecting the third communication channel is received. Therefore, the second network agent will first perform the above-mentioned S404-S405, and then send the second disconnect message to the first network agent (here, the message carries the identifier F 2 ). Correspondingly, the first network agent will first receive the above-mentioned first identification change response, and then receive the above-mentioned second disconnection message. Therefore, the first network agent will first execute S406, and then execute: delete the identifier F 2 and the first service mapping relationship between the identifiers, and disconnecting the first virtual channel.
  • Case 3 The first network agent receives a notification message sent by the first service to disconnect the first communication channel, and at the same time, the second network agent receives a notification message sent by the second service to disconnect the third communication channel.
  • the first service sends a notification message to the first network agent to disconnect the first communication channel.
  • the first network agent After receiving the notification message for disconnecting the first communication channel, the first network agent sends the first disconnect message to the second network agent, and discards the data transmission message sent by the second network agent through the first virtual channel.
  • the second service sends a notification message to the second network agent to disconnect the third communication channel.
  • the second network agent After receiving the notification message for disconnecting the third communication channel, the second network agent sends a second disconnect message to the first network agent, deletes the mapping relationship between the identifier F1 and the identifier of the second service, and discards the third communication channel. All messages sent by a network agent through the first virtual channel (including the above-mentioned first disconnect message).
  • the first network agent After receiving the second disconnection message, the first network agent deletes the mapping relationship between the identifier F 1 and the identifier of the first service, and disconnects the first virtual channel.
  • the first network agent may not send the first identity change request to the second network agent.
  • situation 3 occurs in the process of changing the identity of the first virtual channel
  • the disconnection process of the first virtual channel and the change process of the identity of the first virtual channel are the same as the above situation 1 and situation 2 that occur in the change process.
  • the process of identifying the first virtual channel has the same implementation idea, so for the sake of simplicity, it will not be described here.
  • the disconnection of the first virtual channel will not affect the change of the identifier of the second virtual channel.
  • the reason is as follows: as long as the second network agent can receive the second identity change request sent by the first network agent (or can instruct the second network agent to exchange the first identity change request of identity F 1 and identity F 2 ), it means that the first identity change request
  • the network agent has changed the identity of the second virtual channel in the sending direction, and the second network agent can change the identity of the second virtual channel to the identity F 1 . Since the second virtual channel is in a normal connection state, the second network agent can send a second identity change response to the first network agent through the second virtual channel, and then the first network agent can change the identity of the second virtual channel in the receiving direction. In this way, the change of the identity of the second virtual channel can be completed.
  • the messages transmitted through the first virtual channel are diverse, and may specifically include the heartbeat message in S106, the virtual connection message in S108, the data transmission message R 1 in S202, and the data in S205.
  • the embodiment of the present application sets an operation type field in the message transmitted based on the first virtual channel. This field can be set to different values to distinguish different operations performed on the first virtual channel.
  • the operation type field may include multiple parts.
  • the first field can be used to divide the messages transmitted based on the first virtual channel into two categories.
  • One category is the virtual connection message, the data transmission message R 1 , the data transmission message R 2 , the data transmission message R 3 , and the first disconnection message.
  • messages and second disconnect messages the first fields of such messages are all 0; the other type are heartbeat messages, first identity change requests and first identity change responses, the first fields of such messages are all 1.
  • a third field of 0 indicates that the message is a message for establishing a virtual channel, that is, the above virtual connection message; a third field of 1 indicates that the message is The message is a message used to transmit business data, that is, the above-mentioned data transmission message R 1 , data transmission message R 2 , and data transmission message R 3 ; the third field is 2, indicating that the message is a message used to disconnect the virtual channel, that is, the above-mentioned The first disconnect message and the second disconnect message.
  • the first disconnect message and the second disconnect message can be distinguished by a fourth field, where a fourth field of 0 indicates that the message is the first disconnect message, and a fourth field of 1 indicates that the message is The second disconnect message above.
  • the second field For messages whose first fields are all 1, they can be distinguished by the second field. Specifically: if the second field is 0, it means that the message is a request to change the identity of the virtual channel, that is, the above-mentioned first identity change request; the second field A value of 1 indicates that the message is a response to the first identity change request, that is, the above-mentioned first identity change response; a value of 2 in the second field indicates that the message is the above-mentioned heartbeat message.
  • FIG. 12 only shows an exemplary message structure.
  • various types of messages transmitted based on the first virtual channel can be distinguished in other formats, which is not limited by the embodiment of the present application.
  • the proxy protocol provided by this application has been described in detail through the communication process between the first service and the second service. The following is a detailed description of the proxy protocol provided by the present application through the communication process between the first service and the second service. In conjunction with Figures 13 to 15, from the structure of the first network proxy and the second network proxy that support the proxy protocol, Further describe the above agency agreement.
  • Figure 13 exemplarily shows a schematic structural diagram of a first network agent.
  • the first network agent in the figure may be the first network agent in the above method embodiment (ie, the first network agent in Figures 7 to 12).
  • the first network agent 400 includes a service access module 410 , a channel establishment module 420 , an identity change module 430 and a data storage module 440 .
  • the service access module 410, the channel establishment module 420, the identification changing module 430 and the data storage module 440 work together to implement the steps performed by the first network agent in the above method embodiment.
  • the business access module 410 is responsible for accessing the first service, including the step of receiving the first message in the above S102, the step of receiving the second message in the above S201, the above S202, the above S206, the above S303, and receiving the message from the first service.
  • the step of disconnecting the notification message of the first virtual channel of a service; the channel establishment module 420 is used to perform the steps related to establishing the first communication channel in the above S101, the above S103-S106, and the above S108 related to the establishment of the first virtual channel.
  • the relevant steps of the mapping relationship between the identifications are described.
  • each module within the first network agent may be a software module or a hardware module, or may be partly a software module and partly a hardware module.
  • FIG 14 shows a schematic structural diagram of a computing device.
  • the above-mentioned first network agent 400 can be deployed on the computing device.
  • the computing device can be a computing device (such as a server) in a cloud environment, or a computing device in an edge environment. , or terminal computing device.
  • the computing device 500 includes a memory 510, a processor 520, a communication interface 530, and a bus 540.
  • the memory 510, the processor 520, and the communication interface 530 implement communication connections with each other through the bus 540.
  • the memory 510 may include a read only memory (ROM), a static storage device, a dynamic storage device, a random access memory (RAM), a hard disk, etc.
  • the memory 510 may store program codes, for example, program codes in the service access module 410, program codes in the channel establishment module 420, program codes in the identification changing module 430, and program codes in the data storage module 440, etc.
  • the processor 520 and the communication interface 530 are used to execute part or all of the methods executed by the first network agent 400 (including the above-mentioned S101-S108, S201-S202, S206, The steps performed by the first network agent in S303, and the steps performed by the first network agent when the first virtual channel is disconnected).
  • the memory 510 may also store data, such as intermediate data or result data generated by the processor 520 during execution, such as the identification of the first virtual channel, the data transmission message R 1 , etc.
  • the processor 520 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more integrated circuits.
  • CPU central processing unit
  • ASIC application specific integrated circuit
  • GPU graphics processing unit
  • the processor 520 may also be an integrated circuit chip with signal processing capabilities. During the implementation process, the functions of the first network agent 400 can be completed by instructions in the form of hardware integrated logic circuits or software in the processor 520 .
  • the processor 520 can also be a general-purpose processor, a digital signal process (DSP), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, Discrete hardware components can implement or execute the methods, steps and logical block diagrams disclosed in the embodiments of this application.
  • the general processor can be a microprocessor or the processor can be any conventional processor, etc.
  • the method disclosed in combination with the embodiments of the present application can be directly implemented as a hardware decoding processor to complete the execution, or can be performed using decoding processing.
  • the combination of hardware and software modules in the device is executed.
  • the software module can be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other mature storage media in this field.
  • the storage medium is located in the memory 510.
  • the processor 520 reads the information in the memory 510 and completes part or all of the functions of the first network agent 400 in combination with its hardware.
  • the communication interface 530 uses a transceiver module, such as but not limited to a transceiver, to implement communication between the computing device 500 and other devices or communication networks.
  • a message (such as a first message) from the first service is received through the communication interface 530, and a message (such as a data transmission message R 1 ) is sent to the second network agent.
  • Bus 540 may include a path that carries information between various components in computing device 500 (eg, memory 510, processor 520, and communication interface 530).
  • FIG. 15 shows a schematic structural diagram of a computing device system.
  • the computing device system includes multiple computing devices.
  • the above-mentioned first network agent 400 can be deployed on multiple computing devices in the computing device system in a distributed manner.
  • the computing device system 600 includes multiple computing devices 700.
  • Each computing device 700 includes a memory 710, a processor 720, a communication interface 730, and a bus 740.
  • the memory 710, the processor 720, and the communication interface 730 pass through Bus 740 implements communication connections between each other.
  • Memory 710 may include ROM, RAM, static storage devices, dynamic storage devices, hard disks (such as SSD, HDD) etc.
  • the memory 710 may store program codes, for example, a part of the program code in the service access module 410, a part of the program code in the channel establishment module 420, a part of the program code in the identification changing module 430, and a part of the program code in the data storage module 440, etc.
  • the processor 720 and the communication interface 730 are used to execute part of the method executed by the first network agent 400 (including the above-mentioned S101-S108, S201-S202, S206, S303).
  • the memory 710 may also store data, such as intermediate data or result data generated by the processor 720 during execution, such as the identification of the first virtual channel, the data transmission message R 1 , etc.
  • Processor 720 may employ a CPU, GPU, ASIC, or one or more integrated circuits.
  • the processor 720 may also be an integrated circuit chip with signal processing capabilities. During the implementation process, part of the functions of the first network agent 400 may be implemented by instructions in the form of integrated logic circuits or software in the hardware of the processor 720 .
  • the processor 720 can also be a DSP, FPGA, general-purpose processor, other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and can implement or execute some of the methods, steps and logic block diagrams disclosed in the embodiments of this application.
  • the general processor may be a microprocessor or the processor may be any conventional processor, etc.
  • the steps of the method disclosed in conjunction with the embodiments of the present application may be directly implemented as a hardware decoding processor, or may be executed using a decoding processor.
  • the combination of hardware and software modules in the code processor is executed.
  • the software module can be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other mature storage media in this field.
  • the storage medium is located in the memory 710.
  • the processor 720 reads the information in the memory 710 and completes some functions of the first network agent 400 in combination with its hardware.
  • the communication interface 730 uses a transceiver module, such as but not limited to a transceiver, to implement communication between the computing device 700 and other computing devices or communication networks. For example, a message from the first service (such as a first message) is received through the communication interface 730, or a message (such as a data transmission message R 1 ) is sent to the second network agent.
  • a transceiver module such as but not limited to a transceiver
  • Bus 740 may include a path that carries information between various components in computing device 700 (eg, memory 710, processor 720, and communication interface 730).
  • Any computing device may be a computing device (eg, a server) in a cloud environment, a computing device in an edge environment, or a terminal computing device.
  • the structure of the second network agent may be the same as the structure of the first network agent shown in the above-mentioned Figures 13-15, or it may be a modified structure designed based on the structure of the above-mentioned first network agent. Therefore, the present application The embodiment will no longer describe the structure of the second network proxy.
  • the computer program product providing the first network agent 400 or the container system respectively includes one or more computer program codes executed by the first network agent 400, and one or more computer program codes executed by the container system. computer program code.
  • the above-mentioned computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the above-mentioned computer program code can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another.
  • the above-mentioned computer program code can be transferred from a website, computer, server or data center Transmission to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, twisted pair or wireless (such as infrared, wireless, microwave), etc.) means.
  • the above computer readable storage The storage medium stores computer program code provided for execution by the first network agent 400 or the container system (including the container system shown in Figures 3-6).
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more integrated media.
  • the above available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, optical disk), or semiconductor media (eg, solid state disk (SSD)).

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Library & Information Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer And Data Communications (AREA)

Abstract

Provided in the present application are a communication method and a related product. The method comprises: a first network proxy establishing a first virtual channel on a communication channel between same and a second network proxy, wherein the first network proxy is responsible for access to a first service, the second network proxy is responsible for access to a second service, the first virtual channel is used for transmitting a communication message between the first service and the second service, the communication message carries an identifier of the first virtual channel, and the current identifier of the first virtual channel is a first identifier; and then, the first network proxy changing the identifier of the first virtual channel from the first identifier to a second identifier, wherein the length of the second identifier is less than the length of the first identifier. In this way, more service data can be carried in a communication message, which is transmitted by means of a first virtual channel, such that the efficiency of communication between a first service and a second service can be improved.

Description

一种通信方法及相关产品A communication method and related products
本申请要求于2022年4月21日提交中国专利局、申请号为202210423516.1、申请名称为“一种通信方法及相关产品”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the China Patent Office on April 21, 2022, with application number 202210423516.1 and application title "A communication method and related products", the entire content of which is incorporated into this application by reference. .
技术领域Technical field
本申请涉及云计算技术领域,尤其涉及一种通信方法及相关产品。This application relates to the field of cloud computing technology, and in particular, to a communication method and related products.
背景技术Background technique
在云计算场景下,应用的规模不断增长,一个应用往往由多个应用服务构成,多个应用服务之间采用服务网格技术(service mesh)实现彼此间的调用。基于服务网格技术,客户端的应用服务与服务端的应用服务之间需要经由客户端代理和服务端代理实现通信,这就增加了客户端的应用服务与服务端的应用服务之间的通信时延。In cloud computing scenarios, the scale of applications continues to grow. An application is often composed of multiple application services, and multiple application services use service mesh technology to implement calls to each other. Based on service mesh technology, client application services and server application services need to communicate through client proxies and server proxies, which increases the communication delay between client application services and server application services.
为了减少二者之间的通信时延,目前主要采用的方式有:①在客户端代理和服务端代理之间使用新的应用层协议,例如:第二版超文本传输协议(hypertext transfer protocol 2,HTTP2)、基于用户数据报协议的低时延的互联网连接(quick user datagram protocol internet connection)协议、代理协议(proxyprotocol),来代理默认的应用层协议,即客户端的应用服务与服务端的应用服务协商好的应用层协议,以此减少客户端的应用服务与服务端的应用服务之间建立传输控制协议(transmission control protocol,TCP)连接的次数,从而减少二者之间的通信时延。②使用内核协议连接复用(kernel connection multiplexer,KCM)协议来提高客户端的应用服务和服务端的应用服务发送和接收TCP报文的速率,从而减少二者之间的通信时延。但是,上述两种方式均存在使用范围局限的问题。In order to reduce the communication delay between the two, the main methods currently used are: ① Use a new application layer protocol between the client agent and the server agent, such as: Hypertext Transfer Protocol 2 (Hypertext Transfer Protocol 2) , HTTP2), low-latency Internet connection (quick user datagram protocol Internet connection) protocol and proxy protocol (proxyprotocol) based on user datagram protocol to proxy the default application layer protocol, that is, the client's application service and the server's application service The negotiated application layer protocol can reduce the number of transmission control protocol (TCP) connections established between the client's application service and the server's application service, thereby reducing the communication delay between the two. ② Use the kernel connection multiplexer (KCM) protocol to increase the rate at which the client's application service and the server's application service send and receive TCP messages, thereby reducing the communication delay between the two. However, both of the above methods have the problem of limited scope of use.
因此,如何提高应用服务之间的通信效率仍然是一个急需解决的问题。Therefore, how to improve the communication efficiency between application services is still an urgent problem to be solved.
发明内容Contents of the invention
本申请提供了一种通信方法及相关产品,能够提高服务之间的通信效率。This application provides a communication method and related products, which can improve the communication efficiency between services.
第一方面,本申请提供了一种通信方法,该方法包括:第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道,其中,第一网络代理负责第一服务的访问,第二网络代理负责第二服务的访问,第一虚拟通道用于传输第一服务和第二服务之间的通信消息,该通信消息中携带有所述第一虚拟通道的标识,当前第一虚拟通道的标识是第一标识。之后,第一网络代理将第一虚拟通道的标识从第一标识更改为第二标识,其中,第二标识的长度小于第一标识的长度。如此,通过第一虚拟通道传输的通信消息中便可以携带更多的业务数据,从而能够提高第一服务和第二服务之间的通信效率。In a first aspect, this application provides a communication method, which method includes: a first network agent establishing a first virtual channel on a communication channel with a second network agent, wherein the first network agent is responsible for the first service Access, the second network agent is responsible for access to the second service, the first virtual channel is used to transmit communication messages between the first service and the second service, the communication message carries the identification of the first virtual channel, the current The identification of a virtual channel is the first identification. Afterwards, the first network agent changes the identity of the first virtual channel from the first identity to a second identity, where the length of the second identity is less than the length of the first identity. In this way, the communication message transmitted through the first virtual channel can carry more business data, thereby improving the communication efficiency between the first service and the second service.
在第一方面的一种可能的实现方式中,上述第二标识是上述通信通道上的第二虚拟通道的标识。In a possible implementation of the first aspect, the second identification is an identification of a second virtual channel on the communication channel.
在第一方面的一种可能的实现方式中,当满足以下一个或多个条件时,第一网络代理将第一虚拟通道的标识从第一标识更改为第二标识:第一虚拟通道上传输的业务数据的优先级高于第二虚拟通道上传输的业务数据的优先级,以及第一虚拟通道上传输业务数据的效率低于第二虚拟通道上传输业务数据的效率。如此,可以保证将第一虚拟通道的标识从第一标识 更改为第二标识后,第二虚拟通道上的业务不会受到较大的影响。In a possible implementation of the first aspect, when one or more of the following conditions are met, the first network agent changes the identity of the first virtual channel from the first identity to the second identity: transmission on the first virtual channel The priority of the service data is higher than the priority of the service data transmitted on the second virtual channel, and the efficiency of transmitting the service data on the first virtual channel is lower than the efficiency of transmitting the service data on the second virtual channel. In this way, it can be guaranteed that the identification of the first virtual channel is changed from the first identification After changing to the second ID, the services on the second virtual channel will not be greatly affected.
在第一方面的一种可能的实现方式中,第二网络代理存储有第一虚拟通道的标识与第二服务的标识之间的第一映射关系,其中,第一映射关系用于指示第二网络代理将来自第一虚拟通道的业务数据转发至第二服务。如此,当第二网络代理接收到来自第一虚拟通道的通信消息后,基于该消息中的第一虚拟通道的标识便可以确定将该消息中的业务数据转发至第二服务,也就是说,第二网络代理无需解析上述消息中的业务数据即可将其转发至第二服务,提高了业务数据的发送效率,从而提高了第一服务和第二服务之间的通信效率。In a possible implementation of the first aspect, the second network proxy stores a first mapping relationship between the identifier of the first virtual channel and the identifier of the second service, where the first mapping relationship is used to indicate the second The network proxy forwards the service data from the first virtual channel to the second service. In this way, when the second network agent receives the communication message from the first virtual channel, it can determine to forward the business data in the message to the second service based on the identification of the first virtual channel in the message. That is to say, The second network agent can forward the business data in the above message to the second service without parsing it, which improves the efficiency of sending business data, thereby improving the communication efficiency between the first service and the second service.
在第一方面的一种可能的实现方式中,第一网络代理存储有第一虚拟通道的标识与第一服务的标识之间的第二映射关系,其中,第二映射关系用于指示第一网络代理将来自第一虚拟通道的业务数据转发至第一服务。上述第一网络代理将第一虚拟通道的标识从第一标识更改为第二标识,包括:第一网络代理将第二映射关系中的第一虚拟通道的标识从第一标识更改为第二标识。如此,当第一网络代理接收到来自第一虚拟通道的通信消息后,基于该消息中的第一虚拟通道的标识便可以确定将该消息中的业务数据转发至第一服务,也就是说,第一网络代理无需解析上述消息中的业务数据即可将其转发至第一服务,提高了业务数据的发送效率,从而提高了第一服务和第二服务之间的通信效率。In a possible implementation of the first aspect, the first network proxy stores a second mapping relationship between the identifier of the first virtual channel and the identifier of the first service, where the second mapping relationship is used to indicate the first The network agent forwards the service data from the first virtual channel to the first service. The above-mentioned first network agent changes the identification of the first virtual channel from the first identification to the second identification, including: the first network agent changes the identification of the first virtual channel in the second mapping relationship from the first identification to the second identification. . In this way, when the first network agent receives the communication message from the first virtual channel, it can determine to forward the business data in the message to the first service based on the identification of the first virtual channel in the message. That is to say, The first network agent can forward the business data in the above message to the first service without parsing it, which improves the efficiency of sending business data, thereby improving the communication efficiency between the first service and the second service.
在第一方面的一种可能的实现方式中,上述第一网络代理将第二映射关系中的第一虚拟通道的标识从第一标识更改为第二标识,包括:第一网络代理向第二网络代理发送标识更改请求,其中,标识更改请求用于指示第二网络代理将第一映射关系中的第一虚拟通道的标识从第一标识更改为第二标识。之后,第一网络代理将通过第一虚拟通道发往第二网络代理的通信消息中携带的标识从第一标识更改为第二标识。之后,第一网络代理接收第二网络代理返回的标识更改响应,并基于标识更改响应将用于转发来自第一虚拟通道的业务数据至第一服务的标识从第一标识更改为第二标识。如此,可以在不影响使用第一虚拟通道传输通信消息的基础上,更改第一虚拟通道的标识。In a possible implementation manner of the first aspect, the above-mentioned first network agent changes the identity of the first virtual channel in the second mapping relationship from the first identity to the second identity, including: the first network agent changes the identity of the first virtual channel to the second identity. The network agent sends an identity change request, where the identity change request is used to instruct the second network agent to change the identity of the first virtual channel in the first mapping relationship from the first identity to the second identity. Afterwards, the first network agent changes the identifier carried in the communication message sent to the second network agent through the first virtual channel from the first identifier to the second identifier. Afterwards, the first network agent receives the identity change response returned by the second network agent, and changes the identity used to forward the service data from the first virtual channel to the first service from the first identity to the second identity based on the identity change response. In this way, the identity of the first virtual channel can be changed without affecting the use of the first virtual channel to transmit communication messages.
在第一方面的一种可能的实现方式中,上述通信通道是TCP通道,第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道之前,上述方法还包括:第一网络代理向第二网络代理发送TCP连接消息,以建立上述通信通道。In a possible implementation of the first aspect, the communication channel is a TCP channel, and before the first network agent establishes the first virtual channel on the communication channel with the second network agent, the method further includes: first The network agent sends a TCP connection message to the second network agent to establish the above communication channel.
在第一方面的另一种可能的实现方式中,上述通信通道是TCP通道,第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道之前,上述方法还包括:第一网络代理基于第二网络代理发送的TCP连接消息,建立上述通信通道。如此,可以实现公网中的服务(第一服务)访问私网中的服务(第二服务)。In another possible implementation of the first aspect, the above-mentioned communication channel is a TCP channel, and before the first network agent establishes the first virtual channel on the communication channel with the second network agent, the above-mentioned method further includes: A network agent establishes the communication channel based on the TCP connection message sent by the second network agent. In this way, the service (first service) in the public network can access the service (second service) in the private network.
在第一方面的一种可能的实现方式中,上述第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道,包括:响应于第一服务发送的消息,第一网络代理建立第一虚拟通道,其中,第一服务发送的消息未承载第一服务发往第二服务的业务数据。如此,第一服务和第二服务可以采用例如MySQL之类的应用层协议进行通信,这类协议需要由第二服务(服务端)推动第一服务(客户端)向其发送业务数据。In a possible implementation of the first aspect, the above-mentioned first network agent establishes a first virtual channel on the communication channel with the second network agent, including: in response to a message sent by the first service, the first network agent The agent establishes a first virtual channel, in which the message sent by the first service does not carry the business data sent by the first service to the second service. In this way, the first service and the second service can communicate using an application layer protocol such as MySQL. Such protocols require the second service (server) to push the first service (client) to send business data to it.
在第一方面的一种可能的实现方式中,上述第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道,包括:第一网络代理通过上述通信通道向第二网络代理发送虚拟连接消息,其中,虚拟连接消息包括第一虚拟通道的标识和第二服务的标识,虚拟连接消息用于指示第二网络代理建立与第二服务之间的通信通道。如此,当第一虚拟通道建立后,便会自动触发第二网络代理建立与第二服务之间的通信通道。In a possible implementation of the first aspect, the above-mentioned first network agent establishes a first virtual channel on the communication channel with the second network agent, including: the first network agent sends a message to the second network through the above-mentioned communication channel. The agent sends a virtual connection message, where the virtual connection message includes an identifier of the first virtual channel and an identifier of the second service, and the virtual connection message is used to instruct the second network agent to establish a communication channel with the second service. In this way, when the first virtual channel is established, the second network agent is automatically triggered to establish a communication channel with the second service.
第二方面,本申请提供了一种通信方法,该方法应用于容器系统,容器系统包括第一容 器、第二容器、以及前述第一方面及第一方面的任一种实现方式所描述的第一网络代理和第二网络代理。其中,第一容器运行第一服务;第二容器运行第二服务;第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道,其中,第一网络代理负责第一服务的访问,第二网络代理负责第二服务的访问,第一虚拟通道用于传输第一服务和第二服务之间的通信消息,该通信消息中携带有第一虚拟通道的标识,当前第一虚拟通道的标识是第一标识;第一网络代理将第一虚拟通道的标识从第一标识更改为第二标识,其中,第二标识的长度小于第一标识的长度。如此,通过第一虚拟通道传输的通信消息中便可以携带更多的业务数据,从而能够提高第一服务和第二服务之间的通信效率。In a second aspect, this application provides a communication method, which is applied to a container system. The container system includes a first container system. The server, the second container, and the first network agent and the second network agent described in any of the foregoing first aspects and any implementation manner of the first aspect. Wherein, the first container runs the first service; the second container runs the second service; the first network agent establishes a first virtual channel on the communication channel with the second network agent, wherein the first network agent is responsible for the first service The second network agent is responsible for access to the second service. The first virtual channel is used to transmit communication messages between the first service and the second service. The communication message carries the identification of the first virtual channel. Currently, the first virtual channel is used to transmit communication messages between the first service and the second service. The identity of the virtual channel is a first identity; the first network agent changes the identity of the first virtual channel from the first identity to a second identity, where the length of the second identity is less than the length of the first identity. In this way, the communication message transmitted through the first virtual channel can carry more business data, thereby improving the communication efficiency between the first service and the second service.
在第二方面的一种可能的实现方式中,上述通信通道是TCP通道,在第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道之前,上述方法还包括:第一网络代理向第二网络代理发送TCP连接消息,以建立上述通信通道。In a possible implementation of the second aspect, the communication channel is a TCP channel. Before the first network agent establishes the first virtual channel on the communication channel with the second network agent, the method further includes: One network agent sends a TCP connection message to the second network agent to establish the above communication channel.
在第二方面的一种可能的实现方式中,上述通信通道是TCP通道,在第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道之前,上述方法还包括:第二网络代理向第一网络代理发送TCP连接消息,建立上述通信通道。In a possible implementation of the second aspect, the communication channel is a TCP channel. Before the first network agent establishes the first virtual channel on the communication channel with the second network agent, the method further includes: The second network agent sends a TCP connection message to the first network agent to establish the above communication channel.
在第二方面的一种可能的实现方式中,上述第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道,包括:响应于第一服务发送的消息,第一网络代理建立第一虚拟通道,其中,第一服务发送的消息未承载第一服务发往第二服务的业务数据。如此,第一服务和第二服务可以采用例如MySQL之类的应用层协议进行通信,这类协议需要由第二服务(服务端)推动第一服务(客户端)向其发送业务数据。In a possible implementation of the second aspect, the above-mentioned first network agent establishes a first virtual channel on the communication channel with the second network agent, including: in response to a message sent by the first service, the first network agent The agent establishes a first virtual channel, in which the message sent by the first service does not carry the business data sent by the first service to the second service. In this way, the first service and the second service can communicate using an application layer protocol such as MySQL. Such protocols require the second service (server) to push the first service (client) to send business data to it.
第三方面,本申请提供了一种第一网络代理,第一网络代理包括业务访问模块、通道建立模块以及标识更改模块。其中,业务访问模块用于负责第一服务的访问;通道建立模块用于在与第二网络代理之间的通信通道上建立第一虚拟通道,其中,第二网络代理负责第二服务的访问,第一虚拟通道用于传输第一服务和第二服务之间的通信消息,该通信消息中携带有第一虚拟通道的标识,当前第一虚拟通道的标识是第一标识;标识更改模块用于将第一虚拟通道的标识从第一标识更改为第二标识,其中,第二标识的长度小于第一标识的长度。In a third aspect, this application provides a first network agent. The first network agent includes a service access module, a channel establishment module, and an identity change module. Wherein, the business access module is used for accessing the first service; the channel establishment module is used for establishing a first virtual channel on the communication channel with the second network agent, wherein the second network agent is responsible for accessing the second service, The first virtual channel is used to transmit communication messages between the first service and the second service. The communication message carries the identifier of the first virtual channel. The current identifier of the first virtual channel is the first identifier; the identifier changing module is used to The identification of the first virtual channel is changed from the first identification to a second identification, where the length of the second identification is less than the length of the first identification.
第四方面,本申请提供了一种容器系统,该容器系统包括第一容器、第二容器、以及前述第一方面及第一方面的任一种实现方式所描述的第一网络代理和第二网络代理。其中,第一容器用于运行第一服务;第二容器用于运行第二服务;第二网络代理用于负责第二服务的访问;第一网络代理用于负责第一服务的访问,以及在与第二网络代理之间的通信通道上建立第一虚拟通道,其中,第一虚拟通道用于传输第一服务和第二服务之间的通信消息,通信消息中携带有第一虚拟通道的标识,当前第一虚拟通道的标识是第一标识,以及将第一虚拟通道的标识从第一标识更改为第二标识,其中,第二标识的长度小于第一标识的长度。In a fourth aspect, this application provides a container system, which includes a first container, a second container, a first network agent and a second network agent described in any of the foregoing first aspects and any implementation of the first aspect. Web proxy. Wherein, the first container is used to run the first service; the second container is used to run the second service; the second network agent is used to be responsible for access to the second service; the first network agent is used to be responsible for access to the first service, and in A first virtual channel is established on the communication channel with the second network agent, where the first virtual channel is used to transmit communication messages between the first service and the second service, and the communication messages carry the identification of the first virtual channel. , the current identifier of the first virtual channel is the first identifier, and the identifier of the first virtual channel is changed from the first identifier to the second identifier, where the length of the second identifier is smaller than the length of the first identifier.
第五方面,本申请提供了一种计算设备,该计算设备包括处理器和存储器,处理器执行存储器中的计算机程序代码以实现前述第一方面及第一方面的任一种实现方式所描述部分或全部方法。In a fifth aspect, the present application provides a computing device. The computing device includes a processor and a memory. The processor executes the computer program code in the memory to implement the aforementioned first aspect and the part described in any implementation manner of the first aspect. Or all methods.
第六方面,本申请提供了一种计算机可读存储介质,该计算机存储介质存储有计算机程序代码,当计算机程序代码被计算设备执行时,该计算设备执行前述第一方面及第一方面的任一种实现方式所描述部分或全部方法。 In a sixth aspect, the present application provides a computer-readable storage medium. The computer storage medium stores computer program code. When the computer program code is executed by a computing device, the computing device executes the aforementioned first aspect and any of the first aspects. An implementation describes some or all of the methods.
附图说明Description of the drawings
图1是本申请实施例提供的一种调节系统的结构示意图;Figure 1 is a schematic structural diagram of an adjustment system provided by an embodiment of the present application;
图2是本申请实施例提供的一种分布式存储系统的结构示意图;Figure 2 is a schematic structural diagram of a distributed storage system provided by an embodiment of the present application;
图3是本申请实施例提供的一种容器系统的结构示意图;Figure 3 is a schematic structural diagram of a container system provided by an embodiment of the present application;
图4是本申请实施例提供的另一种容器系统的结构示意图;Figure 4 is a schematic structural diagram of another container system provided by an embodiment of the present application;
图5是本申请实施例提供的又一种容器系统的结构示意图;Figure 5 is a schematic structural diagram of yet another container system provided by an embodiment of the present application;
图6是本申请实施例提供的一种Kubernetes容器系统的结构示意图;Figure 6 is a schematic structural diagram of a Kubernetes container system provided by an embodiment of the present application;
图7是本申请实施例提供的一种建立通信通道的方法的流程示意图;Figure 7 is a schematic flowchart of a method for establishing a communication channel provided by an embodiment of the present application;
图8是本申请实施例提供的一种通信方法的流程示意图;Figure 8 is a schematic flowchart of a communication method provided by an embodiment of the present application;
图9是本申请实施例提供的另一种通信方法的流程示意图;Figure 9 is a schematic flowchart of another communication method provided by an embodiment of the present application;
图10是本申请实施例提供的一种第一虚拟通道的标识的更改方法的流程示意图;Figure 10 is a schematic flowchart of a method for changing the identity of a first virtual channel provided by an embodiment of the present application;
图11是本申请实施例提供的一种第一虚拟通道的标识在更改前后的通信的流程示意图;Figure 11 is a schematic flow chart of communication before and after changing the identity of the first virtual channel provided by an embodiment of the present application;
图12是本申请实施例提供的一种基于第一虚拟通道传输的消息的结构示意图;Figure 12 is a schematic structural diagram of a message transmitted based on the first virtual channel provided by an embodiment of the present application;
图13是本申请实施例提供的一种第一网络代理的结构示意图;Figure 13 is a schematic structural diagram of a first network proxy provided by an embodiment of the present application;
图14是本申请实施例提供的一种计算设备的结构示意图;Figure 14 is a schematic structural diagram of a computing device provided by an embodiment of the present application;
图15是本申请实施例提供的一种计算设备系统的结构示意图。Figure 15 is a schematic structural diagram of a computing device system provided by an embodiment of the present application.
具体实施方式Detailed ways
为了方便理解本申请提供的技术方案,在具体描述之前首先进行相关术语的解释。In order to facilitate understanding of the technical solutions provided in this application, relevant terms are first explained before detailed description.
应用(application,APP)是针对用户的某种特殊应用目的所撰写的计算机程序的集合,具体可以是单一的应用程序或者多个应用程序的集合形成的应用软件,例如,应用可以是编辑器等应用程序,也可以是电商系统、政企管理系统等应用软件。An application (APP) is a collection of computer programs written for a special application purpose of the user. Specifically, it can be a single application or a collection of multiple application programs. For example, an application can be an editor, etc. Applications can also be application software such as e-commerce systems and government and enterprise management systems.
容器技术是一种内核虚拟化技术,能够提供轻量级的虚拟化,方便隔离进程和资源。随着容器技术的快速发展,对应用的运行环境以容器(container)为单位进行隔离,并将应用的配置信息和运行环境一同打包封装,再通过容器集群调度技术(如Kubernetes)进行编排和管理,已经成为了一种发展趋势,它可以将大规模应用的部署与生命周期管理,以及应用的迭代开发与上线效率提升到了一个新的高度。因此,越来越多的用户选择将自己的业务以应用的形式部署在云上。Container technology is a kernel virtualization technology that can provide lightweight virtualization and facilitate the isolation of processes and resources. With the rapid development of container technology, the application's operating environment is isolated in units of containers, and the application's configuration information and operating environment are packaged and encapsulated together, and then orchestrated and managed through container cluster scheduling technology (such as Kubernetes) , has become a development trend, which can bring the deployment and life cycle management of large-scale applications, as well as the iterative development and online efficiency of applications to a new level. Therefore, more and more users choose to deploy their business on the cloud in the form of applications.
随着应用规模的不断增长,一个应用往往需要拆分成多个应用服务,多个应用服务部署在多个容器上,多个应用服务协同工作以实现应用具有的功能。本申请中应用服务是指与应用相关的服务,可以理解为用于完成一项或多项具体业务功能的软件系统。在一种实现方式中,可以使用微服务架构(如Spring Cloud、Dubbo)将应用拆分成若干个应用服务。需要说明的是,由微服务架构拆分得到的应用服务也被称为微服务(microservice),各个微服务之间相互解耦,可独立替换、升级以及伸缩。因此,使用微服务架构不仅有助于开发者更新和维护应用,而且在单个微服务出现故障时,其他微服务仍可继续工作,提高了应用的稳定性。As the scale of applications continues to grow, an application often needs to be split into multiple application services. Multiple application services are deployed on multiple containers, and multiple application services work together to realize the functions of the application. Application services in this application refer to application-related services, which can be understood as software systems used to complete one or more specific business functions. In one implementation, a microservice architecture (such as Spring Cloud, Dubbo) can be used to split the application into several application services. It should be noted that the application services split from the microservice architecture are also called microservices (microservices). Each microservice is decoupled from each other and can be independently replaced, upgraded, and scaled. Therefore, using a microservice architecture not only helps developers update and maintain applications, but also allows other microservices to continue working when a single microservice fails, improving the stability of the application.
当构成应用的多个应用服务的规模不断增长时,这些应用服务之间的调用复杂度也在同步增长。于是,出现了服务网格技术,服务网格技术是基于传统网际协议(internet protocol,IP)网络之上的应用网络技术,通过给应用服务分配代理(也称为边车进程(sidecar)),使得应用服务中非功能性的服务治理逻辑从业务进程剥离到边车进程中,从而以无侵入的方式提供应用服务间的连接、安全、流控、灰度发布以及观测能力,实现业务轻量化和服务治理基础 设施化。Istio作为服务网格技术的一种实现方式,通过将envoy作为应用服务的sidecar来实现应用服务之间的通信。由于envoy支持热重启、动态配置以及插件结构,还具备完善的服务治理、流量控制和可观测能力,因而应用服务之间普遍采用Istio实现服务治理。As the scale of the multiple application services that make up an application continues to grow, the complexity of calls between these application services also increases simultaneously. As a result, service mesh technology emerged. Service mesh technology is an application network technology based on the traditional Internet Protocol (IP) network. By assigning agents (also called sidecar processes) to application services, The non-functional service governance logic in application services is separated from the business process into the sidecar process, thereby providing connection, security, flow control, grayscale publishing and observation capabilities between application services in a non-invasive way, and achieving lightweight business and service governance basics Facilityization. As an implementation of service mesh technology, Istio implements communication between application services by using envoy as the sidecar of application services. Because envoy supports hot restart, dynamic configuration and plug-in structure, and also has complete service governance, flow control and observability capabilities, Istio is commonly used among application services to implement service governance.
在一种可能的实现方式中,如图1所示,对于一项应用,采用微服务架构将该应用拆分成多个微服务,将多个微服务部署在多个容器上,采用Kubernetes对上述多个容器进行管理和编排,采用Istio实现多个微服务之间的服务治理。考虑到微服务架构、容器技术、容器集群调度技术以及服务网格技术具有的优势,可以确定通过上述方式不仅可以简化应用的部署难度、维护以及扩展难度,还可以提高应用的稳定性、可靠性以及可用性,为用户提供更高质量的服务。除此之外,还可以更加有效地利用物理主机上的资源。因此,当前许多用户都选择采用上述方式在云上部署应用。In one possible implementation, as shown in Figure 1, for an application, a microservice architecture is used to split the application into multiple microservices, and multiple microservices are deployed on multiple containers. Kubernetes is used to The above multiple containers are managed and orchestrated, and Istio is used to implement service governance between multiple microservices. Taking into account the advantages of microservice architecture, container technology, container cluster scheduling technology and service grid technology, it can be determined that the above methods can not only simplify the deployment difficulty, maintenance and expansion difficulty of applications, but also improve the stability and reliability of applications. and usability to provide users with higher quality services. In addition, resources on the physical host can be utilized more efficiently. Therefore, many users currently choose to deploy applications on the cloud using the above methods.
应理解,无论是应用之间,还是应用服务之间均可能存在通信需求,本申请将应用之间的通信和应用服务间的通信统称为业务之间的通信。目前,业务之间常采用的应用层协议包括HTTP1和关系型数据库管理系统(MySQL),常采用的运输层协议包括TCP。对于采用服务网格技术实现通信的容器化应用,从数据面角度来说,二者之间的通信还需要经由下游代理和上游代理。其中,下游代理是发送请求的一方(即客户端(client))的代理,用于负责客户端的通信;上游代理是接收请求的一方(即服务端(server))的代理,用于负责服务端的通信。值得注意的一点是,“下游代理”和“上游代理”可以具有不同的名称,例如,不同标准、同一标准的不同版本、不同厂商、不同应用场景对“下游代理”和“上游代理”可以具有不同的称呼,例如,术语“下游代理”有时也可以被称为“客户端代理”,“上游代理”有时也可以被称为“服务端代理”。It should be understood that there may be communication requirements between applications or between application services. In this application, communication between applications and communication between application services are collectively referred to as communication between services. Currently, application layer protocols commonly used between businesses include HTTP1 and relational database management system (MySQL), and transport layer protocols commonly used include TCP. For containerized applications that use service mesh technology to achieve communication, from a data plane perspective, the communication between the two also needs to go through a downstream proxy and an upstream proxy. Among them, the downstream agent is the agent of the party that sends the request (i.e., the client) and is used to be responsible for the client's communication; the upstream agent is the agent of the party that receives the request (i.e., the server) and is used to be responsible for the server's communication. communication. It is worth noting that "downstream agent" and "upstream agent" can have different names. For example, different standards, different versions of the same standard, different manufacturers, and different application scenarios can have different names for "downstream agent" and "upstream agent". Different names, for example, the term "downstream proxy" is sometimes also called "client proxy", and "upstream proxy" is sometimes called "server proxy".
如图2所示,要想实现客户端和服务端之间的业务通信,需要先建立客户端和服务端之间的TCP通道,客户端和服务端之间的TCP通道包括三段:客户端与下游代理之间的TCP通道、下游代理与上游代理之间的TCP通道、以及上游代理与服务端之间的TCP通道,这导致客户端和服务端之间建立连接的时间过长。另外,一个TCP通道在同一时间只能处理一个业务请求,而且在一个业务请求完成后,用于传输该业务请求的TCP通道往往需要断开,当客户端与服务端之间的通信频繁时,二者之间的通信时延会逐渐增加,从而导致大量的业务请求因响应超时而失败。这对于时延性要求高的应用(如金融业务、电商业务)来说,会带来较大的影响。针对这一问题,虽然现有技术常采用的两种方式(具体可参见背景技术),可以在一定程度上减少客户端和服务端之间的通信时延,但是这两种方式的使用范围十分局限。例如,方式①中提到的HTTP2和proxyprotocol不支持代理MySQL这类建立通信通道后由服务端主动向客户端推送数据的应用层协议,也不支持反向连接(即由服务端向客户端发起的连接)的建立。又例如,利用方式②需要对内核协议栈进行修改,而且客户端需要使用新的套接字(socket)接口来建立与服务端的连接,这就导致该方式的通用性不高。As shown in Figure 2, in order to realize business communication between the client and the server, a TCP channel between the client and the server needs to be established first. The TCP channel between the client and the server consists of three sections: client The TCP channel with the downstream proxy, the TCP channel between the downstream proxy and the upstream proxy, and the TCP channel between the upstream proxy and the server, which causes the connection establishment time between the client and the server to be too long. In addition, a TCP channel can only handle one service request at the same time, and after a service request is completed, the TCP channel used to transmit the service request often needs to be disconnected. When communication between the client and the server is frequent, The communication delay between the two will gradually increase, causing a large number of business requests to fail due to response timeouts. This will have a greater impact on applications with high latency requirements (such as financial services and e-commerce services). To address this problem, although there are two methods commonly used in the existing technology (for details, please refer to the background art), which can reduce the communication delay between the client and the server to a certain extent, the scope of use of these two methods is very limited. limitations. For example, HTTP2 and proxyprotocol mentioned in method ① do not support application layer protocols such as proxy MySQL, in which the server actively pushes data to the client after establishing a communication channel, nor do they support reverse connections (that is, initiated by the server to the client). connection) is established. For another example, the utilization method ② requires modification of the kernel protocol stack, and the client needs to use a new socket interface to establish a connection with the server, which results in the low versatility of this method.
针对上述问题,本申请提供了一种代理协议,代理协议包括如下内容:响应于客户端发送的消息(该消息可以承载或者不承载客户端想要发送至服务端的业务数据),下游代理在与上游代理之间的通信通道上建立虚拟通道,其中,该虚拟通道用于传输客户端和服务端之间的通信消息。在上述虚拟通道建立完成后,下游代理存储该虚拟通道的标识与客户端的标识之间的映射关系,上游代理存储该虚拟通道的标识与服务端的标识之间的映射关系。这样,当下游代理接收到客户端想要发往服务端的业务数据(如HTTP1消息、MySQL消息)时,下游代理可以基于本地存储的映射关系使用虚拟通道的标识对上述业务数据进行封装,再通 过虚拟通道将封装后的业务数据发送至上游代理。相应地,上游代理也可以基于本地存储的映射关系使用虚拟通道的标识对上述封装后的业务数据进行解封装,并将解封装得到的业务数据转发至服务端。类似的,当上述代理接收到服务端想要返回至客户端的业务数据(如HTTP1消息、MySQL消息)时,上游代理和下游代理可以基于各自存储的映射关系将上述业务数据从服务端发送至客户端。In response to the above problems, this application provides a proxy protocol. The proxy protocol includes the following content: in response to a message sent by the client (the message may or may not carry the business data that the client wants to send to the server), the downstream agent communicates with A virtual channel is established on the communication channel between the upstream agents, where the virtual channel is used to transmit communication messages between the client and the server. After the above virtual channel is established, the downstream agent stores the mapping relationship between the identifier of the virtual channel and the identifier of the client, and the upstream agent stores the mapping relationship between the identifier of the virtual channel and the identifier of the server. In this way, when the downstream agent receives the business data (such as HTTP1 messages, MySQL messages) that the client wants to send to the server, the downstream agent can use the virtual channel identifier to encapsulate the above business data based on the locally stored mapping relationship, and then pass it through Send the encapsulated business data to the upstream agent through the virtual channel. Correspondingly, the upstream agent can also use the identification of the virtual channel to decapsulate the above-mentioned encapsulated business data based on the locally stored mapping relationship, and forward the decapsulated business data to the server. Similarly, when the above agent receives the business data that the server wants to return to the client (such as HTTP1 message, MySQL message), the upstream agent and the downstream agent can send the above business data from the server to the client based on their respective stored mapping relationships. end.
除此之外,该代理协议还支持:①下游代理与上游代理之间的通信通道可以是TCP通道,而且该TCP通道可以是正向的TCP通道,也可以是反向的TCP通道。其中,正向的TCP通道是指由下游代理向上游代理发送TCP连接消息而建立得到的TCP通道,反向的TCP通道是指由上游代理向下游代理发送TCP连接消息而建立得到的TCP通道。②下游代理与上游代理之间可以建立多条通信通道,虚拟通道可以灵活地建立在上述任一条通信通道上。③下游代理与上游代理之间的通信通道上可以建立多条虚拟通道,而且虚拟通道的标识可以进行更改。In addition, the proxy protocol also supports: ① The communication channel between the downstream proxy and the upstream proxy can be a TCP channel, and the TCP channel can be a forward TCP channel or a reverse TCP channel. Among them, the forward TCP channel refers to the TCP channel established by the downstream agent sending a TCP connection message to the upstream agent, and the reverse TCP channel refers to the TCP channel established by the upstream agent sending a TCP connection message to the downstream agent. ② Multiple communication channels can be established between the downstream agent and the upstream agent, and the virtual channel can be flexibly established on any of the above communication channels. ③ Multiple virtual channels can be established on the communication channel between the downstream agent and the upstream agent, and the identifier of the virtual channel can be changed.
上述代理协议可以应用于部署有应用的容器系统上。图3示例性地展示了一种容器系统的结构示意图,如图3所示,容器系统100包括控制节点110和多个计算节点120。下面简要描述容器系统100的各个部分。The above proxy protocol can be applied to container systems where applications are deployed. Figure 3 exemplarily shows a schematic structural diagram of a container system. As shown in Figure 3, the container system 100 includes a control node 110 and a plurality of computing nodes 120. The various components of container system 100 are briefly described below.
控制节点110可以是物理主机,也可以是虚拟机(virtual machine,VM)。控制节点110用于管理和控制容器系统100中资源的调度以及任务的执行,例如,管理多个计算节点120上的资源(包括计算资源、存储资源和网络资源);又例如,基于各个计算节点120上资源的使用情况将应用分配到合适的计算节点120上运行。The control node 110 may be a physical host or a virtual machine (VM). The control node 110 is used to manage and control the scheduling of resources and the execution of tasks in the container system 100, for example, managing resources (including computing resources, storage resources and network resources) on multiple computing nodes 120; for example, based on each computing node The resource usage on 120 allocates the application to the appropriate computing node 120 for running.
与控制节点110类似的,计算节点120也可以是物理主机,或者是VM。计算节点120包括一个或多个容器组121,其中,容器组121是容器系统100中的最小部署单元,每个容器组121具有对应的网际协议(internet protocol,IP)地址,而且每个容器组121包括一个或多个容器1211,每个容器1211上可以运行一个或多个服务,此处的服务可以是应用,也可以是构成应用的应用服务(如微服务)。计算节点120还包括网络代理122,网络代理122用于负责本节点中业务的访问(以下将这种用于负责计算节点中业务的访问的网络代理简称为节点代理),例如,将外部的业务请求转发至对应的容器上,以及将本地的业务响应转发出去。在一种可能的实现方式中,网络代理122可以以容器的形式部署在计算节点120上,也可以以装置的形式部署在计算节点120上。其中,当网络代理122以装置的形式部署在计算节点120上时,网络代理122可以是软件系统、也可以是硬件设备,还可以是软件系统和硬件设备的结合。Similar to the control node 110, the computing node 120 may also be a physical host or a VM. The computing node 120 includes one or more container groups 121, where the container group 121 is the smallest deployment unit in the container system 100. Each container group 121 has a corresponding Internet Protocol (IP) address, and each container group 121 includes one or more containers 1211. Each container 1211 can run one or more services. The service here can be an application or an application service (such as a microservice) that constitutes an application. The computing node 120 also includes a network agent 122. The network agent 122 is responsible for accessing services in the node (hereinafter, this network agent responsible for accessing services in the computing node will be referred to as a node agent for short). For example, the network agent 122 is responsible for accessing external services. The request is forwarded to the corresponding container and the local business response is forwarded. In a possible implementation manner, the network agent 122 can be deployed on the computing node 120 in the form of a container, or can also be deployed on the computing node 120 in the form of a device. When the network agent 122 is deployed on the computing node 120 in the form of a device, the network agent 122 may be a software system, a hardware device, or a combination of a software system and a hardware device.
应理解,图3仅仅示出了容器系统的一种示例性的结构,在实际应用中,上述容器系统还可能具有其他的结构,例如,图4示出的容器系统200和图5示出的容器系统300。相较于图3示出的容器系统100,图4示出的容器系统200中,多个计算节点220中的每个容器组221除了包括一个或多个容器2211,还包括网络代理2212,其中,网络代理2212用于负责本容器组中业务的访问(以下将这种用于负责容器组中业务的访问的网络代理简称为容器组代理)。相较于图3示出的容器系统100,图5示出的容器系统300中,一部分计算节点320中的网络代理是节点代理,即网络代理322,一部分计算节点320中的网络代理是容器组代理,即网络代理3212。需要说明的是,图4示出的容器系统200和图5示出的容器系统300中的其他部分,例如,控制节点210、计算节点220、容器组221、容器2211,以及控制节点310、计算节点320、容器组321、容器3211的功能,与图3示出的容器系统100中的控制节点110、计算节点120、容器组121、容器1211的功能类似,为了简便,本申请实施例不再 对上述类似的部分进行描述。It should be understood that Figure 3 only shows an exemplary structure of the container system. In actual applications, the above-mentioned container system may also have other structures, for example, the container system 200 shown in Figure 4 and the container system 200 shown in Figure 5 Container system 300. Compared with the container system 100 shown in Figure 3, in the container system 200 shown in Figure 4, each container group 221 in the multiple computing nodes 220 includes not only one or more containers 2211, but also a network agent 2212, where , the network agent 2212 is responsible for accessing services in this container group (hereinafter, this network agent responsible for accessing services in the container group is referred to as a container group agent for short). Compared with the container system 100 shown in Figure 3, in the container system 300 shown in Figure 5, the network agents in some computing nodes 320 are node agents, that is, the network agents 322, and the network agents in some computing nodes 320 are container groups. Agent, i.e. network agent 3212. It should be noted that other parts in the container system 200 shown in Figure 4 and the container system 300 shown in Figure 5, such as the control node 210, the computing node 220, the container group 221, the container 2211, and the control node 310, computing node The functions of the node 320, the container group 321, and the container 3211 are similar to the functions of the control node 110, the computing node 120, the container group 121, and the container 1211 in the container system 100 shown in Figure 3. For simplicity, the embodiments of this application will not Describe similar sections as above.
本申请实施例涉及的容器系统(包括容器系统100、容器系统200以及容器系统300)中的容器可以使用Kubernetes、Docker swarm、Docker compose或者是apachemesos等多种工具进行编排。Containers in the container system (including container system 100, container system 200, and container system 300) involved in the embodiment of this application can be orchestrated using various tools such as Kubernetes, Docker swarm, Docker compose, or apache Mesos.
示例性的,在容器系统中的容器使用Kubernetes进行编排的情况下,如图6所示,以容器系统100为例,控制节点110也被称为master节点,计算节点120也被称为node节点,计算节点120中的容器组121此处是指Pod。除此之外,控制节点110可以包括以下一个或多个组件:应用程序编程接口服务组件(applicationprogramminginterfaceserver,API server)111、控制管理组件(controllermanager)112、调度组件(scheduler)113以及存储组件(ETCD)114,通过这些组件来管理和控制容器系统100中资源的调度以及任务的执行。其中,应用程序编程接口服务组件111用于接收外部请求,以及作为其他组件互相通讯的中转站,还用于将接收到的各种信息写入存储组件114;控制管理组件112用于执行集群级操作,例如,查看计算节点120的配置信息、处理计算节点120的故障、对计算节点120上的容器1211进行管控等;调度组件113负责应用的调度,例如,将部署有应用的容器调度到合适的计算节点120上运行;存储组件114用于存储容器系统100上的所有信息,例如,应用程序编程接口服务组件111写入的信息。计算节点120上还可以包括Kubelet组件123和容器运行(container runtime)组件124。其中,Kubelet组件123主要负责同容器运行组件124和控制节点110中的应用程序编程接口服务组件111进行交互,以此来管理本节点上的容器1211,例如,将控制节点110下发到本节点的任务分配至容器,或者定期向控制节点110上报本节点上资源的使用情况。容器运行组件124用于在容器1211运行时下载镜像,以及控制容器1211的运行。For example, when the containers in the container system are orchestrated using Kubernetes, as shown in Figure 6, taking the container system 100 as an example, the control node 110 is also called the master node, and the computing node 120 is also called the node node. , the container group 121 in the computing node 120 here refers to Pod. In addition, the control node 110 may include one or more of the following components: an application programming interface server (API server) 111, a control management component (controller manager) 112, a scheduling component (scheduler) 113, and a storage component (ETCD). ) 114, these components are used to manage and control the scheduling of resources and the execution of tasks in the container system 100. Among them, the application programming interface service component 111 is used to receive external requests and serve as a transfer station for other components to communicate with each other. It is also used to write various received information to the storage component 114; the control management component 112 is used to execute cluster-level Operations, for example, view the configuration information of the computing node 120, handle the failure of the computing node 120, manage and control the container 1211 on the computing node 120, etc.; the scheduling component 113 is responsible for the scheduling of the application, for example, scheduling the container with the application deployed to the appropriate location. running on the computing node 120; the storage component 114 is used to store all information on the container system 100, for example, information written by the application programming interface service component 111. The computing node 120 may also include a Kubelet component 123 and a container runtime component 124. Among them, the Kubelet component 123 is mainly responsible for interacting with the container running component 124 and the application programming interface service component 111 in the control node 110 to manage the container 1211 on this node, for example, sending the control node 110 to this node Allocate tasks to containers, or regularly report the usage of resources on this node to the control node 110. The container running component 124 is used to download the image when the container 1211 is running, and control the running of the container 1211.
应理解,图6仅仅是一种示例性的展示,在实际应用中,容器系统200和容器系统300也可以使用Kubernetes进行容器编排。另外,本申请实施例涉及的容器系统还可以使用其他的工具进行容器编排,对此本申请实施例不作限定,但为了简便,此处不再展开描述。It should be understood that Figure 6 is only an exemplary display. In actual applications, the container system 200 and the container system 300 can also use Kubernetes for container orchestration. In addition, the container system involved in the embodiments of the present application can also use other tools for container orchestration, which is not limited by the embodiments of the present application, but for the sake of simplicity, the description will not be repeated here.
由前文可知,容器系统(包括图3-图6所示的容器系统)中的容器上可以运行服务,而不同的服务之间存在通信的需求。当服务之间的通信需要跨网络代理实现时,利用本申请提供的代理协议可以减少通信时延,从而提高服务之间的通信效率。下面以运行在上述容器系统上的第一服务和第二服务之间的通信为例,结合图7-图12详细地描述本申请提供的代理协议如何实现第一服务和第二服务之间的通信。As can be seen from the foregoing, services can be run on the containers in the container system (including the container system shown in Figures 3 to 6), and there are communication requirements between different services. When communication between services needs to be implemented across network proxies, the proxy protocol provided by this application can be used to reduce communication delay, thereby improving communication efficiency between services. The following takes the communication between the first service and the second service running on the above-mentioned container system as an example, and describes in detail how the proxy protocol provided by this application realizes the communication between the first service and the second service in conjunction with Figures 7-12. communication.
首先,需要说明的是,第一服务和第二服务可以是应用,也可以是构成应用的应用服务。例如,第一服务和第二服务可以是不同的应用,或者是构成同一个应用的不同应用服务,又或者是构成不同应用的应用服务;又例如,第一服务是一个应用,第二服务是构成另一个应用的应用服务,或者第二服务是一个应用,第一服务是构成另一个应用的应用服务。而且,负责第一服务的访问的网络代理和负责第二服务的访问的网络代理不同。First, it should be noted that the first service and the second service may be applications or application services constituting applications. For example, the first service and the second service may be different applications, or different application services that constitute the same application, or application services that constitute different applications; for another example, the first service is an application, and the second service is An application service that constitutes another application, or the second service is an application and the first service is an application service that constitutes another application. Furthermore, the network agent responsible for access to the first service is different from the network agent responsible for access to the second service.
容器系统包括两类容器组:具有运行第一服务的容器的第一类容器组,和具有运行第二服务的容器的第二类容器组。其中,第一类容器组可以包括一个或多个运行第一服务的容器,第二类容器组也可以包括一个或多个运行第二服务的容器。The container system includes two types of container groups: a first type container group having containers running a first service, and a second type container group having containers running a second service. The first type of container group may include one or more containers running the first service, and the second type container group may also include one or more containers running the second service.
可选的,第一类容器组和第二类容器组的数量均可以是一个或多个。上述一个或多个第一类容器组可以位于容器系统中的一个或多个计算节点上,一个或多个第二类容器组也可以位于容器系统中的一个或多个计算节点上。而且,第一类容器组和第二类容器组可以位于同一个计算节点上,也可以位于不同的计算节点上。但值得注意的是,当第一类容器组和第二 类容器组位于同一个计算节点上时,负责第一服务的访问的网络代理可以位于第一类容器组内,负责第二服务的访问的网络代理可以位于第二类容器组内。如此,可以保证负责第一服务的访问的网络代理与负责第二服务的访问的网络代理不同。Optionally, the number of the first type of container group and the number of the second type of container group can be one or more. The above-mentioned one or more first-type container groups may be located on one or more computing nodes in the container system, and the one or more second-type container groups may also be located on one or more computing nodes in the container system. Moreover, the first type of container group and the second type of container group may be located on the same computing node, or may be located on different computing nodes. But it is worth noting that when the first type of container group and the second type When the class container group is located on the same computing node, the network agent responsible for access to the first service may be located in the first class container group, and the network agent responsible for access to the second service may be located in the second class container group. In this way, it can be ensured that the network agent responsible for access to the first service is different from the network agent responsible for access to the second service.
还需要说明的是,上述容器系统可以是图3-图6示出的任一个容器系统,换言之,第一类容器组及其所在的计算节点、第二类容器组及其所在的计算节点、运行第一服务的容器和运行第二服务的容器、负责第一服务的访问的网络代理和负责第二服务的访问的网络代理可以是对应容器系统中的计算节点、容器组、容器以及网络代理,本申请不作具体限定,在实际应用中,可以根据容器系统上的资源使用情况、具体的业务需求进行适应性调整和部署。It should also be noted that the above-mentioned container system can be any of the container systems shown in Figures 3 to 6. In other words, the first type of container group and the computing node where it is located, the second type of container group and the computing node where it is located, The container running the first service and the container running the second service, the network agent responsible for access to the first service and the network agent responsible for access to the second service may be computing nodes, container groups, containers and network agents in the corresponding container system. , this application does not make specific limitations. In actual applications, adaptive adjustment and deployment can be made according to the resource usage and specific business requirements on the container system.
假设,第一服务想要向第二服务发送业务数据D1,此时第一服务会作为客户端,第二服务会作为服务端。第一服务和第二服务之间的通信过程可以分为以下两个阶段。Assume that the first service wants to send business data D 1 to the second service. At this time, the first service will act as the client and the second service will act as the server. The communication process between the first service and the second service can be divided into the following two stages.
第一阶段、第一服务和第二服务之间的通信通道的建立(如图7所示)The first phase, the establishment of the communication channel between the first service and the second service (shown in Figure 7)
S101:第一服务建立与第一网络代理之间的第一通信通道。S101: The first service establishes a first communication channel with the first network agent.
其中,第一服务运行在第一容器组中的容器上,第一容器组属于第一类容器组。第一网络代理(即前文中的下游代理)用于负责第一服务的访问,第一网络代理可以是容器组代理(如网络代理2212),也可以是节点代理(如网络代理122)。The first service runs on a container in a first container group, and the first container group belongs to the first type of container group. The first network agent (ie, the downstream agent in the preceding article) is responsible for accessing the first service. The first network agent may be a container group agent (such as network agent 2212) or a node agent (such as network agent 122).
在一些实施例中,第一通信通道是TCP通道,那么第一服务建立与第一网络代理之间的第一通信通道,包括:第一服务向第一网络代理发送第一通信通道的建立请求,第一网络代理接收到上述请求后,向第一服务返回确认建立第一通信通道的响应,第一服务接收到上述响应后,再次向第一网络代理发送确认建立第一通信通道的消息,通过上述三次握手后,第一容器组和第一网络代理之间的第一通信通道建立完成。In some embodiments, the first communication channel is a TCP channel, then the first service establishes the first communication channel with the first network agent, including: the first service sends a first communication channel establishment request to the first network agent. , after receiving the above request, the first network agent returns a response confirming the establishment of the first communication channel to the first service. After receiving the above response, the first service again sends a message confirming the establishment of the first communication channel to the first network agent, After the above three-way handshake, the first communication channel between the first container group and the first network agent is established.
S102:第一服务通过第一通信通道向第一网络代理发送第一消息。S102: The first service sends the first message to the first network agent through the first communication channel.
其中,第一消息用于指示第一网络代理建立与第二服务之间的通信通道,第一消息包括第二服务的服务名、第二服务的IP地址以及第二服务的端口(端口A)中的至少一个,端口A是第二容器组上用于收发与第二服务有关的消息的端口。The first message is used to instruct the first network agent to establish a communication channel with the second service. The first message includes the service name of the second service, the IP address of the second service and the port of the second service (port A). At least one of them, port A is a port on the second container group used to send and receive messages related to the second service.
可选的,第一消息可以承载业务数据D1,也可以不承载业务数据D1。其中,业务数据D1是指基于第一服务和第二服务之间的应用层协议生成的消息,由于第一服务和第二服务可以使用多种应用层协议实现通信,例如HTTP1和MySQL,因此业务数据D1可以是HTTP1消息、或者是MySQL消息等。当第一消息不承载业务数据D1时,第一消息可以是连接类消息,即用于建立通信通道的消息,例如TCP三次握手消息。Optionally, the first message may carry the service data D 1 , or may not carry the service data D 1 . Among them, the business data D 1 refers to the message generated based on the application layer protocol between the first service and the second service. Since the first service and the second service can use multiple application layer protocols to implement communication, such as HTTP1 and MySQL, therefore The business data D 1 can be an HTTP1 message, a MySQL message, etc. When the first message does not carry the service data D 1 , the first message may be a connection type message, that is, a message used to establish a communication channel, such as a TCP three-way handshake message.
S103:第一网络代理基于第一消息确定第二网络代理。S103: The first network agent determines the second network agent based on the first message.
具体地,第一网络代理接收到第一消息后,基于第一消息确定第二服务,然后基于第二服务确定第二容器组,之后再基于第二容器组确定第二网络代理(即前文中的上游代理)。其中,第二容器组属于第二类容器组,即第二容器组包括运行有第二服务的容器,第二网络代理用于负责第二容器组中业务(包括第二服务)的访问,第二网络代理可以是容器组代理(如网络代理2212),也可以是节点代理(如网络代理122)。Specifically, after receiving the first message, the first network agent determines the second service based on the first message, then determines the second container group based on the second service, and then determines the second network agent based on the second container group (i.e., as mentioned above the upstream agent). Wherein, the second container group belongs to the second type of container group, that is, the second container group includes containers running the second service, and the second network agent is used to be responsible for access to the business (including the second service) in the second container group. The second network agent may be a container group agent (such as network agent 2212) or a node agent (such as network agent 122).
进一步地,考虑到第二服务可以运行在多个第二类容器组上,因此第一网络代理基于第二服务确定第二容器组,包括:第一网络代理基于第二服务确定多个第二类容器组,然后使用负载均衡算法从上述多个第二类容器组中确定第二容器组。其中,负载均衡算法可以包括轮询算法、随机算法、最小连接算法等,本申请实施例不作限定。Further, considering that the second service can run on multiple second-type container groups, the first network agent determines the second container group based on the second service, including: the first network agent determines multiple second container groups based on the second service. class container group, and then use a load balancing algorithm to determine a second container group from the plurality of second class container groups. The load balancing algorithm may include a polling algorithm, a random algorithm, a minimum connection algorithm, etc., which are not limited in the embodiments of this application.
需要说明的是,由于第一消息可以承载业务数据D1,也可以不承载业务数据D1,相较于第一消息不承载有业务数据D1,当第一消息承载有业务数据D1时,第一网络代理需要对第 一消息进行更多的处理(即使用应用层协议对第一消息中的业务数据D1解封装)才能确定第二网络代理。It should be noted that since the first message may carry the service data D 1 or not, compared with the first message not carrying the service data D 1 , when the first message carries the service data D 1 , the first network agent needs to The second network agent can only be determined by performing more processing on a message (that is, using an application layer protocol to decapsulate the service data D1 in the first message).
S104:第一网络代理判断与第二网络代理之间的第二通信通道是否已建立。如果第二通信通道未建立,则执行S105-S110;如果第二通信通道已建立,则执行S106-S110。S104: The first network agent determines whether the second communication channel with the second network agent has been established. If the second communication channel is not established, S105-S110 is executed; if the second communication channel is established, S106-S110 is executed.
其中,第二通信通道可以是TCP通道。当第二通信通道是TCP通道时,第二通信通道可以是正向的TCP通道,也可以是反向的TCP通道。正向的TCP通道是指由第一网络代理向第二网络代理发送TCP连接消息而建立得到的TCP通道,其具体建立过程请参见S105;反向的TCP通道是指由第二网络代理向第一网络代理发送TCP连接消息而建立得到的TCP通道,其具体建立过程请参见下述描述。Wherein, the second communication channel may be a TCP channel. When the second communication channel is a TCP channel, the second communication channel may be a forward TCP channel or a reverse TCP channel. The forward TCP channel refers to the TCP channel established by the first network agent sending a TCP connection message to the second network agent. For the specific establishment process, please refer to S105; the reverse TCP channel refers to the TCP channel established by the second network agent to the second network agent. A TCP channel is established by sending a TCP connection message through a network agent. Please refer to the following description for the specific establishment process.
当第二通信通道是反向的TCP通道时,在第一网络代理执行S104之前,第二通信通道就已经建立完成。具体地,第二网络代理向第一网络代理发送第二通信通道的建立请求。第一网络代理接收到上述请求后,向第二网络代理返回确认建立第二通信通道的响应。第二网络代理接收到上述响应后,再次向第一网络代理发送确认建立第二通信通道的消息,从而完成了第二通信通道的建立。另外,在第二通信通道建立完成之后,第一网络代理还存储第二网络代理的标识与第二通信通道的标识之间的映射关系。其中,第二网络代理的标识可以是第一网络代理或容器系统中的控制节点(如控制节点110、控制节点210以及控制节点310)为第二网络代理分配的ID、编号等能够用于标识第二网络代理的信息,或者,第二网络代理的标识可以基于第二网络代理的类型进行灵活的设置,例如,当第二网络代理是容器组代理时,第二网络代理的标识可以是第二容器组的IP地址;当第二网络代理是节点代理时,第二网络代理的标识可以是第二网络代理所在的计算节点的IP地址。第二通信通道的标识可以是第一网络代理或容器系统中的控制节点为第二通信通道分配的ID、编号等能够用于标识第二通信通道的信息。When the second communication channel is a reverse TCP channel, the second communication channel has been established before the first network agent executes S104. Specifically, the second network agent sends the establishment request of the second communication channel to the first network agent. After receiving the above request, the first network agent returns a response confirming the establishment of the second communication channel to the second network agent. After receiving the above response, the second network agent sends a message confirming the establishment of the second communication channel to the first network agent again, thus completing the establishment of the second communication channel. In addition, after the establishment of the second communication channel is completed, the first network agent also stores a mapping relationship between the identifier of the second network agent and the identifier of the second communication channel. The identification of the second network agent may be an ID, number, etc. assigned to the second network agent by the first network agent or a control node (such as the control node 110, the control node 210, and the control node 310) in the container system, which can be used to identify the second network agent. The information of the second network agent or the identity of the second network agent can be flexibly set based on the type of the second network agent. For example, when the second network agent is a container group agent, the identity of the second network agent can be the second network agent. The IP address of the second container group; when the second network agent is a node agent, the identifier of the second network agent may be the IP address of the computing node where the second network agent is located. The identification of the second communication channel may be an ID, a number, or other information assigned to the second communication channel by the first network agent or the control node in the container system, which can be used to identify the second communication channel.
在一些实施例中,第一网络代理判断与第二网络代理之间的第二通信通道是否已建立,包括:当第一网络代理存储有第二网络代理的标识与第二通信通道的标识之间的映射关系时,第一网络代理确定第二通信通道已建立;当第一网络代理未存储有第二网络代理的标识与第二通信通道的标识之间的映射关系时,第一网络代理确定第二通信通道未建立。In some embodiments, the first network agent determines whether the second communication channel with the second network agent has been established, including: when the first network agent stores an identifier of the second network agent and an identifier of the second communication channel. When the first network agent determines that the second communication channel has been established; when the first network agent does not store the mapping relationship between the identifier of the second network agent and the identifier of the second communication channel, the first network agent It is determined that the second communication channel is not established.
可选的,第一服务可以是运行在公网中的服务,第二服务可以是运行在私网(如虚拟私有云(virtual private cloud,VPC))中的服务。那么,当第二通信通道可以是反向的TCP通道时,意味着本申请提供的代理支持运行在公网中的服务访问运行在私网中的服务。值得注意的一点是,考虑到实际应用中可能出现以下情况:存在多个私网的IP地址与上述运行有第二服务的私网的IP地址相同,因此,第二网络代理的标识可以包括私网的标识和私网的IP地址。Optionally, the first service may be a service running in a public network, and the second service may be a service running in a private network (such as a virtual private cloud (VPC)). Then, when the second communication channel can be a reverse TCP channel, it means that the proxy provided by this application supports services running in the public network to access services running in the private network. It is worth noting that considering that the following situation may occur in actual applications: there are multiple private networks with the same IP address as the above-mentioned private network running the second service. Therefore, the identifier of the second network proxy may include private network. The network identifier and the IP address of the private network.
S105:第一网络代理建立与第二网络代理之间的第二通信通道。S105: The first network agent establishes a second communication channel with the second network agent.
具体地,第一网络代理向第二网络代理发送第二通信通道的建立请求。第二网络代理接收到上述请求后,向第一网络代理返回确认建立第二通信通道的响应。第一网络代理接收到上述响应后,再次向第二网络代理发送确认建立第二通信通道的消息,从而完成了第二通信通道的建立。Specifically, the first network agent sends the establishment request of the second communication channel to the second network agent. After receiving the above request, the second network agent returns a response confirming the establishment of the second communication channel to the first network agent. After receiving the above response, the first network agent sends a message confirming the establishment of the second communication channel to the second network agent again, thus completing the establishment of the second communication channel.
可选的,为了提高第一服务和第二服务之间通信的安全性,第二通信通道建立成功后(此处的第二通信通道包括正向的TCP通道和反向的TCP通道),第一网络代理还可以在第二通信通道上建立安全通道,例如,安全套接层(secure socket layer,SSL)连接、传输层安全协议(transport layer security,TLS)连接。以SSL通道为例,第一网络代理可以通过以下方式在 第二通信通道上建立安全通道:首先,第一网络代理通过第二通信通道向第二网络代理发送安全通道的建立请求(如client hello消息),第二网络代理接收到上述请求后,通过第二通信通道向第一网络代理返回相应的响应消息(如server hello消息),其中,上述响应消息包括第二网络代理生成的密钥对中的公钥。之后,第一网络代理生成会话密钥,并使用公钥对会话密钥进行加密,再将加密后的会话密钥通过第二通信通道发送至第二网络代理。第二网络代理接收到上述加密后的会话密钥后,使用私钥对上述加密后的会话密钥进行解密得到上述会话密钥。之后,第一网络代理和第二网络代理便可以使用上述会话密钥对待传输的数据进行加密,从而完成SSL通道的建立。应理解,在实际应用中,除了可以在第二通信通道上建立安全通道,还可以在前文中的第一通信通道以及后文中的第三通信通道上建立安全通道,其具体建立过程可参见在第二通信通道上建立安全通道的过程,为了简便此处不再展开描述。Optionally, in order to improve the security of communication between the first service and the second service, after the second communication channel is successfully established (the second communication channel here includes a forward TCP channel and a reverse TCP channel), the second communication channel is A network proxy can also establish a secure channel on the second communication channel, for example, a secure socket layer (SSL) connection or a transport layer security (TLS) connection. Taking the SSL channel as an example, the first network proxy can use the following method to Establishing a secure channel on the second communication channel: First, the first network agent sends a secure channel establishment request (such as a client hello message) to the second network agent through the second communication channel. After receiving the above request, the second network agent sends the request to the second network agent through the second communication channel. The second communication channel returns a corresponding response message (such as a server hello message) to the first network agent, where the above response message includes the public key in the key pair generated by the second network agent. Afterwards, the first network agent generates a session key, uses the public key to encrypt the session key, and then sends the encrypted session key to the second network agent through the second communication channel. After receiving the encrypted session key, the second network agent uses the private key to decrypt the encrypted session key to obtain the session key. Afterwards, the first network agent and the second network agent can use the session key to encrypt the data to be transmitted, thereby completing the establishment of the SSL channel. It should be understood that in practical applications, in addition to establishing a secure channel on the second communication channel, a secure channel can also be established on the first communication channel mentioned above and the third communication channel mentioned below. The specific establishment process can be found in The process of establishing a secure channel on the second communication channel will not be described here for simplicity.
可选的,在第二通信通道建立完成之后,第一网络代理还存储第二网络代理的标识与第二通信通道的标识之间的映射关系。Optionally, after the second communication channel is established, the first network agent also stores a mapping relationship between the identifier of the second network agent and the identifier of the second communication channel.
S106:第一网络代理将第二通信通道配置为代理通道。S106: The first network agent configures the second communication channel as a proxy channel.
在一些实施例中,第一网络代理将第二通信通道配置为代理通道,包括:第一网络代理通过第二通信通道向第二网络代理发送第一协商请求,其中,第一协商请求用于与第二网络代理协商将第二通信通道配置为代理通道,代理通道是指基于代理协议传输消息的通道,代理通道支持复用,即代理通道上可以传输至少两个服务(包括第一服务和第二服务)之间的通信消息。第二网络代理接收到第一协商请求后,基于第一协商请求将第二通信通道配置为代理通道,并向第一网络代理返回第一协商响应,以告知第一网络代理确认将第二通信通道配置为代理通道。In some embodiments, the first network agent configures the second communication channel as a proxy channel, including: the first network agent sends a first negotiation request to the second network agent through the second communication channel, wherein the first negotiation request is used to Negotiate with the second network agent to configure the second communication channel as a proxy channel. The proxy channel refers to a channel that transmits messages based on the proxy protocol. The proxy channel supports multiplexing, that is, at least two services (including the first service and the first service) can be transmitted on the proxy channel. communication messages between the second service). After receiving the first negotiation request, the second network agent configures the second communication channel as a proxy channel based on the first negotiation request, and returns a first negotiation response to the first network agent to inform the first network agent to confirm that the second communication channel will be used. The channel is configured as a proxy channel.
其中,第一协商请求和第一协商响应均包括协商标识,协商标识用于表示该消息是用于协商是否将某个通信通道配置为代理通道,协商标识可以是魔术字(magic number)或者校验符等。Among them, both the first negotiation request and the first negotiation response include a negotiation identifier. The negotiation identifier is used to indicate that the message is used to negotiate whether to configure a certain communication channel as a proxy channel. The negotiation identifier can be a magic number or a calibration number. Verifier, etc.
可选的,第一协商请求还包括第二通信通道的标识。此处,第二通信通道的标识除了可以是上述S104中提及的由第一网络代理或容器系统中的控制节点为第二通信通道分配的ID、编号,还可以是第一网络代理的IP地址。需要说明的是,当第二通信通道的标识是第一网络代理的IP地址时,第二网络代理接收到第一协商请求后,先基于第二通信通道的标识确定第一网络代理,再基于第一网络代理确定第二通信通道,之后,结合第一协商请求中的协商标识获知第一网络代理想要与之协商是否要将第二通信通道配置为代理通道。Optionally, the first negotiation request also includes an identification of the second communication channel. Here, in addition to the ID and number assigned to the second communication channel by the first network agent or the control node in the container system mentioned in S104 above, the identifier of the second communication channel may also be the IP of the first network agent. address. It should be noted that when the identifier of the second communication channel is the IP address of the first network agent, after receiving the first negotiation request, the second network agent first determines the first network agent based on the identifier of the second communication channel, and then determines the first network agent based on the identifier of the second communication channel. The first network agent determines the second communication channel, and then uses the negotiation identifier in the first negotiation request to learn whether the first network agent wants to negotiate with it whether to configure the second communication channel as a proxy channel.
可选的,第一协商请求还包括连接超时时间,其中,连接超时时间用于告知第二网络代理:第一网络代理在发出第一协商请求后,期望接收到第二网络代理返回心跳消息的时间,其中,心跳消息用于表示第二通信通道处于正常连接状态。在一些实施例中,如果第一网络代理未在上述连接超时时间内接收到第二网络代理返回的心跳消息,则第一网络代理可以断开第二通信通道。应理解,由于第二通信通道可以是反向的TCP通道,因此当上述连接超时时间是从第一网络代理发出第一协商请求的时间开始计算时,可以保证第二通信通道在建立后长时间未被使用的情况下仍然可以保持正常连接状态。另外,关于上述心跳消息,本申请实施例还提出:第一网络代理和第二网络代理采用“击鼓传花”的模式来相互发送心跳消息,即心跳消息不是固定由一方发送,另一方接收,而是双方交替发送和接收。Optionally, the first negotiation request also includes a connection timeout period, where the connection timeout period is used to inform the second network agent that after sending the first negotiation request, the first network agent expects to receive a heartbeat message returned by the second network agent. time, where the heartbeat message is used to indicate that the second communication channel is in a normal connection state. In some embodiments, if the first network agent does not receive the heartbeat message returned by the second network agent within the above-mentioned connection timeout period, the first network agent may disconnect the second communication channel. It should be understood that since the second communication channel may be a reverse TCP channel, when the above-mentioned connection timeout period is calculated from the time when the first network agent sends the first negotiation request, it can be guaranteed that the second communication channel will be established for a long time after Normal connection status can still be maintained when not in use. In addition, regarding the above-mentioned heartbeat message, the embodiment of the present application also proposes that the first network agent and the second network agent use the "drum-beating and flower-passing" mode to send heartbeat messages to each other, that is, the heartbeat message is not sent by one party and received by the other party. Both parties alternate sending and receiving.
可选的,第一协商响应还包括能够用于表示第二网络代理同意将第二通信通道配置为代理通道的信息,例如,用户预设的字符等。Optionally, the first negotiation response also includes information that can be used to indicate that the second network agent agrees to configure the second communication channel as a proxy channel, for example, characters preset by the user, etc.
可选的,由于第二通信通道上还可以建立安全通道,因此,第一网络代理还可以通过安 全通道将第二通信通道配置为代理通道。具体地,仍以安全通道是SSL通道为例:基于应用层协议协商(application layer protocol negotiation,ALPN)协议,第一网络代理向第二网络代理发送的安全通道的建立请求(如client hello消息)中可以包括第一网络代理支持的一个或多个协议的标识,其中,上述一个或多个协议的标识包括上述代理协议的标识。响应于上述安全通道的建立请求,第二网络代理从上述一个或多个协议中选择出自身支持的协议(包括代理协议),并通过相应的响应消息(如server hello消息)将代理协议的标识返回至第一网络代理。如此,在SSL通道建立完成后,第一网络代理可以通过SSL通道向第二网络代理发送第一协商请求,第二网络代理也可以通过SSL通道向第一网络代理返回第一协商响应,从而将第二通信通道配置为代理通道。Optionally, since a secure channel can also be established on the second communication channel, the first network agent can also Full channel configures the second communication channel as a proxy channel. Specifically, taking the secure channel as an SSL channel as an example: Based on the application layer protocol negotiation (ALPN) protocol, the first network agent sends a secure channel establishment request (such as a client hello message) to the second network agent. may include identifiers of one or more protocols supported by the first network proxy, wherein the identifiers of the one or more protocols include identifiers of the above-mentioned proxy protocols. In response to the above secure channel establishment request, the second network agent selects a protocol it supports (including a proxy protocol) from the above one or more protocols, and sends the identifier of the proxy protocol through a corresponding response message (such as a server hello message). Return to first network proxy. In this way, after the SSL channel is established, the first network agent can send the first negotiation request to the second network agent through the SSL channel, and the second network agent can also return the first negotiation response to the first network agent through the SSL channel, thereby The second communication channel is configured as a proxy channel.
需要说明的是,上述过程描述的是在第二网络代理支持代理协议的情况下,将第二通信通道配置为代理通道的建立过程。但在实际应用中,可能存在第二网络代理不支持代理协议,的情况,为此,本申请实施例提出:当第二网络代理不支持代理协议时,第一网络代理可以断开第二通信通道,或者采用其他的方法继续实现第一服务和第二服务之间的通信,例如,采用现有技术中提到的任一个方法实现第一服务和第二服务之间的通信。It should be noted that the above process describes the establishment process of configuring the second communication channel as a proxy channel when the second network proxy supports the proxy protocol. However, in practical applications, there may be situations where the second network agent does not support the proxy protocol. To this end, embodiments of the present application propose that when the second network agent does not support the proxy protocol, the first network agent can disconnect the second communication. channel, or use other methods to continue to implement communication between the first service and the second service. For example, use any method mentioned in the prior art to implement communication between the first service and the second service.
进一步地,第一网络代理可以通过以下任一种方式确定第二网络代理不支持代理协议:(1)第一网络代理发送第一协商请求后,未接收到或者未在期望的时间内接收到第二网络代理返回的第一协商响应。(2)第一网络代理发送安全通道的建立请求(包括协商标识)后,接收到的第二网络代理返回的响应消息中未包括协商标识。Further, the first network agent may determine that the second network agent does not support the proxy protocol in any of the following ways: (1) After the first network agent sends the first negotiation request, it does not receive it or does not receive it within the expected time. The first negotiation response returned by the second network proxy. (2) After the first network agent sends a secure channel establishment request (including a negotiation identifier), the response message returned by the second network agent does not include the negotiation identifier.
在另一些实施例中,第一网络代理将第二通信通道配置为代理通道,包括:第一网络代理接收第二网络代理通过第二通信通道发送的第二协商请求,第一网络代理接收到第二协商请求后,基于第二协商请求将第二通信通道配置为代理通道,并向第二网络代理返回第二协商响应,从而将第二通信通道配置为代理通道。其中,第二协商请求和第一协商请求类似,第二协商请求用于与第一网络代理协商将第二通信通道配置为代理通道,第二协商请求包括上述协商标识,除此之外,还可以包括第二通信通道的标识以及连接超时时间。需要说明的是,第二协商请求中的第二通信通道的标识除了可以是上述S104中提及的由第一网络代理或容器系统中的控制节点为第二通信通道分配的ID、编号,还可以是第二网络代理的IP地址。第二协商响应和第一协商响应类似,用于告知第二网络代理确认将第二通信通道配置为代理通道,第二协议响应包括上述协商标识,除此之外,还可以包括能够用于表示第一网络代理同意将第二通信通道配置为代理通道的信息。In other embodiments, the first network agent configures the second communication channel as a proxy channel, including: the first network agent receives a second negotiation request sent by the second network agent through the second communication channel, and the first network agent receives After the second negotiation request, the second communication channel is configured as a proxy channel based on the second negotiation request, and a second negotiation response is returned to the second network agent, thereby configuring the second communication channel as a proxy channel. The second negotiation request is similar to the first negotiation request. The second negotiation request is used to negotiate with the first network agent to configure the second communication channel as a proxy channel. The second negotiation request includes the above negotiation identifier. In addition, it also The identifier of the second communication channel and the connection timeout may be included. It should be noted that, in addition to the ID and number assigned to the second communication channel by the first network agent or the control node in the container system mentioned in S104, the identifier of the second communication channel in the second negotiation request may also be the identifier of the second communication channel. Can be the IP address of the second network proxy. The second negotiation response is similar to the first negotiation response and is used to inform the second network agent to confirm that the second communication channel is configured as a proxy channel. The second protocol response includes the above negotiation identifier. In addition, it may also include information that can be used to indicate Information that the first network agent agrees to configure the second communication channel as a proxy channel.
S107:第一网络代理存储第二网络代理的标识与代理通道的标识之间的映射关系。S107: The first network agent stores the mapping relationship between the identifier of the second network agent and the identifier of the agent channel.
其中,代理通道的标识可以是第一网络代理或容器系统中的控制节点为代理通道分配的ID、编号等能够用于标识代理通道的信息。The identifier of the proxy channel may be an ID, a number, and other information assigned to the proxy channel by the first network proxy or the control node in the container system that can be used to identify the proxy channel.
可选的,代理通道的标识和上述第二通信通道的标识可以是同一个标识,也可以是不同的标识。需要说明的是,第一网络代理存储第二网络代理的标识与代理通道的标识之间的映射关系的目的是:在后续的通信时可以确定第二通信通道已经被配置为代理通道,而第一网络代理存储第二网络代理的标识与第二通信通道的标识之间的映射关系的目的是:在后续的通信时可以确定第二通信通道已建立。因此,当代理通道的标识和第二通信通道的标识是同一个标识时,为了同时满足上述两个目的,本申请实施例提出:第一网络代理可以在第二通信通道被配置为代理通道后再存储第二网络代理与第二通信通道的标识(即代理通道的标识)之间的映射关系。Optionally, the identifier of the proxy channel and the identifier of the second communication channel may be the same identifier, or they may be different identifiers. It should be noted that the purpose of the first network agent storing the mapping relationship between the identifier of the second network agent and the identifier of the agent channel is: in subsequent communications, it can be determined that the second communication channel has been configured as a proxy channel, and the second communication channel has been configured as a proxy channel. The purpose of a network agent storing the mapping relationship between the identifier of the second network agent and the identifier of the second communication channel is to determine that the second communication channel has been established in subsequent communications. Therefore, when the identity of the proxy channel and the identity of the second communication channel are the same identity, in order to satisfy the above two purposes at the same time, the embodiment of the present application proposes: the first network proxy can configure the second communication channel as a proxy channel Then store the mapping relationship between the second network agent and the identifier of the second communication channel (that is, the identifier of the agent channel).
S108:第一网络代理在第二通信通道上建立第一虚拟通道,并存储第一虚拟通道的标识 与第一服务的标识之间的映射关系。S108: The first network agent establishes the first virtual channel on the second communication channel and stores the identifier of the first virtual channel. Mapping relationship with the identity of the first service.
其中,第一虚拟通道用于传输第一服务和第二服务之间的通信消息。第一虚拟通道的标识可以是第一网络代理或容器系统中的控制节点为第一虚拟通道分配的ID、编号等能够用于标识第一虚拟通道的信息。应理解,由上述S105可知,代理通道可以支持复用,也就是说,第二通信通道上可以承载多条虚拟通道,每条虚拟通道均可用于传输两个服务之间的通信消息。因此,在具体实现中,第一虚拟通道的标识可以主要用于在上述多条虚拟通道中标识出第一虚拟通道,即第一虚拟通道的标识在上述多条虚拟通道的标识内保持唯一即可。The first virtual channel is used to transmit communication messages between the first service and the second service. The identification of the first virtual channel may be an ID, a number, or other information assigned to the first virtual channel by the first network agent or the control node in the container system, which can be used to identify the first virtual channel. It should be understood that from the above S105, the proxy channel can support multiplexing, that is to say, the second communication channel can carry multiple virtual channels, and each virtual channel can be used to transmit communication messages between two services. Therefore, in a specific implementation, the identifier of the first virtual channel may be mainly used to identify the first virtual channel among the plurality of virtual channels, that is, the identifier of the first virtual channel remains unique among the identifiers of the plurality of virtual channels. Can.
本申请实施例中,第一网络代理或控制节点可以采用多种规则为第二通信通道上的虚拟通道(包括第一虚拟通道)分配标识,下面列举了几种可能的分配规则:In this embodiment of the present application, the first network agent or control node can use multiple rules to allocate identifiers to the virtual channels (including the first virtual channel) on the second communication channel. Several possible allocation rules are listed below:
(1)生成多个不同的随机数,并将上述多个不同的随机数分别分配给不同的虚拟通道作为其标识。(1) Generate multiple different random numbers, and assign the above multiple different random numbers to different virtual channels as their identifiers.
(2)按照从小到大或从大到小的顺序分别给每条虚拟通道分配一个编号以作为其标识。例如,假设第一网络代理依次在第二通信通道上建立了虚拟通道1、虚拟通道2、…、虚拟通道n(其中,n是大于1的整数),那么第一网络代理给上述n条虚拟通道分配的标识可以依次是1、2、…、n-1;或者是m、m-1、…、m-n+2(其中,m是大于或等于n的整数)。(2) Assign a number to each virtual channel as its identification in order from small to large or from large to small. For example, assuming that the first network agent successively establishes virtual channel 1, virtual channel 2, ..., virtual channel n (where n is an integer greater than 1) on the second communication channel, then the first network agent provides the above n virtual channels with The identification of channel allocation can be 1, 2,..., n-1; or m, m-1,..., m-n+2 (where m is an integer greater than or equal to n).
(3)分配给虚拟通道的标识包括两个字段:第一字段和第二字段,其中,第一字段是表示该标识长度的字段,第二字段是在满足上述长度要求的范围内设置编号(或ID)的字段。(3) The identifier assigned to the virtual channel includes two fields: the first field and the second field, where the first field is a field indicating the length of the identifier, and the second field is a number set within the range that meets the above length requirements ( or ID) field.
示例性的,虚拟通道的标识具有3种格式:①长度是4比特(bit)的标识、②长度是8比特的标识、③长度是16比特的标识。在一种可能的实现方式中,上述3种格式的标识中的第一字段可以基于标识的长度是否大于4比特,以及是否小于16比特进行设置,例如,标识的长度小于或等于4比特时,记作“0”,标识的长度大于4比特时,记作“1”,标识的长度小于16比特时,记作“0”,标识的长度大于或等于16比特时,记作“1”。那么,如表1所示,对于长度是4比特的标识,第一字段是“0”,占用1个比特;对于长度是8比特的标识,第一字段是“01”,占用2个比特;对于长度是16比特的标识,第一字段是“11”,占用2个比特。进一步地,对于长度是4比特的标识,第二字段可以占用3个比特,其表示范围是0-7;对于长度是8比特的标识,第二字段占用6个比特,其表示范围是0-63;对于长度是16比特的标识,第二字段占用14个比特,其表示范围是0-16383。更进一步地,利用格式①可以标识8条虚拟通道,利用格式②可以标识64条虚拟通道,利用格式③可以标识16384条虚拟通道,即利用上述3种格式总共可以标识8+64+16384=16456条虚拟通道。For example, the identifier of the virtual channel has three formats: ① an identifier with a length of 4 bits (bit), ② an identifier with a length of 8 bits, and ③ an identifier with a length of 16 bits. In a possible implementation, the first field in the above three formats of identifiers can be set based on whether the length of the identifier is greater than 4 bits, and whether it is less than 16 bits. For example, when the length of the identifier is less than or equal to 4 bits, It is recorded as "0". When the length of the identifier is greater than 4 bits, it is recorded as "1". When the length of the identifier is less than 16 bits, it is recorded as "0". When the length of the identifier is greater than or equal to 16 bits, it is recorded as "1". Then, as shown in Table 1, for an identifier with a length of 4 bits, the first field is "0", occupying 1 bit; for an identifier with a length of 8 bits, the first field is "01", occupying 2 bits; For an identifier with a length of 16 bits, the first field is "11", occupying 2 bits. Further, for an identifier with a length of 4 bits, the second field can occupy 3 bits, and its representation range is 0-7; for an identifier with a length of 8 bits, the second field occupies 6 bits, and its representation range is 0-7. 63; For an identifier with a length of 16 bits, the second field occupies 14 bits, and its representation range is 0-16383. Furthermore, format ① can be used to identify 8 virtual channels, format ② can be used to identify 64 virtual channels, and format ③ can be used to identify 16384 virtual channels, that is, a total of 8+64+16384=16456 can be identified using the above three formats. virtual channel.
表1
Table 1
应理解,上述3种格式的标识中的第一字段还可以设置其他的形式,例如,使用其他的标识符(如数字、字符)来表示标识的长度是4比特、8比特以及16比特。另外,标识中的第一字段除了可以设置上述3种格式,还可以基于第二通信通道上可承载的虚拟通道的数量、待传输数据的大小以及通信质量等实际情况进行灵活的设置,例如,设置成其他长度的标识,或者设置更多长度的标识。It should be understood that the first field in the above three formats of identification can also be set in other forms. For example, other identifiers (such as numbers and characters) can be used to indicate that the length of the identification is 4 bits, 8 bits, or 16 bits. In addition, in addition to the above three formats, the first field in the identification can also be flexibly set based on the number of virtual channels that can be carried on the second communication channel, the size of the data to be transmitted, and the communication quality. For example, Set to a different length of identifier, or set more lengths of identifiers.
还应理解,在实际应用中,一般会预先设置好虚拟标识的长度,因此采用方式(1)或方 式(2)来给虚拟通道分配标识时,不同的虚拟通道的标识具有相同的长度。那么,相较于方式(1)和方式(2),采用方式(3)给虚拟通道分配标识能够提高业务数据的传输效率,理由如下:举例说明,假设采用方式(2)给虚拟通道分配的标识的长度被设置为16比特,那么,采用方式(2)提及的按照从小到大的顺序给虚拟通道8分配标识时,虚拟通道8的标识是0000000000000111,而采用方式(3)给虚拟通道8分配标识时,虚拟通道8的标识是0111;采用方式(2)提及的按照从小到大的顺序给虚拟通道72分配标识时,虚拟通道72的标识是0000000001001000,而采用方式(3)给虚拟通道72分配标识时,虚拟通道72的标识是10111111。不难看出,采用方式(3)给虚拟通道分配的标识可以占用更少的字节。由后文的图8-图9可知,通过虚拟通道传输的消息中需要携带该虚拟通道的标识,那么当虚拟通道的标识占用的字节更少时,可以使得消息中携带更多的业务数据,从而提高了业务数据的传输效率。It should also be understood that in actual applications, the length of the virtual logo is generally preset, so method (1) or method When formula (2) is used to assign identifiers to virtual channels, the identifiers of different virtual channels have the same length. Then, compared with methods (1) and (2), using method (3) to assign identifiers to virtual channels can improve the transmission efficiency of business data. The reasons are as follows: For example, assume that method (2) is used to allocate identifiers to virtual channels. The length of the identifier is set to 16 bits. Then, when allocating identifiers to virtual channel 8 in ascending order as mentioned in method (2), the identifier of virtual channel 8 is 0000000000000111, while using method (3) to assign identifiers to virtual channel 8 8 When allocating identifiers, the identifier of virtual channel 8 is 0111; when using method (2) to allocate identifiers to virtual channel 72 in ascending order, the identifier of virtual channel 72 is 0000000001001000, and using method (3) to When the virtual channel 72 is assigned an identifier, the identifier of the virtual channel 72 is 10111111. It is not difficult to see that the identifier assigned to the virtual channel using method (3) can occupy fewer bytes. As can be seen from Figures 8 and 9 below, messages transmitted through a virtual channel need to carry the identifier of the virtual channel. When the identifier of the virtual channel occupies fewer bytes, the message can carry more business data. This improves the transmission efficiency of business data.
第一服务的标识可以是第一网络代理或容器系统中的控制节点为第一服务分配的ID、编号等能够标识第一服务的信息。或者,第一服务的标识也可以基于第一网络代理的类型进行灵活的设置,例如,当第一网络代理是容器组代理时,第一服务的标识可以是第一服务的服务名、第一容器组给第一服务分配的ID、编号等;当第一网络代理是节点代理时,第一服务的标识可以包括第一容器组的IP地址、第一服务的端口(端口B)中的至少一个,其中,端口B是第一容器组上用于收发与第一服务有关的消息的端口。又或者,第一服务的标识还可以是第一网络代理或容器系统中的控制节点为第一通信通道分配的ID、编号等能够标识第一通信通道的信息。The identification of the first service may be an ID, a number, or other information that can identify the first service assigned to the first service by the first network agent or the control node in the container system. Alternatively, the identity of the first service can also be flexibly set based on the type of the first network proxy. For example, when the first network proxy is a container group proxy, the identity of the first service can be the service name of the first service, the first The ID, number, etc. assigned by the container group to the first service; when the first network agent is a node agent, the identification of the first service may include at least the IP address of the first container group and the port (port B) of the first service. One, wherein port B is a port on the first container group used to send and receive messages related to the first service. Alternatively, the identification of the first service may also be information that can identify the first communication channel, such as an ID, a number, etc. assigned to the first communication channel by the first network agent or the control node in the container system.
在一些实施例中,第一网络代理在第二通信通道上建立第一虚拟通道,包括:第一网络代理向第二网络代理发送虚拟连接消息。其中,虚拟连接消息包括第一虚拟通道的标识,如此,当第二网络代理接收到虚拟连接消息后,基于虚拟连接消息可以确定在第二通信通道上建立了第一虚拟通道。In some embodiments, the first network agent establishes the first virtual channel on the second communication channel, including: the first network agent sends a virtual connection message to the second network agent. The virtual connection message includes an identifier of the first virtual channel. In this way, after the second network agent receives the virtual connection message, it can be determined based on the virtual connection message that the first virtual channel is established on the second communication channel.
虚拟连接消息还包括第二服务的标识。其中,与第一服务的标识类似的:第二服务的标识可以是第一网络代理或容器系统中的控制节点为第二服务分配的ID、编号等能够标识第二服务的信息。第二服务的标识也可以基于第二网络代理的类型进行灵活的设置,例如,当第二网络代理是容器组代理时,第二服务的标识可以是第二服务的服务名、第二容器组给第二服务分配的ID、编号等;当第二网络代理是节点代理时,第二服务的标识可以包括第二容器组的IP地址、端口A中的至少一个。第二服务的标识还可以是第一网络代理或容器系统中的控制节点为后文中的第三通信通道分配的ID、编号等能够标识第三通信通道的信息。The virtual connection message also includes the identification of the second service. The identifier of the second service may be similar to the identifier of the first service: the identifier of the second service may be an ID, number, or other information that can identify the second service assigned by the first network agent or the control node in the container system to the second service. The identity of the second service can also be flexibly set based on the type of the second network proxy. For example, when the second network proxy is a container group proxy, the identity of the second service can be the service name of the second service, the second container group The ID, number, etc. assigned to the second service; when the second network agent is a node agent, the identifier of the second service may include at least one of the IP address of the second container group and port A. The identification of the second service may also be information that can identify the third communication channel, such as an ID, a number, etc. assigned by the first network agent or the control node in the container system to the third communication channel later.
需要说明的是,本申请实施例并不限定第一网络代理在第二通信通道上建立第一虚拟通道,以及存储第一虚拟通道的标识与第一服务的标识之间的映射关系这两个步骤的执行顺序,即这两个步骤可以同时执行,也可以先后执行。It should be noted that the embodiment of the present application is not limited to the first network agent establishing the first virtual channel on the second communication channel and storing the mapping relationship between the identifier of the first virtual channel and the identifier of the first service. The execution order of the steps, that is, the two steps can be executed at the same time or one after another.
S109:第二网络代理基于虚拟连接消息存储第一虚拟通道的标识与第二服务的标识之间的映射关系。S109: The second network agent stores the mapping relationship between the identifier of the first virtual channel and the identifier of the second service based on the virtual connection message.
具体地,第二网络代理接收到上述虚拟连接消息后,基于虚拟连接消息获取第一虚拟通道的标识和第二服务的标识,然后存储第一虚拟通道的标识与第二服务的标识之间的映射关系。Specifically, after receiving the virtual connection message, the second network agent obtains the identity of the first virtual channel and the identity of the second service based on the virtual connection message, and then stores the relationship between the identity of the first virtual channel and the identity of the second service. Mapping relations.
S110:第二网络代理基于虚拟连接消息建立与第二服务之间的第三通信通道。S110: The second network agent establishes a third communication channel with the second service based on the virtual connection message.
具体地,第二网络代理接收到上述虚拟连接消息后,基于虚拟连接消息获取第二服务的标识,然后基于第二服务的标识建立与第二服务之间的第三通信通道。其中,第二网络代理建立与第二服务之间的第三通信通道的过程与上述S101中第一服务建立与第一网络代理之 间的第一通信通道的过程类似,都是通过三次握手建立得到的,因此为了简便,此处不再对这一过程展开描述。Specifically, after receiving the virtual connection message, the second network agent obtains the identity of the second service based on the virtual connection message, and then establishes a third communication channel with the second service based on the identity of the second service. Among them, the process of the second network agent establishing the third communication channel with the second service is the same as the process of the first service establishing the third communication channel with the first network agent in S101. The process of the first communication channel between the two parties is similar and is established through a three-way handshake. Therefore, for the sake of simplicity, this process will not be described here.
通过上述S101-S110,第一服务与第二服务之间的通信通道(包括第一通信通道、第一虚拟通道以及第三通信通道)建立完成,接下来进行第二阶段。Through the above-mentioned S101-S110, the communication channel (including the first communication channel, the first virtual channel and the third communication channel) between the first service and the second service is established, and then the second phase is performed.
第二阶段、第一服务和第二服务基于上述已建立的通信通道进行通信In the second phase, the first service and the second service communicate based on the above-mentioned established communication channel.
其中,有鉴于第一服务和第二服务采用的应用层协议多种多样,因此将第一服务和第二服务之间的通信分为以下两种情况。Among them, in view of the various application layer protocols adopted by the first service and the second service, the communication between the first service and the second service is divided into the following two situations.
情况1、第一服务主动向第二服务发送业务数据,即第一服务和第二服务采用例如HTTP1之类的应用层协议进行通信。那么,第一服务和第二服务的通信过程可以参见图8。Case 1: The first service actively sends business data to the second service, that is, the first service and the second service communicate using an application layer protocol such as HTTP1. Then, the communication process between the first service and the second service can be seen in Figure 8.
S201:第一服务通过第一通信通道向第一网络代理发送第二消息。S201: The first service sends a second message to the first network agent through the first communication channel.
其中,第二消息包括第一服务想要发送至第二服务的业务数据D1。需要说明的一点是,当上述S102中的第一消息承载有业务数据D1时,第二消息和第一消息可以是同一个消息。The second message includes the service data D 1 that the first service wants to send to the second service. It should be noted that when the first message in S102 above carries service data D 1 , the second message and the first message may be the same message.
S202:第一网络代理基于第二消息生成数据传输消息R1,并通过第一虚拟通道将数据传输消息R1发送至第二网络代理。S202: The first network agent generates a data transmission message R 1 based on the second message, and sends the data transmission message R 1 to the second network agent through the first virtual channel.
具体地,第一网络代理通过解析第二消息确定需要将该消息中的业务数据D1发送至第二服务,从而确定运行有第二服务的第二容器组以及负责第二容器组中业务访问的第二网络代理。之后,第一网络代理基于本地存储的第二网络代理的标识与第二通信通道的标识之间的映射关系,以及第二网络代理的标识与代理通道的标识之间的映射关系,确定第二通信通道已建立且第二通信通道是代理通道。然后,第一网络代理基于第二消息来自第一服务,以及本地存储的第一虚拟通道的标识与第一服务的标识之间的映射关系,获得第一虚拟通道的标识。之后,第一网络代理再基于第一虚拟通道的标识对业务数据D1进行封装获得数据传输消息R1,并通过第一虚拟通道将数据传输消息R1发送至第二网络代理。其中,数据传输消息R1除了可以包括第一虚拟通道的标识和业务数据D1,还可以包括业务数据D1的长度。Specifically, the first network agent determines that the business data D 1 in the message needs to be sent to the second service by parsing the second message, thereby determining the second container group running the second service and being responsible for business access in the second container group. second network proxy. Afterwards, the first network agent determines the second network agent based on the locally stored mapping relationship between the identifier of the second network agent and the identifier of the second communication channel, and the mapping relationship between the identifier of the second network agent and the identifier of the agent channel. The communication channel is established and the second communication channel is the proxy channel. Then, the first network agent obtains the identity of the first virtual channel based on the second message from the first service and the mapping relationship between the locally stored identity of the first virtual channel and the identity of the first service. Afterwards, the first network agent encapsulates the service data D 1 based on the identifier of the first virtual channel to obtain the data transmission message R 1 , and sends the data transmission message R 1 to the second network agent through the first virtual channel. In addition to the identification of the first virtual channel and the service data D 1 , the data transmission message R 1 may also include the length of the service data D 1 .
S203:第二网络代理基于数据传输消息R1将业务数据D1通过第三通信通道转发至第二服务。S203: The second network agent forwards the service data D 1 to the second service through the third communication channel based on the data transmission message R 1 .
具体地,第二网络代理接收到数据传输消息R1后,基于数据传输消息R1获取第一虚拟通道的标识和业务数据D1,然后基于本地存储的第一虚拟通道的标识与第二服务的标识之间的映射关系将业务数据D1通过第三通信通道发送至第二服务。Specifically, after receiving the data transmission message R 1 , the second network agent obtains the identity of the first virtual channel and the service data D 1 based on the data transmission message R 1 , and then obtains the identity of the first virtual channel and the second service based on the locally stored identity of the first virtual channel. The mapping relationship between the identifiers sends the business data D 1 to the second service through the third communication channel.
可选的,第二服务接收到第一服务发送的业务数据D1后,响应于业务数据D1,第二服务可能还向第一服务返回业务数据D2,其中,与业务数据D1类似的,业务数据D2是指基于第一服务和第二服务之间的应用层协议生成的消息。因此,第一服务和第二服务之间的通信还可能包括下述S204-S206。Optionally, after the second service receives the service data D 1 sent by the first service, in response to the service data D 1 , the second service may also return service data D 2 to the first service, where the service data D 1 is similar to the service data D 1 . , the business data D 2 refers to a message generated based on the application layer protocol between the first service and the second service. Therefore, the communication between the first service and the second service may also include the following S204-S206.
S204:第二服务基于业务数据D2生成第三消息,并通过第三通信通道将第三消息发送至第二网络代理。其中,第三消息包括上述业务数据D2S204: The second service generates a third message based on the service data D2 , and sends the third message to the second network agent through the third communication channel. Among them, the third message includes the above-mentioned service data D 2 .
S205:第二网络代理基于第三消息生成数据传输消息R2,并通过第一虚拟通道将数据传输消息R2发送至第一网络代理。S205: The second network agent generates the data transmission message R 2 based on the third message, and sends the data transmission message R 2 to the first network agent through the first virtual channel.
具体地,第二网络代理通过解析第三消息确定需要将该消息中的业务数据D2发送至第一服务,即该消息是第二消息的响应,从而获得第一虚拟通道的标识。然后,第二网络代理基于第一虚拟通道的标识对业务数据D2进行封装获得数据传输消息R2,并通过第一虚拟通道将数据传输消息R2发送至第一网络代理。其中,数据传输消息R2除了可以包括第一虚拟通道的标识和业务数据D2,还可以包括业务数据D2的长度。 Specifically, the second network agent determines by parsing the third message that the service data D2 in the message needs to be sent to the first service, that is, the message is a response to the second message, thereby obtaining the identity of the first virtual channel. Then, the second network agent encapsulates the service data D 2 based on the identification of the first virtual channel to obtain the data transmission message R 2 , and sends the data transmission message R 2 to the first network agent through the first virtual channel. In addition to the identification of the first virtual channel and the service data D 2 , the data transmission message R 2 may also include the length of the service data D 2 .
S206:第一网络代理基于数据传输消息R2将业务数据D2通过第一通信通道转发至第一服务。S206: The first network agent forwards the service data D2 to the first service through the first communication channel based on the data transmission message R2 .
具体地,第一网络代理接收到数据传输消息R2后,基于数据传输消息R2获取第一虚拟通道的标识和业务数据D2,然后基于本地存储的第一虚拟通道的标识与第一服务的标识之间的映射关系将业务数据D2通过第一通信通道转发至第一服务。Specifically, after receiving the data transmission message R 2 , the first network agent obtains the identity of the first virtual channel and the service data D 2 based on the data transmission message R 2 , and then obtains the identity of the first virtual channel and the first service based on the locally stored identity of the first virtual channel. The mapping relationship between the identifiers forwards the service data D2 to the first service through the first communication channel.
情况2、第二服务推动第一服务向其发送业务数据(第二服务向第一服务发送消息后,第一服务才向第二服务发送业务数据),即第一服务和第二服务采用例如MySQL之类的应用层协议进行通信。那么,第一服务和第二服务的通信过程可以参见图9。Case 2: The second service pushes the first service to send business data to it (the first service sends business data to the second service only after the second service sends a message to the first service), that is, the first service and the second service use, for example, Application layer protocols such as MySQL communicate. Then, the communication process between the first service and the second service can be seen in Figure 9.
S301:第二服务通过第三通信通道向第二网络代理发送第四消息。S301: The second service sends a fourth message to the second network agent through the third communication channel.
其中,第四消息包括用于指示第一服务向第二服务发送业务数据的指示数据。指示数据是指基于第一服务和第二服务之间的应用层协议生成的消息(此处可以是MySQL消息)。The fourth message includes instruction data used to instruct the first service to send service data to the second service. The indication data refers to a message generated based on the application layer protocol between the first service and the second service (here it may be a MySQL message).
S302:第二网络代理基于第四消息生成数据传输消息R3,并通过第一虚拟通道将数据传输消息R3发送至第一网络代理。S302: The second network agent generates the data transmission message R 3 based on the fourth message, and sends the data transmission message R 3 to the first network agent through the first virtual channel.
其中,数据传输消息R3包括第一虚拟通道的标识和上述指示数据。The data transmission message R 3 includes the identification of the first virtual channel and the above-mentioned indication data.
S303:第一网络代理基于数据传输消息R3将上述指示数据通过第一通信通道转发至第一服务。S303: The first network agent forwards the above instruction data to the first service through the first communication channel based on the data transmission message R3 .
第一服务接收到上述指示数据之后,向第二服务发送业务数据D1,其具体过程可参见上述S201-S203,此处不再重复描述。另外,与情况1类似,第二服务接收到业务数据D1后,响应于业务数据D1,第二服务可能还向第一服务返回业务数据D2,其具体过程可参见上述S204-S206,此处也不再重复描述。还应理解,上述关于第二服务向第一服务发送指示数据的过程(S301-S303)与上述第二服务向第一服务发送业务数据D2的过程(S204-S206)类似,因此,为了简便此处将不对这一过程展开描述。After receiving the above indication data, the first service sends the service data D 1 to the second service. For the specific process, please refer to the above S201-S203, and the description will not be repeated here. In addition, similar to case 1, after the second service receives the business data D 1 , in response to the business data D 1 , the second service may also return the business data D 2 to the first service. For the specific process, please refer to S204-S206 above. The description will not be repeated here. It should also be understood that the above-mentioned process (S301-S303) of the second service sending the instruction data to the first service is similar to the above-mentioned process (S204-S206) of the second service sending the business data D2 to the first service. Therefore, for simplicity, This process will not be described here.
值得注意的几点是:①由上述S202、S205以及S302可知,第一网络代理和第二网络代理之间传输的消息(包括数据传输消息R1、数据传输消息R2以及数据传输消息R3)均是使用第一虚拟通道的标识对待传输的数据(包括业务数据D1、业务数据D1以及指示数据)进行封装后得到的,其封装过程对于应用层协议来说是“透明”的,即待传输的数据不会感知到使用了代理协议对其进行封装,因此,代理协议的使用并不会影响应用层协议。②由上述S203可知,当第二网络代理接收到来自第一网络代理发送的数据传输消息R1后,由于第二网络代理支持代理协议,因此第二网络代理可以使用第一虚拟通道的标识对数据传输消息R1解封装,从而获得业务数据D1。除此之外,第二网络代理还可以基于本地存储的第一虚拟通道的标识与第二服务的标识之间的映射关系将业务数据D1转发至第二服务,在这一过程中,第二网络代理无需使用应用层协议对业务数据D1进行解封装就可以直接将业务数据D1转发至第二服务,因此提高了业务数据D1的传输效率。类似的,在上述S206和S303中,由于也使用了代理协议,因此也提高了业务数据D1以及指示数据的传输效率。Several points worth noting are: ① It can be seen from the above S202, S205 and S302 that the messages transmitted between the first network agent and the second network agent (including data transmission message R 1 , data transmission message R 2 and data transmission message R 3 ) are obtained by encapsulating the data to be transmitted (including business data D 1 , business data D 1 and indication data) using the identifier of the first virtual channel. The encapsulation process is "transparent" to the application layer protocol. That is, the data to be transmitted will not be aware that the proxy protocol is used to encapsulate it. Therefore, the use of the proxy protocol will not affect the application layer protocol. ② It can be seen from the above S203 that when the second network agent receives the data transmission message R 1 sent from the first network agent, since the second network agent supports the agent protocol, the second network agent can use the identification pair of the first virtual channel. The data transmission message R 1 is decapsulated to obtain service data D 1 . In addition, the second network agent can also forward the business data D 1 to the second service based on the mapping relationship between the locally stored identity of the first virtual channel and the identity of the second service. In this process, the second network agent forwards the business data D 1 to the second service. The second network agent can directly forward the service data D 1 to the second service without using the application layer protocol to decapsulate the service data D 1 , thus improving the transmission efficiency of the service data D 1 . Similarly, in the above-mentioned S206 and S303, since the proxy protocol is also used, the transmission efficiency of the service data D1 and the instruction data is also improved.
基于上述图7-图9可知,第一网络代理和第二网络代理在基于代理协议传输业务数据时,需要使用第一虚拟通道的标识来封装业务数据,并且封装后的业务数据需要承载于传输层消息上,传输层消息是指在第二通信通道上传输的消息,例如,当第二通信通道是TCP通道时,传输层消息可以是TCP消息。对于传输层消息来说,第一虚拟通道的标识占用的字节越多,业务数据占用的字节便越少,换言之,第一虚拟通道的标识占用的字节越少,传输层消息上就能够承载越多的业务数据。因此,本申请实施例提出:如果当前第一虚拟通道的标识(以 下称为标识F1)不能满足第一服务和第二服务之间的通信需求时,第一网络代理将第一虚拟通道的标识从标识F1更改为标识F2。其中,标识F2的长度小于标识F1的长度。Based on the above figures 7 to 9, it can be seen that when the first network agent and the second network agent transmit service data based on the agent protocol, they need to use the identifier of the first virtual channel to encapsulate the service data, and the encapsulated service data needs to be carried in the transmission In terms of layer messages, transport layer messages refer to messages transmitted on the second communication channel. For example, when the second communication channel is a TCP channel, the transport layer message may be a TCP message. For transport layer messages, the more bytes the identifier of the first virtual channel occupies, the fewer bytes the service data occupies. In other words, the fewer bytes the identifier of the first virtual channel occupies, the less bytes the identifier of the first virtual channel occupies. Can carry more business data. Therefore, the embodiment of this application proposes that if the current identification of the first virtual channel (with When the identifier F 1 (hereinafter referred to as the identifier) cannot meet the communication requirements between the first service and the second service, the first network agent changes the identifier of the first virtual channel from the identifier F 1 to the identifier F 2 . Among them, the length of the mark F 2 is smaller than the length of the mark F 1 .
在一些实施例中,当满足以下一个或多个条件时,第一虚拟通道的标识不能满足第一服务和第二服务之间的通信需求:①第一虚拟通道上传输的业务数据的优先级高于第一阈值;②第一虚拟通道上传输业务数据的效率低于第二阈值。其中,第一阈值可以是用户预设的优先级,也可以是第一网络代理基于第二通信通道上各个虚拟通道传输的业务数据的优先级以及实际的业务需求动态调整的;第二阈值可以是用户预设的,也可以是第一网络代理基于上述各个虚拟通道传输业务数据的效率以及实际的业务需求进行动态调整得到的。In some embodiments, when one or more of the following conditions are met, the identification of the first virtual channel cannot meet the communication requirements between the first service and the second service: ① The priority of the service data transmitted on the first virtual channel Higher than the first threshold; ② The efficiency of transmitting service data on the first virtual channel is lower than the second threshold. The first threshold may be a priority preset by the user, or may be dynamically adjusted by the first network agent based on the priority of business data transmitted by each virtual channel on the second communication channel and actual business requirements; the second threshold may be It is preset by the user, or may be dynamically adjusted by the first network agent based on the efficiency of transmitting business data of each of the above virtual channels and the actual business requirements.
在一种可能的实现方式中,如图10所示,第一网络代理将第一虚拟通道的标识从标识F1更改为标识F2,包括以下步骤:In a possible implementation, as shown in Figure 10, the first network agent changes the identity of the first virtual channel from the identity F 1 to the identity F 2 , including the following steps:
S401:第一网络代理确定标识F2S401: The first network agent determines the identifier F 2 .
在一些实施例中,标识F2是第二通信通道上的第二虚拟通道的标识,那么,第一网络代理确定标识F2,包括:第一网络代理确定建立在第二通信通道上的多条虚拟通道,其中,多条虚拟通道包括第一虚拟通道和第二虚拟通道。然后,第一网络代理确定多条虚拟通道中的每条虚拟通道上传输的业务数据的优先级,以及每条虚拟通道传输业务数据的效率中的至少一个,其中,虚拟通道传输业务数据的效率是指单位时间内通过该通道传输的消息中业务数据的占比。然后,第一网络代理基于每条虚拟通道上传输的业务数据的优先级,以及每条虚拟通道传输业务数据的效率中的至少一个确定第二虚拟通道,从而确定标识F2,其中,第二虚拟通道用于传输其他服务通信时的业务数据,第二虚拟通道满足以下一个或多个条件:第二虚拟通道上传输的业务数据的优先级低于第一虚拟通道上传输的业务数据的优先级,以及第二虚拟通道上传输业务数据的效率小于第一虚拟通道上传输业务数据的效率。In some embodiments, the identifier F 2 is the identifier of the second virtual channel on the second communication channel. Then, the first network agent determines the identifier F 2 , including: the first network agent determines the multiplexed number established on the second communication channel. virtual channels, wherein the plurality of virtual channels include a first virtual channel and a second virtual channel. Then, the first network agent determines at least one of a priority of the service data transmitted on each of the plurality of virtual channels and an efficiency of each virtual channel in transmitting the service data, wherein the efficiency of the virtual channel in transmitting the service data It refers to the proportion of business data in the messages transmitted through the channel within a unit time. Then, the first network agent determines the second virtual channel based on at least one of the priority of the service data transmitted on each virtual channel and the efficiency of each virtual channel in transmitting the service data, thereby determining the identifier F 2 , where the second The virtual channel is used to transmit business data when communicating with other services. The second virtual channel satisfies one or more of the following conditions: the priority of the business data transmitted on the second virtual channel is lower than the priority of the business data transmitted on the first virtual channel. level, and the efficiency of transmitting service data on the second virtual channel is less than the efficiency of transmitting service data on the first virtual channel.
进一步地,第一网络代理可以通过以下方式确定每条虚拟通道传输数据的效率:第一网络代理确定每条虚拟通道发送消息的速率、消息的大小以及消息中携带的业务数据的大小,从而计算得到每条虚拟通道传输业务数据的效率。Further, the first network agent can determine the data transmission efficiency of each virtual channel in the following manner: the first network agent determines the rate at which each virtual channel sends messages, the size of the message, and the size of the business data carried in the message, thereby calculating Obtain the efficiency of each virtual channel in transmitting business data.
在另一些实施例中,第一网络代理设置有备用标识集合,例如,如果采用上述S108中的分配规则(3)来给第二通信通道上的虚拟通道分配标识,则可以将部分长度较短的标识(如4比特的标识)添加到备用标识集合中。备用标识集合中的标识可以用于分配给需要更改标识的虚拟通道,标识F2可以是备用标识集合中的任一个。In other embodiments, the first network agent is set with a backup identifier set. For example, if the allocation rule (3) in S108 above is used to allocate identifiers to the virtual channel on the second communication channel, the partial length may be shorter. The identifier (such as a 4-bit identifier) is added to the backup identifier set. The identifiers in the standby identifier set can be used to be assigned to the virtual channel whose identifier needs to be changed, and the identifier F2 can be any one in the standby identifier set.
S402:第一网络代理通过第二通信通道向第二网络代理发送第一标识更改请求。S402: The first network agent sends a first identity change request to the second network agent through the second communication channel.
其中,第一标识更改请求包括标识F1和标识F2Wherein, the first identification change request includes identification F 1 and identification F 2 .
可选的,第一网络代理可以通过第一虚拟通道向第二网络代理发送第一标识更改请求,也可以通过第二虚拟通道向第二网络代理发送第一标识更改请求。Optionally, the first network agent may send the first identity change request to the second network agent through the first virtual channel, or may send the first identity change request to the second network agent through the second virtual channel.
S403:第一网络代理将发送方向的第一虚拟通道的标识从标识F1更改为标识F2S403: The first network agent changes the identity of the first virtual channel in the sending direction from the identity F 1 to the identity F 2 .
其中,由前文可知,第一网络代理中的第一虚拟通道的标识包括以下两个功能:①在第一网络代理通过第一虚拟通道发送消息时,需要使用第一虚拟通道的标识来封装待传输的业务数据;②在第一网络代理接收到来自第一虚拟通道的消息时,需要使用第一虚拟通道的标识来将上述消息中的业务数据转发至第一服务。上述发送方向的第一虚拟通道的标识是指用于实现功能①的标识,即第一网络代理通过第一虚拟通道发往第二网络代理的消息中需要携带发送方向的第一虚拟通道的标识。Among them, as can be seen from the above, the identifier of the first virtual channel in the first network agent includes the following two functions: ① When the first network agent sends a message through the first virtual channel, the identifier of the first virtual channel needs to be used to encapsulate the message to be processed. Transmitted business data; ② When the first network agent receives a message from the first virtual channel, it needs to use the identifier of the first virtual channel to forward the business data in the above message to the first service. The above identification of the first virtual channel in the sending direction refers to the identification used to implement function ①, that is, the message sent by the first network agent to the second network agent through the first virtual channel needs to carry the identification of the first virtual channel in the sending direction. .
在一些实施例中,第一网络代理存储有第一虚拟通道的标识与第一服务的标识之间的映射关系,第一网络代理基于该映射关系来实现上述功能①,因此第一网络代理将发送方向的 第一虚拟通道的标识从标识F1更改为标识F2,包括:第一网络代理将发送方向的映射关系从标识F1与第一服务的标识之间的映射关系更改为标识F2与第一服务的标识之间的映射关系。其中,发送方向的映射关系是指用于实现上述功能①的映射关系。In some embodiments, the first network agent stores a mapping relationship between the identifier of the first virtual channel and the identifier of the first service. The first network agent implements the above function ① based on the mapping relationship. Therefore, the first network agent will sending direction Changing the identity of the first virtual channel from the identity F 1 to the identity F 2 includes: the first network agent changes the mapping relationship of the sending direction from the mapping relationship between the identity F 1 and the identity of the first service to the mapping relationship between the identity F 2 and the first service. The mapping relationship between the identifiers of a service. Among them, the mapping relationship in the sending direction refers to the mapping relationship used to realize the above function ①.
S404:第二网络代理基于第一标识更改请求将第一虚拟通道的标识从标识F1更改为标识F2S404: The second network agent changes the identity of the first virtual channel from the identity F 1 to the identity F 2 based on the first identity change request.
在一些实施例中,第二网络代理存储有第一虚拟通道的标识与第二服务的标识之间的映射关系,而且当前第一虚拟通道的标识是标识F1,因此,第二网络代理基于第一标识更改请求将第一虚拟通道的标识从标识F1更改为标识F2,包括:第二网络代理基于第一标识更改请求将标识F1与第二服务的标识之间的映射关系更改为标识F2与第二服务的标识之间的映射关系。In some embodiments, the second network agent stores a mapping relationship between the identifier of the first virtual channel and the identifier of the second service, and the current identifier of the first virtual channel is the identifier F 1 . Therefore, the second network agent is based on The first identity change request changes the identity of the first virtual channel from the identity F 1 to the identity F 2 , including: the second network agent changes the mapping relationship between the identity F 1 and the identity of the second service based on the first identity change request. is the mapping relationship between the identifier F 2 and the identifier of the second service.
S405:第二网络代理通过第一虚拟通道向第一网络代理发送第一标识更改响应。S405: The second network agent sends the first identity change response to the first network agent through the first virtual channel.
其中,第一标识更改响应包括标识F1和标识F2Wherein, the first identification change response includes identification F 1 and identification F 2 .
S406:第一网络代理基于第一标识更改响应将接收方向的第一虚拟通道的标识从标识F1更改为标识F2S406: The first network agent changes the identity of the first virtual channel in the receiving direction from the identity F 1 to the identity F 2 based on the first identity change response.
其中,接收方向的第一虚拟通道的标识是指用于实现上述功能②的标识,即用于转发来自第一虚拟通道的业务数据至第一服务的标识。The identifier of the first virtual channel in the receiving direction refers to the identifier used to implement the above function ②, that is, the identifier used to forward the service data from the first virtual channel to the first service.
在一些实施例中,第一网络代理基于第一虚拟通道的标识与第一服务的标识之间的映射关系不仅可以实现上述功能①,还可以实现上述功能②,因此第一网络代理将接收方向的第一虚拟通道的标识从标识F1更改为标识F2,包括:第一网络代理将接收方向的映射关系从标识F1与第一服务的标识之间的映射关系更改为标识F2与第一服务的标识之间的映射关系。其中,接收方向的映射关系是指用于实现上述功能②的映射关系。In some embodiments, the first network agent can not only realize the above function ① but also realize the above function ② based on the mapping relationship between the identity of the first virtual channel and the identity of the first service. Therefore, the first network agent will receive the direction Changing the identity of the first virtual channel from the identity F 1 to the identity F 2 includes: the first network agent changes the mapping relationship in the receiving direction from the mapping relationship between the identity F 1 and the identity of the first service to the mapping relationship between the identity F 2 and the identity of the first service. The mapping relationship between the identifiers of the first service. Among them, the mapping relationship in the receiving direction refers to the mapping relationship used to realize the above function ②.
应理解,在标识F2是第二虚拟通道的标识的情况下,将第一虚拟通道的标识从标识F1更改为标识F2之后,为了避免通信异常,第二虚拟通道的标识也需要更改。可选的,第二虚拟通道的标识可以从标识F2更改为标识F1,也可以从标识F2更改为标识F3,其中,标识F3是第一网络代理或容器系统中的控制节点新分配给第二虚拟通道的标识。第二虚拟通道的标识的更改过程与上述第一虚拟通道的标识的更改过程类似,因此不再展开描述。It should be understood that in the case where the identifier F2 is the identifier of the second virtual channel, after the identifier of the first virtual channel is changed from the identifier F1 to the identifier F2 , in order to avoid communication abnormalities, the identifier of the second virtual channel also needs to be changed. . Optionally, the identity of the second virtual channel can be changed from the identity F 2 to the identity F 1 , or from the identity F 2 to the identity F 3 , where the identity F 3 is the first network agent or the control node in the container system. The identifier newly assigned to the second virtual channel. The process of changing the identity of the second virtual channel is similar to the above-mentioned process of changing the identity of the first virtual channel, and therefore will not be described further.
但值得注意的一点是,在第一虚拟通道及第二虚拟通道的标识的更改过程中,为了不影响第一虚拟通道和第二虚拟通道传输消息,二者应该同步进行。例如,第一网络代理向第二网络代理发送标识更改请求时,也向第二网络代理发送第二标识更改请求,以用于指示第二网络代理更改第二虚拟通道的标识;又例如,第一网络代理在更改接收方向的第一虚拟通道的标识时,还更改接收方向的第二虚拟通道的标识。However, it is worth noting that during the process of changing the identifiers of the first virtual channel and the second virtual channel, in order not to affect the transmission of messages by the first virtual channel and the second virtual channel, the two should be performed simultaneously. For example, when the first network agent sends an identity change request to the second network agent, it also sends a second identity change request to the second network agent to instruct the second network agent to change the identity of the second virtual channel; for another example, the first network agent sends an identity change request to the second network agent. When a network agent changes the identity of the first virtual channel in the receiving direction, it also changes the identity of the second virtual channel in the receiving direction.
可选的,当第二虚拟通道的标识从标识F2更改为标识F1时,相当于交换了第一虚拟通道的标识和第二虚拟通道的标识。因此,为了节省通信资源,第一标识更改请求可以被配置为用于指示第二网络代理交换标识F1和标识F2(即将第一虚拟通道的标识从标识F1更改为标识F2,以及将第二虚拟通道的标识从标识F2更改为标识F1)的指令。此时,第一网络代理便可以无需向第二网络代理发送第二标识更改请求。但考虑到实际应用中可能出现后文中的情况1-情况3,因此第二网络代理还应分别通过第一虚拟通道和第二虚拟通道向第一网络代理返回第一标识更改响应和第二标识更改响应。Optionally, when the identity of the second virtual channel is changed from the identity F 2 to the identity F 1 , it is equivalent to exchanging the identity of the first virtual channel and the identity of the second virtual channel. Therefore, in order to save communication resources, the first identity change request may be configured to instruct the second network agent to exchange the identity F 1 and the identity F 2 (ie, change the identity of the first virtual channel from the identity F 1 to the identity F 2 , and An instruction to change the identification of the second virtual channel from identification F 2 to identification F 1 ). At this time, the first network agent does not need to send the second identity change request to the second network agent. However, considering that situations 1 to 3 described below may occur in actual applications, the second network agent should also return the first identity change response and the second identity to the first network agent through the first virtual channel and the second virtual channel respectively. Change response.
可以看出,当标识F2是第二虚拟通道的标识时,上述更改第一虚拟通道的标识的方法不会打断第一虚拟通道和第二虚拟通道传输消息的过程,换言之,上述方法能够在不影响使用第一虚拟通道和第二虚拟通道传输消息的基础上,更改第一虚拟通道的标识。以通过交换标 识F1和标识F2的方式来更改第一虚拟通道的标识为例,如图11所示,假设第二虚拟通道用于传输第三服务和第二服务之间的通信消息:It can be seen that when the identifier F2 is the identifier of the second virtual channel, the above method of changing the identifier of the first virtual channel will not interrupt the process of transmitting messages between the first virtual channel and the second virtual channel. In other words, the above method can On the basis of not affecting the use of the first virtual channel and the second virtual channel to transmit messages, the identifier of the first virtual channel is changed. to pass the exchange mark Taking the method of identifying F 1 and identifying F 2 as an example to change the identity of the first virtual channel, as shown in Figure 11, assume that the second virtual channel is used to transmit communication messages between the third service and the second service:
(1)在第一网络代理向第二网络代理发送第一标识更改请求之前,第一虚拟通道的标识是标识F1,第二虚拟通道的标识是标识F2,因此,第一网络代理和第二网络代理均会使用标识F1来处理需要经由第一虚拟通道传输的业务数据,使用标识F2来处理需要经由第二虚拟通道传输的业务数据。具体地,第一网络代理(第二网络代理)通过第一虚拟通道发往第二网络代理(第一网络代理)的消息中会携带标识F1;第一网络代理(第二网络代理)接收到来自第一虚拟通道的消息时,会使用标识F1来将该消息中的业务数据转发至第一服务(第二服务);第一网络代理(第二网络代理)通过第二虚拟通道发往第二网络代理(第一网络代理)的消息中会携带标识F2;第一网络代理(第二网络代理)接收到来自第二虚拟通道的消息时,会使用标识F2来将该消息中的业务数据转发至第三服务(第四服务)。(1) Before the first network agent sends the first identity change request to the second network agent, the identity of the first virtual channel is the identity F 1 and the identity of the second virtual channel is the identity F 2 , therefore, the first network agent and The second network agent will use the identifier F1 to process the service data that needs to be transmitted through the first virtual channel, and use the identifier F2 to process the service data that needs to be transmitted through the second virtual channel. Specifically, the message sent by the first network agent (second network agent) to the second network agent (first network agent) through the first virtual channel will carry the identifier F 1 ; the first network agent (second network agent) receives When receiving a message from the first virtual channel, the identifier F 1 will be used to forward the business data in the message to the first service (second service); the first network agent (second network agent) sends the message through the second virtual channel. The message to the second network agent (first network agent) will carry the identifier F 2 ; when the first network agent (second network agent) receives the message from the second virtual channel, it will use the identifier F 2 to convert the message. The business data in is forwarded to the third service (fourth service).
(2)在第一网络代理向第二网络代理发送第一标识更改请求后,由上述S403可知,第一网络代理会将发送方向的第一虚拟通道的标识从标识F1更改为标识F2,以及将发送方向的第二虚拟通道的标识从标识F2更改为标识F1,因此第一网络代理通过第一虚拟通道发往第二网络代理的消息中携带的是标识F1,通过第二虚拟通道发往第二网络代理的消息中携带的是标识F2。由上述S404可知,第二网络代理接收到第一标识更改请求后,会基于第一标识更改请求将第一虚拟通道的标识从标识F1更改为标识F2,以及将第二虚拟通道的标识从标识F2更改为标识F1,因此在后续过程中,第二网络代理接收到来自第一虚拟通道的消息时,会使用标识F2来将该消息中的业务数据转发至第二服务,第二网络代理接收到来自第二虚拟通道的消息时,会使用标识F1来将该消息中的业务数据转发至第四服务。(2) After the first network agent sends the first identity change request to the second network agent, it can be known from the above S403 that the first network agent will change the identity of the first virtual channel in the sending direction from the identity F 1 to the identity F 2 , and the identity of the second virtual channel in the sending direction is changed from the identity F 2 to the identity F 1 , so the message sent by the first network agent to the second network agent through the first virtual channel carries the identity F 1 . The message sent by the second virtual channel to the second network agent carries the identifier F 2 . It can be seen from the above S404 that after receiving the first identity change request, the second network agent will change the identity of the first virtual channel from the identity F 1 to the identity F 2 based on the first identity change request, and change the identity of the second virtual channel to The identifier F 2 is changed to the identifier F 1 , so in the subsequent process, when the second network agent receives a message from the first virtual channel, it will use the identifier F 2 to forward the business data in the message to the second service. When the second network agent receives the message from the second virtual channel, it will use the identifier F1 to forward the service data in the message to the fourth service.
(3)在第二网络代理向第一网络代理返回第一标识更改响应和第二标识更改响应之后,由于第二网络代理已经将第一虚拟通道的标识从标识F1更改为标识F2,以及将第二虚拟通道的标识从标识F2更改为标识F1,因此在后续过程中,第二网络代理通过第一虚拟通道发往第一网络代理的消息中携带的是标识F2,通过第二虚拟通道发往第一网络代理的消息中携带的是标识F1。由上述S406可知,第一网络代理接收到第一标识更改响应后,会基于第一标识更改响应将接收方向的第一虚拟通道的标识从标识F1更改为标识F2,第一网络代理接收到第二标识更改响应后,会基于第二标识更改响应将接收方向的第二虚拟通道的标识从标识F2更改为标识F1。因此在后续过程中,第一网络代理接收到来自第一虚拟通道的消息时,会使用标识F2来将该消息中的业务数据转发至第一服务,第一网络代理接收到来自第二虚拟通道的消息时,会使用标识F1来将该消息中的业务数据转发至第三服务。(3) After the second network agent returns the first identity change response and the second identity change response to the first network agent, since the second network agent has changed the identity of the first virtual channel from the identity F 1 to the identity F 2 , And the identity of the second virtual channel is changed from the identity F 2 to the identity F 1 , so in the subsequent process, the message sent by the second network agent to the first network agent through the first virtual channel carries the identity F 2 , through The message sent by the second virtual channel to the first network agent carries the identifier F 1 . It can be seen from the above S406 that after receiving the first identity change response, the first network agent will change the identity of the first virtual channel in the receiving direction from the identity F 1 to the identity F 2 based on the first identity change response. The first network agent receives After receiving the second identity change response, the identity of the second virtual channel in the receiving direction is changed from the identity F 2 to the identity F 1 based on the second identity change response. Therefore, in the subsequent process, when the first network agent receives the message from the first virtual channel, it will use the identifier F2 to forward the business data in the message to the first service. The first network agent receives the message from the second virtual channel. When sending a message to the channel, the identifier F 1 will be used to forward the business data in the message to the third service.
本申请实施例中,除了可以通过上述更改第一虚拟通道的标识来提高业务数据的传输效率之外,还可以通过以下方式实现:In the embodiment of this application, in addition to improving the transmission efficiency of business data by changing the identity of the first virtual channel as described above, it can also be achieved in the following ways:
考虑到第一网络代理和第二网络代理之间可以建立多条通信通道(包括上述第二通信通道),每条通信通道上均可以建立虚拟通道,其过程可参见上述S106-S108。因此,第一网络代理可以从上述多条通信通道中选择出已承载虚拟通道的数量最少的通信通道,然后在该条通信通道上建立第一虚拟通道。这样,第一网络代理或容器系统的控制节点就可以为第一虚拟通道分配长度较短的标识。Considering that multiple communication channels (including the above-mentioned second communication channel) can be established between the first network agent and the second network agent, a virtual channel can be established on each communication channel, and the process can be referred to the above-mentioned S106-S108. Therefore, the first network agent can select the communication channel that carries the smallest number of virtual channels from the plurality of communication channels, and then establish the first virtual channel on the communication channel. In this way, the first network agent or the control node of the container system can allocate a short-length identifier to the first virtual channel.
具体实现中,第一网络代理在创建第一虚拟通道之前,可以先确定待传输的业务数据的大小。当待传输的业务数据较大时,第一网络代理可以选择已承载虚拟通道的数量最少的通信通道,并再该通道上建立第一虚拟通道,或者第一网络代理可以建立一条新的、连接到第二网络代理的通信通道,并再新通道上建立第一虚拟通道。 In specific implementation, before creating the first virtual channel, the first network agent may first determine the size of the service data to be transmitted. When the business data to be transmitted is large, the first network agent can select the communication channel with the smallest number of virtual channels and establish the first virtual channel on this channel, or the first network agent can establish a new connection. to the communication channel of the second network agent, and establish the first virtual channel on the new channel.
上述图7-图10描述的是在第一虚拟通道正常的情况下,第一服务和第二服务之间的通信过程。但在实际应用中,还可能存在第一虚拟通道断开的情况,其中,导致第一虚拟通道断开的情况包括以下一种或两种:第一服务断开与第一网络代理之间的第一通信通道,以及第二服务断开与第二网络代理之间的第三通信通道。下面分别描述在上述一种或两种情况下,第一服务和第二服务之间的通信的断开过程。The above-mentioned Figures 7 to 10 describe the communication process between the first service and the second service when the first virtual channel is normal. However, in actual applications, there may also be situations where the first virtual channel is disconnected. The situations that cause the first virtual channel to be disconnected include one or both of the following: disconnection of the first service and the first network agent. a first communication channel, and a third communication channel between the second service disconnect and the second network agent. The following describes respectively the disconnection process of the communication between the first service and the second service in one or both of the above situations.
情况1、第一服务断开与第一网络代理之间的第一通信通道Scenario 1: The first service disconnects the first communication channel with the first network agent
第一服务向第一网络代理发送断开第一通信通道的通知消息。第一网络代理接收到上述断开第一通信通道的通知消息后,向第二网络代理发送第一断开消息,其中,第一断开消息用于表示当前第一网络代理在本地将第一虚拟通道设置为半关闭状态,半关闭状态包括第一网络代理可以接收来自第一虚拟通道的指定的消息(如后文中的第二断开消息),但不可以接收来自第一虚拟通道的数据传输消息(如数据传输消息R2和数据传输消息R3)。第二网络代理接收到第一断开消息后,向第一网络代理返回第二断开消息,并删除第一虚拟通道的标识与第二服务的标识之间的映射关系,其中,第二断开消息用于表示当前第二网络代理在本地将第一虚拟通道设置为全关闭状态,全关闭状态包括第二网络代理不接收来自第一虚拟通道的所有消息。第一网络代理接收到上述第二断开消息后,删除第一虚拟通道的标识与第一服务的标识之间的映射关系,并断开第一虚拟通道。如此,第一虚拟通道的标识便被释放,第一网络代理可将该标识分配给其他虚拟通道。The first service sends a notification message to the first network agent to disconnect the first communication channel. After receiving the notification message for disconnecting the first communication channel, the first network agent sends a first disconnect message to the second network agent, where the first disconnect message is used to indicate that the first network agent currently locally disconnects the first communication channel. The virtual channel is set to a semi-closed state. The semi-closed state includes that the first network agent can receive a specified message from the first virtual channel (such as the second disconnect message below), but cannot receive data from the first virtual channel. Transmission messages (such as data transmission message R 2 and data transmission message R 3 ). After receiving the first disconnection message, the second network agent returns the second disconnection message to the first network agent, and deletes the mapping relationship between the identifier of the first virtual channel and the identifier of the second service, wherein the second disconnection message The open message is used to indicate that the second network agent currently sets the first virtual channel to a fully closed state locally. The fully closed state includes that the second network agent does not receive all messages from the first virtual channel. After receiving the second disconnection message, the first network agent deletes the mapping relationship between the identifier of the first virtual channel and the identifier of the first service, and disconnects the first virtual channel. In this way, the identity of the first virtual channel is released, and the first network agent can allocate the identity to other virtual channels.
可选的,如果第一网络代理在接收到上述断开第一通信通道的通知消息后,还接收到第二网络代理通过第一虚拟通道发送的数据传输消息(如数据传输消息R2和数据传输消息R3),则第一网络代理丢弃上述数据传输消息。Optionally, if the first network agent, after receiving the above-mentioned notification message for disconnecting the first communication channel, also receives a data transmission message (such as data transmission message R2 and data transmission message R2 ) sent by the second network agent through the first virtual channel. transmission message R 3 ), the first network agent discards the above-mentioned data transmission message.
可选的,如果情况1发生在更改第一虚拟通道的标识之前,即第一网络代理接收到上述断开第一通信通道的通知消息发生在第一网络代理向第二网络代理发送第一标识更改请求(即S402)之前,则第一网络代理可以不向第二网络代理发送第一标识更改请求。Optionally, if situation 1 occurs before changing the identity of the first virtual channel, that is, the first network agent receives the above-mentioned notification message of disconnecting the first communication channel and occurs when the first network agent sends the first identity to the second network agent. Before the change request (ie S402), the first network agent may not send the first identity change request to the second network agent.
可选的,如果情况1发生在更改第一虚拟通道的标识的过程中,则第一虚拟通道的标识从标识F1更改为标识F2之后,再断开第一虚拟通道,即情况1的出现并不会打断第一虚拟通道的标识的更改过程。具体地:当第一网络代理接收到上述断开第一通信通道的通知消息发生(此处该消息携带标识F1)在第一网络代理向第二网络代理发送第一标识更改请求之后,对于第二网络代理来说,第二网络代理会先接收到第一标识更改请求,再接收到第一断开消息。因此,第二网络代理会先执行上述S404-S405,再执行:向第一网络代理返回第二断开消息(此处该消息携带标识F2),以及删除标识F2与第二服务的标识之间的映射关系。相应地,第一网络代理会先执行上述S406,在接收到上述第二断开消息后,再执行:删除标识F2与第一服务的标识之间的映射关系,以及断开第一虚拟通道。Optionally, if situation 1 occurs during the process of changing the identity of the first virtual channel, then the first virtual channel is disconnected after the identity of the first virtual channel is changed from the identity F 1 to the identity F 2 , that is, the first virtual channel is disconnected. The occurrence does not interrupt the process of changing the identity of the first virtual channel. Specifically: when the first network agent receives the above-mentioned notification message to disconnect the first communication channel (here the message carries the identifier F 1 ), after the first network agent sends the first identifier change request to the second network agent, for For the second network agent, the second network agent will first receive the first identity change request, and then receive the first disconnect message. Therefore, the second network agent will first execute the above-mentioned S404-S405, and then execute: return the second disconnect message to the first network agent (here, the message carries the identifier F 2 ), and delete the identifier F 2 and the identifier of the second service. mapping relationship between them. Correspondingly, the first network agent will first execute the above-mentioned S406, and after receiving the above-mentioned second disconnection message, then execute: delete the mapping relationship between the identifier F 2 and the identifier of the first service, and disconnect the first virtual channel .
情况2、第二服务断开与第二网络代理之间的第三通信通道Scenario 2: The second service disconnects the third communication channel with the second network agent
第二服务向第二网络代理发送断开第三通信通道的通知消息。第二网络代理接收到上述断开第三通信通道的通知消息后,向第一网络代理发送第二断开消息,并删除第一虚拟通道的标识与第二服务的标识之间的映射关系。第一网络代理接收到上述第二断开消息后,删除第一虚拟通道的标识与第一服务的标识之间的映射关系,并断开第一虚拟通道。The second service sends a notification message to the second network agent to disconnect the third communication channel. After receiving the notification message for disconnecting the third communication channel, the second network agent sends a second disconnect message to the first network agent, and deletes the mapping relationship between the identifier of the first virtual channel and the identifier of the second service. After receiving the second disconnection message, the first network agent deletes the mapping relationship between the identifier of the first virtual channel and the identifier of the first service, and disconnects the first virtual channel.
可选的,如果第二网络代理在接收到上述断开第三通信通道的通知消息后,还接收到第一网络代理通过第一虚拟通道发送的数据传输消息(如数据传输消息R1),则第二网络代理丢弃上述数据传输消息。 Optionally, if the second network agent, after receiving the notification message for disconnecting the third communication channel, also receives a data transmission message (such as data transmission message R 1 ) sent by the first network agent through the first virtual channel, Then the second network agent discards the above data transmission message.
可选的,如果情况2发生在更改第一虚拟通道的标识的过程中,具体地:Optional, if situation 2 occurs during the process of changing the identity of the first virtual channel, specifically:
(1)当第二网络代理接收到上述断开第三通信通道的通知消息发生在第一网络代理向第二网络代理发送第一标识更改请求(即S402)之后,且第二网络代理接收到第一标识更改请求之前,也就是说,第二网络代理会先接收到上述断开第三通信通道的通知消息,再接收到第一标识更改请求。因此,第二网络代理会先执行向第一网络代理发送第二断开消息(此处该消息携带标识F1),再执行删除标识F1与第二服务的标识之间的映射关系。相应地,第一网络代理会先执行上述S401-S403;在接收上述第二断开消息之后,再执行:删除接收方向的第一虚拟通道的标识(即标识F1)与第一服务的标识之间的映射关系,删除发送方向的第一虚拟通道的标识(即标识F2)与第一服务的标识之间的映射关系,以及断开第一虚拟通道。(1) When the second network agent receives the notification message for disconnecting the third communication channel, it occurs after the first network agent sends the first identity change request to the second network agent (i.e. S402), and the second network agent receives Before the first identity change request, that is to say, the second network agent will first receive the notification message for disconnecting the third communication channel, and then receive the first identity change request. Therefore, the second network agent will first send a second disconnect message to the first network agent (here, the message carries the identifier F 1 ), and then delete the mapping relationship between the identifier F 1 and the identifier of the second service. Correspondingly, the first network agent will first execute the above-mentioned S401-S403; after receiving the above-mentioned second disconnection message, it will then execute: delete the identifier of the first virtual channel in the receiving direction (ie, the identifier F 1 ) and the identifier of the first service. deleting the mapping relationship between the identifier of the first virtual channel in the sending direction (ie, the identifier F 2 ) and the identifier of the first service, and disconnecting the first virtual channel.
(2)当第二网络代理接收到上述断开第三通信通道的通知消息发生在第二网络代理接收到上述第一标识更改请求之前,也就是说,第二网络代理会先接收到第一标识更改请求,再接收到上述断开第三通信通道的通知消息。因此,第二网络代理会先执行上述S404-S405,再向第一网络代理发送第二断开消息(此处该消息携带标识F2)。相应地,第一网络代理会先接收到上述第一标识更改响应,再接收到上述第二断开消息,因此,第一网络代理会先执行S406,再执行:删除标识F2与第一服务的标识之间的映射关系,以及断开第一虚拟通道。(2) When the second network agent receives the notification message for disconnecting the third communication channel, it occurs before the second network agent receives the first identity change request. That is to say, the second network agent will first receive the first identification change request. The identification change request is received, and then the notification message for disconnecting the third communication channel is received. Therefore, the second network agent will first perform the above-mentioned S404-S405, and then send the second disconnect message to the first network agent (here, the message carries the identifier F 2 ). Correspondingly, the first network agent will first receive the above-mentioned first identification change response, and then receive the above-mentioned second disconnection message. Therefore, the first network agent will first execute S406, and then execute: delete the identifier F 2 and the first service mapping relationship between the identifiers, and disconnecting the first virtual channel.
情况3:第一网络代理接收到第一服务发送的断开第一通信通道的通知消息,与此同时第二网络代理接收到第二服务发送的断开第三通信通道的通知消息。Case 3: The first network agent receives a notification message sent by the first service to disconnect the first communication channel, and at the same time, the second network agent receives a notification message sent by the second service to disconnect the third communication channel.
第一服务向第一网络代理发送断开第一通信通道的通知消息。第一网络代理接收到上述断开第一通信通道的通知消息后,向第二网络代理发送第一断开消息,以及丢弃第二网络代理通过第一虚拟通道发送的数据传输消息。The first service sends a notification message to the first network agent to disconnect the first communication channel. After receiving the notification message for disconnecting the first communication channel, the first network agent sends the first disconnect message to the second network agent, and discards the data transmission message sent by the second network agent through the first virtual channel.
第二服务向第二网络代理发送断开第三通信通道的通知消息。第二网络代理接收到上述断开第三通信通道的通知消息后,向第一网络代理发送第二断开消息,并删除标识F1与第二服务的标识之间的映射关系,以及丢弃第一网络代理通过第一虚拟通道发送的所有消息(包括上述第一断开消息)。The second service sends a notification message to the second network agent to disconnect the third communication channel. After receiving the notification message for disconnecting the third communication channel, the second network agent sends a second disconnect message to the first network agent, deletes the mapping relationship between the identifier F1 and the identifier of the second service, and discards the third communication channel. All messages sent by a network agent through the first virtual channel (including the above-mentioned first disconnect message).
第一网络代理接收到第二断开消息后,删除标识F1与第一服务的标识之间的映射关系,并断开第一虚拟通道。After receiving the second disconnection message, the first network agent deletes the mapping relationship between the identifier F 1 and the identifier of the first service, and disconnects the first virtual channel.
可选的,如果情况3发生在更改第一虚拟通道的标识之前,则第一网络代理可以不向第二网络代理发送第一标识更改请求。Optionally, if situation 3 occurs before changing the identity of the first virtual channel, the first network agent may not send the first identity change request to the second network agent.
可选的,如果情况3发生在更改第一虚拟通道的标识的过程中,则第一虚拟通道的断开过程以及第一虚拟通道的标识的更改过程,与上述情况1和情况2发生在更改第一虚拟通道的标识的过程中时的实现思路一致,因此,为了简便此处不再展开描述。Optionally, if situation 3 occurs in the process of changing the identity of the first virtual channel, the disconnection process of the first virtual channel and the change process of the identity of the first virtual channel are the same as the above situation 1 and situation 2 that occur in the change process. The process of identifying the first virtual channel has the same implementation idea, so for the sake of simplicity, it will not be described here.
需要说明的是,第一虚拟通道的断开(包括上述任一种情况)不会影响到第二虚拟通道的标识的更改。理由如下:只要第二网络代理可以接收到第一网络代理发送的第二标识更改请求(或能够指示第二网络代理交换标识F1和标识F2的第一标识更改请求),就说明第一网络代理已经更改了发送方向的第二虚拟通道的标识,且第二网络代理可以将第二虚拟通道的标识更改为标识F1。由于第二虚拟通道处于正常连接状态,因此第二网络代理可以通过第二虚拟通道向第一网络代理发送第二标识更改响应,那么第一网络代理可以更改接收方向的第二虚拟通道的标识。如此,可以完成第二虚拟通道的标识的更改。It should be noted that the disconnection of the first virtual channel (including any of the above situations) will not affect the change of the identifier of the second virtual channel. The reason is as follows: as long as the second network agent can receive the second identity change request sent by the first network agent (or can instruct the second network agent to exchange the first identity change request of identity F 1 and identity F 2 ), it means that the first identity change request The network agent has changed the identity of the second virtual channel in the sending direction, and the second network agent can change the identity of the second virtual channel to the identity F 1 . Since the second virtual channel is in a normal connection state, the second network agent can send a second identity change response to the first network agent through the second virtual channel, and then the first network agent can change the identity of the second virtual channel in the receiving direction. In this way, the change of the identity of the second virtual channel can be completed.
结合上述图7-图11可知,通过第一虚拟通道传输的消息多种多样,具体可以包括S106中的心跳消息、S108中的虚拟连接消息、S202中的数据传输消息R1、S205中的数据传输消 息R2、S302中的数据传输消息R3、S402中的第一标识更改请求、S405中的第一标识更改响应、以及上述第一断开消息和第二断开消息。为了区分这些信息,本申请实施例给基于第一虚拟通道传输的消息中设置了操作类型字段,该字段可以被设置为不同的值,以用于区分在第一虚拟通道上执行的不同操作。Combining the above-mentioned Figures 7 to 11, it can be seen that the messages transmitted through the first virtual channel are diverse, and may specifically include the heartbeat message in S106, the virtual connection message in S108, the data transmission message R 1 in S202, and the data in S205. transmission message message R 2 , the data transmission message R 3 in S302, the first identity change request in S402, the first identity change response in S405, and the above-mentioned first disconnection message and second disconnection message. In order to distinguish this information, the embodiment of the present application sets an operation type field in the message transmitted based on the first virtual channel. This field can be set to different values to distinguish different operations performed on the first virtual channel.
示例性的,如图12所示,操作类型字段可以包括多个部分。其中,第一字段可用于将基于第一虚拟通道传输的消息分为两类,一类是虚拟连接消息、数据传输消息R1、数据传输消息R2、数据传输消息R3、第一断开消息以及第二断开消息,这类消息的第一字段均是0;另一类是心跳消息、第一标识更改请求以及第一标识更改响应,这类消息的第一字段均是1。For example, as shown in Figure 12, the operation type field may include multiple parts. Among them, the first field can be used to divide the messages transmitted based on the first virtual channel into two categories. One category is the virtual connection message, the data transmission message R 1 , the data transmission message R 2 , the data transmission message R 3 , and the first disconnection message. messages and second disconnect messages, the first fields of such messages are all 0; the other type are heartbeat messages, first identity change requests and first identity change responses, the first fields of such messages are all 1.
对于第一字段均是0的消息,可用第三字段进行区分,具体地:第三字段是0表示该消息是用于建立虚拟通道的消息,即上述虚拟连接消息;第三字段是1表示该消息是用于传输业务数据的消息,即上述数据传输消息R1、数据传输消息R2、数据传输消息R3;第三字段是2表示该消息是用于断开虚拟通道的消息,即上述第一断开消息和第二断开消息。另外,对于上述第一断开消息和第二断开消息,可用第四字段进行区分,其中,第四字段是0表示该消息是上述第一断开消息,第四字段是1标识该消息是上述第二断开消息。For messages whose first fields are all 0, they can be distinguished by the third field. Specifically: a third field of 0 indicates that the message is a message for establishing a virtual channel, that is, the above virtual connection message; a third field of 1 indicates that the message is The message is a message used to transmit business data, that is, the above-mentioned data transmission message R 1 , data transmission message R 2 , and data transmission message R 3 ; the third field is 2, indicating that the message is a message used to disconnect the virtual channel, that is, the above-mentioned The first disconnect message and the second disconnect message. In addition, the first disconnect message and the second disconnect message can be distinguished by a fourth field, where a fourth field of 0 indicates that the message is the first disconnect message, and a fourth field of 1 indicates that the message is The second disconnect message above.
对于第一字段均是1的消息,可用第二字段进行区分,具体地:第二字段是0表示该消息是用于更改虚拟通道的标识的请求,即上述第一标识更改请求;第二字段是1表示该消息是第一标识更改请求的响应,即上述第一标识更改响应;第二字段是2表示该消息是上述心跳消息。For messages whose first fields are all 1, they can be distinguished by the second field. Specifically: if the second field is 0, it means that the message is a request to change the identity of the virtual channel, that is, the above-mentioned first identity change request; the second field A value of 1 indicates that the message is a response to the first identity change request, that is, the above-mentioned first identity change response; a value of 2 in the second field indicates that the message is the above-mentioned heartbeat message.
应理解,图12仅仅示出了一种示例性的消息结构,在实际应用中,基于第一虚拟通道传输的各类消息可以采用其他的格式进行区分,对此本申请实施例不进行限定。It should be understood that FIG. 12 only shows an exemplary message structure. In practical applications, various types of messages transmitted based on the first virtual channel can be distinguished in other formats, which is not limited by the embodiment of the present application.
前文通过第一服务和第二服务之间的通信过程详细描述了本申请提供的代理协议,下面结合图13-图15,从支持代理协议的第一网络代理和第二网络代理的结构方面,进一步描述上述代理协议。The proxy protocol provided by this application has been described in detail through the communication process between the first service and the second service. The following is a detailed description of the proxy protocol provided by the present application through the communication process between the first service and the second service. In conjunction with Figures 13 to 15, from the structure of the first network proxy and the second network proxy that support the proxy protocol, Further describe the above agency agreement.
图13示例性地展示了第一网络代理的结构示意图,图中的第一网络代理可以是上述方法实施例(即图7-图12中的第一网络代理)。如图13所示,第一网络代理400包括业务访问模块410、通道建立模块420、标识更改模块430以及数据存储模块440。业务访问模块410、通道建立模块420、标识更改模块430以及数据存储模块440协同工作,以实现上述方法实施例中第一网络代理执行的步骤。具体地,业务访问模块410用于负责第一服务的访问,包括上述S102中接收第一消息的步骤、上述S201中接收第二消息的步骤、上述S202、上述S206、上述S303、以及接收来自第一服务的断开第一虚拟通道的通知消息的步骤;通道建立模块420用于执行上述S101中与建立第一通信通道的相关步骤、上述S103-S106、上述S108中与建立第一虚拟通道相关的步骤、以及向第二网络代理发送第一断开消息和接收来自第二网络代理的第二断开消息的相关步骤;标识更改模块430用于执行上述S401-S403以及上述S406;存储模块440用于执行上述S107、上述S108中存储第一虚拟通道的标识与第一服务的标识之间的映射关系、以及在第一虚拟通道断开的情况下删除第一虚拟通道的标识与第一服务的标识之间的映射关系的相关步骤。Figure 13 exemplarily shows a schematic structural diagram of a first network agent. The first network agent in the figure may be the first network agent in the above method embodiment (ie, the first network agent in Figures 7 to 12). As shown in FIG. 13 , the first network agent 400 includes a service access module 410 , a channel establishment module 420 , an identity change module 430 and a data storage module 440 . The service access module 410, the channel establishment module 420, the identification changing module 430 and the data storage module 440 work together to implement the steps performed by the first network agent in the above method embodiment. Specifically, the business access module 410 is responsible for accessing the first service, including the step of receiving the first message in the above S102, the step of receiving the second message in the above S201, the above S202, the above S206, the above S303, and receiving the message from the first service. The step of disconnecting the notification message of the first virtual channel of a service; the channel establishment module 420 is used to perform the steps related to establishing the first communication channel in the above S101, the above S103-S106, and the above S108 related to the establishment of the first virtual channel. The steps, as well as the related steps of sending a first disconnection message to the second network agent and receiving a second disconnection message from the second network agent; the identification changing module 430 is used to perform the above-mentioned S401-S403 and the above-mentioned S406; the storage module 440 For performing the above S107, storing the mapping relationship between the identifier of the first virtual channel and the identifier of the first service in the above S108, and deleting the identifier of the first virtual channel and the first service when the first virtual channel is disconnected. The relevant steps of the mapping relationship between the identifications.
应理解,图13所示的结构示意图仅仅是根据功能对上述第一网络代理进行划分的一种示例性的结构划分方式,本申请实施例并不对第一网络代理的结构的具体划分方式进行限定。还应理解,第一网络代理内部的各个模块可以是软件模块,也可以是硬件模块,也可以部分是软件模块部分是硬件模块。 It should be understood that the schematic structural diagram shown in Figure 13 is only an exemplary structural division method for dividing the first network agent according to functions. The embodiment of the present application does not limit the specific division method of the structure of the first network agent. . It should also be understood that each module within the first network agent may be a software module or a hardware module, or may be partly a software module and partly a hardware module.
图14示出了一种计算设备的结构示意图,上述第一网络代理400可以部署在该计算设备上,该计算设备可以是云环境中的计算设备(如服务器),或边缘环境中的计算设备,或终端计算设备。如图14所示,计算设备500包括存储器510、处理器520、通信接口530以及总线540,其中,存储器510、处理器520、通信接口530通过总线540实现彼此之间的通信连接。Figure 14 shows a schematic structural diagram of a computing device. The above-mentioned first network agent 400 can be deployed on the computing device. The computing device can be a computing device (such as a server) in a cloud environment, or a computing device in an edge environment. , or terminal computing device. As shown in Figure 14, the computing device 500 includes a memory 510, a processor 520, a communication interface 530, and a bus 540. The memory 510, the processor 520, and the communication interface 530 implement communication connections with each other through the bus 540.
存储器510可以包括只读存储器(read only memory,ROM)、静态存储设备、动态存储设备或者随机存取存储器(random access memory,RAM)、硬盘等。存储器510可以存储程序代码,例如,业务访问模块410中的程序代码、通道建立模块420中的程序代码、标识更改模块430中的程序代码以及数据存储模块440中的程序代码等。当存储器510中存储的程序代码被处理器520执行时,处理器520和通信接口530用于执行第一网络代理400所执行的部分或全部方法(包括上述S101-S108、S201-S202、S206、S303中第一网络代理执行的步骤、以及当第一虚拟通道断开时第一网络代理执行的步骤)。存储器510还可以存储数据,例如:处理器520在执行过程中产生的中间数据或结果数据,例如,第一虚拟通道的标识、数据传输消息R1等。The memory 510 may include a read only memory (ROM), a static storage device, a dynamic storage device, a random access memory (RAM), a hard disk, etc. The memory 510 may store program codes, for example, program codes in the service access module 410, program codes in the channel establishment module 420, program codes in the identification changing module 430, and program codes in the data storage module 440, etc. When the program code stored in the memory 510 is executed by the processor 520, the processor 520 and the communication interface 530 are used to execute part or all of the methods executed by the first network agent 400 (including the above-mentioned S101-S108, S201-S202, S206, The steps performed by the first network agent in S303, and the steps performed by the first network agent when the first virtual channel is disconnected). The memory 510 may also store data, such as intermediate data or result data generated by the processor 520 during execution, such as the identification of the first virtual channel, the data transmission message R 1 , etc.
处理器520可以采用中央处理器(central processing unit,CPU)、专用集成电路(application specificintegrated circuit,ASIC)、图形处理器(graphics processing unit,GPU)或者一个或多个集成电路。The processor 520 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more integrated circuits.
处理器520还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,第一网络代理400的功能可以通过处理器520中的硬件的集成逻辑电路或者软件形式的指令完成。处理器520还可以是通用处理器、数据信号处理器(digital signal process,DSP)、现场可编程逻辑门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件,分立门或者晶体管逻辑器件,分立硬件组件,可以实现或者执行本申请实施例中公开的方法、步骤及逻辑框图。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等,结合本申请实施例所公开的方法可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器、闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器510,处理器520读取存储器510中的信息,结合其硬件完成第一网络代理400的部分或全部功能。The processor 520 may also be an integrated circuit chip with signal processing capabilities. During the implementation process, the functions of the first network agent 400 can be completed by instructions in the form of hardware integrated logic circuits or software in the processor 520 . The processor 520 can also be a general-purpose processor, a digital signal process (DSP), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, Discrete hardware components can implement or execute the methods, steps and logical block diagrams disclosed in the embodiments of this application. Among them, the general processor can be a microprocessor or the processor can be any conventional processor, etc. The method disclosed in combination with the embodiments of the present application can be directly implemented as a hardware decoding processor to complete the execution, or can be performed using decoding processing. The combination of hardware and software modules in the device is executed. The software module can be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other mature storage media in this field. The storage medium is located in the memory 510. The processor 520 reads the information in the memory 510 and completes part or all of the functions of the first network agent 400 in combination with its hardware.
通信接口530使用例如但不限于收发器一类的收发模块,来实现计算设备500与其他设备或通信网络之间的通信。示例性的,通过通信接口530接收来自第一服务的消息(如第一消息),以及向第二网络代理发送消息(如数据传输消息R1)。The communication interface 530 uses a transceiver module, such as but not limited to a transceiver, to implement communication between the computing device 500 and other devices or communication networks. Exemplarily, a message (such as a first message) from the first service is received through the communication interface 530, and a message (such as a data transmission message R 1 ) is sent to the second network agent.
总线540可以包括在计算设备500中的各个部件(例如,存储器510、处理器520以及通信接口530)之间传送信息的通路。Bus 540 may include a path that carries information between various components in computing device 500 (eg, memory 510, processor 520, and communication interface 530).
图15示出的一种计算设备系统的结构示意图,该计算设备系统包括多个计算设备,上述第一网络代理400可以分布式地部署在该计算设备系统中的多个计算设备上。如图15所示,计算设备系统600包括多个计算设备700,每个计算设备700包括存储器710、处理器720、通信接口730以及总线740,其中,存储器710、处理器720、通信接口730通过总线740实现彼此之间的通信连接。Figure 15 shows a schematic structural diagram of a computing device system. The computing device system includes multiple computing devices. The above-mentioned first network agent 400 can be deployed on multiple computing devices in the computing device system in a distributed manner. As shown in Figure 15, the computing device system 600 includes multiple computing devices 700. Each computing device 700 includes a memory 710, a processor 720, a communication interface 730, and a bus 740. The memory 710, the processor 720, and the communication interface 730 pass through Bus 740 implements communication connections between each other.
存储器710可以包括ROM、RAM、静态存储设备、动态存储设备、硬盘(例如SSD、 HDD)等。存储器710可以存储程序代码,例如,业务访问模块410中的一部分程序代码、通道建立模块420中的一部分程序代码、标识更改模块430中的一部分程序代码以及数据存储模块440中的一部分程序代码等。当存储器710中存储的程序代码被处理器720执行时,处理器720和通信接口730用于执行第一网络代理400所执行的部分方法(包括上述S101-S108、S201-S202、S206、S303中第一网络代理执行的步骤、以及当第一虚拟通道断开时第一网络代理执行的步骤)。存储器710还可以存储数据,例如:处理器720在执行过程中产生的中间数据或结果数据,例如,第一虚拟通道的标识、数据传输消息R1等。Memory 710 may include ROM, RAM, static storage devices, dynamic storage devices, hard disks (such as SSD, HDD) etc. The memory 710 may store program codes, for example, a part of the program code in the service access module 410, a part of the program code in the channel establishment module 420, a part of the program code in the identification changing module 430, and a part of the program code in the data storage module 440, etc. When the program code stored in the memory 710 is executed by the processor 720, the processor 720 and the communication interface 730 are used to execute part of the method executed by the first network agent 400 (including the above-mentioned S101-S108, S201-S202, S206, S303). steps performed by the first network agent, and steps performed by the first network agent when the first virtual channel is disconnected). The memory 710 may also store data, such as intermediate data or result data generated by the processor 720 during execution, such as the identification of the first virtual channel, the data transmission message R 1 , etc.
处理器720可以采用CPU、GPU、ASIC或者一个或多个集成电路。处理器720还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,第一网络代理400的部分功能可用通过处理器720中的硬件的集成逻辑电路或者软件形式的指令完成。处理器720还可以是DSP、FPGA、通用处理器、其他可编程逻辑器件,分立门或者晶体管逻辑器件、分立硬件组件,可以实现或者执行本申请实施例中公开的部分方法、步骤及逻辑框图。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等,结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器、闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器710,处理器720读取存储器710中的信息,结合其硬件完成第一网络代理400的部分功能。Processor 720 may employ a CPU, GPU, ASIC, or one or more integrated circuits. The processor 720 may also be an integrated circuit chip with signal processing capabilities. During the implementation process, part of the functions of the first network agent 400 may be implemented by instructions in the form of integrated logic circuits or software in the hardware of the processor 720 . The processor 720 can also be a DSP, FPGA, general-purpose processor, other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and can implement or execute some of the methods, steps and logic block diagrams disclosed in the embodiments of this application. The general processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application may be directly implemented as a hardware decoding processor, or may be executed using a decoding processor. The combination of hardware and software modules in the code processor is executed. The software module can be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other mature storage media in this field. The storage medium is located in the memory 710. The processor 720 reads the information in the memory 710 and completes some functions of the first network agent 400 in combination with its hardware.
通信接口730使用例如但不限于收发器一类的收发模块,来实现计算设备700与其他计算设备或通信网络之间的通信。例如,通过通信接口730接收来自第一服务的消息(如第一消息)、或者向第二网络代理发送消息(如数据传输消息R1)。The communication interface 730 uses a transceiver module, such as but not limited to a transceiver, to implement communication between the computing device 700 and other computing devices or communication networks. For example, a message from the first service (such as a first message) is received through the communication interface 730, or a message (such as a data transmission message R 1 ) is sent to the second network agent.
总线740可以包括在计算设备700中的各个部件(例如,存储器710、处理器720以及通信接口730)之间传送信息的通路。Bus 740 may include a path that carries information between various components in computing device 700 (eg, memory 710, processor 720, and communication interface 730).
上述多个计算设备700之间通过通信网络建立通信通路,以实现第一网络代理400的功能。任一计算设备可以是云环境中的计算设备(例如,服务器),或边缘环境中的计算设备,或终端计算设备。Communication paths are established between the above-mentioned plurality of computing devices 700 through a communication network to implement the function of the first network agent 400 . Any computing device may be a computing device (eg, a server) in a cloud environment, a computing device in an edge environment, or a terminal computing device.
本申请实施例中,第二网络代理的结构与上述图13-图15所示的第一网络代理的结构可以相同,也可以是基于上述第一网络代理的结构设计的变型结构,因此本申请实施例不再对第二网络代理的结构展开描述。In the embodiment of the present application, the structure of the second network agent may be the same as the structure of the first network agent shown in the above-mentioned Figures 13-15, or it may be a modified structure designed based on the structure of the above-mentioned first network agent. Therefore, the present application The embodiment will no longer describe the structure of the second network proxy.
上述各个附图对应的流程的描述各有侧重,某个流程中没有详细描述的部分,可以参见其他流程的相关描述。The descriptions of the processes corresponding to each of the above drawings have different emphases. For parts that are not described in detail in a certain process, you can refer to the relevant descriptions of other processes.
在上述实施例中,可以全部或部分地通过软件、硬件或者其组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。提供第一网络代理400或容器系统(包括图3-图6所示的容器系统)的计算机程序产品分别包括第一网络代理400执行的一个或多个计算机程序代码,容器系统执行的一个或多个计算机程序代码。在计算机上加载和执行这些计算机程序代码时,全部或部分地产生按照本申请实施例所述的流程或功能。In the above embodiments, it may be implemented in whole or in part by software, hardware, or a combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product. The computer program product providing the first network agent 400 or the container system (including the container system shown in Figures 3-6) respectively includes one or more computer program codes executed by the first network agent 400, and one or more computer program codes executed by the container system. computer program code. When these computer program codes are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part.
上述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。上述计算机程序代码可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,上述计算机程序代码可以从一个网站站点、计算机、服务器或数据中心通过有线(例如,同轴电缆、光纤、双绞线或无线(例如,红外、无线、微波)等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。上述计算机可读存 储介质存储有提供第一网络代理400或容器系统(包括图3-图6所示的容器系统)执行的计算机程序代码。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个介质集成的服务器、数据中心等数据存储设备。上述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,光盘)、或者半导体介质(例如,固态硬盘(solid state disk,SSD))。 The above-mentioned computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The above-mentioned computer program code can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another. For example, the above-mentioned computer program code can be transferred from a website, computer, server or data center Transmission to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, twisted pair or wireless (such as infrared, wireless, microwave), etc.) means. The above computer readable storage The storage medium stores computer program code provided for execution by the first network agent 400 or the container system (including the container system shown in Figures 3-6). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more integrated media. The above available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, optical disk), or semiconductor media (eg, solid state disk (SSD)).

Claims (18)

  1. 一种通信方法,其特征在于,包括:A communication method, characterized by including:
    第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道,其中,所述第一网络代理负责第一服务的访问,所述第二网络代理负责第二服务的访问,所述第一虚拟通道用于传输所述第一服务和所述第二服务之间的通信消息,所述通信消息中携带有所述第一虚拟通道的标识,当前所述第一虚拟通道的标识是第一标识;The first network agent establishes a first virtual channel on the communication channel with the second network agent, wherein the first network agent is responsible for access to the first service, and the second network agent is responsible for access to the second service, The first virtual channel is used to transmit communication messages between the first service and the second service. The communication message carries an identifier of the first virtual channel. The current identifier of the first virtual channel is The logo is the first logo;
    所述第一网络代理将所述第一虚拟通道的标识从所述第一标识更改为第二标识,其中,所述第二标识的长度小于所述第一标识的长度。The first network agent changes the identification of the first virtual channel from the first identification to a second identification, wherein the length of the second identification is less than the length of the first identification.
  2. 根据权利要求1所述的方法,其特征在于,所述第二标识是所述通信通道上的第二虚拟通道的标识。The method according to claim 1, characterized in that the second identification is an identification of a second virtual channel on the communication channel.
  3. 根据权利要求2所述的方法,其特征在于,当满足以下一个或多个条件时,所述第一网络代理将所述第一虚拟通道的标识从所述第一标识更改为第二标识:The method according to claim 2, characterized in that when one or more of the following conditions are met, the first network agent changes the identity of the first virtual channel from the first identity to a second identity:
    所述第一虚拟通道上传输的业务数据的优先级高于所述第二虚拟通道上传输的业务数据的优先级,以及所述第一虚拟通道上传输业务数据的效率低于所述第二虚拟通道上传输业务数据的效率。The priority of service data transmitted on the first virtual channel is higher than the priority of service data transmitted on the second virtual channel, and the efficiency of transmitting service data on the first virtual channel is lower than that of the second virtual channel. The efficiency of transmitting business data on virtual channels.
  4. 根据权利要求1-3任一项所述的方法,其特征在于,所述第二网络代理存储有所述第一虚拟通道的标识与所述第二服务的标识之间的第一映射关系,其中,所述第一映射关系用于指示所述第二网络代理将来自所述第一虚拟通道的业务数据转发至所述第二服务。The method according to any one of claims 1 to 3, characterized in that the second network proxy stores a first mapping relationship between the identifier of the first virtual channel and the identifier of the second service, Wherein, the first mapping relationship is used to instruct the second network agent to forward the service data from the first virtual channel to the second service.
  5. 根据权利要求4所述的方法,其特征在于,所述第一网络代理存储有所述第一虚拟通道的标识与所述第一服务的标识之间的第二映射关系,其中,所述第二映射关系用于指示所述第一网络代理将所述来自所述第一虚拟通道的业务数据转发至所述第一服务;The method of claim 4, wherein the first network proxy stores a second mapping relationship between the identifier of the first virtual channel and the identifier of the first service, wherein the first network agent stores a second mapping relationship between the identifier of the first virtual channel and the identifier of the first service. The second mapping relationship is used to instruct the first network agent to forward the service data from the first virtual channel to the first service;
    所述第一网络代理将所述第一虚拟通道的标识从所述第一标识更改为第二标识,包括:The first network agent changes the identity of the first virtual channel from the first identity to a second identity, including:
    所述第一网络代理将所述第二映射关系中的所述第一虚拟通道的标识从所述第一标识更改为所述第二标识。The first network agent changes the identity of the first virtual channel in the second mapping relationship from the first identity to the second identity.
  6. 根据权利要求5所述的方法,其特征在于,所述第一网络代理将所述第二映射关系中的所述第一虚拟通道的标识从所述第一标识更改为所述第二标识,包括:The method according to claim 5, characterized in that the first network agent changes the identity of the first virtual channel in the second mapping relationship from the first identity to the second identity, include:
    所述第一网络代理向所述第二网络代理发送标识更改请求,其中,所述标识更改请求用于指示所述第二网络代理将所述第一映射关系中的所述第一虚拟通道的标识从所述第一标识更改为所述第二标识;The first network agent sends an identity change request to the second network agent, wherein the identity change request is used to instruct the second network agent to change the identity of the first virtual channel in the first mapping relationship. The identification is changed from the first identification to the second identification;
    所述第一网络代理将通过所述第一虚拟通道发往所述第二网络代理的通信消息中携带的标识从所述第一标识更改为所述第二标识;The first network agent changes the identifier carried in the communication message sent to the second network agent through the first virtual channel from the first identifier to the second identifier;
    所述第一网络代理接收所述第二网络代理返回的标识更改响应,并基于所述标识更改响应将用于转发来自所述第一虚拟通道的业务数据至所述第一服务的标识从所述第一标识更改为所述第二标识。The first network agent receives the identity change response returned by the second network agent, and based on the identity change response, changes the identity used to forward the business data from the first virtual channel to the first service from the identity change response. The first identifier is changed to the second identifier.
  7. 根据权利要求1-6任一项所述的方法,其特征在于,所述通信通道是传输控制协议TCP通道,所述第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道之前,所述方法还包括:The method according to any one of claims 1 to 6, characterized in that the communication channel is a Transmission Control Protocol TCP channel, and the first network agent establishes a first communication channel on the communication channel with the second network agent. Before the virtual channel, the method also includes:
    所述第一网络代理向所述第二网络代理发送TCP连接消息,以建立所述通信通道。The first network agent sends a TCP connection message to the second network agent to establish the communication channel.
  8. 根据权利要求1-6任一项所述的方法,其特征在于,所述通信通道是TCP通道,所述第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道之前,所述方法还包括: The method according to any one of claims 1 to 6, characterized in that the communication channel is a TCP channel, and the first network agent establishes a first virtual channel on the communication channel with the second network agent before , the method also includes:
    所述第一网络代理基于所述第二网络代理发送的TCP连接消息,建立所述通信通道。The first network agent establishes the communication channel based on the TCP connection message sent by the second network agent.
  9. 根据权利要求1-8任一项所述的方法,其特征在于,所述第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道,包括:The method according to any one of claims 1 to 8, characterized in that the first network agent establishes a first virtual channel on the communication channel with the second network agent, including:
    响应于所述第一服务发送的消息,所述第一网络代理建立所述第一虚拟通道,其中,所述第一服务发送的消息未承载所述第一服务发往所述第二服务的业务数据。In response to the message sent by the first service, the first network agent establishes the first virtual channel, wherein the message sent by the first service does not carry the message sent by the first service to the second service. business data.
  10. 根据权利要求1-9任一项所述的方法,其特征在于,所述第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道,包括:The method according to any one of claims 1 to 9, characterized in that the first network agent establishes a first virtual channel on the communication channel with the second network agent, including:
    所述第一网络代理通过所述通信通道向所述第二网络代理发送虚拟连接消息,其中,所述虚拟连接消息包括所述第一虚拟通道的标识和所述第二服务的标识,所述虚拟连接消息用于指示所述第二网络代理建立与所述第二服务之间的通信通道。The first network agent sends a virtual connection message to the second network agent through the communication channel, wherein the virtual connection message includes an identifier of the first virtual channel and an identifier of the second service, and The virtual connection message is used to instruct the second network agent to establish a communication channel with the second service.
  11. 一种通信方法,其特征在于,应用于容器系统,所述系统包括第一容器、第二容器、以及前述权利要求1-10任一项所述的第一网络代理和第二网络代理,其中,A communication method, characterized in that it is applied to a container system, the system includes a first container, a second container, and the first network agent and the second network agent according to any one of the preceding claims 1-10, wherein ,
    所述第一容器运行第一服务;The first container runs a first service;
    所述第二容器运行第二服务;The second container runs a second service;
    所述第一网络代理在与所述第二网络代理之间的通信通道上建立第一虚拟通道,其中,所述第一网络代理负责所述第一服务的访问,所述第二网络代理负责所述第二服务的访问,所述第一虚拟通道用于传输所述第一服务和所述第二服务之间的通信消息,所述通信消息中携带有所述第一虚拟通道的标识,当前所述第一虚拟通道的标识是第一标识;The first network agent establishes a first virtual channel on the communication channel with the second network agent, wherein the first network agent is responsible for access to the first service, and the second network agent is responsible for Access to the second service, the first virtual channel is used to transmit communication messages between the first service and the second service, and the communication messages carry the identification of the first virtual channel, The current identifier of the first virtual channel is the first identifier;
    所述第一网络代理将所述第一虚拟通道的标识从所述第一标识更改为第二标识,其中,所述第二标识的长度小于所述第一标识的长度。The first network agent changes the identification of the first virtual channel from the first identification to a second identification, wherein the length of the second identification is less than the length of the first identification.
  12. 根据权利要求11所述的方法,其特征在于,所述通信通道是传输控制协议TCP通道,所述第一网络代理在与所述第二网络代理之间的通信通道上建立第一虚拟通道之前,所述方法还包括:The method of claim 11, wherein the communication channel is a Transmission Control Protocol (TCP) channel, and the first network agent establishes a first virtual channel on the communication channel with the second network agent before , the method also includes:
    所述第一网络代理向所述第二网络代理发送TCP连接消息,以建立所述通信通道。The first network agent sends a TCP connection message to the second network agent to establish the communication channel.
  13. 根据权利要求11所述的方法,其特征在于,所述通信通道是TCP通道,所述第一网络代理在与所述第二网络代理之间的通信通道上建立第一虚拟通道之前,所述方法还包括:The method of claim 11, wherein the communication channel is a TCP channel, and before the first network agent establishes a first virtual channel on the communication channel with the second network agent, the Methods also include:
    所述第二网络代理向所述第一网络代理发送TCP连接消息,建立所述通信通道。The second network agent sends a TCP connection message to the first network agent to establish the communication channel.
  14. 根据权利要求11-13任一项所述的方法,其特征在于,所述第一网络代理在与第二网络代理之间的通信通道上建立第一虚拟通道,包括:The method according to any one of claims 11 to 13, characterized in that the first network agent establishes a first virtual channel on the communication channel with the second network agent, including:
    响应于所述第一服务发送的消息,所述第一网络代理建立所述第一虚拟通道,其中,所述第一服务发送的消息未承载所述第一服务发往所述第二服务的业务数据。In response to the message sent by the first service, the first network agent establishes the first virtual channel, wherein the message sent by the first service does not carry the message sent by the first service to the second service. business data.
  15. 一种第一网络代理,其特征在于,包括:A first network agent, characterized by including:
    业务访问模块,用于负责第一服务的访问;The business access module is responsible for access to the first service;
    通道建立模块,用于在与第二网络代理之间的通信通道上建立第一虚拟通道,其中,所述第二网络代理负责第二服务的访问,所述第一虚拟通道用于传输所述第一服务和所述第二服务之间的通信消息,所述通信消息中携带有所述第一虚拟通道的标识,当前所述第一虚拟通道的标识是第一标识;A channel establishment module, configured to establish a first virtual channel on the communication channel with a second network agent, wherein the second network agent is responsible for accessing the second service, and the first virtual channel is used to transmit the The communication message between the first service and the second service, the communication message carries the identifier of the first virtual channel, and the current identifier of the first virtual channel is the first identifier;
    标识更改模块,用于将所述第一虚拟通道的标识从所述第一标识更改为第二标识,其中,所述第二标识的长度小于所述第一标识的长度。An identification changing module, configured to change the identification of the first virtual channel from the first identification to a second identification, wherein the length of the second identification is smaller than the length of the first identification.
  16. 一种容器系统,其特征在于,包括第一容器、第二容器、以及前述权利要求1-10任一项所述的第一网络代理和第二网络代理,其中, A container system, characterized by comprising a first container, a second container, and the first network agent and the second network agent according to any one of the preceding claims 1-10, wherein,
    所述第一容器,用于运行第一服务;The first container is used to run the first service;
    所述第二容器,用于运行第二服务;The second container is used to run the second service;
    所述第二网络代理,用于负责所述第二服务的访问;The second network agent is responsible for access to the second service;
    所述第一网络代理,用于负责所述第一服务的访问,以及在与所述第二网络代理之间的通信通道上建立第一虚拟通道,其中,所述第一虚拟通道用于传输所述第一服务和所述第二服务之间的通信消息,所述通信消息中携带有所述第一虚拟通道的标识,当前所述第一虚拟通道的标识是第一标识,以及将所述第一虚拟通道的标识从所述第一标识更改为第二标识,其中,所述第二标识的长度小于所述第一标识的长度。The first network agent is responsible for accessing the first service and establishing a first virtual channel on the communication channel with the second network agent, wherein the first virtual channel is used for transmission The communication message between the first service and the second service, the communication message carries the identifier of the first virtual channel, the current identifier of the first virtual channel is the first identifier, and the The identity of the first virtual channel is changed from the first identity to a second identity, wherein the length of the second identity is less than the length of the first identity.
  17. 一种计算设备,其特征在于,包括处理器和存储器,所述处理器执行所述存储器中的计算机程序代码以实现前述权利要求1-10所述的任一项方法。A computing device, characterized by comprising a processor and a memory, the processor executing computer program code in the memory to implement the method of any one of the preceding claims 1-10.
  18. 一种计算机可读存储介质,其特征在于,存储有计算机程序代码,当所述计算机程序代码被计算设备执行时,所述计算设备执行前述权利要求1-10任一项所述的方法。 A computer-readable storage medium, characterized in that computer program code is stored therein. When the computer program code is executed by a computing device, the computing device performs the method described in any one of the preceding claims 1-10.
PCT/CN2023/079651 2022-04-21 2023-03-03 Communication method and related product WO2023202241A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210423516.1 2022-04-21
CN202210423516.1A CN116980476A (en) 2022-04-21 2022-04-21 Communication method and related product

Publications (1)

Publication Number Publication Date
WO2023202241A1 true WO2023202241A1 (en) 2023-10-26

Family

ID=88419038

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/079651 WO2023202241A1 (en) 2022-04-21 2023-03-03 Communication method and related product

Country Status (2)

Country Link
CN (1) CN116980476A (en)
WO (1) WO2023202241A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070239922A1 (en) * 2005-12-09 2007-10-11 Horigan John W Technique for link reconfiguration
US20170331677A1 (en) * 2014-12-25 2017-11-16 Wangsu Science & Technology Co., Ltd Data transmission method, apparatus, and terminal
CN113940044A (en) * 2019-05-20 2022-01-14 思杰系统有限公司 System and method for managing packet flows via an intermediary device
CN114077502A (en) * 2020-08-14 2022-02-22 华为技术有限公司 Method for establishing data transmission channel, terminal system and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070239922A1 (en) * 2005-12-09 2007-10-11 Horigan John W Technique for link reconfiguration
US20170331677A1 (en) * 2014-12-25 2017-11-16 Wangsu Science & Technology Co., Ltd Data transmission method, apparatus, and terminal
CN113940044A (en) * 2019-05-20 2022-01-14 思杰系统有限公司 System and method for managing packet flows via an intermediary device
CN114077502A (en) * 2020-08-14 2022-02-22 华为技术有限公司 Method for establishing data transmission channel, terminal system and storage medium

Also Published As

Publication number Publication date
CN116980476A (en) 2023-10-31

Similar Documents

Publication Publication Date Title
WO2020052605A1 (en) Network slice selection method and device
CN113485823A (en) Data transmission method, device, network equipment and storage medium
WO2015058698A1 (en) Data forwarding
US20220086063A1 (en) Real-time scalable virtual session and network analytics
WO2015058699A1 (en) Data forwarding
CN110505244B (en) Remote tunnel access technology gateway and server
WO2022068756A1 (en) Service mesh system employing microservice, and service governance method
WO2024037296A1 (en) Protocol family-based quic data transmission method and device
US20240152290A1 (en) Data writing method, data reading method, apparatus, device, system, and medium
WO2017028399A1 (en) Communication data transmission method and system
WO2021185083A1 (en) Vnf instantiation method and device
WO2023098050A1 (en) Remote data access method and apparatus
CN115686875A (en) Method, apparatus and program product for transferring data between multiple processes
CN112968919B (en) Data processing method, device, equipment and storage medium
WO2018107433A1 (en) Information processing method and device
CN112968965B (en) Metadata service method, server and storage medium for NFV network node
WO2020187124A1 (en) Data processing method and device
WO2023179457A1 (en) Method, apparatus and system for identifying service connection, and storage medium
WO2023202241A1 (en) Communication method and related product
WO2022028092A1 (en) Vnf instantiation method and apparatus
WO2019052363A1 (en) Method and apparatus for modifying network slice instance
US11558812B2 (en) System and methods for multi-links SD-WAN using cellular device connections
WO2024034057A1 (en) Network management device, network management method, and program
WO2023198128A1 (en) Distributed resource sharing method and related apparatus
WO2023222077A1 (en) Resource configuration method and apparatus, and related device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23790904

Country of ref document: EP

Kind code of ref document: A1