A service processing method, device and equipment

By using a preset connection table in the Nginx server to associate the client and service identifiers with the target worker process, the problem of service stability during the hot upgrade of the Nginx server is solved, and the effect of still being able to handle service requests normally when the target worker process is closed.

CN114416149BActive Publication Date: 2025-05-23BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210004008.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-04
Publication Date
2025-05-23
Estimated Expiration
2042-01-04

AI Technical Summary

Technical Problem

When the Nginx server is hot upgraded, how to ensure the stable operation of the service and avoid abnormal interruption of user requests.

Method used

By using a preset connection table in the nginx server, the client's identity and service identity are associated with the target worker process identity, and the allocation and management of service requests are realized.

Benefits of technology

When the target worker process is closed, the nginx server can still allocate service requests normally, ensure the service is running stably, and support the hot upgrade of the nginx server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114416149B_ABST
    Figure CN114416149B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, device and equipment for processing a service, wherein the method comprises: receiving a service request sent by a client, wherein the service request includes the client's identifier and the service identifier; and assigning the service request to a target work process corresponding to the target work process identifier when a preset connection table contains a target work process identifier corresponding to the client's identifier and the service identifier. In this way, when the target work process is closed, the nginx server can still normally assign the service request to the target work process for processing, thereby achieving that when the nginx server is hot-upgraded, the client's service request can still be processed normally.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of Internet technology, and in particular to a service processing method, device and equipment. Background Art

[0002] With the development of computer technology and Internet technology, people have higher and higher requirements on the performance of Internet products.

[0003] In the related art, Nginx server usually uses bind service port to provide service. When the configuration is upgraded or the software package is upgraded, the service needs to be stopped, resulting in abnormal interruption of user requests. Therefore, how to ensure stable operation of the service during hot upgrade is an urgent problem to be solved. Summary of the invention

[0004] The present disclosure provides a service processing method, device and equipment to at least solve the problem of unstable services in related technologies. The technical solution of the present disclosure is as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, a service processing method is provided, including:

[0006] Receiving a service request sent by a client, wherein the service request includes an identifier of the client and the service identifier;

[0007] In a case where the preset connection table contains a target work process identifier corresponding to the client identifier and the service identifier, the service request is allocated to the target work process corresponding to the target work process identifier.

[0008] In a possible implementation manner of the embodiment of the first aspect of the present disclosure, after receiving the service request sent by the client, the method further includes:

[0009] In the case that the preset connection table does not contain a target work process identifier corresponding to the client identifier and the service identifier, performing a hash operation on the client identifier and the service identifier to determine the target work process identifier;

[0010] The service request is allocated to the target work process corresponding to the target work process identifier.

[0011] In a possible implementation manner of the embodiment of the first aspect of the present disclosure, before allocating the service request to the target work process corresponding to the target work process identifier, the method further includes:

[0012] Receiving a connection call request sent by the target work process, wherein the call request includes the target work process identifier, the client identifier and the service identifier;

[0013] The target work process identifier, the client identifier and the service identifier are associated and stored in the preset connection table.

[0014] In a possible implementation manner of the embodiment of the first aspect of the present disclosure, the present invention further includes:

[0015] Receiving a close function call request sent by the target working process, wherein the close function call request includes the target working process identifier;

[0016] Delete each connection item associated with the target working process identifier in the preset connection table.

[0017] According to a second aspect of an embodiment of the present disclosure, a service processing method is provided, including:

[0018] The target work process receives a service allocation instruction, wherein the allocation instruction includes a client identifier and a service identifier;

[0019] Send a connection call request, wherein the call request includes the identifier of the target work process, the identifier of the client and the service identifier, so as to associate the identifier of the target work process, the identifier of the client and the service identifier and store them in a preset connection table.

[0020] In a possible implementation manner of the second aspect of the present disclosure, the present invention further includes:

[0021] When the service corresponding to the service identifier ends, determining the current state of the socket of the target working process;

