Service management method and related device
By querying the socket ID table or execution unit ID table to identify the request message and routing it to the corresponding version of the execution unit, the problem that the old process cannot exit during the UDP server upgrade process is solved, and lossless service upgrade and efficient port management are realized.
Patent Information
- Application Number
- CN202311231316.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-06-25
- Filing Date
- 2023-09-21
- Publication Date
- 2024-12-27
AI Technical Summary
During the upgrade process of the UDP protocol-based server, the old process cannot exit because the old process cannot close the listening socket. Continuing to listen to the socket will cause both new and old processes to receive new requests, resulting in the old process being unable to exit. The prior art requires the definition of multiple port groups for polling and synchronization, which is complex and affects reliability and efficiency.
By querying the socket ID table or execution unit ID table, the request message is identified and routed to the corresponding version of the execution unit to ensure that the new request is no longer forwarded to the old execution unit, but only routed to the new execution unit, ensuring that the old execution unit can Exit without defining multiple port groups or listening for additional ports, simplifying port management.
The lossless service upgrade is achieved, the reliability and efficiency of service is improved, the complexity and rotation process of port management are avoided, and the old execution unit can exit normally.
Smart Images

Figure CN119201585A_ABST
Abstract
Description
[0001] This application claims priority to a Chinese patent application filed with the State Intellectual Property Office of China on June 25, 2023, with application number 202310752881.1 and invention name “A service upgrade method and related equipment”, the entire contents of which are incorporated by reference in this application. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to a service management method, device, server, computer-readable storage medium, and computer program product. Background Art
[0003] With the continuous development of computer technology, services with various functions have been generated. In applications with high requirements for data real-time performance, the server can usually use the User Datagram Protocol (UDP) to communicate with the client. In order to meet user needs or for security reasons, the server can usually perform version iterations, such as version upgrades.
[0004] Since UDP only has listening sockets but no connected sockets, UDP-based servers usually face the following problems during the upgrade process: if the old process (or old process) closes the listening socket, the old process can no longer send or receive messages of the old request; if the listening socket continues, both the old and new processes have a probability of receiving messages of the new request, and the old process cannot exit.
[0005] To this end, the relevant technology proposes to define multiple sets of port groups, and use polling to switch the currently used port groups each time the service is upgraded. The front-end load balancer and the back-end service synchronize the used port group information to ensure consistency, thereby achieving lossless upgrades. However, the above method requires the use of multiple sets of listening port groups, each worker process listens to multiple different ports, and the ports are rotated each time the upgrade is performed. The management and interaction of the port groups are relatively complex, which affects reliability and efficiency. Summary of the invention
[0006] The present application provides a service management method, which identifies the request message by querying the socket identifier (ID) table or the execution unit ID table (for example, the process ID table), and routes the request message to the execution unit of the corresponding version (such as the new process, the old process), so as to ensure the lossless service, and after the upgrade, the new request message is no longer forwarded to the old execution unit, but is only routed to the new execution unit, so as to ensure that the old execution unit (such as the old process) can exit. The method does not need to define multiple sets of port groups, nor does it need to monitor additional ports, which simplifies the port management during the lossless upgrade of the service and ensures the reliability and efficiency of the service. The present application also provides a service management device, a server, a computer-readable storage medium and a computer program product corresponding to the above method.
[0007] In a first aspect, the present application provides a service management method. The method is applied to a service management device. The service management device is deployed on a server, and the service management device is used to implement service version management. Among them, service version management may include service version upgrade. During the service version upgrade process, when execution units of different versions of the service exist at the same time, the request message can be routed and managed to achieve lossless service upgrade.
[0008] Specifically, the service management device can receive a request message from the client, and then query the socket ID table or the execution unit ID table according to the request message to obtain the listening socket. Among them, the socket ID table records the mapping relationship between the socket ID and the listening socket, and the execution unit ID table records the mapping relationship between the execution unit ID and the new version of the listening socket. When the listening socket is obtained from the execution unit ID table, the service management device routes the request message to the new version of the execution unit according to the listening socket. When the listening socket is obtained from the socket ID table, the request message is routed to the execution unit of the corresponding version according to the listening socket.
[0009] The method identifies the version of the request message by querying the socket ID table or the execution unit ID table (such as identifying whether the request message is a new request message or an old request message), and routes the request message to the execution unit of the corresponding version (such as a new process or an old process), thereby ensuring lossless services. Moreover, after the upgrade, the new request message is no longer forwarded to the old execution unit, but is only routed to the new execution unit, thereby ensuring that the old execution unit (such as the old process) can exit. Moreover, the method does not need to define multiple sets of port groups or monitor additional ports, thereby simplifying the port management of lossless service upgrades and ensuring the reliability and efficiency of services.
[0010] In some possible implementations, the service management device can query the listening socket corresponding to the socket ID from the socket ID table based on the socket ID in the request message; when the query fails, it means that the request message is a new request (for example, the first packet of the request message of a new user, which can usually be a handshake message), and the service management device can query the execution unit ID table based on the request message to obtain the listening socket.
[0011] In this method, since the destination connection identifier (DCID) of a new request (such as a handshake message) can usually be randomly generated by the client, the socket ID randomly generated by the client and the corresponding listening socket cannot be found in the socket ID table maintained by the server. Therefore, the request message can be identified as a new request through a simple table lookup operation, and it is routed to the execution unit of the new version for processing, rather than being routed to the execution unit of the old version, ensuring that the execution unit of the old version can exit after executing the old request, thereby realizing lossless upgrade of the service. Moreover, this method does not need to define multiple sets of port groups, so there is no need to rotate ports during the upgrade, which improves the efficiency and reliability of service upgrades.
[0012] In some possible implementations, the service management device can also obtain a response message, and update the source connection identifier SCID in the response message to the socket ID of the new version of the execution unit, so that the destination connection identifier of the subsequent data packet of the request message carries the socket ID of the new version of the execution unit. In this way, the subsequent data packets of the request message can be directly routed to the new version of the execution unit through the socket ID table without passing through the execution unit ID table, further improving the efficiency of lossless service upgrade.
[0013] In some possible implementations, before receiving a request message from the client, the service management device may also obtain the execution unit ID, socket ID, and listening socket of the execution unit that is successfully created when the service is started or upgraded, and then register an execution unit ID table based on the execution unit ID and listening socket of the successfully created execution unit, and register a socket ID table based on the socket ID and listening socket of the successfully created execution unit.
[0014] The method maintains the mapping relationship between the execution unit ID and the listening socket by registering the execution unit ID table when the service is started or upgraded. The registered socket ID table maintains the mapping relationship between the socket ID and the listening socket, provides a reference for request message identification and routing, and realizes lossless upgrade.
[0015] In some possible implementations, when the execution unit is restarted or upgraded, the service management device can also update the listening socket corresponding to the execution unit ID in the execution unit ID table, for example, by replacing the listening socket corresponding to the execution unit ID with a new version of the listening socket, and adding a socket ID and the listening socket corresponding to the socket ID (new version of the listening socket) in the socket ID table.
[0016] Since the latest listening socket is stored in the execution unit ID table, the execution unit selected through the execution unit ID table is the new version of the execution unit, which avoids routing new requests to the old version of the execution unit, making it difficult for the old version of the execution unit to exit, thereby achieving lossless service upgrade.
[0017] In some possible implementations, the execution unit includes a process or a thread. Both a process and a thread can be used to run program code and provide services. A process is usually an encapsulation of a runtime program and is the basic unit for resource scheduling and allocation by the operating system, thus realizing the concurrency of the operating system. A thread is a subtask of a process and is the basic unit for scheduling and dispatching by the central processing unit (CPU), which is used to ensure the real-time performance of the program and realize the concurrency within the process.
[0018] This method supports the creation of a process ID table or a thread ID table. Through the process ID table or the thread ID table, new requests can be routed to new processes or threads instead of old processes or old threads, ensuring that the old process or old thread can exit after processing the old request, thereby achieving lossless service upgrade.
[0019] In a second aspect, the present application provides a service management device. The service management device is deployed on a server and is used to implement service version management. The device includes:
[0020] A communication module, used for receiving a request message from a client;
[0021] A port selection module is used to query the socket ID table or the execution unit ID table according to the request message to obtain a listening socket. When the listening socket is obtained from the execution unit ID table, the request message is routed to the execution unit corresponding to the new version according to the listening socket. When the listening socket is obtained from the socket ID table, the request message is routed to the execution unit of the old version according to the listening socket.
[0022] In some possible implementations, the port selection module is specifically used to:
[0023] According to the socket ID in the request message, query the listening socket corresponding to the socket ID from the socket ID table;
[0024] When the query fails, the execution unit ID table is queried according to the request message to obtain the listening socket.
[0025] In some possible implementations, the device further includes:
[0026] The rewriting module is used to obtain a response message and update the source connection identifier SCID in the response message to the socket ID of the new version of the execution unit, so that the destination connection identifier of the subsequent data packet of the request message carries the socket ID of the new version of the execution unit.
[0027] In some possible implementations, the device further includes:
[0028] A mapping module is used to obtain the execution unit ID, socket ID and listening socket of the execution unit successfully created when the service is started or upgraded, and then register the execution unit ID table according to the execution unit ID and listening socket of the successfully created execution unit, and register the socket ID table according to the socket ID and listening socket of the successfully created execution unit.
[0029] In some possible implementations, the mapping module is further configured to:
[0030] When the execution unit is restarted or upgraded, the listening socket corresponding to the execution unit ID in the execution unit ID table is updated, and a socket ID and the listening socket corresponding to the socket ID are newly added to the socket ID table.
[0031] In some possible implementations, the execution unit includes a process or a thread.
[0032] In a third aspect, the present application provides a computing device. The computing device may be a server. The server includes at least one processor and at least one memory. The at least one processor and the at least one memory communicate with each other. The at least one processor is used to execute instructions stored in the at least one memory, so that the computing device executes the service management method as described in the first aspect or any one of the implementations of the first aspect.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium, in which instructions are stored, and the instructions instruct a computing device (for example, a server) to execute the service management method described in the first aspect or any one of the implementations of the first aspect.
[0034] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed on a computing device (eg, a server), enables the computing device to execute the service management method described in the first aspect or any one of the implementations of the first aspect.
[0035] Based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical method of the embodiments of the present application, the drawings required for use in the embodiments are briefly introduced below.
[0037] Figure 1 A schematic diagram of the architecture of a service management system provided in an embodiment of the present application;
[0038] Figure 2 A schematic diagram of a routing process for new requests and old requests in a service management system provided in an embodiment of the present application;
[0039] Figure 3 A flowchart of a service management method provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram of a registered process ID table and a registered socket ID table in a service management method provided in an embodiment of the present application;
[0041] Figure 5 An interactive flow chart of new request routing in a service management method provided in an embodiment of the present application;
[0042] Figure 6 An interactive flow chart of old request routing in a service management method provided in an embodiment of the present application;
[0043] Figure 7 A schematic diagram of the structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] The terms "first" and "second" in the embodiments of the present application are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0045] First, some technical terms involved in the embodiments of the present application are introduced.
[0046] A server refers to a device that manages resources and provides services to users. Among them, a server can be hardware that provides services, such as a computing device with high-speed computing capabilities, long-term reliable operation, and powerful input / output (I / O) capabilities. A server can be software deployed on the above computing device, also known as a server, which is used to provide services to a client (or client). For ease of description, the following description uses a server as a hardware example. Among them, a client can be a personal computer (PC), a smart phone, a smart wearable device (such as smart glasses) and other terminals.
[0047] Servers usually use the Internet as a medium, and can provide services internally through the intranet or externally through the Internet. The services provided by the server can usually achieve network interaction through transport layer protocols such as Transmission Control Protocol (TCP), User Datagram Protocol (UDP), and Quick UDP Internet Connection (QUIC).
[0048] The QUIC protocol is a transport layer protocol based on the UDP protocol, which aims to solve some problems existing in the TCP protocol, such as congestion control, transmission speed, security, etc. The architecture of the QUIC protocol can be divided into the following parts: QUIC transport layer protocol, QUIC security layer protocol, and QUIC application layer protocol.
[0049] The QUIC transport layer protocol is a UDP-based protocol. The QUIC transport layer protocol uses a reliable transmission and congestion control mechanism similar to the TCP protocol, and adds some new features based on TCP, such as multiplexing and fast connection establishment.
[0050] The QUIC security layer protocol is a protocol that uses the Transport Layer Security (TLS) 1.3 protocol to ensure security. The QUIC security layer protocol provides end-to-end encryption and authentication mechanisms to ensure data security and privacy.
[0051] The QUIC application layer protocol is a protocol based on Hyper Text Transfer Protocol (HTTP) / 2 or HTTP / 3. The QUIC application layer protocol provides some new features, such as multiplexing, flow control, server push, etc.
[0052] In the QUIC protocol, the Source Connection Identifier (SCID) and the Destination Connection Identifier (DCID) are two important identifiers used to identify the QUIC connection. In the QUIC handshake process, the SCID and DCID can be used to negotiate the connection ID used by both parties. The QUIC terminal (or QUIC client) will use the SCID field returned by the QUIC server (or QUIC server) to specify the connection ID used by itself. In subsequent message interactions, the QUIC terminal will also use the SCID field it receives to fill in the DCID field in the message it sends. Therefore, the QUIC server can fill in the SCID in the response message to implement QUIC session information delivery or connection migration.
[0053] Considering business needs or security, servers (such as QUIC servers) usually need to perform service version management. For example, a content delivery network (CDN) or an Internet content source (such as an origin station) that supports the QUIC protocol can perform service version management to meet specific business needs or improve business security. Service version management includes but is not limited to version upgrades of services. Version upgrade refers to updating a service from one version to another. In some examples, a version upgrade can be updating a lower version (such as an old version) to a higher version (such as a new version). In other examples, for example, when the new version has vulnerabilities that are difficult to fix in a short period of time, a version upgrade can also be updating the new version to the old version.
[0054] One of the goals of service version management is lossless upgrade. There is a problem with lossless upgrade for QUIC servers based on UDP. Specifically, in the implementation of the UDP protocol, there are only listening sockets, but no connected sockets. Therefore, during the service upgrade, if the old process closes the listening socket, the old process can no longer send or receive old request messages (also called old requests); if the listening socket continues, then both the old and new processes have a probability of receiving new request messages, and the old process cannot exit.
[0055] In order to achieve lossless technology, the relevant technology provides a service upgrade mechanism based on polling. Specifically, multiple sets of port groups are defined, and each time a service is upgraded (such as a QUIC service upgrade), the currently used port group is switched by polling. The front-end load balancing service and the back-end QUIC service synchronize the port group information used to ensure consistency and avoid new requests being routed to the old process, causing the old process to be unable to exit. However, the port rotation for each service upgrade makes the management and interaction of the port group more complicated, affecting reliability and efficiency.
[0056] In view of this, the present application provides a service management method. The method is applied to a service management device, and the service management device is deployed on a server. The service management device is used to implement service version management. The service management device can be a software device, which can be deployed on a server in the form of a software package, or can be deployed on a server (such as a cloud server) in the form of a cloud service. The service management device can also be a hardware device, such as hardware in a server for implementing service version management.
[0057] Specifically, the service management device can receive a request message from the client, query the socket ID table or the execution unit ID table according to the request message, and obtain the listening socket. Among them, the execution unit is a unit used to execute code to provide services, for example, it can be a process or a thread. This application uses the execution unit ID table as an example of the process ID table. The socket ID table records the mapping relationship between the socket ID and the listening socket, and the execution unit ID table (such as the process ID table) records the mapping relationship between the execution unit ID (such as the process ID) and the new version of the listening socket. When the listening socket is obtained from the execution unit ID table, the service management device can route the request message to the new version of the execution unit according to the listening socket; when the listening socket is obtained from the socket ID table, the service management device can route the request message to the corresponding version of the execution unit according to the listening socket. Among them, the socket ID table can record the socket IDs of different versions of execution units and the corresponding listening sockets. When the socket ID is the socket ID of a new version of the execution unit, the service management device can route the request message to the new version of the execution unit. When the socket ID is the socket ID of an old version of the execution unit, the service management device can route the request message to the old version of the execution unit.
[0058] The method identifies the request message (such as identifying whether the request message is a new request message or an old request message) by querying the socket ID table or the execution unit ID table (process ID table), and routes the request message to the execution unit of the corresponding version (such as a new process or an old process), thereby ensuring lossless services. Moreover, after the upgrade, the new request message is no longer forwarded to the old execution unit, but is only routed to the new execution unit, thereby ensuring that the old execution unit (such as the old process) can exit. In addition, the method does not need to define multiple sets of port groups, nor does it need to monitor additional ports, thereby simplifying port management for lossless service upgrades.
[0059] In order to make the technical solution of the present application clearer and easier to understand, the system architecture of the present application is introduced below.
[0060] See also Figure 1The service management system shown in FIG. 1 includes a client and a server. The service management device 100 is deployed on the server (for example, a QUIC server). The service management device 100 includes a communication module ( Figure 1 ) and a reuse port selection module 102. Further, the service management device 100 also includes a mapping module 104 and a rewriting module 106. The communication module and the port selection module 102 can run in the kernel space, and the mapping module 104 and the rewriting module 106 can run in the user space, such as an application or a business process.
[0061] The communication module is used to receive a request message from a client. In some examples, the request message from the client may be an old request, such as a request message from an old user. In other examples, the request message from the client may also be a new request, such as a request message from a new user.
[0062] The port selection module 102 is used to query the socket ID table or the execution unit ID table according to the request message to obtain the listening socket. Wherein, the socket ID table records the mapping relationship between the socket ID and the listening socket, and the execution unit ID table (such as the process ID table) records the mapping relationship between the execution unit ID and the new version of the listening socket. The port selection module 102 can select the execution unit (such as the process) of the corresponding version according to the query situation of the listening socket. Specifically, the port selection module 102 is used to obtain the listening socket from the execution unit ID table, and route the request message to the execution unit of the new version according to the listening socket; when the listening socket is obtained from the socket ID table, the request message is routed to the execution unit of the corresponding version according to the listening socket. Since the socket ID table can record the socket ID of the execution unit of different versions and the listening socket corresponding to the socket ID, the request message can be routed to the execution unit of the old version or the execution unit of the new version. For example, if the socket ID is an old version of the socket ID, the port selection module 102 can route the request message to the old version of the execution unit according to the listening socket. For another example, if the socket ID is a new version of the socket ID, the port selection module 102 can route the request message to the new version of the execution unit.
[0063] The port selection module 102 is essentially a functional module for packet filtering. In specific implementation, the port selection module 102 can be an extended Berkeley Packet Filter (eBPF) reused port selection module. eBPF is a kernel technology derived from BPF, and is suitable for a functional module for network packet filtering. eBPF can be a general execution engine, and its essence is a functional module similar to a virtual machine in the kernel. eBPF allows developers to write custom code that runs in the kernel, and executes it by attaching it to a kernel event that triggers the execution of the eBPF program. There is no need to recompile a new kernel module, and the eBPF program can be dynamically loaded and unloaded as needed. Thus, developers can develop various network and security tools based on eBPF. At the same time, the eBPF program and the application can achieve two-way communication through the eBPF MAP. The eBPF MAP is a very important data structure in the kernel. It provides an efficient data storage and sharing mechanism for the eBPF program, and also facilitates the data interaction between the kernel space and the user space.
[0064] In this application, the eBPF reuse port selection module is responsible for rewriting the QUIC reuse port selection program, and based on the work process ID, socket ID mapping table and socket ID carried in the request message in the eBPFMAP, the corresponding work process is selected to process the request message. Specifically, the eBPF reuse port selection module binds the reuse port selection function in the kernel protocol stack, such as the QUIC service reuse port selection function. The eBPF reuse port selection module can parse the socket ID of the associated process from the DCID field of the request message. If the listening socket is successfully found through the socket ID table, it means that the request message is a request message of a user who has been served (for example, it can be a request message of an old user), and the corresponding version of the execution unit (such as an old process) can be selected based on the socket ID table; if the listening socket is not found through the socket ID table, it means that the request message is a new request (a request message of a new user), and a new version of the execution unit can be selected based on the execution unit ID table (such as a process ID table), for example, a new version of the work process can be selected in combination with the five-tuple information. Among them, the quintuple may include a source address, a source port, a destination address, a destination port, and a transport protocol. In other possible implementations of the present application embodiment, the eBPF reuse port selection module may also select a new version of the working process by other means based on the execution unit ID table. For example, the eBPF reuse port selection module may also select a new version of the working process in combination with the triple information. Among them, the triple may include a source address, a destination address, and a transport protocol. In addition, in addition to selecting a new version of the working process by a hash selection method based on metadata such as a quintuple or a triple, the eBPF reuse port selection module also supports selecting a new version of the working process by polling, and the method of selecting a new version of the execution unit based on the execution unit ID table in this embodiment is not limited.
[0065] The mapping module 104 is used to maintain the socket ID table and the execution unit ID table. For example, the mapping module 104 can obtain the mapping relationship between the process ID of the working process, the socket ID and the listening socket of the working process, and register it in the eBPF MAP data structure of the kernel space for use by the eBPF reuse port selection module when selecting the working process. Among them, the process ID of the working process is an integer that increases from 0 or 1, that is, the number of the working process. If there are 4 working processes, the process IDs of the above working processes can be 0, 1, 2, and 3. When a service (such as a QUIC service) is upgraded, the process ID of the working process will not change, but the socket ID and listening socket corresponding to the process ID of the working process will change.
[0066] The rewriting module 106 is used to update the SCID field in the response message corresponding to the new user's request message. Specifically, the rewriting module 106 can fill the socket ID of the new version of the execution unit (for example, a new work process) in the SCID field in the response message corresponding to the first packet in the new user's request message, so as to bind the user to the corresponding execution unit, and then realize that subsequent data packets can be directly routed to the new version of the execution unit (such as a new work process) through the socket ID of the new version of the execution unit.
[0067] It should be noted that the eBPF reuse port selection module is only a specific implementation of the present application for implementing reuse port selection. Similarly, the eBPF MAP data structure is only a specific implementation for registering the socket ID table and the execution unit ID table. In other possible implementations of the present application embodiment, reuse port selection can also be implemented through other reuse port selection functions, and socket ID tables and execution unit ID tables can be registered through other data structures. This embodiment does not limit this.
[0068] The following is an example to illustrate the routing process of the request message of a new user and the request message of an old user.
[0069] like Figure 2 As shown, during the lossless upgrade of services (such as QUIC services), in order to ensure lossless business, there are usually two groups of new and old working processes in the user space at the same time. Each group of working processes is created by its own master process. Among them, the process ID mapping can be implemented by the master process and registered in the eBPF MAP. The socket ID table registered with the eBPF MAP contains a mapping relationship between the socket IDs of the new and old working processes and the listening sockets. The socket ID table can be used for routing old requests (request messages from old users); the process ID table contains a mapping relationship between the working process ID and the new version of the listening socket. The process ID table can be used for routing new requests (request messages from new users).
[0070] based on Figure 1 The present application also provides a service management method. The service management method of the present application is introduced below in conjunction with an embodiment.
[0071] See also Figure 3 A flow chart of a service management method is shown, the method comprising the following steps:
[0072] S302: The service management device 100 receives a request message from the client.
[0073] The client's request message may be a request message from a new user or an old user. The request message from a new user is used to be routed to the execution unit of the new version (such as a new process) for processing, and the request message from an old user is used to be routed to the execution unit of the old version (old process) for processing. The new process and the old process that process the request message are working processes.
[0074] S304: The service management device 100 searches the socket ID table or the execution unit ID table according to the request message to obtain the monitoring socket. When the monitoring socket is obtained from the execution unit ID table, S306 is executed; when the monitoring socket is obtained from the socket ID table, S308 is executed.
[0075] The socket ID table records the mapping relationship between the socket ID and the listening socket, and the execution unit ID table records the mapping relationship between the execution unit ID and the new version of the listening socket. The execution unit may be a functional unit that executes code to provide a service, such as a process or a thread. Taking a process as an example, the execution unit ID table may be a process ID table, which records the mapping relationship between the process ID and the new version of the listening socket.
[0076] When a worker process is restarted or upgraded, the socket ID is globally incremented by the kernel. The socket ID of each worker process is unique, so a new mapping relationship between the socket ID and the listening socket is generated. Considering that the process ID of the worker process does not change with the restart or upgrade of the worker process, the listening socket mapping corresponding to the process ID in the process ID table is replaced by the new version of the listening socket.
[0077] Specifically, the service management device 100 can first obtain the socket ID from the request message, so as to query the socket ID table based on the socket ID and obtain the listening socket corresponding to the socket ID. Among them, the service management device 100 can extract the DCID identifier in the request message (such as the QUIC message), and then obtain the socket ID from the DCID identifier.
[0078] When the request message is a request message from a new user, for example, the first packet of a request message from a new user (such as a QUIC handshake message), the DCID can usually be randomly generated by the client, and the mapping relationship between the socket ID randomly generated by the client and the listening socket is not recorded in the socket ID table, and the service management device 100 fails to query. The service management device 100 can query the execution unit ID table according to the request message. In some possible implementations, the service management device 100 can calculate a hash value for the five-tuple of the request message based on the kernel default mechanism, and then select the corresponding listening socket based on the hash of the execution unit ID table (such as the process ID table). During the lossless upgrade of the service, the execution unit selected based on the execution unit ID table (such as the process ID table) is the execution unit of the new version (such as a new process, a new working process).
[0079] Furthermore, the service management device 100 can also rewrite the DCID of the response message corresponding to the first packet. For example, the service management device 100 can fill the socket ID of the new version of the execution unit (for example, the current working process, i.e., the new working process) in the DCID field of the response message to bind the user to the new version of the execution unit (such as the working process), and the subsequent data packets of the request message can be routed to the new version of the execution unit (for example, the new working process) bound by the user through the socket ID table.
[0080] When the request message is a request message of an old user, the DCID can usually be constructed by the server, so the corresponding listening socket can be successfully queried from the socket ID table using the socket ID. In other words, the query result of the service management device 100 querying the socket ID table according to the request message is a successful query, and the service management device 100 can obtain the listening socket from the socket ID table.
[0081] S306: The service management device 100 routes the request message to the execution unit of the new version according to the listening socket.
[0082] Specifically, the service management device 100 obtains the listening socket from the execution unit ID table, indicating that the request message is a new request. The service management device 100 can deliver the request message to the corresponding listening socket and notify the new version of the execution unit (such as a new process or a new working process) to process the above request message.
[0083] It should be noted that for the first packet of a new request, the service management device 100 can rewrite the socket ID in the response message, for example, by filling in the socket ID of the new version of the execution unit in the SCID field. In this way, the DCID of subsequent data packets of the new request can be updated to the socket ID of the above-mentioned new version of the execution unit, and the listening socket corresponding to the above-mentioned socket ID can be successfully queried in the socket ID table. The service management device 100 can directly route it to the new version of the execution unit (for example, a new process or a new working process) according to the socket ID table.
[0084] S308. The service management device 100 routes the request message to the execution unit of the corresponding version according to the listening socket.
[0085] Each listening socket corresponds to an execution unit, and the service management device 100 can route the request message to the execution unit corresponding to the listening socket according to the listening socket found in the socket ID table. Since the socket ID table can record the socket IDs of execution units of different versions and the listening sockets corresponding to the socket IDs, the service management device 100 can route the request message to the new version of the execution unit or the old version of the execution unit. When the socket ID found in the socket ID table is the socket ID of the old version of the execution unit, the service management device 100 can route the request message to the old version of the execution unit (for example, the old working process). When the socket ID found in the socket ID table is the socket ID of the new version of the execution unit, the service management device 100 can route the request message to the new version of the execution unit (for example, the new working process).
[0086] Based on the above description, the method identifies the request message by querying the socket ID table or the execution unit ID table, and routes the request message to the execution unit of the corresponding version to ensure lossless service. Moreover, after the upgrade, the new request message is no longer forwarded to the old execution unit, but only routed to the new execution unit, ensuring that the old execution unit (such as the old process) can exit. Moreover, the method does not need to define multiple sets of port groups, does not need to monitor additional ports, and simplifies port management during lossless service upgrade.
[0087] Figure 3The service management method shown relies on a socket ID table and an execution unit ID table. When a service is started or upgraded, an execution unit of the service can be created, for example, a working process can be created by a main process. The service management device 100 can obtain the execution unit ID, socket ID, and listening socket of the successfully created execution unit, register the execution unit ID table according to the execution unit ID and listening socket of the successfully created execution unit, and register the socket ID table according to the socket ID and listening socket of the successfully created execution unit. Further, when the execution unit is restarted or upgraded, the service management device 100 can update the listening socket corresponding to the execution unit ID in the execution unit ID table, for example, updating the listening socket corresponding to the execution unit ID to a new version of the listening socket, and adding a socket ID and a listening socket corresponding to the socket ID in the socket ID table (for example, a new version of the socket ID, a new version of the listening socket).
[0088] The registration process and the routing process are described in detail below in conjunction with different embodiments.
[0089] First, see Figure 4 The interactive flow chart of the registration process in a service management method shown in the figure specifically includes the following steps:
[0090] S402: The main process creates a working process.
[0091] The main process (such as the QUIC service manager) creates a worker process when the service is started or upgraded. If there are multiple worker processes, they can be created in sequence according to the number.
[0092] S404: The main process obtains the process ID, socket ID and listening socket of the successfully created working process.
[0093] The socket ID may be obtained by global self-increment of the kernel. The mapping module 104 in the main process may obtain the above socket ID, process ID and listening socket for registering the socket ID table and process ID table.
[0094] S406. The main process registers the mapping relationship between the process ID of the working process and the listening socket in the process ID table in the kernel eBPF MAP.
[0095] S408. The main process registers the mapping relationship between the socket ID and the listening socket in the socket ID table in the kernel eBPF MAP.
[0096] Specifically, the main process can store the mapping relationship between the process ID of the working process and the listening socket in the process ID table in the kernel eBPF MAP through the mapping module 104, thereby realizing the registration of the process ID table, and store the mapping relationship between the socket ID and the listening socket in the socket ID table in the kernel eBPF MAP, thereby realizing the registration of the socket ID table.
[0097] When the working process is restarted or upgraded, the process ID of the working process will not change, the socket ID is globally incremented by the kernel, and the listening socket will also change. Therefore, the listening socket corresponding to the process ID in the process ID table is replaced by the new listening socket, and the mapping relationship between the new socket ID and the new listening socket is recorded in the socket ID table.
[0098] It should be noted that the above S406 and S408 can be executed in parallel or sequentially in a set order. This application does not limit the execution order of S406 and S408.
[0099] Next, see Figure 5 The interactive flow chart of the routing process of a request message in a service management method shown in the figure specifically includes the following steps:
[0100] S502: The reuse port selection module 102 registers a reuse port function.
[0101] Specifically, the reuse port selection module 102 may be bound to an event corresponding to a reuse port of the kernel, thereby implementing a registration reuse port function.
[0102] It should be noted that the above S502 is a pre-processing step. After the registration is completed, a work process can be selected for multiple requests from different clients or a work process can be selected for multiple different requests from a client.
[0103] S504: The client sends a new request.
[0104] A new request refers to a request message from a new user. The first packet of the request message may be a handshake message.
[0105] S506: The kernel protocol stack calls the corresponding port selection function according to the new request.
[0106] S508. The reuse port selection module 102 extracts the DCID in the new request, and obtains the socket ID from the DCID.
[0107] S510: The reuse port selection module 102 queries a socket ID table according to the socket ID.
[0108] For a new request, the DCID in the new request can be randomly generated by the client, so the corresponding listening socket cannot be queried from the socket ID table of the eBPF MAP using the socket ID. In other words, in this case, the reuse port selection module 102 fails to query the listening socket, and S512 can be executed.
[0109] S512: If the reuse port selection module 102 fails to find a listening socket, the process ID table is used for load balancing to obtain a listening socket.
[0110] Specifically, the reuse port selection module 102 calculates a hash value based on the five-tuple of the request message according to the kernel default mechanism. The five-tuple may include a source IP address, a source port, a destination IP address, a destination port, and a transport layer protocol. Then the reuse port selection module 102 selects the corresponding listening socket through a hash based on the process ID table of the eBPF MAP.
[0111] During the lossless service upgrade, the listening socket selected based on the process ID table is the listening socket of the new process.
[0112] S514 . The reuse port selection module 102 returns the listening socket to the kernel protocol stack.
[0113] S516: The kernel delivers the new request to the listening socket and notifies the new process.
[0114] S518: The new process receives the first packet of the new request and fills the socket ID of the new process in the SCID field of the response message.
[0115] S520: The new process returns a response message.
[0116] The SCID field of the response message is filled with the socket ID. The DCID in the subsequent data packets of the new request (such as the 2nd data packet, the 3rd data packet...the i+1th data packet) can be updated according to the socket ID in the SCID field of the response message. The listening socket corresponding to the socket ID can be found in the socket ID table, based on which the subsequent data packets of the new request can be routed to the new process through the socket ID table. In other words, the subsequent data packets of the new request (except the first packet) can be routed to the new process in a similar manner to the old request.
[0117] In this method, the request message is identified as a new request or an old request by querying the socket ID table. For new requests, the request message is routed to a new process (such as a new worker process) to ensure lossless services. After the upgrade, new requests are no longer forwarded to the old process, but only routed to the new process to ensure that the old process can exit. Moreover, this method does not require the definition of multiple sets of port groups or the monitoring of additional ports, thus simplifying port management for lossless service upgrades. In addition, lossless service upgrades can be closed-loop within the service without the need to introduce additional external components (such as load balancing components) for coordination, which reduces the degree of coupling between services or components.
[0118] Then, see Figure 6 The interactive flow chart of the routing process of a request message in a service management method shown in the figure specifically includes the following steps:
[0119] S602: The reuse port selection module 102 registers a reuse port function.
[0120] The specific implementation of S602 can refer to the description of S502, which will not be repeated here. In addition, S602 is a pre-processing step. After the registration is completed, a work process can be selected for multiple requests from different clients or a work process can be selected for multiple different requests from the client.
[0121] S604: The client sends an old request.
[0122] Old requests refer to request messages from old users.
[0123] S606: The kernel protocol stack calls the corresponding port selection function according to the new request.
[0124] S608. The reuse port selection module 102 extracts the DCID in the new request, and obtains the socket ID from the DCID.
[0125] S610: The reuse port selection module 102 queries a socket ID table according to the socket ID.
[0126] For the old request, the DCID in the old request can be constructed by the server, so the corresponding listening socket can be successfully queried from the socket ID table of the eBPF MAP using the socket ID. In other words, in this case, the reuse port selection module 102 queries the listening socket and can execute S612.
[0127] S612: The reuse port selection module 102 returns the listening socket to the kernel protocol stack.
[0128] S614: The kernel delivers the old request to the listening socket and notifies the old process.
[0129] S516: The old process processes the received old request and returns a response message.
[0130] The old process can process the received old request until the old request service is completed, and then the old process can exit.
[0131] In this method, the request message is identified as a new request or an old request by querying the socket ID table. For the old request, the request message can be routed to the old process (such as the worker old process) through the socket ID table to ensure lossless service. After the upgrade, the old request is forwarded to the old process, and the old process can exit after processing all the old requests. In addition, this method does not need to define multiple sets of port groups, does not need to monitor additional ports, and simplifies port management for lossless service upgrades.
[0132] Based on the above method embodiment, the present application also provides a service management device 100, such as Figure 1 As shown, the service management device 100 is deployed on a server, and the service management device is used to implement service version management. The service management device 100 includes:
[0133] Communication Module( Figure 1 ), for receiving a request message from a client;
[0134] The port selection module 102 is used to query the socket ID table or the execution unit ID table according to the request message to obtain the listening socket. When the listening socket is obtained from the execution unit ID table, the request message is routed to the execution unit corresponding to the new version according to the listening socket. When the listening socket is obtained from the socket ID table, the request message is routed to the execution unit of the old version according to the listening socket.
[0135] Exemplarily, the above-mentioned communication module and port selection module 102 may be implemented by hardware or by software.
[0136] When implemented by software, the communication module and the port selection module 102 may be applications running on a computing device (such as a server). For example, the port selection module 102 may be a computing engine running on a computing device, etc. The application may be provided to users in the form of a virtualized service. Virtualization services may include virtual machine (VM) services, bare metal server (BMS) services, and container services. Among them, the VM service may be a service that uses virtualization technology to virtualize a virtual machine (VM) resource pool on multiple physical hosts (such as computing devices) to provide users with VMs on demand for use. The BMS service is a service that virtualizes a BMS resource pool on multiple physical hosts to provide users with BMS on demand for use. The container service is a service that virtualizes a container resource pool on multiple physical hosts to provide users with containers on demand for use. VM is a simulated virtual computer, that is, a logical computer. BMS is a high-performance computing service that can be elastically scalable, and its computing performance is no different from that of a traditional physical machine, and it has the characteristics of secure physical isolation. Container is a kernel virtualization technology that can provide lightweight virtualization to achieve the purpose of isolating user space, processes and resources. It should be understood that the VM service, BMS service and container service in the above virtualization services are only used as specific examples. In actual applications, the virtualization service can also be other lightweight or heavyweight virtualization services, which are not specifically limited here.
[0137] When implemented by hardware, the communication module may be a transceiver module including a transceiver, and the port selection module 102 may include at least one processing unit, such as a central processing unit. The port selection module 102 may also be a device implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0138] In some possible implementations, the port selection module 102 is specifically configured to:
[0139] According to the socket ID in the request message, query the listening socket corresponding to the socket ID from the socket ID table;
[0140] When the query fails, the execution unit ID table is queried according to the request message to obtain the listening socket.
[0141] In some possible implementations, the apparatus 100 further includes:
[0142] The rewriting module 106 is used to obtain a response message, and update the source connection identifier SCID in the response message to the socket ID of the new version of the execution unit, so that the destination connection identifier of the subsequent data packet of the request message carries the socket ID of the new version of the execution unit.
[0143] Similar to the port selection module 102 , the rewriting module 106 may be implemented by hardware or may be implemented by software.
[0144] When implemented by software, the rewriting module 106 may be an application running on a computing device. For example, the rewriting module 106 may be a computing engine running on a computing device. The application may also be virtualized, for example, an application encapsulated in a virtual machine (virtual machine application, virtual machine service) or an application encapsulated in a container (container application, container service).
[0145] When implemented by hardware, the rewriting module 106 may include at least one processing unit, such as a central processing unit. The port selection module 102 may also be implemented by an application specific integrated circuit ASIC or a programmable logic device PLD. The PLD may be implemented by a CPLD, FPGA, GAL or any combination thereof.
[0146] In some possible implementations, the apparatus 100 further includes:
[0147] The mapping module 104 is used to obtain the execution unit ID, socket ID and listening socket of the execution unit successfully created when the service is started or upgraded, register the execution unit ID table according to the execution unit ID and listening socket of the successfully created execution unit, and register the socket ID table according to the socket ID and listening socket of the successfully created execution unit.
[0148] Similar to the port selection module 102 , the mapping module 104 may also be implemented by hardware or software.
[0149] When implemented by software, the mapping module 104 may be an application running on a computing device (such as a server). For example, the rewriting module 106 may be a computing engine running on a computing device. The application may also be virtualized, for example, an application encapsulated in a virtual machine (virtual machine application, virtual machine service) or an application encapsulated in a container (container application, container service).
[0150] When implemented by hardware, the mapping module 104 may include at least one processing unit, such as a central processing unit. The port selection module 102 may also be implemented by an application specific integrated circuit ASIC or a programmable logic device PLD. The PLD may be implemented by a CPLD, FPGA, GAL or any combination thereof.
[0151] In some possible implementations, the mapping module 104 is further configured to:
[0152] When the execution unit is restarted or upgraded, the listening socket corresponding to the execution unit ID in the execution unit ID table is updated, and a socket ID and the listening socket corresponding to the socket ID are newly added to the socket ID table.
[0153] In some possible implementations, the execution unit includes a process or a thread.
[0154] The present application also provides a computing device 700. Figure 7 As shown, the computing device 700 includes: a bus 702, a processor 704, a memory 706, and a communication interface 708. The processor 704, the memory 706, and the communication interface 708 communicate through the bus 702. The computing device 700 can be a server. It should be noted that the server can be a physical server (or a local server), or it can be a cloud server in a cloud computing cluster built by a cloud vendor, including but not limited to a central cloud server and an edge cloud server. It should be understood that this application does not limit the number of processors and memories in the computing device 700.
[0155] The bus 702 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The bus 702 may include a path for transmitting information between various components of the computing device 700 (eg, the memory 706, the processor 704, and the communication interface 708).
[0156] The processor 704 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0157] The memory 706 may include a volatile memory, such as a random access memory (RAM). The memory 706 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid state drive (SSD). The memory 706 stores executable program code, and the processor 704 executes the executable program code to implement the aforementioned service management method. Specifically, the memory 706 stores instructions for the service management device 100 to execute the service management method.
[0158] like Figure 7 As shown, the memory 706 can store the program codes of the communication module and the port selection module 102, and accordingly, the processor 704 can execute the program codes of the communication module and the port selection module 102, thereby implementing the aforementioned service management method. Further, the memory 706 can also store the program codes of the rewriting module 106 or the mapping module 104, and accordingly, the processor 704 can execute the program codes of the rewriting module 106 or the mapping module 104, thereby implementing the steps or processes related to the connection ID rewriting, the socket ID table registration, and the execution unit ID table registration in the aforementioned service management method.
[0159] The communication interface 708 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 700 and other devices or communication networks.
[0160] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the above-mentioned application to the service management device 100 for executing the service management method.
[0161] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the above-mentioned service management method.
[0162] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.
Claims
1. A service management method, characterized in that: Applied to a service management device, the service management device is deployed on a server, the service management device is used to implement service version management, the method includes: Receive the client's request message; According to the request message, a socket ID table or an execution unit ID table is queried to obtain a listening socket, wherein the socket ID table records a mapping relationship between a socket ID and a listening socket, and the execution unit ID table records a mapping relationship between an execution unit ID and a new version of the listening socket; When the listening socket is obtained from the execution unit ID table, the request message is routed to the execution unit of the new version according to the listening socket; when the listening socket is obtained from the socket ID table, the request message is routed to the execution unit of the corresponding version according to the listening socket.
2. The method according to claim 1, characterized in that The querying of the socket ID table or the execution unit ID table according to the request message to obtain the listening socket includes: According to the socket ID in the request message, query the listening socket corresponding to the socket ID from the socket ID table; When the query fails, the execution unit ID table is queried according to the request message to obtain the listening socket.
3. The method according to claim 2, characterized in that The method further comprises: A response message is obtained, and a source connection identifier SCID in the response message is updated to the socket ID of the execution unit of the new version, so that the destination connection identifier of the subsequent data packet of the request message carries the socket ID of the execution unit of the new version.
4. The method according to any one of claims 1 to 3, characterized in that: Before receiving the request message from the client, the method further includes: Get the execution unit ID, socket ID, and listening socket of the execution unit that was successfully created when the service was started or upgraded; The execution unit ID table is registered according to the execution unit ID and the listening socket of the successfully created execution unit, and the socket ID table is registered according to the socket ID and the listening socket of the successfully created execution unit.
5. The method according to claim 4, characterized in that The method further comprises: When the execution unit is restarted or upgraded, the listening socket corresponding to the execution unit ID in the execution unit ID table is updated, and a socket ID and the listening socket corresponding to the socket ID are newly added to the socket ID table.
6. The method according to any one of claims 1 to 5, characterized in that: The execution unit includes a process or a thread.
7. A service management device, characterized in that: The service management device is deployed on a server, and is used to implement service version management. The device includes: A communication module, used for receiving a request message from a client; A port selection module is used to query the socket ID table or the execution unit ID table according to the request message to obtain a listening socket. When the listening socket is obtained from the execution unit ID table, the request message is routed to the execution unit corresponding to the new version according to the listening socket. When the listening socket is obtained from the socket ID table, the request message is routed to the execution unit of the old version according to the listening socket.
8. The device according to claim 7, characterized in that The port selection module is specifically used for: According to the socket ID in the request message, query the listening socket corresponding to the socket ID from the socket ID table; When the query fails, the execution unit ID table is queried according to the request message to obtain the listening socket.
9. The device according to claim 8, characterized in that The device also includes: The rewriting module is used to obtain a response message and update the source connection identifier SCID in the response message to the socket ID of the new version of the execution unit, so that the destination connection identifier of the subsequent data packet of the request message carries the socket ID of the new version of the execution unit.
10. The device according to any one of claims 7 to 9, characterized in that The device also includes: A mapping module is used to obtain the execution unit ID, socket ID and listening socket of the execution unit successfully created when the service is started or upgraded, register the execution unit ID table according to the execution unit ID and listening socket of the successfully created execution unit, and register the socket ID table according to the socket ID and listening socket of the successfully created execution unit.
11. The device according to claim 10, characterized in that The mapping module is also used to: When the execution unit is restarted or upgraded, the listening socket corresponding to the execution unit ID in the execution unit ID table is updated, and a socket ID and the listening socket corresponding to the socket ID are newly added to the socket ID table.
12. The device according to any one of claims 7 to 11, characterized in that The execution unit includes a process or a thread.
13. A server, characterized in that: The server includes at least one processor and at least one memory, wherein the at least one memory stores computer-readable instructions; the at least one processor executes the computer-readable instructions so that the server executes the service management method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that: Comprising computer-readable instructions; the computer-readable instructions are used to implement the service management method described in any one of claims 1 to 6.
15. A computer program product, characterized in that Comprising computer-readable instructions; the computer-readable instructions are used to implement the service management method described in any one of claims 1 to 6.
