Remote procedure calling method and device for service request processing, equipment and medium

By configuring the IP address, port number, and maximum number of target connections of the remote procedure call service in Nginx and creating a circular linked list for load balancing, this solves the problem that Nginx's subrequest function cannot ensure that subrequests initiated before and after the same business request use the same network connection, thereby improving the processing efficiency of the remote procedure call service.

CN120602533APending Publication Date: 2025-09-05CETC CYBERSPACE SECURITY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510829718.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

Nginx's subrequest function cannot guarantee that subrequests initiated before and after the same business request use the same network connection, and cannot store data bound to the network connection. As a result, the connection-bound request function cannot be implemented, and performance degrades when load balancing is performed on multiple servers.

Method used

Configure the IP address, port number, and maximum number of target connections of the remote procedure call service in the target client, create a circular linked list for load balancing, use idle connections and preset storage space to send sub-requests, receive responses, and build a connection pool to optimize resource scheduling.

Benefits of technology

It optimizes resource scheduling for asynchronous RPC clients, improves the processing efficiency of remote procedure call services, and avoids connection waste and performance degradation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120602533A_ABST
    Figure CN120602533A_ABST
Patent Text Reader

Abstract

The invention discloses a service request processing-oriented remote procedure calling method and device, equipment and a medium, and relates to the field of computer software, and the method comprises the steps of configuring a target maximum connection number of a plurality of remote procedure calling services in a plurality of working processes of a target client; creating a circular linked list about a plurality of remote procedure call services; the method comprises the following steps: after initialization operation of a plurality of remote procedure call services is completed, when a business request is processed, creating a corresponding sub-request, and determining a target remote procedure call service from the plurality of remote procedure call services based on a preset load balancing rule and a circular linked list; and when the idle connection exists in the connection pool of the target remote procedure call service, sending the sub-request by using the idle connection in the connection pool and the preset storage space bound with the connection based on the asynchronous network framework of the target client, and receiving the response of the sub-request. Therefore, the resource scheduling optimization of the asynchronous RPC client can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer software, and in particular to a remote procedure call method, device, equipment and medium for business request processing. Background Art

[0002] In today's network services landscape, processing business requests often requires initiating new sub-requests to call other sub-services or external services to complete necessary operations, such as querying a database or requesting encryption from a cryptographic machine. These sub-requests are essentially remote procedure calls (RPCs), with the network service acting as the RPC client and other services acting as the RPC server.

[0003] Nginx, a mainstream high-performance web server based on a single-threaded, asynchronous, non-blocking network model, features a built-in subrequest feature, an asynchronous, high-performance RPC client implementation. However, based on the upstream mechanism (which defines a group of servers as a server group and distributes requests through this group to achieve features such as load balancing and failover), it suffers from numerous shortcomings. Technically, subrequests cannot guarantee that subsequent subrequests within the same service request use the same network connection, nor can they store data bound to the network connection. This makes connection-bound request features, such as a cryptographic machine generating a session key and then using that key to encrypt data, impossible. Furthermore, the traversal algorithm used for load balancing across multiple servers significantly degrades performance as the number of servers increases.

[0004] Therefore, how to achieve resource scheduling optimization of asynchronous RPC clients is a technical problem that needs to be solved urgently. Summary of the Invention

[0005] In view of this, the purpose of the present invention is to provide a remote procedure call method for business request processing, which can achieve resource scheduling optimization of asynchronous RPC clients. The specific solution is as follows:

[0006] In a first aspect, the present application provides a remote procedure call method for business request processing, comprising:

[0007] In the target client, IP addresses, port numbers, and target maximum number of connections of multiple remote procedure call services are configured; the target maximum number of connections is an upper limit of the number of connections that can be established from the working process of the target client to the multiple remote procedure call services;

[0008] In each of the working processes of the target client, a circular linked list of the plurality of remote procedure call services is created to complete initialization operations of the plurality of remote procedure call services; the circular linked list is a linked list for balancing the load of the remote procedure call services by each of the working processes;

[0009] After completing the initialization operations of the plurality of remote procedure call services, when processing a service request, creating a corresponding sub-request, and determining a target remote procedure call service from the plurality of remote procedure call services based on a preset load balancing rule and the circular linked list;

[0010] A connection pool is constructed from each of the working processes to the target remote procedure call service. When the connection pool has an idle connection, the sub-request is sent based on the asynchronous network framework of the target client and using the idle connection and a preset storage space pre-bound to the idle connection, and a response to the sub-request is received.

[0011] Optionally, configuring the IP addresses, port numbers, and target maximum number of connections of several remote procedure call services includes:

[0012] Configuring IP addresses and port numbers of several remote procedure call services to complete a first configuration operation;

[0013] Selecting a remote procedure call service from unselected remote procedure call services among the plurality of remote procedure call services as a current remote procedure call service;

[0014] Numbering each work process in the target client in sequence based on a preset numbering sequence, and selecting a numbered work process from the obtained numbered work processes in sequence based on the preset numbering sequence as the current work process; wherein, if the numbered work process selected last time is the work process corresponding to the last work process number, then the numbered work process corresponding to the first work process number is selected as the current work process this time;

[0015] In the current working process, the current target number of connections from the current working process to the current remote procedure call service is summed with the preset connection increment to obtain a new current target number of connections; wherein the initial value of the current target number of connections is zero;

[0016] Subtracting the current maximum number of connections of the current remote procedure call service from the preset connection deduction value to obtain a new current maximum number of connections; wherein the current maximum number of connections of the current remote procedure call service represents the upper limit of the number of connections that can be established from the remote procedure call service to the working process;