[0022] When the socket of the target working process is currently in a closed state, a close function call request is sent, wherein the close function call request includes the target working process identifier.

[0023] According to a third aspect of an embodiment of the present disclosure, an embodiment of the present disclosure provides a service processing device, including:

[0024] A receiving module, configured to receive a service request sent by a client, wherein the service request includes an identifier of the client and the service identifier;

[0025] The allocation module is used to allocate the service request to the target work process corresponding to the target work process identifier when the preset connection table contains the target work process identifier corresponding to the client identifier and the service identifier.

[0026] In a possible implementation manner of the third aspect of the present disclosure, the allocation module is further configured to:

[0027] In the case that the preset connection table does not contain a target work process identifier corresponding to the client identifier and the service identifier, performing a hash operation on the client identifier and the service identifier to determine the target work process identifier;

[0028] The service request is allocated to the target work process corresponding to the target work process identifier.

[0029] In a possible implementation manner of the third aspect of the present disclosure, the receiving module is further configured to:

[0030] Receiving a connection call request sent by the target work process, wherein the call request includes the target work process identifier, the client identifier and the service identifier;

[0031] The device also includes:

[0032] The storage module is used to associate the target working process identifier, the client identifier and the service identifier and store them in the preset connection table.

[0033] In a possible implementation manner of the third aspect of the present disclosure, the receiving module is further configured to:

[0034] Receiving a close function call request sent by the target working process, wherein the close function call request includes the target working process identifier;

[0035] The device also includes:

[0036] The deletion module is used to delete each connection item associated with the target working process identifier in the preset connection table.

[0037] According to a fourth aspect of an embodiment of the present disclosure, an embodiment of the present disclosure provides a service processing device, including:

[0038] A receiving module, used for the target work process to receive a service allocation instruction, wherein the allocation instruction includes a client identifier and a service identifier;

[0039] A sending module is used to send a connection call request, wherein the call request includes the identifier of the target working process, the identifier of the client and the service identifier, so as to associate the identifier of the target working process, the identifier of the client and the service identifier and store them in a preset connection table.

[0040] In a possible implementation manner of the fourth aspect of the present disclosure, the present invention further includes:

[0041] A determination module, used for determining the current state of the socket of the target working process when the service corresponding to the service identifier ends;

[0042] The sending module is further used to send a close function call request when the socket of the target working process is currently in a closed state, wherein the close function call request includes the target working process identifier.

[0043] According to a fifth aspect of an embodiment of the present disclosure, the present disclosure provides a computer device, the computer device comprising:

[0044] A memory storing executable program code;

[0045] a processor coupled to the memory;

[0046] The processor calls the executable program code stored in the memory to execute the service processing method according to any one of claims 1 to 6.

[0047] According to a sixth aspect of an embodiment of the present disclosure, there is provided a computer-readable storage medium on which a computer program is stored, wherein the program, when executed by a processor, implements a method for processing a service as described in any one of claims 1 to 6.

[0048] The technical solution provided by the embodiment of the present disclosure brings at least the following beneficial effects: In this embodiment, after receiving the service request, the nginx server can determine the target work process identifier corresponding to the client identifier and the service identifier by querying the connection table, and according to the target work process identifier, the service request can be allocated to the corresponding target work process. In this way, when the target work process is closed, the nginx server can still normally allocate the service request to the target work process for processing, so that when the nginx server is hot upgraded, the client's service request can still be processed normally.

[0049] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0051] Figure 1 is a flow chart of a method for processing a service according to an exemplary embodiment;

[0052] Figure 2 is a flow chart of a method for processing a service according to an exemplary embodiment;

[0053] Figure 3is a schematic diagram of a processing process of a service according to an exemplary embodiment;

[0054] Figure 4 is a flow chart of a method for processing a service according to an exemplary embodiment;

[0055] Figure 5 is a flow chart of a method for processing a service according to an exemplary embodiment;

[0056] Figure 6 is a structural diagram of a service processing device according to an exemplary embodiment;

