Remote procedure call method, device and remote procedure call execution method
By performing two-step serialization processing of business data and remote procedure call configuration information in a distributed RPC framework, and separating message serialization and interface serialization, the problems of low communication efficiency and high maintenance cost in the existing technology are solved, and the More efficient communication and reduced application layer code modification requirements.
Patent Information
- Application Number
- CN201910667077.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-23
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2039-07-23
AI Technical Summary
The existing distributed RPC framework cannot support load balancing, service discovery, health status monitoring and call chain tracking analysis, resulting in low communication efficiency. Moreover, due to its close relationship with the business, maintenance costs are high, and changes in the underlying framework require a large number of application layer code modifications. .
By performing two-step serialization processing of business data and remote procedure call configuration information, message serialization and interface serialization are separated. The interface serialization code is only modified when the underlying framework changes, and the message serialization code is modified when business data changes, reducing applications. Modification requirements for layer code.
It significantly reduces the labor cost of maintaining normal communication, improves communication efficiency, and reduces the amount of application layer code modifications when adapting to the needs of different business scenarios.
Smart Images

Figure CN112286698B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer communication technology, and in particular to a remote procedure call method, device, remote procedure call execution method, electronic device and computer-readable storage medium. Background Art
[0002] In distributed systems, remote procedure call (RPC) technology, as a kind of inter-process communication technology, is widely used in network communication. RPC hides the underlying network communication details and provides interface description language and corresponding compiler, which is convenient for users. Some software companies in the industry, such as Apache and Google, have launched their own distributed RPC frameworks, such as Apache's thrift and Google's gRPC. However, these distributed RPC frameworks cannot support distributed management functions such as load balancing, downstream service discovery, service health status monitoring, call chain tracking and analysis, so the communication efficiency is low. In addition, these distributed RPC frameworks are difficult to use due to their close relationship with specific businesses, and they have high requirements for developers. Since the underlying communication and application layer codes of these frameworks are closely related, once the underlying framework changes, such as switching from thrift to gRPC, more application layer codes have to be modified; at the same time, since the communication process is based on actual business data, once the business data agreed upon by the two parties in communication changes, more application layer codes also need to be modified. This requires modifying a lot of application layer codes to adapt to the needs of different business scenarios, which will not only significantly increase the manpower cost of maintaining normal communication, but also significantly affect the communication efficiency. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a remote procedure call method, device, remote procedure call execution method, electronic device and computer-readable storage medium, which solve the problems of high maintenance cost and low communication efficiency of existing remote procedure client-side.
[0004] According to one aspect of the present application, a remote procedure call method provided by an embodiment of the present application includes: serializing business data to obtain first serialized data; serializing remote procedure call configuration information and the first serialized data to obtain second serialized data; storing the second serialized data in a sending buffer; and sending the second serialized data in the sending buffer to a target server.
[0005] According to another aspect of the present application, a remote procedure call execution method provided by an embodiment of the present application includes: receiving second serialized data from a send buffer of a client; and deserializing the second serialized data to obtain business data, and executing the remote procedure called by the client based on the business data; wherein the second serialized data is generated by the client based on the following steps: serializing the business data to obtain first serialized data; serializing the remote procedure call configuration information and the first serialized data to obtain the second serialized data.
[0006] According to one aspect of the present application, a remote procedure call device provided by an embodiment of the present application includes: a first serialization module, configured to serialize business data to obtain first serialized data; a second serialization module, configured to serialize remote procedure call configuration information and the first serialized data to obtain second serialized data; a storage module, configured to store the second serialized data in a sending buffer; and a transmission module, configured to send the second serialized data in the sending buffer to a target server.
[0007] According to another aspect of the present application, an electronic device is provided, comprising: a processor; a memory; and computer program instructions stored in the memory, wherein when the computer program instructions are executed by the processor, the processor executes the remote procedure call method as described in any one of the above items.
[0008] According to another aspect of the present application, a computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes any of the above-mentioned remote procedure call methods.
[0009] According to another aspect of the present application, a computer program product is provided, comprising computer program instructions, which, when executed by a processor, enable the processor to execute any of the remote procedure call methods described above.
[0010] A remote procedure call method, device, remote procedure call execution method, electronic device and computer-readable storage medium provided by the embodiment of the present application adopt two-step serialization when serializing the business data agreed upon by the communicating parties. The first step is to serialize the business data into the first serialized data to realize message serialization, and the second step is to serialize the first serialized data and the remote procedure call configuration information into the second serialized data together to realize interface serialization, thereby realizing the separation of message serialization and interface serialization. In this way, when the underlying framework sends changes, only the application layer code of the interface serialization needs to be modified, and the application layer code of the message serialization can remain unchanged; when the business data changes, only the application layer code of the message serialization needs to be modified, and the application layer code of the interface serialization can remain unchanged. It can be seen that through this serialization processing method, the application layer code modification to adapt to the needs of different business scenarios can be significantly reduced, thereby effectively reducing the manpower cost of maintaining normal communication and improving communication efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 The figure is a flowchart of a remote procedure call method provided in one embodiment of the present application.
[0012] Figure 2 The figure is a flowchart of a remote procedure call method provided in one embodiment of the present application.
[0013] Figure 3 The figure is a flow chart of determining a target server in a remote procedure call method provided in an embodiment of the present application.
[0014] Figure 4 The figure is a schematic diagram of a process for determining a scheduling strategy in a remote procedure call method provided in an embodiment of the present application.
[0015] Figure 5 The figure is a flow chart of a stateless polling scheduling strategy in a remote procedure call method provided in an embodiment of the present application.
[0016] Figure 6 The figure is a flow chart of a stateful scheduling strategy in a remote procedure call method provided in an embodiment of the present application.
[0017] Figure 7 The figure is a flow chart of a remote procedure call method provided in an embodiment of the present application based on a response time scheduling strategy.
[0018] Figure 8 The figure is a flow chart of a scheduling strategy based on remaining computing capacity in a remote procedure call method provided in an embodiment of the present application.
[0019] Fig. 9The figure is a schematic diagram showing the principle of the process of obtaining a list of available servers in a remote procedure call method provided in an embodiment of the present application.
[0020] Fig.10 Shown is a schematic diagram of the structure of a remote procedure call device provided in one embodiment of the present application.
[0021] Fig.11 Shown is a schematic structural diagram of a remote procedure call device provided in another embodiment of the present application.
[0022] Fig.12 Shown is a schematic structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0024] Application Overview
[0025] As mentioned above, although the traditional remote procedure call method can achieve the purpose of remote procedure call, it is closely related to the specific business. Once the specific business scenario of the application changes, it is necessary to make major adjustments to the application layer code, thereby increasing the manpower cost of maintaining normal communication and reducing communication efficiency.
[0026] In view of the above technical problems, the basic concept of this application is to propose a remote procedure call method, device, remote procedure call execution method, electronic device and computer-readable storage medium, and make another layer of abstraction on the serialization of the underlying framework to separate the message serialization process and the interface serialization process. In this way, the update of business information and the update of the underlying framework will not interfere with each other, so that the remote procedure call framework can be applied to different scenario requirements.
[0027] It should be noted that the remote procedure call method provided in this application can be applied to the remote procedure call process in any scenario. Specifically, the remote call process is the process in which the client performs a specific operation by calling the resources on the target server. The resource can be a computing resource or storage resource used to complete a specific operation in any application scenario. This application does not limit the specific application scenario to which the remote procedure call method is applicable.
[0028] After introducing the basic principles of the present application, various non-limiting embodiments of the present application will be described in detail with reference to the accompanying drawings.
[0029] Exemplary Remote Procedure Call Method
[0030] Figure 1 FIG. 1 is a flow chart of a remote procedure call method provided by an embodiment of the present application. Figure 1 As shown, the remote procedure call method includes the following steps:
[0031] Step 101: Serialize the business data to obtain first serialized data.
[0032] Business data is the data required for remotely calling the process on the target server. The client needs to send the business data to the target server. After receiving the business data, the target server can execute the remote process called by the client based on the business data. It should be understood that the specific content of the business data is related to the business scenario of the remote process called by the client, and this application does not limit the specific content of the business data.
[0033] In order to enable the business data to meet the transmission requirements of remote communication, the business data needs to be serialized to be converted into a transmittable form. The first serialized data obtained after serialization can be restored to business data through a deserialization process. In one embodiment of the present application, the first serialized data can be binary data, but the present application does not limit the specific data form of the first serialized data.
[0034] Step 102: Serialize the remote procedure call configuration information and the first serialized data to obtain second serialized data.
[0035] The remote procedure call configuration information is some communication configuration information required for the communication process of executing the remote procedure call, for example, it may include the version information of the client and the server, and the context information of the remote procedure call. The version information of the client and the server is used to check whether the client and the server correspond during the remote communication process. The context information of the remote procedure call is used for link call analysis. Specifically, the version information of the client and the server can be serialized into the version field of the send buffer; the context information of the remote procedure call can be serialized into the information field of the send buffer; and the first serialized data is serialized again as the content field of the send buffer, and the content field represents the actual data to be transmitted in the send buffer. In this way, the second serialized data satisfies the data structure of the send buffer and can be stored in the send buffer to be sent to the target server by the client.
[0036] In an embodiment of the present application, the second serialized data may be binary data, but the present application does not limit the specific data format of the second serialized data.
[0037] Step 103: Store the second serialized data in the sending buffer.
[0038] The sending buffer is a buffer for the client to send data to the target server. When the sending opportunity is met according to the communication protocol between the client and the server, the client will send the data in the sending buffer to the target server. The sending buffer is generally present in a buffer memory electrically connected to the processor.
[0039] Step 104: Send the second serialized data in the sending buffer to the target server.
[0040] After receiving the data in the sending buffer from the client, the target server deserializes the received second serialized data to obtain the business data, and executes the called remote process based on the business data. Since the business data is obtained by the second serialized data after two serialization processes, the target server also needs to go through two steps of deserialization to obtain the business data. Specifically, the second serialized data is first deserialized to obtain the first serialized data, and then the first serialized data is deserialized to obtain the business data.
[0041] It can be seen that a remote procedure call method provided by an embodiment of the present application adopts a two-step serialization when serializing the business data agreed upon by the communicating parties. The first step is to serialize the business data into the first serialized data to realize message serialization, and the second step is to serialize the first serialized data and the remote procedure call configuration information into the second serialized data together to realize interface serialization, thereby realizing the separation of message serialization and interface serialization. In this way, when the underlying framework sends changes, only the application layer code of the interface serialization needs to be modified, and the application layer code of the message serialization can remain unchanged; when the business data changes, only the application layer code of the message serialization needs to be modified, and the application layer code of the interface serialization can remain unchanged. It can be seen that through this serialization processing method, the application layer code modification to adapt to the needs of different business scenarios can be significantly reduced, thereby effectively reducing the manpower cost of maintaining normal communication and improving communication efficiency.
[0042] In one embodiment of the present application, the context information of the remote procedure call may include: a call chain trace identifier (traceid) and a call information identifier (spanid). In the call chain of the remote procedure call, the two ends of each intermediate node are respectively associated with a client and a server, and the call chain trace identifier is transmitted throughout the entire call chain, so that all relevant logs can be retrieved at one time through the call chain trace identifier. The call information identifier represents the call level and call sequence according to the preset rules, so that the complete recording and tracking of the call process can be achieved. For example, when the call information identifier is 0.1.1, 0.1.1 can be a child call of 0.1, and 0.1 is a parent call of 0.1.1, so 0.1.1 itself completely describes the call path as a node with a call information identifier of 0, a node with a call information identifier of 0.1, and a node with a call information identifier of 0.1.1. In addition, 0.1.1 can also represent the first call initiated by 0.1, and 0.1.2 represents the second call initiated by 0.1. However, it should be understood that the preset rules for setting the call information identifier can be adjusted according to the actual scenario requirements, and the present application does not limit the preset rules.
[0043] It can be seen that the call chain tracking identifier and the call information identifier can help technical personnel quickly locate problems and ensure that the failure problems of a single business or node can be solved in a timely manner, thereby greatly improving the service quality of remote procedure calls on the entire call chain.
[0044] As mentioned above, the call link of the remote procedure call is composed of multiple nodes, and the two ends of each intermediate node are respectively associated with a client and a server, that is, each intermediate node is the server of the previous node and also the client of the next node. The first node can only be the client of the next node, and the tail node can only be the server of the previous node. In order to monitor the health of the call link of the entire remote procedure call, it is necessary to check the working conditions and related time consumption of each node in it to analyze the performance of the nodes in the call link. Therefore, in an embodiment of the present application, when the remote procedure call method is applied to the first node of the call link, the time taken to receive the feedback data of the target server can be recorded after the data in the send buffer is sent to the target server; when the remote procedure call method is applied to the intermediate node of the call link, the time taken to receive the feedback data of the target server can be recorded after the data in the send buffer is sent to the target server, and the time taken for the target server to return the feedback data from receiving the data in the send buffer can be recorded; and when the remote procedure call method is applied to the tail node of the call link, the time taken from receiving the second serialized data to returning the feedback data can be recorded. Based on the above recorded time, the performance of each node in the entire call chain can be analyzed, so that the nodes in the call chain can be optimized in a targeted manner.
[0045] In one embodiment of the present application, in order to enable the communication process of the remote procedure call to run normally, it is necessary to perform some configuration work before the communication starts. Figure 2 As shown, before serializing the business data, the remote procedure call method may further include:
[0046] Step 100: Load a configuration file, wherein the configuration file includes the communication protocol and communication mode executed during the communication process with the target server. The communication protocol may include one of the following communication protocols: gRPC, thrift, and a user-defined communication protocol; the communication mode includes one of the following modes: synchronous mode and asynchronous mode. However, it should be understood that the specific content and form of the communication protocol and communication mode can be adjusted according to the specific application scenario, and this application does not limit the specific content and form of the communication protocol and communication mode.
[0047] In another embodiment of the present application, Figure 3 As shown, before serializing the business data, the remote procedure call method may further include:
[0048] Step 301: Load a configuration file, wherein the configuration file includes a scheduling policy specified by a user.
[0049] The configuration file includes a scheduling strategy, which can be embodied as a target server list maintained based on preset scheduling rules. The target server assigned to the current processing request can be determined based on the target server list. The scheduling strategy specified by the user in the configuration file can be a scheduling strategy selected from multiple preset scheduling strategies, or it can be a scheduling strategy customized by the user according to actual scenario requirements. This application does not limit the specific content of the scheduling strategy.
[0050] Step 302: Determine the target server according to the scheduling policy specified by the user.
[0051] The target server corresponds to the server assigned to the current processing request, and is used to perform the specific computing task of the current processing request. It should be understood that when a new processing request is obtained, the target server needs to be updated according to the scheduling policy specified by the user. The aforementioned process of loading the configuration file and determining the target server can be considered to be completed by the scheduling policy layer located at the upper layer, and the scheduling policy layer outputs the determined target server to the scheduling framework layer located at the bottom layer.
[0052] After the target server is determined, the current processing request can be assigned to the target server for execution, that is, the business data corresponding to the current processing request is sent to the target server through the remote procedure call method provided by the embodiment of the present application. The process of assigning the current processing request to the target server can be considered to be completed by the scheduling framework layer located at the bottom layer, and the scheduling framework layer is responsible for the communication interaction when the current processing request is assigned to the target server. The scheduling framework layer obtains the target server corresponding to the current processing request from the scheduling policy layer, and does not directly participate in the determination process of the scheduling policy. It should be understood that in addition to assigning the current processing request to the target server to execute the processing of the current processing request, it may also be necessary to complete some initialization configurations of the scheduling framework layer to adapt to the specific application scenario requirements, and the user can complete the configuration of the scheduling framework layer by adjusting these initialization configurations.
[0053] It should be understood that although the execution logic of cluster scheduling is divided into a scheduling policy layer at the upper layer and a scheduling framework layer at the bottom layer in the above description, this logical division does not mean that the scheduling policy layer and the scheduling framework layer must be located in two different software program entities. In fact, the scheduling policy layer and the scheduling framework layer can be integrated in the same software program entity.
[0054] It can be seen that the cluster scheduling method in a remote procedure call method provided by the embodiment of the present application, by setting a loadable configuration file to obtain the scheduling strategy specified by the user, divides the execution logic of the cluster scheduling into a scheduling strategy layer located at the upper layer and a scheduling framework layer located at the bottom layer, and realizes a cluster scheduling method in which the configuration / execution of the scheduling strategy and the configuration / execution of the scheduling framework are completely decoupled. In this way, the user can establish a general communication interaction framework configuration through the scheduling framework layer, without having to consider the impact of the configuration change of the scheduling framework layer on the scheduling strategy, so that the execution of the scheduling process is freed from the component dependence and environment dependence on the application scenario, and reduces the additional system performance overhead. At the same time, the user can also freely configure the scheduling strategy by loading the configuration file, without having to consider the impact on the existing configuration of the scheduling framework layer, thereby greatly improving the portability and scalability of the scheduling strategy. In addition, since the user can also customize the scheduling strategy according to the actual scenario requirements, this also saves the user's learning and use costs.
[0055] Figure 4 FIG. 1 is a flow chart of determining a scheduling strategy in a remote procedure call method provided in an embodiment of the present application. Figure 4 As shown, the remote procedure call method may also include the following steps:
[0056] Step 401: Determine the data packet composition method of the business data.
[0057] Step 402: Based on the data packet composition mode of the service data, one of at least one preset scheduling strategies is selected as a user-specified scheduling strategy.
[0058] In order to further improve the efficiency and quality of cluster scheduling, it is necessary to determine the appropriate scheduling strategy based on the data structure of the business data corresponding to the current processing request. Specifically, the business data may be composed of multiple data packets. Depending on the application scenario, there may or may not be a certain logical connection relationship between the data packets of the acquired business data. It is necessary to determine the appropriate scheduling strategy based on whether there is a certain logical connection relationship between the data packets. Therefore, the data packet composition method of the business data can be determined first, and then based on the data packet composition method of the business data, one of the at least one preset scheduling strategies can be selected as the user-specified scheduling strategy.
[0059] In one embodiment of the present application, business data includes multiple data packets, but there may not be a necessary logical connection between these data packets. For example, in the data processing scenario of a large website with high traffic and high concurrency, the user-specified scheduling strategy can be a stateless polling scheduling strategy to ensure the efficiency of data processing.
[0060] In another embodiment of the present application, the service data includes a plurality of data packets connected in sequence, and the scheduling strategy specified by the user is a stateful scheduling strategy. Figure 5 As shown, the stateless polling scheduling strategy may include:
[0061] Step 501: When processing the first data packet of business data, randomly select one from the available server list as the target server for processing the first data packet.
[0062] The available server list is a list of servers in the cluster that can be used to complete the processing request. As mentioned above, when the first data packet is to be processed, since the servers in the available server list may all be idle at this time, a random server can be selected from the available server list as the target server for processing the first data packet.
[0063] In one embodiment of the present application, the random selection method can be implemented by the following steps: first, the summary information of the first data packet is obtained, the summary information is converted into an integer value, and then based on the integer value and the number of available servers in the available server list, an available server is determined from the available server list as the target server for processing the first data packet. In a further embodiment, the integer value can be modulo the number of available servers in the available server list to obtain a first remainder; then, according to the first remainder, an available server in the available server list is determined as the target server for processing the first data packet. For example, the summary information of the first data packet obtained can be in the form of a string, and according to the type of the string, it can be converted into a decimal integer value by one of the following functions: BKDRHash, APHash, DJBHash, JSHash, RSHash, SDBMHash, PJWHash and ELFHash, etc. For example, when the decimal integer value obtained by conversion is 13, and the number of available servers is 10, the first remainder obtained by modulo is 3, and at this time, the third available server in the available server list can be selected as the target server for processing the first data packet. Since the summary information of the data packet is random, the integer value converted from the summary information is also random, and thus the first remainder is also random, thereby achieving random selection. However, the present application does not strictly limit the method of randomly selecting the target server of the first data packet.
[0064] Step 502: When processing other data packets of business data, select an available server from the available server list in round-robin fashion according to the connection sequence of the other data packets as a target server for processing the other data packets.
[0065] Specifically, since the target server corresponding to the first data packet is already in working state, the next server can be selected from the available server list in a polling manner according to the connection order of other data packets as the target server for processing the next data packet. When the servers in the available server list are polled, if there are still data packets to be processed, they can be circulated to the target server corresponding to the first data packet in the available server list until all data packets of business data are processed.
[0066] In one embodiment of the present application, when processing other data packets of business data, if the first data packet selects the target server by taking the remainder of the number of available servers by the integer conversion value based on the summary information, the integer value corresponding to the summary information of the previous other data packet can be incremented, and the increment step is 1; then the integer value after the increment is taken the remainder of the number of available servers in the available server list to obtain a second remainder; and one of the available servers in the available server list is determined as the target server for processing the current other data packet according to the second remainder. The process of incrementing enables the second remainder to be incremented, thereby realizing a polling selection mechanism for the available server list.
[0067] It can be seen that when there is no necessary logical connection between the data packets of business data, the load balancing between the servers in the cluster can be easily achieved through the stateless polling scheduling strategy. For example, in the field of face recognition, when an industrial camera captures a snapshot of a face, the snapshot frame information of the snapshot can be used as a data packet of the current processing request, and a random target server in the cluster is requested to recognize the face based on the snapshot frame information. When the next snapshot is captured, the next available server can be selected from the available server list in a polling manner as the target server for face recognition based on the next snapshot.
[0068] In another embodiment of the present application, considering that in some application scenarios, business data includes multiple data packets connected in sequence, and there is a certain logical connection relationship between these data packets, a stateful scheduling strategy can be used to send these data packets to the same server for processing, so as to improve the effect and accuracy of data processing. For example, in technical fields related to artificial intelligence such as speech recognition, video or voice information is often divided into multiple segments, and these segments are generally connected in time. When these segments are intelligently processed, it is often necessary to combine the previous segment and / or the next segment to make a comprehensive judgment, so these segments need to be sent to the same server for processing. Figure 6 As shown, the stateful scheduling strategy may include:
[0069] Step 601: When processing the first data packet of business data, randomly select one from the available server list as the target server for processing the first data packet.
[0070] Although there is a certain logical connection between the data packets, when the first data packet is to be processed, since the servers in the available server list may all be idle at this time, a random selection can still be made from the available server list as the target server for processing the first data packet. The random selection method can still adopt the aforementioned selection method based on the integer conversion value of the summary information modulo the number of available servers, which will not be described in detail here.
[0071] Step 602: When processing other data packets of business data, select the target server that processes the first data packet as the target server that processes other data packets.
[0072] Since there is a logical connection between the data packets, the processing requests of other data packets need to be assigned to the target server that processes the first data packet, so that the target server can continuously obtain all data packets to complete the processing of business data.
[0073] It can be seen that when there is a certain logical connection between the data packets of business data, the accuracy of business data processing can be better guaranteed by the stateful polling scheduling strategy. For example, in the field of speech recognition, it is often necessary to perform speech recognition on a person's speech. However, a speech may be very long and will be split into multiple voice segments by the voice client. At this time, the voice information of a segment can be used as a data packet of the current processing request each time, and all voice segments of the same segment can be sent to the same server in the cluster to request speech recognition. In this way, the server will receive all complete voice segments and can more accurately identify the speaker's identity.
[0074] In another embodiment of the present application, the scheduling strategy specified by the user may also be a scheduling strategy based on response time. Figure 7 As shown, the response time-based scheduling strategy includes:
[0075] Step 701: Obtain the average request response time of each available server in the available server list.
[0076] Each time an available server receives a request for processing, the response time is accumulated. The average response time is calculated by dividing the accumulated response time by the total number of response requests.
[0077] Step 702: Select the server with the shortest average request response time in the available server list as the target server.
[0078] The available server with the shortest average request response time has relatively strong computing power. As more processing requests are carried out, the average request response time of each available server is constantly updated. If an available server with strong computing power receives too many processing requests, the average request response time will also increase, and the priority of the available server in the available server list will also be reduced. Therefore, the server with the shortest average request response time in the available server list can always be selected as the target server for processing the current processing request.
[0079] In one embodiment of the present application, when the feedback information of the target server corresponding to a past processing request includes information that the processing was unsuccessful, the response request time of the target server to the past processing request can be used as the average response request time of the target server. Since the processing was unsuccessful, the average response request time of the target server will be updated to infinity, thereby ensuring that the faulty server will no longer be selected as the target server.
[0080] It can be seen that the response time-based scheduling strategy can achieve load balancing among cluster servers in a more reasonable and efficient manner. For example, in the search field, when a user initiates a web page request, the search client can use the search condition as the content of the current request and select the server with the fastest response speed in the cluster as the target server, which will provide the user with the search query service.
[0081] In another embodiment of the present application, the scheduling strategy specified by the user may also be a scheduling strategy based on the remaining computing capacity. Figure 8 As shown, the scheduling strategy based on the remaining computing capacity includes:
[0082] Step 801: Obtain the remaining computing capacity parameters of each available server in the available server list.
[0083] The remaining computing capacity parameter is used to characterize the remaining computing capacity of the available servers. In one embodiment of the present application, the available server list may include servers of any type, CPU servers and GPU servers. The remaining computing capacity parameter of the CPU server may be the number of idle threads in the thread pool of the CPU server, and the remaining computing capacity parameter of the GPU server may be the number of video signal paths that the GPU server can process. However, the present application does not limit the specific content of the remaining computing capacity parameter.
[0084] Step 802: Select the server with the largest remaining computing capacity parameter in the available server list as the target server.
[0085] By scheduling strategies based on the remaining computing power, load balancing of servers between clusters can be achieved more reasonably and efficiently, and the computing power of relatively idle servers in the cluster can be fully called. For example, in the field of video signal processing, some video signal processing parts require CPU to process, and some video signal processing parts require GPU to calculate. At this time, the processing of video signal information can be used as the current processing request, and the video signal processing client can select the idlest CPU and the idlest GPU in the cluster to complete the current processing request to obtain the fastest processing speed. It can be seen that the cluster scheduling method in the remote procedure call method provided in this application actually supports both homogeneous and heterogeneous working modes. When in a heterogeneous working mode, the CPU can report the available idle resources of the thread pool in real time, and the GPU can report the computing resources in real time. By obtaining the remaining computing power parameters of the CPU and GPU, dynamic scheduling of processing requests in heterogeneous working modes can be achieved.
[0086] In one embodiment of the present application, the scheduling strategy specified by the user may also be a custom scheduling strategy, and the target server is determined based on the server acquisition interface function configured by the user. Specifically, the feedback information of the past processing request can be obtained based on the feedback acquisition interface function StrategyFeedback() configured by the user, and then the feedback information is input into the server acquisition interface function GetServer() to determine the target server. In this way, the user only needs to implement the logic function of the above interface function, and then call the open API interface of the scheduling framework layer and specify the scheduling strategy to complete the integration of the new scheduling strategy.
[0087] In one embodiment of the present application, the configuration file may include a preset monitoring path of the external service registration center, and a real-time updated list of available servers may be obtained by monitoring the preset monitoring path of the external service registration center, and then a target server may be selected from the list of available servers according to a scheduling policy specified by a user. The external service registration center updates the list of available servers in real time according to the acquired heartbeat information of each server in the cluster.
[0088] Specifically, if Fig. 9As shown, the process of obtaining the list of available servers in the remote procedure call method provided in the embodiment of the present application can be implemented in the form of SDK (Software Development Kit), which can be installed on the service consumer end 902 (for example, a smart mobile terminal) so that the service consumer end 902 has the function of executing the cluster scheduling method in the remote procedure call method. For example, the SDK can be used when developing an intelligent application for the operating system of the service consumer end 902, and the developed intelligent application can be installed in the operating system of the service consumer end 902. All servers in the cluster report heartbeat information to the external service registration center as service providers 903; the service consumer end 902 obtains a real-time updated list of available servers by monitoring the preset monitoring path of the external service registration center 901; when the service consumer end 902 determines the target server corresponding to the current processing request, it will assign the current processing request to the target server in the cluster for processing.
[0089] It should be understood that the external service registration center can be implemented in the form of a single server or a cluster, and the specific device form of the service consumer end is related to the specific application scenario. For example, for face recognition or video signal processing application scenarios, the device form of the service consumer end can be a camera, a mobile phone or a personal computer equipped with a camera, etc., and the server in the cluster is configured to perform face recognition tasks. For example, in the field of voice recognition, the service consumer end can be an intelligent mobile terminal equipped with a radio device, and the server in the cluster is configured to perform voiceprint recognition tasks. For another example, for a search application scenario, the service consumer end can be an intelligent mobile terminal with a device for users to input search conditions, and the server in the cluster is configured to perform Internet search tasks. However, this application does not limit the specific device form of the service consumer end.
[0090] In a further embodiment, the external service registration center can be implemented in the form of a single server or a cluster. By installing the zookeeper component on the single server or the cluster, the monitoring function of the heartbeat information of each server in the cluster for providing request processing services can be realized. The zookeeper component is a software that provides consistency services for distributed applications, and the functions provided include: configuration maintenance, domain name services, distributed synchronization, group services, etc.
[0091] Exemplary remote procedure call apparatus
[0092] Fig.10 Schematic diagram of a remote procedure call device provided by an embodiment of the present application. Fig.10 As shown, the remote procedure call device 1000 includes:
[0093] The first serialization module 1001 is configured to perform serialization processing on the business data to obtain first serialized data;
[0094] A second serialization module 1002 is configured to serialize the remote procedure call configuration information and the first serialization data to obtain second serialization data;
[0095] The storage module 1003 is configured to store the second serialized data in a sending buffer; and
[0096] The transmission module 1004 is configured to send the second serialized data in the sending buffer to a target server.
[0097] In one embodiment of the present application, the remote procedure call configuration information includes: version information of the client and the server, and context information of the remote procedure call.
[0098] In one embodiment of the present application, the context information of the remote procedure call includes: a call chain tracking identifier and a call information identifier, wherein the call information identifier represents the call level and call timing according to a preset rule.
[0099] In one embodiment of the present application, Fig.11 As shown, the remote procedure call apparatus 1000 further includes: a first recording module 1005, configured to record the time taken to receive feedback data from the target server after sending the data in the sending buffer to the target server.
[0100] In another embodiment of the present application, Fig.11 As shown, the remote procedure call device 1000 further includes: a second recording module 1006, configured to record the time taken to receive feedback data from the target server after sending the data in the sending buffer to the target server; and record the time taken by the target server from receiving the data in the sending buffer to returning the feedback data.
[0101] In an embodiment of the present application, the first serialized data and / or the second serialized data are binary data.
[0102] In one embodiment of the present application, Fig.11 As shown, the remote procedure call device 1000 further includes: a first loading module 1007, configured to load a configuration file before serializing the business data, wherein the configuration file includes a communication protocol and a communication mode executed during the communication process with the target server.
[0103] In one embodiment of the present application, the communication protocol includes one of the following communication protocols: gRPC, thrift, and a user-defined communication protocol; the communication mode includes one of the following modes: synchronous mode and asynchronous mode.
[0104] In one embodiment of the present application, Fig.11 As shown, the remote procedure call device 1000 further includes: a second loading module 1008, configured to load a configuration file before serializing the business data, wherein the configuration file includes a scheduling policy specified by a user; and a target server determination module 1009, configured to determine a target server according to the scheduling policy specified by the user.
[0105] In one embodiment of the present application, Fig.11 As shown, the remote procedure call device 1000 further includes: a data composition determination module 1010, configured to determine the data packet composition method of the business data; and a selection module 1011, configured to select one from at least one preset scheduling strategy as a user-specified scheduling strategy based on the data packet composition method of the business data.
[0106] In one embodiment of the present application, the business data includes multiple data packets, and the user-specified scheduling policy is a stateless polling scheduling policy; or, the business data includes multiple data packets connected in sequence, and the user-specified scheduling policy is a stateful scheduling policy.
[0107] In one embodiment of the present application, the scheduling policy specified by the user is a scheduling policy based on response time; or, the scheduling policy specified by the user is a scheduling policy based on remaining computing capacity.
[0108] In one embodiment of the present application, the configuration file includes a preset monitoring path of the external service registration center, such as Fig.11 As shown, the remote procedure call device 1000 further includes: a monitoring module 1012, configured to obtain a real-time updated list of available servers by monitoring a preset monitoring path of an external service registration center; wherein the target server determination module 1009 is further configured to: select a target server from the list of available servers according to a scheduling strategy specified by a user.
[0109] The specific functions and operations of each module in the remote procedure call device 1000 have been described in the above reference. Figures 1 to 9 The remote procedure call method described in detail is described in , so its repeated description will be omitted here.
[0110] It should be noted that the remote procedure call device 1000 according to the embodiment of the present application can be integrated into the electronic device 120 as a software module and / or a hardware module. In other words, the electronic device 120 can include the remote procedure call device 1000. For example, the remote procedure call device 1000 can be a software module in the operating system of the electronic device 120, or can be an application developed for the electronic device 120; of course, the remote procedure call device 1000 can also be one of the many hardware modules of the electronic device 120.
[0111] In another embodiment of the present application, the remote procedure call apparatus 1000 and the electronic device 120 may also be separate devices (e.g., servers), and the remote procedure call apparatus 1000 may be connected to the electronic device 120 via a wired and / or wireless network and transmit interactive information in accordance with an agreed data format.
[0112] Exemplary Electronic Devices
[0113] Fig.12 FIG. 1 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Figure 7 As shown, the electronic device 120 includes: one or more processors 1201 and a memory 1202; and computer program instructions stored in the memory 1202, and when the computer program instructions are executed by the processor 1201, the processor 1201 executes a remote procedure call method as described in any of the above embodiments.
[0114] The processor 1201 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0115] The memory 1202 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on a computer-readable storage medium, and the processor 1201 may run the program instructions to implement the steps in the remote procedure call method of each embodiment of the present application above and / or other desired functions. Information such as light intensity, compensation light intensity, and the position of the filter may also be stored in the computer-readable storage medium.
[0116] In one example, the electronic device 120 may further include: an input device 1203 and an output device 1204, which are connected via a bus system and / or other forms of connection mechanisms ( Fig.12 ) interconnected.
[0117] For example, when the electronic device is a robot on an industrial production line, the input device 1203 may be a camera for capturing the position of the part to be processed. When the electronic device is a stand-alone device, the input device 1203 may be a communication network connector for receiving the collected input signal from an external removable device. In addition, the input device 1203 may also include, for example, a keyboard, a mouse, a microphone, and the like.
[0118] The output device 1204 can output various information to the outside, and may include, for example, a display, a speaker, a printer, a communication network and its connected remote output devices, etc.
[0119] Of course, to simplify, Figure 7 Only some of the components related to the present application in the electronic device 120 are shown, and components such as a bus, an input device / output interface, etc. are omitted. In addition, according to specific application conditions, the electronic device 120 may also include any other appropriate components.
[0120] Exemplary computer program products and computer-readable storage media
[0121] In addition to the above methods and devices, the embodiments of the present application may also be a computer program product, including computer program instructions, which, when executed by a processor, enable the processor to execute the steps in the remote procedure call method of any of the above embodiments.
[0122] The computer program product may be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0123] In addition, an embodiment of the present application may also be a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes the steps of the remote procedure call method according to various embodiments of the present application described in the above "Exemplary Remote Procedure Call Method" section of this specification.
[0124] Computer readable storage media can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0125] The basic principles of the present application are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present application are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present application. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, not for limitation, and the above details do not limit the present application to being implemented by adopting the above specific details.
[0126] The block diagrams of the devices, apparatuses, equipment, and systems involved in this application are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The words "such as" used here refer to the phrase "such as but not limited to", and can be used interchangeably with them.
[0127] It should also be noted that in the apparatus, device and method of the present application, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present application.
[0128] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present application. Therefore, the present application is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0129] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present application to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
[0130] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A remote procedure call method, comprising: Serialize the business data to obtain first serialized data; Serializing the remote procedure call configuration information and the first serialized data to obtain second serialized data, wherein the remote procedure call configuration information includes context information of the remote procedure call, and the context information of the remote procedure call includes: a call chain tracking identifier and a call information identifier, wherein the call chain tracking identifier is transmitted throughout the entire call chain to retrieve all relevant logs at one time, and the call information identifier represents the call level and call sequence according to a preset rule to achieve complete recording and tracking of the call process; storing the second serialized data in a sending buffer; and The second serialized data in the sending buffer is sent to a target server.
2. The remote procedure call method according to claim 1, wherein: The remote procedure call configuration information also includes: version information of the client and the server.
3. The remote procedure call method according to claim 1, wherein: After sending the data in the sending buffer to the target server, the method further includes: recording the time taken to receive the feedback data from the target server.
4. The remote procedure call method according to claim 1, wherein: After sending the data in the sending buffer to the target server, the method further includes: recording the time taken to receive the feedback data from the target server; and recording the time taken by the target server from receiving the data in the sending buffer to returning the feedback data.
5. The remote procedure call method according to claim 1, wherein: The first serialized data and / or the second serialized data are binary data.
6. The remote procedure call method according to claim 1, wherein: Before serializing the business data, it further includes: A configuration file is loaded, wherein the configuration file includes a communication protocol and a communication mode executed during the communication process with the target server.
7. The remote procedure call method according to claim 6, wherein: The communication protocol includes one of the following communication protocols: gRPC, thrift, and a user-defined communication protocol; The communication mode includes one of the following modes: a synchronous mode and an asynchronous mode.
8. The remote procedure call method according to claim 1, wherein: Before serializing the business data, it further includes: Loading a configuration file, wherein the configuration file includes a scheduling policy specified by a user; and The target server is determined according to the scheduling policy specified by the user.
9. The remote procedure call method according to claim 8, wherein: The method further comprises: Determining a data packet composition method for the service data; and Based on the data packet composition mode of the service data, one is selected from at least one preset scheduling strategy as the user-specified scheduling strategy.
10. The remote procedure call method according to claim 9, wherein: The service data includes a plurality of data packets, and the scheduling strategy specified by the user is a stateless polling scheduling strategy; or, The service data includes a plurality of data packets connected in sequence, and the scheduling strategy specified by the user is a stateful scheduling strategy.
11. The remote procedure call method according to claim 8, wherein: The scheduling strategy specified by the user is a scheduling strategy based on response time; or, the scheduling strategy specified by the user is a scheduling strategy based on remaining computing capacity.
12. The remote procedure call method according to claim 8, wherein: The configuration file includes a preset monitoring path of the external service registration center, and the method further includes: By monitoring the preset monitoring path of the external service registration center, a real-time updated list of available servers is obtained; Wherein, determining the target server according to the scheduling policy specified by the user includes: The target server is selected from the available server list according to the scheduling policy specified by the user.
13. A remote procedure call execution method, comprising: receiving second serialized data from the send buffer of the client; as well as Deserializing the second serialized data to obtain business data, and executing the remote procedure called by the client based on the business data; The second serialized data is generated by the client based on the following steps: Serializing the business data to obtain first serialized data; The remote procedure call configuration information and the first serialized data are serialized to obtain the second serialized data, wherein the remote procedure call configuration information includes context information of the remote procedure call, and the context information of the remote procedure call includes: a call chain tracking identifier and a call information identifier, wherein the call chain tracking identifier is passed throughout the entire call chain to retrieve all relevant logs at one time, and the call information identifier represents the call level and call timing according to preset rules to achieve complete recording and tracking of the call process.
14. The remote procedure call execution method according to claim 13, wherein: The method further comprises: The time taken from receiving the second serialized data to returning the feedback data is recorded.
15. A remote procedure call device, comprising: A first serialization module is configured to perform serialization processing on the business data to obtain first serialized data; A second serialization module is configured to serialize the remote procedure call configuration information and the first serialization data to obtain second serialization data, wherein the remote procedure call configuration information includes context information of the remote procedure call, and the context information of the remote procedure call includes: a call chain tracking identifier and a call information identifier, wherein the call chain tracking identifier is transmitted throughout the entire call chain to retrieve all relevant logs at one time, and the call information identifier represents the call level and call timing according to a preset rule to achieve complete recording and tracking of the call process; a storage module, configured to store the second serialized data in a sending buffer; and A transmission module is configured to send the second serialized data in the sending buffer to a target server.
16. An electronic device comprising: processor; as well as A memory, in which computer program instructions are stored, and when the computer program instructions are executed by the processor, the processor is caused to perform the method according to any one of claims 1 to 12.
17. A computer-readable storage medium having computer program instructions stored thereon, wherein when the computer program instructions are executed by a processor, the processor is enabled to perform the method according to any one of claims 1 to 12.