[0017] Jumping to the step of selecting a numbered working process from the obtained numbered working processes in sequence based on the preset numbering sequence as the current working process, until the current maximum number of connections of the current remote procedure call service is zero;

[0018] Jumping to the step of selecting a remote procedure call service from unselected remote procedure call services among the plurality of remote procedure call services as the current remote procedure call service, until all remote procedure call services among the plurality of remote procedure call services are executed;

[0019] The current target connection numbers corresponding to each of the current work processes and each of the remote procedure call services when the execution is completed are determined as the target maximum connection numbers corresponding to each of the work processes and each of the remote procedure call services, so as to complete the second configuration operation.

[0020] Optionally, the creating a circular linked list of the plurality of remote procedure call services includes:

[0021] In the working process, determining a minimum value among the maximum number of connections from the working process to each of the target remote procedure call services, and determining the minimum value as a load factor;

[0022] Determining load weights corresponding to the remote procedure call services based on the target maximum number of connections and the load factor, and generating polling nodes corresponding to the remote procedure call services using the load weights;

[0023] Each polling node points to a remote procedure call service, one remote procedure call service corresponds to multiple polling nodes, and the number of polling nodes is the same as the number of the load weights;

[0024] The polling node is used to create a circular linked list about the plurality of remote procedure call services; wherein each working process has its own circular linked list, and the circular linked list is a closed-loop data structure used in the working process to dynamically allocate remote procedure call service connection requests.

[0025] Optionally, determining a target remote procedure call service from the plurality of remote procedure call services based on a preset load balancing rule and the circular linked list includes:

[0026] Determine the remote procedure call service pointed to by the current polling node in the circular linked list as the target remote procedure call service;

[0027] In the process of determining the target remote procedure call service, the number of active connections of the target remote procedure call service is increased based on a preset connection number increase rule to obtain an increased number of connections; the number of active connections is the number of connections currently established from the working process to the target remote procedure call service;

[0028] If the increased number of connections is a preset integer multiple of the load factor or the increased number of connections is the target maximum number of connections, transferring the current polling node from the circular linked list to a preset standby linked list corresponding to the target remote procedure call service;

[0029] In the circular linked list, the next polling node of the current polling node is determined as a new current polling node.

[0030] Optionally, when processing a business request, creating a corresponding sub-request includes:

[0031] When processing a service request, extracting service data parameters, service context information, and service authorization information in the service request to determine service resource information;

[0032] Extract the system resource information from the target client, and create a corresponding sub-request using the business resource information or the system resource information.

[0033] Optionally, when the connection pool has an idle connection, sending the sub-request based on the asynchronous network framework of the target client and utilizing the idle connection and a preset storage space pre-bound to the idle connection, and receiving a response to the sub-request includes:

[0034] When there is an idle connection in the connection pool, determining a preset storage space pre-bound to the idle connection, and obtaining a service request parameter corresponding to the service request from the preset storage space;

[0035] Sending the sub-request on the idle connection based on the service request parameters and the asynchronous network framework of the target client;

[0036] When there is no idle connection in the connection pool of the target remote procedure call service, creating a new connection and allocating target storage space for the new connection;

[0037] The service request parameters are obtained from the target storage space, and the sub-request is sent on the newly added connection based on the service request parameters and the asynchronous network framework of the target server.

[0038] Optionally, after receiving the response to the sub-request, the method further includes:

[0039] triggering a corresponding first preset business processing operation based on a response to the sub-request;

[0040] During the execution of the first preset service processing operation, storing target data that satisfies a preset association relationship with the idle connection in the preset storage space;

[0041] After completing the first preset business processing operation, jumping to the step of obtaining the business request parameters corresponding to the business request from the preset storage space based on business requirements, so as to perform a second preset business processing operation based on the target data;

[0042] Reducing the number of active connections of the target remote procedure call service based on a preset connection number reduction rule;

[0043] If the number of active connections before the reduction is a preset integer multiple of the load factor or the number of active connections before the reduction is the target maximum number of connections, a polling node in the preset standby linked list corresponding to the target remote procedure call service is transferred to the circular linked list.

[0044] In a second aspect, the present application provides a remote procedure call device for service request processing, comprising:

[0045] an information configuration module configured to configure, in a target client, IP addresses, port numbers, and a target maximum number of connections for a plurality of remote procedure call services; the target maximum number of connections being an upper limit on the number of connections that can be established from a working process of the target client to the plurality of remote procedure call services;

[0046] a service initialization module, configured to create a circular linked list of the plurality of remote procedure call services in each of the working processes of the target client to complete initialization operations on the plurality of remote procedure call services; the circular linked list being a linked list for balancing the load of the plurality of remote procedure call services by each of the working processes;

[0047] a service determination module, configured to, after completing the initialization operations of the plurality of remote procedure call services, create corresponding sub-requests when processing a service request, and determine a target remote procedure call service from the plurality of remote procedure call services based on a preset load balancing rule and the circular linked list;

[0048] A request sending module is used to build a connection pool from each working process to the target remote procedure call service. When there is an idle connection in the connection pool, the sub-request is sent based on the asynchronous network framework of the target client and using the idle connection and the preset storage space pre-bound to the idle connection, and the response to the sub-request is received.

[0049] In a third aspect, the present application provides an electronic device, comprising:

[0050] Memory, used to store computer programs;

[0051] The processor is used to execute the computer program to implement the aforementioned remote procedure call method for business request processing.

[0052] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned remote procedure call method for business request processing is implemented.