[0057] Figure 7 is a structural diagram of a service processing device according to an exemplary embodiment;

[0058] Figure 8 The invention is a block diagram of a terminal device showing processing of a service according to an exemplary embodiment. DETAILED DESCRIPTION

[0059] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0060] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0061] The following describes in detail the service processing method, device and system of the embodiments of the present disclosure with reference to the accompanying drawings.

[0062] In the present disclosure, when considering using the unconnected UDP protocol for data transmission, each time data is sent, the three steps of establishing connection, outputting datagrams, and disconnecting will be repeated. If data is continuously sent to the same destination address, the efficiency is low. However, the connected UDP protocol only needs to execute the connection establishment step once, the connection disconnection step once, and the output datagram is executed cyclically to complete the continuous sending of data. That is, compared with the connectionless UDP protocol, the connected UDP protocol reduces the operation steps, thereby improving the efficiency of data transmission. Therefore, in the nginx server, the connection relationship between the client and the working process is stored to enable the nginx service to achieve hot upgrade. The processing method of the service provided by the present disclosure is described in detail below in conjunction with the accompanying drawings.

[0063] Figure 1 A flowchart of a method for processing a service provided in an embodiment of the present disclosure.

[0064] like Figure 1 As shown, the method includes:

[0065] Step 101: receiving a service request sent by a client, wherein the service request includes a client identifier and a service identifier.

[0066] The client identifier may be the IP, port number, etc. corresponding to the client, and the service identifier may be the service name, method, etc., which is not limited in the present disclosure.

[0067] In the present disclosure, after the nginx server is started, the main process will create a manager process, and the manager process can create multiple worker processes. Among them, the manager process is mainly responsible for scheduling the worker process, and the worker process is a worker process, which is mainly used to handle basic network transactions.

[0068] When the nginx server starts, first, the Master process will parse the configuration file, obtain the port and IP address to be listened, and initialize the monitored socket. The Manager process can create multiple worker processes according to the configuration file. After that, the worker processes will compete to accept new connections.

[0069] When the client initiates a connection to the nginx server, the nginx server can determine the worker process used to handle the client request. After that, a connected socket can be established between the worker process and the client. Then, the worker process can exchange data with the client through read and write events.

[0070] In this embodiment, after the nginx server is started, the main process can receive the service request from the client, and then parse the service request to determine the corresponding client identifier and service identifier.

[0071] Step 102: when the preset connection table contains a target work process identifier corresponding to the client identifier and the service identifier, the service request is allocated to the target work process corresponding to the target work process identifier.

[0072] Among them, the connection table may include the determined client identifier, service identifier and association information of each work process identifier. The association relationship between the client identifier and the service identifier and the work process identifier may be pre-configured or determined on the nginx server based on the work process assigned to the service. This disclosure does not limit this.

[0073] The work process identifier may be any information such as a process number, a process name, etc. that can be used to uniquely identify the process, and this solution does not impose any restrictions on this.

[0074] In the present disclosure, after the nginx server receives the service request sent by the client, it first determines the client identifier and service identifier corresponding to the service request. After that, the client identifier and service identifier can be matched with the data information in the connection table. When the match is successful and the corresponding target working process identifier item is not an empty value, the target working process identifier corresponding to the client identifier and service identifier can be determined. Then, the service request data can be packaged and the data packet can be sent to the target working process through the connectionless UDP protocol.

[0075] For example, Figure 3 A schematic diagram of the processing process of a service is shown, such as Figure 3 As shown in a, assuming that the connection table udp_table records the target worker process worker1 for processing the service request of the client1 client, after receiving the service request of the client1 client, the nginx server can query the connection table udp_table to determine the client identifier and the target worker process identifier corresponding to the service identifier, and then send the service request to the target worker process worker1 corresponding to the target worker process identifier through the User Datagram Protocol (UDP) protocol.

[0076] Optionally, if the preset connection table does not contain the target work process identifier corresponding to the client identifier and service identifier, a hash operation can be performed on the client identifier and service identifier to determine the target work process identifier; and then the service request can be assigned to the target work process corresponding to the target work process identifier.