[0053] In the present application, in a target client, the IP addresses, port numbers, and target maximum number of connections of several remote procedure call services are configured; the target maximum number of connections is the upper limit of the number of connections that can be established from the working process of the target client to the several remote procedure call services; in each of the working processes of the target client, a circular linked list of the several remote procedure call services is created to complete the initialization operation of the several remote procedure call services; the circular linked list is a linked list for each of the working processes to balance the load of each of the remote procedure call services; after completing the initialization operation of the several remote procedure call services, when processing a business request, a corresponding sub-request is created, and a target remote procedure call service is determined from the several remote procedure call services based on a preset load balancing rule and the circular linked list; a connection pool is constructed from each of the working processes to the target remote procedure call service, and when the connection pool has an idle connection, the sub-request is sent based on the asynchronous network framework of the target client and using the idle connection and a preset storage space pre-bound to the idle connection, and a response to the sub-request is received. As can be seen above, in this application, the IP addresses, port numbers, and target maximum number of connections for multiple remote procedure call services are configured in the target client. The target maximum number of connections here refers to the upper limit of the number of connections that can be established from the target client's work process to the multiple remote procedure call services. Subsequently, a circular linked list of these remote procedure call services is created in each work process of the target client, thereby completing the initialization of the multiple remote procedure call services. After the initialization of the multiple remote procedure call services is completed, corresponding sub-requests are created when processing a service request. Then, based on preset load balancing rules and the circular linked list, a target remote procedure call service is determined from the multiple remote procedure call services. A connection pool is established from the work process to the target remote procedure call service. If there are idle connections in the connection pool, sub-requests are sent and responses to the sub-requests are received based on the target client's asynchronous network framework, using the idle connections and the preset storage space bound to the idle connections. This allows this application to optimize resource scheduling for asynchronous RPC clients, thereby improving the processing efficiency of remote procedure call services. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0055] Figure 1A flowchart of a remote procedure call method for business request processing disclosed in this application;

[0056] Figure 2 This is a schematic diagram of the structure of a remote procedure call device for business request processing disclosed in this application;

[0057] Figure 3 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0058] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0059] Currently, Nginx's built-in subrequest function is based on the upstream mechanism, but it has many shortcomings. Technically, subrequest cannot guarantee that subrequests initiated before and after the same business request use the same network connection, nor can it store data bound to the network connection. As a result, connection-bound request functions such as a cipher first generating a session key and then encrypting data with the key cannot be implemented. In addition, when a traversal algorithm is used for load balancing across multiple servers, performance will significantly decrease as the number of servers increases. To this end, the present application provides a remote procedure call method, device, equipment, and medium for business request processing, which can achieve resource scheduling optimization for asynchronous RPC clients.

[0060] See also Figure 1 As shown, the embodiment of the present invention discloses a remote procedure call method for business request processing, including:

[0061] Step S11: In the target client, configure the IP addresses, port numbers and target maximum number of connections of several remote procedure call services; the target maximum number of connections is the upper limit of the number of connections that can be established from the working process of the target client to the several remote procedure call services.

[0062] In this embodiment, in the target client, it is first necessary to configure the IP addresses, port numbers and target maximum number of connections of several remote procedure call services. Among them, the target maximum number of connections is the upper limit of the number of connections that can be established from the work process of the target client to the several remote procedure call services. Specifically, first, the IP addresses and port numbers of the several remote procedure call services are configured to complete the first configuration operation. Then, a remote procedure call service is selected from the remote procedure call services that have not been selected in the several remote procedure call services as the current remote procedure call service. The work processes in the target client are numbered in sequence based on a preset numbering sequence, and a numbered work process is selected from the obtained numbered work processes in sequence based on the preset numbering sequence as the current work process. In addition, it should be emphasized that if the numbered work process selected last time is the work process corresponding to the last work process number, then the numbered work process corresponding to the first work process number is selected as the current work process this time.

[0063] In the current working process, the current target number of connections for the current remote procedure call service is summed with the preset connection increment to obtain a new current target number of connections. The initial value of the current target number of connections is zero. Accordingly, the current maximum number of connections for the current remote procedure call service is subtracted from the preset connection decrement to obtain a new current maximum number of connections. The current maximum number of connections for the current remote procedure call service represents the upper limit of the number of connections that can be established from the remote procedure call service to the working process. Furthermore, since the preset connection increment and the preset connection decrement are for the same remote procedure call service, the values ​​of the preset connection increment and the preset connection decrement are identical. It should be emphasized that the maximum number of connections for the remote procedure call service itself is fixed and does not change due to external allocation operations. When subtracting the current maximum number of connections for the current remote procedure call service from the preset connection decrement, changes in the current maximum number of connections are solely due to the allocation of the remote procedure call service to the working process. The underlying maximum number of connections for the remote procedure call service remains constant and is not affected by the allocation process.

[0064] Furthermore, the process jumps to the step of selecting a numbered work process from the obtained numbered work processes in sequence based on a preset numbering order as the current work process until the current maximum number of connections of the current remote procedure call service reaches zero. Then, the process jumps to the step of selecting a remote procedure call service from the plurality of remote procedure call services that have not been selected as the current remote procedure call service until all the remote procedure call services in the plurality of remote procedure call services are executed.

[0065] Finally, upon completion, the current target number of connections from each work process to each remote procedure call service is determined as the maximum target number of connections from each work process to each remote procedure call service, completing the second configuration operation. Upon completion of the second configuration operation, the target client establishes a connection configuration system for the remote procedure call service, providing a foundation and guarantee for executing remote procedure calls during subsequent business request processing. This system effectively controls the number of connections from each work process to each remote procedure call service, avoiding resource waste and performance issues caused by excessive connections, and ensuring the smooth execution of remote procedure calls during business request processing.

[0066] Step S12: In each of the working processes of the target client, a circular linked list of the remote procedure call services is created to complete the initialization operation of the remote procedure call services; the circular linked list is a linked list for balancing the load of each remote procedure call service by each working process.

[0067] In this embodiment, within a work process, the minimum value among the maximum number of connections from the work process to each target of each remote procedure call service is determined, and this minimum value is used as the load factor. In other words, by finding the minimum value among the maximum number of connections for all remote procedure call service targets, a relatively fair benchmark can be provided for subsequent load weight calculations.

[0068] Next, the load weight for each remote procedure call service is determined based on the target maximum number of connections and the load factor. Specifically, the target maximum number of connections for each remote procedure call service is divided by the load factor and then rounded up. The purpose of rounding up is to ensure that each remote procedure call service has at least one polling node, ensuring that each service has a chance to be selected during the load balancing process.

[0069] After obtaining the load weights of each remote procedure call service, the load weights are used to generate polling nodes corresponding to each remote procedure call service. It should be noted that each polling node points to a remote procedure call service, and one remote procedure call service corresponds to multiple polling nodes. The load weight value is the same as the number of polling nodes. That is, a remote procedure call service with a load weight of 1 will generate one polling node, a remote procedure call service with a load weight of 2 will generate two polling nodes, and so on. These polling nodes serve as the basic components of a circular linked list, each of which points to a corresponding remote procedure call service. Furthermore, the circular linked list is used to balance the load of the remote procedure call services. In this way, remote procedure call services with greater load weights have more corresponding polling nodes in the circular linked list, which means they are more likely to be selected during the load balancing process. Accordingly, after generating the polling nodes corresponding to all remote procedure call services, the polling nodes are used to create a circular linked list for the remote procedure call services, completing the initialization of the remote procedure call services.

[0070] It is understandable that each working process has its own circular linked list, and the circular linked list is a closed-loop data structure formed by randomly connecting polling nodes in the working process and connecting them end to end, which is used to dynamically allocate remote procedure call service connection requests.

[0071] Step S13: After completing the initialization operations of the several remote procedure call services, when processing a business request, create a corresponding sub-request, and determine the target remote procedure call service from the several remote procedure call services based on the preset load balancing rules and the circular linked list.

[0072] In this embodiment, after completing the initialization operations for several remote procedure call services, that is, successfully creating a circular linked list for load balancing, the service request processing phase can be entered. When processing a service request, the service data parameters, service context information, and service authorization information in the service request are extracted. By extracting and analyzing this information, the resources required by the service request, namely the service resource information, can be determined.

[0073] Next, the system resource information from the target client is extracted, and a corresponding sub-request is created using the business resource information or system resource information. It should be noted that sub-requests can be created in different ways. Specifically, if the business resource information is clear and the system resources can meet the business requirements, a sub-request can be created directly based on the business resource information. For example, if the business request is to query user information in a database, and the business resource information clearly points to a specific database table and query conditions, a sub-request can be created directly for that database query.

[0074] Furthermore, the multiple remote procedure call services pointed to by the current polling node in the circular linked list are determined as target remote procedure call services for sending the created sub-request. During the process of determining the target remote procedure call service, the number of active connections of the target remote procedure call service is increased based on a preset connection number increase rule to obtain an increased connection number. The active connection number is the number of connections currently established from the working process to the target remote procedure call service, and the preset connection number increase rule may be to increase the active connection number by 1.

[0075] In one embodiment, if the increased number of connections is a preset integer multiple of the load factor or the increased number of connections is the target maximum number of connections, the current polling node is transferred from the circular linked list to a preset standby linked list corresponding to the target remote procedure call service. Furthermore, the next polling node of the current polling node is designated as the new current polling node.

[0076] Step S14: Build a connection pool from each of the work processes to the target remote procedure call service. When the connection pool has an idle connection, send the sub-request based on the asynchronous network framework of the target client and using the idle connection and the preset storage space pre-bound to the idle connection, and receive the response to the sub-request.

[0077] In this embodiment, a connection pool is first established for each worker process to the target remote procedure call service. If there are idle connections in the connection pool, the default storage space associated with each idle connection is first determined. This default storage space is allocated when the connection is established and is used to store business data and context information related to that connection. Dedicating independent storage space to each connection ensures that data between different connections does not interfere with each other, ensuring accurate and independent business processing.

[0078] After determining the preset storage space, the service request parameters corresponding to the service request are retrieved from the preset storage space. These service request parameters, already stored in the preset storage space during the sub-request creation phase, contain key information required for the service request, such as query conditions and operation type. Retrieving the service request parameters from the preset storage space avoids retransmitting these parameters each time a sub-request is sent, improving data transmission efficiency. Next, based on the service request parameters and the target client's asynchronous network framework, the sub-request is sent over an idle connection.

[0079] In a specific embodiment, when there is no idle connection in the connection pool of the target remote procedure call service, a new connection is created and a target storage space is allocated for the newly allocated connection. The business request parameters are obtained from the target storage space, and the sub-request is sent on the newly added connection based on the business request parameters and the asynchronous network framework of the target client. It can be understood that, similar to sending a sub-request using an idle connection, when sending a sub-request on a newly added connection, it is also necessary to use the asynchronous network framework to encapsulate the business request parameters into a network data packet for transmission. However, creating a new connection will bring certain overheads, including the occupation of network resources and the time cost of connection establishment. Therefore, in actual applications, idle connections can be used first.

[0080] After sending a sub-request, a response to the sub-request may be received. Therefore, a corresponding first preset service processing operation is further triggered based on the sub-request response. During the execution of the first preset service processing operation, target data that satisfies a preset association with the idle connection is stored in a preset storage space. For example, when processing cryptographic machine-related services, the generated session key handle may be stored in the preset storage space corresponding to the connection, so that subsequent requests using the connection can directly obtain and use the session key handle.