[0077] In actual use, the nginx server can also determine the target working process in other ways. For example, the source IP address and port corresponding to the current service and the target IP and port are subjected to a four-tuple hash operation to determine the target working process ID, and then the current service is sent to the target working process corresponding to the target working process ID.

[0078] In this embodiment, after receiving the service request, the nginx server can determine the target working process ID corresponding to the client ID and the service ID by querying the connection table, and according to the target working process ID, the service request can be allocated to the corresponding target working process. In this way, it can be achieved that when the target working process is closed, the nginx server can still normally allocate the service request to the target working process for processing, thereby achieving that when the nginx server is hot upgraded, the service request of the client can still be processed normally.

[0079] See also Figure 2 , Figure 2 Another service processing method provided by the embodiment of the present disclosure. Figure 2 As shown, the method can be executed by an nginx server, and the method may include but is not limited to the following steps:

[0080] Step 201: receiving a service request sent by a client, wherein the service request includes a client identifier and a service identifier.

[0081] Step 202: When the preset connection table does not contain the target work process identifier corresponding to the client identifier and the service identifier, a hash operation is performed on the client identifier and the service identifier to determine the target work process identifier.

[0082] Step 203: Allocate the service request to the target work process corresponding to the target work process identifier.

[0083] In this embodiment, the specific implementation process of step 201 to step 203 can be found in the detailed description of any embodiment of the present disclosure, and will not be repeated here.

[0084] Step 204: receiving a connection call request sent by the target work process, wherein the call request includes the target work process identifier, the client identifier, and the service identifier.

[0085] In the present disclosure, after the target work process receives any service request for the first time, it can send a connection call request to the nginx server kernel. After receiving the connection call request, the kernel can establish an association relationship between the target work process identifier and the client identifier, and store the association relationship in the connection table. Afterwards, when the service request sent by the client is received again, the service request can be directly assigned to the corresponding target work process according to the association relationship in the connection table.

[0086] Among them, the target working process can trigger a connection call request by calling the connect function.

[0087] For example, Figure 3 As shown in a, after receiving the service request sent by client1, the nginx server can determine the identifier of the corresponding target worker process as worker1 through hash operation, and then send an allocation instruction to it. When the worker process worker1 receives the allocation instruction, it can send a connection call request to the nginx server kernel, and the kernel can establish an association relationship between the identifier of the worker process worker1, the client identifier, and the service identifier based on the connection call request.

[0088] Step 205: associate the target work process identifier, the client identifier and the service identifier and store them in a preset connection table.

[0089] In the present disclosure, after the nginx server establishes an association relationship between the target working process identifier and the client identifier, the determined connection relationship can be stored in the connection table. Afterwards, when the service request sent by the client is received again, the service request can be directly sent to the corresponding target working process based on the association relationship.

[0090] Optionally, when determining the client's ID and service ID, the nginx server can match the client's ID and service ID with relevant items in the connection table to obtain the association between the client's ID and the target working process ID, and then send the service request to the target working process based on this association.

[0091] For example, Figure 3 As shown, assuming that the connection table udp_table contains the association relationship established between the client1 client and the worker process worker1, when the nginx server receives the service request sent by the client1 client, it can query the connection table udp_table based on the client1 client identifier and the service identifier, determine the association relationship between the client1 client identifier and the worker process worker1 identifier, and based on this association relationship, send the service request to the target worker process worker1.

[0092] It should be noted that if Figure 3 As shown, after the worker process identifier worker1 sends a connection call request, a connection connect1 is established between it and the connection table. Through connect1, the relationship between client1, service identifier and worker1 can be queried.

[0093] In addition, if Figure 3 As shown in b, assuming that the connection table udp_table contains the association relationship established between the client1 client and the worker process worker1, when the listen socket of the worker process worker1 is in the closed state, if client1 is still sending a service request, the nginx server can still determine the association relationship established between the client1 client and the worker process worker1 by querying the connection table udp_table, and continue to send the service request of client1 to the worker process worker1.

[0094] It should be noted that when the listen socket of worker1 is in closed state, when a new client newclient1 sends a service request, this service request will be assigned to the new worker process new worker1. At the same time, the worker process new worker1 can also send a connection call request to establish an association between the client newclient1 and the worker process newworker1.

[0095] Step 206: Receive a close function call request sent by the target working process, wherein the close function call request includes the target working process identifier.

[0096] Optionally, when the service request processed by the target process ends, a close function may be called so that the kernel deletes the association relationship corresponding to the target working process identifier in the connection table after receiving the close function call request.

[0097] In the present disclosure, when the service request ends, the target work process can close the association relationship corresponding to the target work process by calling a close function.

[0098] In the present disclosure, when the kernel receives a close function request sent by a target work process, the close function call request can be parsed to obtain the identifier of the target work process, and the close function is called to close the target work process corresponding to the identifier of the target work process. Through the above steps, the target work process can be closed in time, thereby preventing the occupation of system resources and causing the problem of slowing down system performance.

[0099] Step 207: Delete each connection item associated with the target working process identifier in the preset connection table.

[0100] In the present disclosure, after the kernel closes the target work process, it can query the connection table according to the target work process identifier to determine the connection items associated with the target work process identifier, and then delete the connection items associated with the target work process identifier. Through this operation, the resources occupied by the connection table can be released in time to prevent the system crash caused by continuous writing to the connection table.

[0101] In this embodiment, after receiving the connection call request sent by the target working process, the nginx server can create an association relationship with the identifier of the corresponding client for it. After that, when receiving the service request sent by the client, the corresponding target working process can be determined according to this connection relationship. In this way, when the listen socket of the target working process is closed, the kernel can still allocate the service request to the target working process corresponding to the target working process identifier for processing, thereby ensuring the normal and stable operation of the connected service while performing the service hot upgrade.

[0102] See also Figure 4 , Figure 4 Another service processing method provided by the embodiment of the present disclosure. Figure 4 As shown, the method can be executed by the target work process, and the method can include but is not limited to the following steps:

[0103] Step 401: The target work process receives a service allocation instruction, wherein the allocation instruction includes a client identifier and a service identifier.

[0104] The client identifier may be the IP, port number, etc. corresponding to the client, and the service identifier may be the service name, method, etc., which is not limited in the present disclosure.

[0105] In the present disclosure, after the nginx server receives the service request sent by the client, it first determines the client identifier and service identifier corresponding to the service request. After that, it can match the client identifier and service identifier with the data information in the connection table. When the match is successful and the corresponding target working process identifier item is not an empty value, the target working process identifier corresponding to the client identifier and service identifier can be determined. Then, the nginx server can send a service allocation instruction to the target working process.

[0106] In the present disclosure, the target working process can receive the service allocation instruction by monitoring the main process, and then parse the allocation instruction to determine the client identifier and the service identifier.

[0107] Step 402, sending a connection call request, wherein the call request includes the identifier of the target work process, the identifier of the client, and the service identifier, so as to associate the identifier of the target work process, the identifier of the client, and the service identifier and store them in a preset connection table.

[0108] In the present disclosure, after the target work process receives any service request for the first time, it can send a connection call request to the nginx server kernel. After receiving the connection call request, the kernel can establish an association relationship between the target work process identifier and the client identifier, and store the association relationship in the connection table. Afterwards, when the service request sent by the client is received again, the service request can be directly assigned to the corresponding target work process according to the association relationship in the connection table.

[0109] Among them, the target working process can trigger a connection call request by calling the connect function.

[0110] For example, Figure 3 As shown, after receiving the service request sent by client1, the nginx server can determine that the identifier of the corresponding target worker process is worker1 through hash operation, and then send an allocation instruction to it. When the worker process worker1 receives the allocation instruction, it can send a connection call request to the nginx server kernel, and the kernel can establish an association relationship between the identifier of the worker process worker1, the client identifier and the service identifier based on the connection call request.