[0081] After completing the first preset business processing operation, the process jumps to the step of retrieving the business request parameters corresponding to the business request from the preset storage space based on business needs, thereby executing the second preset business processing operation based on the target data. Business needs are determined based on specific business scenarios and business processes. Some businesses may require continuing to perform subsequent operations after completing the first preset business processing operation. For example, in a cryptographic machine service, a cryptographic machine may be requested to generate a session key. After completing the first preset business processing operation, it may be necessary to continue to request the cryptographic machine to encrypt data based on this session key, which requires executing the second preset business processing operation.

[0082] Furthermore, in this embodiment, after the response processing of the sub-request is completed, the number of active connections of the target remote procedure call service used to send the sub-request is reduced by 1 to obtain the reduced number of active connections. If the number of active connections before the reduction is an integer multiple of the target remote procedure call service load factor or is equal to the target maximum number of connections of the target remote procedure call service, then a polling node in the preset standby linked list corresponding to the target remote procedure call service is transferred to the circular linked list.

[0083] As can be seen above, in this application, the IP addresses, port numbers, and target maximum number of connections for multiple remote procedure call services are configured in the target client. The target maximum number of connections here refers to the upper limit of the number of connections that can be established from the target client's work process to the multiple remote procedure call services. Subsequently, a circular linked list of these remote procedure call services is created in each work process of the target client, thereby completing the initialization of the multiple remote procedure call services. After the initialization of the multiple remote procedure call services is completed, corresponding sub-requests are created when processing a service request. Then, based on preset load balancing rules and the circular linked list, a target remote procedure call service is determined from the multiple remote procedure call services. A connection pool is established from the work process to the target remote procedure call service. If there are idle connections in the connection pool, sub-requests are sent and responses to the sub-requests are received based on the target client's asynchronous network framework, using the idle connections and the preset storage space bound to the idle connections. This allows this application to optimize resource scheduling for asynchronous RPC clients, thereby improving the processing efficiency of remote procedure call services.

[0084] The technical solutions of the embodiments of the present application are described in detail below with reference to specific examples.

[0085] Specifically, first you need to complete the initialization of the RPC service configuration in the RPC client module. Specifically, set the relevant parameters of the RPC service, including the number of servers and the IP address, port number and maximum number of connections (that is, the target maximum number of connections) of each server, and then calculate the maximum number of connections from each worker process of nginx to each RPC server. Specifically, number the worker processes (that is, working processes) of nginx, and number n worker processes as 1, 2, ..., n. At the same time, point the process indicator to worker process 1 (that is, the current working process), assign the number of connections of each RPC server in each worker process (that is, the current target number of connections) to 0, and take out the first RPC server, increases the number of connections of the RPC server in the worker process indicated by the process indicator by 1 (that is, the preset connection increment), and reduces the number of connections of the RPC server (that is, the current maximum number of connections) by 1 (that is, the preset connection decrement), and points the process indicator to the next worker process. If the current worker process is n, the next worker process is 1, and repeats the operations of increasing the number of connections, decreasing the number of connections, and pointing the process indicator to the next worker process until the number of connections of the RPC server is reduced to 0.

[0086] Next, we remove the second RPC server and repeat the process of increasing and decreasing the number of connections until all RPC servers have been processed. The maximum number of connections from each worker process to each RPC server calculated according to the above rules is relatively balanced. This allows us to control the number of connections from each worker process to each RPC server. Each connection number is independent and easy to control, which effectively solves the problem of being unable to effectively control the number of connections to the RPC server in the network persistent connection mode.

[0087] Then, in a worker process, find the minimum maximum number of connections from that process to all RPC servers and use this minimum as the load factor. Divide the maximum number of connections for each RPC server by the load factor and round up to the nearest integer to obtain the RPC server's load weight. Based on the load weight, generate polling nodes. For example, if an RPC server has a load weight of 5, generate five polling nodes, all pointing to that RPC server. All polling nodes are randomly sorted and connected to form a load-balancing circular linked list.

[0088] After generating this circular linked list, when a subrequest needs to be sent, the next polling node in the circular linked list is searched in turn. The RPC request is then sent to the RPC server pointed to by this polling node, thus achieving load balancing across multiple RPC servers. When an RPC service has multiple servers, the greater the maximum number of connections a server can accept, the more polling nodes it will have in the circular linked list, making it more likely to be requested. This load balancing solution ensures that no matter how many RPC servers there are, the appropriate server can be found to send requests to as quickly as possible.

[0089] After completing the RPC service configuration initialization, you can initiate an RPC subrequest when processing a business request. When you need to initiate an RPC subrequest, there are two ways to create an RPC subrequest: one is to create an RPC subrequest through resources related to the business request. This method is mainly used to create RPC subrequests required in the business request processing process; the other is to create an independent RPC subrequest through system resources. This method is mainly used to create RPC subrequests similar to those initiated in scheduled tasks.

[0090] Then, the next polling node is queried in the load balancing circular linked list, and the RPC server pointed to by this polling node is taken out. The current number of active connections of the server is increased by 1. If the current number of active connections is exactly equal to an integer multiple of the load factor, or exactly equal to the maximum number of connections of the server, the polling node found is taken out from the circular linked list and placed in the standby linked list of the server. In this way, as the number of active connections on a server increases, the chance of the server appearing in the circular linked list will decrease. When the number of active connections is equal to the maximum number of connections, the last polling node of the server in the circular linked list will be taken out.

[0091] Next, the server's connection pool is checked for idle connections. If so, it is retrieved and the request will be issued on that connection. If no connection is available, a new connection is established and its associated storage is allocated, and the request will be issued on that connection. The service request parameters for the RPC subrequest are then set. When setting these parameters, data from the associated storage can be read. The nginx asynchronous network framework is then used to asynchronously send the RPC request and receive the response.

[0092] After receiving the RPC response, business processing of the request response is performed. During the business processing, data associated with the connection can be written to the connection binding storage space. For example, the session key handle generated on a connection of the cipher machine can only be used on this connection. The session key handle can be stored in the connection binding storage space, so that subsequent requests using the connection can use the session key handle.

[0093] After completing the business processing of the request response, a new RPC sub-request can be issued again based on the same network connection. This allows the cipher machine to generate a session key first, and then request the cipher machine to use the generated session key to encrypt data again on the same cipher machine connection. Furthermore, after completing the business processing of the request response, the RPC sub-request can be directly terminated. When terminating the RPC sub-request, the currently used network connection needs to be placed in the connection pool of the corresponding RPC server. At the same time, if the current number of active connections is exactly equal to an integer multiple of the load factor, or exactly equal to the maximum number of connections of the server, a polling node is taken from the server's standby list and added to the circular list. The current number of active connections of the server is then reduced by 1. As the number of active connections on a server decreases, the chance of that server appearing in the circular list increases. When the number of active connections equals 0, all polling nodes of that server are added to the circular list.

[0094] Accordingly, see Figure 2 As shown, the embodiment of the present application provides a remote procedure call device for business request processing, including:

[0095] An information configuration module 11 is configured to configure, in a target client, IP addresses, port numbers, and a target maximum number of connections for a plurality of remote procedure call services; the target maximum number of connections being an upper limit on the number of connections that can be established from a working process of the target client to the plurality of remote procedure call services;

[0096] A service initialization module 12 is configured to create a circular linked list of the plurality of remote procedure call services in each of the working processes of the target client to complete initialization operations of the plurality of remote procedure call services; the circular linked list is a linked list for balancing the load of the plurality of remote procedure call services by each of the working processes;

[0097] a service determination module 13 configured to, after completing the initialization operations of the plurality of remote procedure call services, create corresponding sub-requests when processing a service request, and determine a target remote procedure call service from the plurality of remote procedure call services based on a preset load balancing rule and the circular linked list;

[0098] The request sending module 14 is used to build a connection pool from each working process to the target remote procedure call service. When there is an idle connection in the connection pool, the sub-request is sent based on the asynchronous network framework of the target client and using the idle connection and the preset storage space pre-bound to the idle connection, and the response to the sub-request is received.

[0099] As can be seen above, in this application, the IP addresses, port numbers, and target maximum number of connections for multiple remote procedure call services are configured in the target client. The target maximum number of connections here refers to the upper limit of the number of connections that can be established from the target client's work process to the multiple remote procedure call services. Subsequently, a circular linked list of these remote procedure call services is created in each work process of the target client, thereby completing the initialization of the multiple remote procedure call services. After the initialization of the multiple remote procedure call services is completed, corresponding sub-requests are created when processing a service request. Then, based on preset load balancing rules and the circular linked list, a target remote procedure call service is determined from the multiple remote procedure call services. A connection pool is established from the work process to the target remote procedure call service. If there are idle connections in the connection pool, sub-requests are sent and responses to the sub-requests are received based on the target client's asynchronous network framework, using the idle connections and the preset storage space bound to the idle connections. This allows this application to optimize resource scheduling for asynchronous RPC clients, thereby improving the processing efficiency of remote procedure call services.

[0100] In some specific implementations, the information configuration module 11 specifically includes:

[0101] An information configuration unit, configured to configure IP addresses and port numbers of a plurality of remote procedure call services to complete a first configuration operation;

[0102] A first service determining unit is configured to select one remote procedure call service from among the plurality of remote procedure call services that have not been selected as a current remote procedure call service;

[0103] A process determination unit is used to sequentially number each work process in the target client based on a preset numbering sequence, and select a numbered work process from the obtained numbered work processes based on the preset numbering sequence as the current work process; wherein, if the numbered work process selected last time is the work process corresponding to the last work process number, then the numbered work process corresponding to the first work process number is selected as the current work process this time;

[0104] A first connection number setting unit is configured to sum, under a current working process, a current target number of connections from the current working process to the current remote procedure call service and a preset connection increment to obtain a new current target number of connections; wherein an initial value of the current target number of connections is zero;

[0105] a second connection number setting unit, configured to obtain a new current maximum number of connections by subtracting a current maximum number of connections of the current remote procedure call service from a preset connection deduction value; wherein the current maximum number of connections of the current remote procedure call service represents an upper limit of the number of connections that can be established from the remote procedure call service to the working process;

[0106] a third connection number setting unit, configured to jump to the step of selecting a numbered working process from the obtained numbered working processes in sequence based on the preset numbering sequence as the current working process, until the current maximum number of connections of the current remote procedure call service is zero;

[0107] a service selection unit, configured to jump to the step of selecting a remote procedure call service from unselected remote procedure call services among the plurality of remote procedure call services as the current remote procedure call service, until all remote procedure call services among the plurality of remote procedure call services are executed;

[0108] The connection number configuration unit is used to determine the current target connection number corresponding to each of the current work processes to each of the remote procedure call services as the maximum target connection number corresponding to each of the work processes to each of the remote procedure call services when the execution is completed, so as to complete the second configuration operation.

[0109] In some specific implementations, the service initialization module 12 specifically includes:

[0110] a load factor determining unit, configured to determine, in the work process, a minimum value among the maximum number of connections from the work process to each of the remote procedure call services, and determine the minimum value as the load factor;

[0111] a node generating unit, configured to determine load weights corresponding to the remote procedure call services based on the target maximum number of connections and the load factor, and to generate polling nodes corresponding to the remote procedure call services using the load weights;