[0111] In the present embodiment, after the target work process receives the service allocation instruction, it can send a connection call request to associate the target work process identifier, the client identifier and the service identifier and store them in a preset connection table. Afterwards, when receiving the service request sent by the client, the corresponding target work process can be determined according to this connection relationship. In this way, when the listen socket of the target work process is closed, the kernel can still allocate the service request to the target work process corresponding to the target work process identifier for processing, thereby realizing that while performing a hot upgrade of the service, the normal and stable operation of the connected service is guaranteed.

[0112] See also Figure 5 , Figure 5 Another service processing method provided by the embodiment of the present disclosure. Figure 5 As shown, the method can be executed by the target work process, and the method can include but is not limited to the following steps:

[0113] Step 501: The target work process receives a service allocation instruction, wherein the allocation instruction includes a client identifier and a service identifier.

[0114] Step 502, sending a connection call request, wherein the call request includes the identifier of the target working process, the identifier of the client and the service identifier, so as to associate the identifier of the target working process, the identifier of the client and the service identifier and store them in a preset connection table.

[0115] In the present disclosure, the specific implementation process of step 501-step 502 can be found in the detailed description of any embodiment of the present disclosure, and will not be repeated here.

[0116] Step 503: When the service corresponding to the service identifier is finished, determine the current state of the socket of the target working process.

[0117] In the present disclosure, when the service request ends, the target work process can close the association relationship corresponding to the target work process by calling the close function. When the socket of the target work process is in a closed state, a close function call request can be sent to the Nginx server, so that the kernel deletes the association relationship corresponding to the target work process identifier in the connection table after receiving the close function call request.

[0118] In the present disclosure, the target working process can obtain the status information of the socket of the target working process by checking the status command of the system socket. When the status is CLOSED, it can be determined that the socket of the target working process is in a closed state.

[0119] Step 504: When the socket of the target working process is currently in a closed state, a close function call request is sent, wherein the close function call request includes the target working process identifier.

[0120] Optionally, when the service request processed by the target process ends, a close function may be called so that the kernel deletes the association relationship corresponding to the target working process identifier in the connection table after receiving the close function call request.

[0121] In the present disclosure, when the service request ends, the target work process can close the association relationship corresponding to the target work process by calling a close function.

[0122] In the present disclosure, when the kernel receives a close function request sent by a target work process, the close function call request can be parsed to obtain the identifier of the target work process, and the close function is called to close the target work process corresponding to the identifier of the target work process. Through the above steps, the target work process can be closed in time, thereby preventing the occupation of system resources and causing the problem of slowing down system performance.

[0123] In addition, after the kernel closes the target working process, it can query the connection table according to the target working process identifier to determine each connection item associated with the target working process identifier, and then delete each connection item associated with the target working process identifier.

[0124] In this embodiment, when the socket of the target working process is currently in a closed state, a close function call request is sent. In this way, the association relationship of the target working process can be deleted in time. Through this operation, on the one hand, the resources occupied by the connection table can be released in time to prevent the system from crashing due to continuous writing of the connection table. On the other hand, the interference of historical association relationships on determining the target process can be eliminated.

[0125] Figure 6 The invention is a block diagram of a service processing device according to an exemplary embodiment.

[0126] like Figure 6 As shown, the processing device 600 of the service includes:

[0127] The receiving module 610 is used to receive a service request sent by a client, wherein the service request includes an identifier of the client and the service identifier;

[0128] The allocation module 620 is used to allocate the service request to the target work process corresponding to the target work process identifier when the preset connection table contains the target work process identifier corresponding to the client identifier and the service identifier.

[0129] In a possible implementation of the embodiment of the present disclosure, the allocation module 620 is further configured to:

[0130] In the case that the preset connection table does not contain a target work process identifier corresponding to the client identifier and the service identifier, performing a hash operation on the client identifier and the service identifier to determine the target work process identifier;