[0112] Each polling node points to a remote procedure call service, one remote procedure call service corresponds to multiple polling nodes, and the number of polling nodes is the same as the number of the load weights;

[0113] A linked list creation unit is used to use the polling node to create a circular linked list about the multiple remote procedure call services; wherein each working process has its own circular linked list, and the circular linked list is a closed-loop data structure used to dynamically allocate remote procedure call service connection requests in the working process.

[0114] In some specific implementations, the service determination module 13 specifically includes:

[0115] a second service determining unit, configured to determine the remote procedure call service pointed to by the current polling node in the circular linked list as a target remote procedure call service;

[0116] a connection number increasing unit, configured to increase the number of active connections of the target remote procedure call service based on a preset connection number increasing rule during the process of determining the target remote procedure call service, and obtain an increased number of connections; the number of active connections being the number of connections currently established from the working process to the target remote procedure call service;

[0117] a first node transfer unit, configured to transfer a current polling node from the circular linked list to a preset standby linked list corresponding to the target remote procedure call service if the increased number of connections is a preset integer multiple of the load factor or the increased number of connections is the target maximum number of connections;

[0118] The node determination unit is used to determine the next polling node of the current polling node as the new current polling node in the circular linked list.

[0119] In some specific implementations, the service determination module 13 specifically includes:

[0120] An information determination unit, configured to extract service data parameters, service context information, and service authorization information from a service request when processing the service request, to determine service resource information;

[0121] The request creation unit is used to extract the system resource information in the target client and create a corresponding sub-request using the business resource information or the system resource information.

[0122] In some specific implementations, the request sending module 14 specifically includes:

[0123] a parameter acquisition unit, configured to, when there is an idle connection in the connection pool, determine a preset storage space pre-bound to the idle connection, and acquire a service request parameter corresponding to the service request from the preset storage space;

[0124] A first request sending unit, configured to send the sub-request on the idle connection based on the service request parameters and the asynchronous network framework of the target client;

[0125] a space allocation unit, configured to create a new connection when there is no idle connection in the connection pool of the target remote procedure call service, and allocate a target storage space for the new connection;

[0126] The second request sending unit is configured to obtain the service request parameters from the target storage space, and send the sub-request on the newly added connection based on the service request parameters and the asynchronous network framework of the target server.

[0127] In some specific implementations, the request sending module 14 further includes:

[0128] a response triggering unit, configured to trigger a corresponding first preset business processing operation based on a response to the sub-request;

[0129] A data storage unit, configured to store target data that satisfies a preset association relationship with the idle connection in the preset storage space during the execution of the first preset service processing operation;

[0130] a service jump unit, configured to, after completing the first preset service processing operation, jump to the step of obtaining the service request parameters corresponding to the service request from the preset storage space based on service requirements, so as to perform a second preset service processing operation based on the target data;

[0131] a connection number reduction unit, configured to reduce the number of active connections of the target remote procedure call service based on a preset connection number reduction rule;

[0132] The second node transfer unit is used to transfer a polling node in the preset standby linked list corresponding to the target remote procedure call service to the circular linked list if the number of active connections before reduction is a preset integer multiple of the load factor or the number of active connections before reduction is the target maximum number of connections.

[0133] Furthermore, the embodiment of the present application also discloses an electronic device, Figure 3 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation on the scope of use of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the remote procedure call method for business request processing disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0134] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0135] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0136] The operating system 221 is used to manage and control the hardware devices on the electronic device 20 and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of implementing the remote procedure call method for business request processing performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include computer programs capable of completing other specific tasks.

[0137] Furthermore, this application discloses a computer-readable storage medium for storing a computer program; wherein, when executed by a processor, the computer program implements the aforementioned remote procedure call method for processing business requests. The specific steps of this method can be found in the corresponding contents disclosed in the aforementioned embodiments and will not be further described here.

[0138] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.

[0139] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0140] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0141] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0142] The above is a detailed introduction to the technical solution provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A remote procedure call method for business request processing, characterized in that: include: On the target client, configure the IP addresses, port numbers, and maximum number of target connections of several remote procedure call services; The target maximum number of connections is the upper limit of the number of connections that can be established from the working process of the target client to the plurality of remote procedure call services; In each of the working processes of the target client, a circular linked list of the plurality of remote procedure call services is created to complete initialization operations of the plurality of remote procedure call services; the circular linked list is a linked list for balancing the load of the remote procedure call services by each of the working processes; After completing the initialization operations of the plurality of remote procedure call services, when processing a service request, creating a corresponding sub-request, and determining a target remote procedure call service from the plurality of remote procedure call services based on a preset load balancing rule and the circular linked list; A connection pool is constructed from each of the working processes to the target remote procedure call service. When the connection pool has an idle connection, the sub-request is sent based on the asynchronous network framework of the target client and using the idle connection and a preset storage space pre-bound to the idle connection, and a response to the sub-request is received.

2. The remote procedure call method for business request processing according to claim 1, characterized in that: The configuration of the IP addresses, port numbers and target maximum number of connections of several remote procedure call services includes: Configuring IP addresses and port numbers of several remote procedure call services to complete a first configuration operation; Selecting a remote procedure call service from unselected remote procedure call services among the plurality of remote procedure call services as a current remote procedure call service; Numbering each work process in the target client in sequence based on a preset numbering sequence, and selecting a numbered work process from the obtained numbered work processes in sequence based on the preset numbering sequence as the current work process; wherein, if the numbered work process selected last time is the work process corresponding to the last work process number, then the numbered work process corresponding to the first work process number is selected as the current work process this time; In the current working process, the current target number of connections from the current working process to the current remote procedure call service is summed with the preset connection increment to obtain a new current target number of connections; wherein the initial value of the current target number of connections is zero; Subtracting the current maximum number of connections of the current remote procedure call service from the preset connection deduction value to obtain a new current maximum number of connections; wherein the current maximum number of connections of the current remote procedure call service represents the upper limit of the number of connections that can be established from the remote procedure call service to the working process; Jumping to the step of selecting a numbered working process from the obtained numbered working processes in sequence based on the preset numbering sequence as the current working process, until the current maximum number of connections of the current remote procedure call service is zero; Jumping to the step of selecting a remote procedure call service from unselected remote procedure call services among the plurality of remote procedure call services as the current remote procedure call service, until all remote procedure call services among the plurality of remote procedure call services are executed; The current target connection numbers corresponding to each of the current work processes and each of the remote procedure call services when the execution is completed are determined as the target maximum connection numbers corresponding to each of the work processes and each of the remote procedure call services, so as to complete the second configuration operation.

3. The remote procedure call method for business request processing according to claim 1, characterized in that: The step of creating a circular linked list of the plurality of remote procedure call services includes: In the working process, determining a minimum value among the maximum number of connections from the working process to each of the target remote procedure call services, and determining the minimum value as a load factor; Determining load weights corresponding to the remote procedure call services based on the target maximum number of connections and the load factor, and generating polling nodes corresponding to the remote procedure call services using the load weights; Each polling node points to a remote procedure call service, one remote procedure call service corresponds to multiple polling nodes, and the number of polling nodes is the same as the number of the load weights; The polling node is used to create a circular linked list about the plurality of remote procedure call services; wherein each working process has its own circular linked list, and the circular linked list is a closed-loop data structure used in the working process to dynamically allocate remote procedure call service connection requests.

4. The remote procedure call method for business request processing according to claim 3, characterized in that: The determining a target remote procedure call service from the plurality of remote procedure call services based on a preset load balancing rule and the circular linked list includes: Determine the remote procedure call service pointed to by the current polling node in the circular linked list as the target remote procedure call service; In the process of determining the target remote procedure call service, the number of active connections of the target remote procedure call service is increased based on a preset connection number increase rule to obtain an increased number of connections; the number of active connections is the number of connections currently established from the working process to the target remote procedure call service; If the increased number of connections is a preset integer multiple of the load factor or the increased number of connections is the target maximum number of connections, transferring the current polling node from the circular linked list to a preset standby linked list corresponding to the target remote procedure call service; In the circular linked list, the next polling node of the current polling node is determined as a new current polling node.

5. The remote procedure call method for business request processing according to any one of claims 1 to 4, characterized in that: When processing a business request, a corresponding sub-request is created, including: When processing a service request, extracting service data parameters, service context information, and service authorization information in the service request to determine service resource information; Extract the system resource information from the target client, and create a corresponding sub-request using the business resource information or the system resource information.

6. The remote procedure call method for business request processing according to claim 1, characterized in that: When the connection pool has an idle connection, sending the sub-request based on the asynchronous network framework of the target client and using the idle connection and a preset storage space pre-bound to the idle connection, and receiving a response to the sub-request, including: When there is an idle connection in the connection pool, determining a preset storage space pre-bound to the idle connection, and obtaining a service request parameter corresponding to the service request from the preset storage space; Sending the sub-request on the idle connection based on the service request parameters and the asynchronous network framework of the target client; When there is no idle connection in the connection pool of the target remote procedure call service, creating a new connection and allocating target storage space for the new connection; The service request parameters are obtained from the target storage space, and the sub-request is sent on the newly added connection based on the service request parameters and the asynchronous network framework of the target server.

7. The remote procedure call method for business request processing according to claim 6, characterized in that: After receiving the response to the sub-request, the method further includes: triggering a corresponding first preset business processing operation based on a response to the sub-request; During the execution of the first preset service processing operation, storing target data that satisfies a preset association relationship with the idle connection in the preset storage space; After completing the first preset business processing operation, jumping to the step of obtaining the business request parameters corresponding to the business request from the preset storage space based on business requirements, so as to perform a second preset business processing operation based on the target data; Reducing the number of active connections of the target remote procedure call service based on a preset connection number reduction rule; If the number of active connections before the reduction is a preset integer multiple of the load factor or the number of active connections before the reduction is the target maximum number of connections, a polling node in the preset standby linked list corresponding to the target remote procedure call service is transferred to the circular linked list.

8. A remote procedure call device for business request processing, characterized in that: include: An information configuration module is used to configure the IP addresses, port numbers and target maximum number of connections of several remote procedure call services in the target client; The target maximum number of connections is the upper limit of the number of connections that can be established from the working process of the target client to the plurality of remote procedure call services; a service initialization module, configured to create a circular linked list of the plurality of remote procedure call services in each of the working processes of the target client to complete initialization operations on the plurality of remote procedure call services; the circular linked list being a linked list for balancing the load of the plurality of remote procedure call services by each of the working processes; a service determination module, configured to, after completing the initialization operations of the plurality of remote procedure call services, create corresponding sub-requests when processing a service request, and determine a target remote procedure call service from the plurality of remote procedure call services based on a preset load balancing rule and the circular linked list; A request sending module is used to build a connection pool from each working process to the target remote procedure call service. When there is an idle connection in the connection pool, the sub-request is sent based on the asynchronous network framework of the target client and using the idle connection and the preset storage space pre-bound to the idle connection, and the response to the sub-request is received.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor is configured to execute the computer program to implement the remote procedure call method for business request processing according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that Used to store a computer program; wherein, when the computer program is executed by a processor, the remote procedure call method for business request processing according to any one of claims 1 to 7 is implemented.