[0131] The service request is allocated to the target work process corresponding to the target work process identifier.

[0132] In a possible implementation of the embodiment of the present disclosure, the receiving module 610 is further configured to:

[0133] Receiving a connection call request sent by the target work process, wherein the call request includes the target work process identifier, the client identifier and the service identifier;

[0134] The device also includes:

[0135] The storage module is used to associate the target working process identifier, the client identifier and the service identifier and store them in the preset connection table.

[0136] In a possible implementation of the embodiment of the present disclosure, the receiving module 610 is further configured to:

[0137] Receiving a close function call request sent by the target working process, wherein the close function call request includes the target working process identifier;

[0138] The device also includes:

[0139] The deletion module is used to delete each connection item associated with the target working process identifier in the preset connection table.

[0140] In this embodiment, after receiving the service request, the nginx server can determine the target working process ID corresponding to the client ID and the service ID by querying the connection table, and according to the target working process ID, the service request can be allocated to the corresponding target working process. In this way, it can be achieved that when the target working process is closed, the nginx server can still normally allocate the service request to the target working process for processing, thereby achieving that when the nginx server is hot upgraded, the service request of the client can still be processed normally.

[0141] Figure 7 The figure is a block diagram of another service processing device according to an exemplary embodiment.

[0142] like Figure 7 As shown, the processing device 700 of the service includes:

[0143] The receiving module 710 is used for the target work process to receive the service allocation instruction, wherein the allocation instruction includes the client identifier and the service identifier;

[0144] The sending module 720 is used to send a connection call request, wherein the call request includes the identifier of the target working process, the identifier of the client and the service identifier, so as to associate the identifier of the target working process, the identifier of the client and the service identifier and store them in a preset connection table.

[0145] In a possible implementation of the embodiment of the present disclosure, the following further includes:

[0146] A determination module, used for determining the current state of the socket of the target working process when the service corresponding to the service identifier ends;

[0147] The sending module 720 is further configured to send a close function call request when the socket of the target working process is currently in a closed state, wherein the close function call request includes the target working process identifier.

[0148] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0149] In this embodiment, after receiving the allocation instruction, the target work process can send a connection call request to the nginx server to establish an association relationship between the client's identifier and the identifier of the target work process. In this way, when the listen socket of the target work process is closed, the nginx server can still allocate the service request to the target work process corresponding to the target work process identifier for processing, thereby ensuring the normal and stable operation of the connected service while performing a hot upgrade of the service.

[0150] Figure 8 Schematic diagram of a computer device provided by an embodiment of the present disclosure. Figure 7 As shown, the computer device may include:

[0151] A memory 801 storing executable program codes;

[0152] a processor 802 coupled to the memory 801;

[0153] The processor 802 calls the executable program code stored in the memory 801 to execute the service processing method provided by any embodiment of the present disclosure.

[0154] The computer device embodiment and the method embodiment are embodiments based on the same inventive concept, and the relevant parts can be referenced to each other. The computer device embodiment corresponds to the method embodiment and has the same technical effect as the method embodiment. For specific description, refer to the method embodiment.

[0155] An embodiment of the present disclosure discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute a service processing method provided by any embodiment of the present disclosure.

[0156] In the various embodiments of the present disclosure, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.

[0157] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0158] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present disclosure, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several requests for a computer device (which can be a personal computer, a server or a network device, etc., specifically a processor in a computer device) to perform some or all of the steps of the above-mentioned methods of various embodiments of the present disclosure.

[0159] The storage medium embodiment and the above method embodiment are embodiments based on the same inventive concept, and the relevant parts can be referenced to each other. The above storage medium embodiment corresponds to the method embodiment and has the same technical effect as the method embodiment. For specific description, please refer to the method embodiment.

[0160] Those skilled in the art can understand that the drawing is only a schematic diagram of an embodiment, and the modules or processes in the drawing are not necessarily required to implement the present disclosure.

[0161] Those skilled in the art can understand that the modules in the device in the embodiment can be distributed in the device in the embodiment according to the description of the embodiment, or can be changed accordingly and located in one or more devices different from the embodiment. The modules in the above embodiment can be combined into one module, or can be further divided into multiple sub-modules.

[0162] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present disclosure.

Claims

1. A method for processing a service, It is characterized in that Applied to the nginx server, the processing method includes: Receiving a service request sent by a client, and parsing the service request to determine a client identifier and a service identifier; The client identifier and the service identifier are matched with the data information in the preset connection table. When the match is successful and the target work process identifier item corresponding to the client identifier and the service identifier is not a null value, the target work process identifier corresponding to the client identifier and the service identifier is determined, the data of the service request is packaged, and the packaged data packet is allocated to the target work process corresponding to the target work process identifier by means of a connectionless UDP protocol; After determining the target working process identifier, the nginx server also sends a service allocation instruction to the target working process, so that when the target process is closed, the nginx server can still allocate the data packet to the target working process.

2. The method according to claim 1, It is characterized in that After receiving the service request sent by the client, the method further includes: When no match is successful, performing a hash operation on the client identifier and the service identifier to determine the target work process identifier; The service request is allocated to the target work process corresponding to the target work process identifier.

3. The method according to claim 1, It is characterized in that Before allocating the service request to the target work process corresponding to the target work process identifier, the method further includes: Receiving a connection call request sent by the target work process, wherein the call request includes the target work process identifier, the client identifier and the service identifier; The target work process identifier, the client identifier and the service identifier are associated and stored in the preset connection table.

4. The method according to claim 1, It is characterized in that Also includes: Receiving a close function call request sent by the target working process, wherein the close function call request includes the target working process identifier; Delete each connection item associated with the target working process identifier in the preset connection table.

5. A method for processing a service, It is characterized in that include: The target work process receives the service allocation instruction according to any one of claims 1 to 4, wherein the service allocation instruction includes a client identifier and a service identifier; Send a connection call request, wherein the call request includes a target work process identifier, the client identifier and the service identifier, so as to associate the target work process identifier, the client identifier and the service identifier and store them in a preset connection table.

6. The method according to claim 5, It is characterized in that Also includes: When the service corresponding to the service identifier ends, determining the current state of the socket of the target working process; When the socket of the target working process is currently in a closed state, a close function call request is sent, wherein the close function call request includes the target working process identifier.

7. A processing device for a service, It is characterized in that Applied to the nginx server, the processing method includes: A receiving module, used for receiving a service request sent by a client, and parsing the service request to determine a client identifier and a service identifier; An allocation module is used to match the client identifier and the service identifier with the data information in a preset connection table. When the match is successful and the target work process identifier item corresponding to the client identifier and the service identifier is not a null value, the target work process identifier corresponding to the client identifier and the service identifier is determined, the data of the service request is packaged, and the packaged data packet is allocated to the target work process corresponding to the target work process identifier by means of a connectionless UDP protocol; After determining the target working process identifier, the nginx server also sends a service allocation instruction to the target working process, so that when the target process is closed, the nginx server can still allocate the data packet to the target working process.

8. A processing device for a service, It is characterized in that include: A receiving module, configured for a target work process to receive a service allocation instruction according to any one of claims 1 to 4, wherein the service allocation instruction includes a client identifier and a service identifier; The sending module is used to send a connection call request, wherein the call request includes a target work process identifier, the client identifier and the service identifier, so as to associate the target work process identifier, the client identifier and the service identifier and store them in a preset connection table.

9. A computer device, It is characterized in that The computer device comprises: A memory storing executable program code; a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the service processing method according to any one of claims 1 to 6.

10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the service processing method as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method and device for establishing connection

    CN113055436A

  • Task processing method, device and equipment and computer readable storage medium

    CN113377507A

  • Service processing method and device, computer equipment and storage medium

    CN113448594A

  • Data transmission method and device and computer equipment

    CN113810349A