Remote procedure calling method, system and equipment and storage medium
By introducing alias management mapping tables and dynamic weight calculations in RPC calls, the problem of high complexity of class correspondence relationships in RPC call methods is solved, efficient RPC communication and node load balancing are achieved, and the system development efficiency and stability are improved.
Patent Information
- Application Number
- CN202510628301.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-15
- Publication Date
- 2025-08-22
AI Technical Summary
In application systems with multi-service and multi-node architectures, the construction of class correspondence relationships of RPC calling methods is high, resulting in increased development complexity and reduced ease of use. The existing methods cannot effectively balance node load, affecting system stability.
By introducing alias management mapping table and dynamic weight calculation, using fully qualified names to query alias and serializers, a message byte stream is generated, IDL file writing is omitted, and load allocation is achieved in combination with dynamic node weights, cross-project RPC communication is realized.
The construction process of class correspondence is simplified, the development efficiency and call efficiency of RPC calling methods are improved, the load balancing of nodes is optimized, and the stability and scalability of the system are improved.
Smart Images

Figure CN120523622A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a remote procedure call method, system, device, and storage medium. Background Art
[0002] Currently, in application system business service processing scenarios, application systems are typically supported by a multi-service, multi-node architecture. System business functions are broken down into multiple subtasks, which are then computed and returned across different services and nodes via RPC (Remote Procedure Call) calls. In this process, efficient communication between different projects using RPC call methods is crucial. When implementing RPC communication between different projects, the fully qualified names of the classes involved in the same call may differ across different projects. Defining and maintaining the corresponding relationships between classes across different projects is key to achieving RPC communication.
[0003] The related RPC calling method involves writing IDL (Interface Definition Language) files in different projects to define the structure of classes and interfaces, and to determine the corresponding relationships between classes in different projects, thereby achieving cross-project communication. However, the large number of business service projects in an application system requires writing a large number of IDL files to implement RPC calling methods, which increases development complexity and reduces the ease of use and development efficiency of RPC calling methods. Summary of the Invention
[0004] The embodiments of the present application provide a remote procedure call method, system, device and storage medium, which can simplify the process of constructing the correspondence relationship of classes in the remote procedure call method, improve the development efficiency and call efficiency of the remote procedure call method, and solve the technical problem of the high complexity of constructing the correspondence relationship of classes in the remote procedure call method.
[0005] In a first aspect, an embodiment of the present application provides a remote procedure call method, comprising:
[0006] Obtain the RPC request message to be sent, query the pre-built alias management mapping table based on the fully qualified name of the target class called by the RPC request message, and determine the alias and serializer of the corresponding target class from the serialization information of the target class stored in the alias management mapping table. The serialization information of the target class includes the alias, fully qualified name and serializer of the corresponding target class. The alias is the specified unique identification information of the target class.
[0007] Serialize the RPC request message based on the serializer, generate a message byte stream corresponding to the RPC request message, and write the alias into the message byte stream;
[0008] The message byte stream is sent to the target node, and the response information returned by the target node based on the message byte stream is received. The target node pre-configures an alias management mapping table. The target node is used to query the alias management mapping table based on the alias of the message byte stream, determine the serialization information of the corresponding target class, deserialize the message byte stream, and generate response information based on the RPC request message obtained by the deserialization process.
[0009] In a second aspect, an embodiment of the present application provides a remote procedure call system, including:
[0010] a query module configured to obtain an RPC request message to be sent, query a pre-built alias management mapping table based on the fully qualified name of a target class called by the RPC request message, and determine an alias and a serializer corresponding to the target class from serialization information of the target class stored in the alias management mapping table, where the serialization information of the target class includes the alias, fully qualified name, and serializer of the target class, and the alias is designated unique identification information of the target class;
[0011] A serialization module is configured to serialize the RPC request message based on the serializer, generate a message byte stream corresponding to the RPC request message, and write the alias into the message byte stream;
[0012] The calling module is configured to send the message byte stream to the target node and receive the response information returned by the target node based on the message byte stream. The target node pre-configures the alias management mapping table. The target node is used to query the alias management mapping table based on the alias of the message byte stream, determine the serialization information of the corresponding target class, deserialize the message byte stream, and generate response information based on the RPC request message obtained by the deserialization process.
[0013] In a third aspect, an embodiment of the present application provides a remote procedure call device, including:
[0014] memory and one or more processors;
[0015] The memory is configured to store one or more programs;
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the remote procedure call method as described in the first aspect.
[0017] In a fourth aspect, an embodiment of the present application provides a non-volatile computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by a computer processor, they are configured to execute the remote procedure call method described in the first aspect.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes instructions. When the instructions are executed on a computer or a processor, the computer or the processor executes the remote procedure call method as described in the first aspect.
[0019] An embodiment of the present application obtains an RPC request message to be sent, queries a pre-built alias management mapping table based on the fully qualified name of the target class called by the RPC request message, and determines the alias and serializer of the corresponding target class from the serialization information of the target class stored in the alias management mapping table. The serialization information of the target class includes the alias, fully qualified name and serializer of the corresponding target class, and the alias is the designated unique identification information of the target class; serializes the RPC request message based on the serializer, generates a message byte stream corresponding to the RPC request message, and writes the alias into the message byte stream; sends the message byte stream to the target node, receives the response information returned by the target node based on the message byte stream, and pre-configures the alias management mapping table at the target node. The target node is used to query the alias management mapping table based on the alias of the message byte stream, determine the serialization information of the corresponding target class, deserialize the message byte stream, and generate response information based on the RPC request message obtained by the deserialization process. Using this technical approach, RPC request messages are serialized using serialization information containing a unified alias, eliminating the need to write an IDL file. This allows the target node to retrieve the corresponding serialization information based on the unified alias, deserialize the RPC request information, and respond to the RPC request. This improves the development and call efficiency of remote procedure call methods and enhances the user experience of remote procedure call services. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is a flowchart of a remote procedure call method provided by an embodiment of the present application;
[0021] Figure 2 This is a schematic diagram of a remote method call in an embodiment of the present application;
[0022] Figure 3 This is a flowchart of constructing serialization information in an embodiment of the present application;
[0023] Figure 4 This is a data serialization flow chart in an embodiment of the present application;
[0024] Figure 5 This is a schematic diagram of the structure of a remote procedure call system provided by an embodiment of the present application;
[0025] Figure 6 This is a structural diagram of a remote procedure call device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solutions and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. It should also be noted that, for ease of description, only parts related to the present application, not all of the contents, are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0027] The remote procedure call method provided in this application aims to serialize the RPC request message through serialization information containing a unified alias, thereby omitting the IDL file writing process, so that the target node can query the corresponding serialization information according to the unified alias, and obtain the RPC request information through deserialization processing to respond to the RPC request.
[0028] As the scale of system applications continues to expand, traditional monolithic architectures are struggling to meet business service demands. Microservices, however, have become the mainstream software architecture and are gaining widespread adoption thanks to their loose coupling, decentralization, and flexible scalability. In a microservices architecture, business functions are split into multiple independent services and distributed across various machines in a cluster. This inevitably requires remote calls between services to transmit and interact with each other. As the mainstream method for remote calls, remote procedure calls (RPCs) offer high standardization, efficient transmission, and low performance consumption, making them a common method for implementing calls between services.
[0029] In actual production environments, application systems are typically supported by a multi-service, multi-node architecture. Business functions are broken down into multiple subtasks, which are then computed and returned across different services and nodes via RPC calls. In this process, the ability of RPC calls to efficiently communicate between projects and distribute tasks appropriately to each node is crucial. When implementing RPC communication between different projects, the fully qualified names of the classes involved in the same call may differ across projects. Defining and maintaining the corresponding relationships between classes across projects is a key consideration in implementing RPC communication.
[0030] In addition, during RPC communication, in order to reasonably distribute tasks to each node, it is necessary to consider information such as the hardware capabilities and load status of different nodes; how to comprehensively utilize the information of each node to reasonably distribute the load of each node is the key that directly affects the response performance and stability of the system.
[0031] Related open source RPC communication methods mainly implement cross-project communication by writing Interface Definition Language (IDL) files on different projects to define the structure of classes and interfaces. However, developers need to write a large number of cumbersome IDL files, which increases development complexity and reduces the usability of RPC communication methods. At the same time, these methods use the weight of each node to select the optimal node, and the node weight can be pre-set based on hardware information to achieve load distribution on different nodes. However, in actual applications, the pre-set weights are difficult to reflect the actual working status of the machine. Machines with high loads may still receive more loads, resulting in reduced service quality and even affecting system stability.
[0032] Obviously, in cross-project, multi-node communication scenarios, the current RPC communication method has the following shortcomings:
[0033] 1. The fully qualified names of classes involved in the same call may differ across different projects. Therefore, cross-project RPC communication requires an agreed-upon class definition conversion protocol so that both communicating parties can correctly resolve the corresponding class. Existing methods define class structures through IDL files, requiring developers to write numerous and cumbersome IDL files. This increases development complexity, reduces the usability of RPC calls, and makes subsequent code maintenance difficult.
[0034] 2. The current RPC communication method uses the pre-set weights of each node to select the optimal node. However, the pre-set weights cannot accurately reflect the load status of the node when it is working, and cannot effectively balance the load of each node.
[0035] Based on this, the remote procedure call method of the embodiment of the present application is provided to solve the technical problem of the high complexity of constructing the corresponding relationship between classes in the remote procedure call method. In combination with the node status, a weight increase coefficient is introduced to calculate the dynamic weight of each node, thereby allocating the load to the optimal node to calculate the RPC call result, thereby optimizing the load of each node.
[0036] Example:
[0037] Figure 1A flowchart of a remote procedure call method provided in an embodiment of the present application is provided. The remote procedure call method provided in this embodiment can be executed by a remote procedure call device. The remote procedure call device can be implemented through software and / or hardware. The remote procedure call device can be composed of two or more physical entities or a single physical entity. Generally speaking, the remote procedure call device can be a client for performing remote procedure calls, such as a computer, mobile phone, or tablet.
[0038] The following description is made by taking the remote procedure call device as an example of the subject of executing the remote procedure call method. Figure 1 , the remote procedure call method specifically includes:
[0039] S110. Obtain the RPC request message to be sent, query the pre-built alias management mapping table based on the fully qualified name of the target class called by the RPC request message, and determine the alias and serializer of the corresponding target class from the serialization information of the target class stored in the alias management mapping table. The serialization information of the target class includes the alias, fully qualified name and serializer of the corresponding target class. The alias is the specified unique identification information of the target class.
[0040] When initiating a remote procedure call, the first step is to obtain the RPC request message to be sent. Once the request message is received, the target class involved in the call must be determined. The target class can be determined by parsing the call information contained in the RPC request message. The fully qualified name contained in the RPC request message can be used to determine the target class being called by the RPC request message. The fully qualified name includes the complete class information, including the package name and class name, and uniquely identifies the location of a class within a project.
[0041] Furthermore, a pre-built alias management mapping table can be queried based on the obtained fully qualified name of the target class. The alias management mapping table pre-builds and stores a large amount of key information about the class. By accurately querying the mapping table using the fully qualified name, the alias and serializer of the corresponding target class can be determined from the serialization information of the target class stored in the mapping table. The serialization information of the target class is a comprehensive data set that includes the alias, fully qualified name, and serializer of the corresponding target class. The alias here serves as the designated unique identification information of the target class and acts as a bridge and link. It shields possible differences in the fully qualified names of classes in different projects. Because the same class may have different fully qualified names in different projects due to factors such as naming conventions and project structure, the alias is unified and unique. Therefore, when communicating across projects, the target class can be accurately identified and located by the alias without having to worry about differences in the fully qualified name, greatly simplifying the construction and maintenance of class correspondence relationships. For different classes, you only need to configure the alias management mapping table in the customer order and the corresponding service node. The alias management mapping table stores the serialization information of the corresponding class, and you can implement cross-project remote calls of the corresponding class.
[0042] Furthermore, the serializer determines how RPC request messages are encoded and decoded during transmission. Different serializers have different performance characteristics and compatibility. Choosing the right serializer ensures that the byte stream generated by serializing the RPC request message can be transmitted efficiently and accurately, and that the original RPC request message can be perfectly restored when deserialized on the target node.
[0043] For example, referring to Figure 2 In a multi-service, multi-node system, the web service is responsible for interacting with the front-end web page, receiving HTTP requests from the front-end web page, processing and returning response results; the report service is responsible for pulling data, indicator analysis, etc.; the permission service completes the permission authentication for various user operations; the AI service implements tasks such as intelligent dialogue, text generation, and code completion.
[0044] When a user interacts on an application's interactive page, the web service receives an HTTP request from the front-end web page, breaks the task into multiple subtasks, and distributes them to the nodes of different services (i.e., reporting service, permissions service, and AI service) via RPC communication. After receiving the web service request, each service node parses the requested method, parameters, and other information of the web service's subtask, calls the corresponding method to execute the subtask, and then returns the task execution result to the web service. After receiving the response from each service, the corresponding node of the web service further processes the result and returns it to the front-end web page for display.
[0045] Throughout the entire process, RPC communication is used across different services and nodes. Using RPC, web services can call remote service methods just as easily as local methods, eliminating the need to worry about the specific RPC communication process. Furthermore, during RPC communication, the target class's alias is uniformly passed using an alias management mechanism, ensuring consistent class correspondence across different projects.
[0046] Optionally, after querying the pre-built alias management mapping table based on the fully qualified name of the target class called by the RPC request message, the method further includes:
[0047] If serialization information of the target class is not found based on the fully qualified name, the serialization information of the target class is constructed in the alias management mapping table.
[0048] This application establishes an alias management mapping table through an alias management mechanism to support predefined and dynamically registered class aliases, thereby identifying corresponding classes in different projects, avoiding the problem of different fully qualified names of corresponding classes in different projects, and realizing cross-project serialization. After querying the pre-built alias management mapping table based on the fully qualified name of the target class called by the RPC request message, if the serialization information of the target class is not found, it is necessary to construct the serialization information of the target class in the alias management mapping table. Among them, in the alias management mapping table, the serialization information of the class includes alias, fully qualified name, class serializer, etc. By constructing the above serialization information, it is convenient to realize RPC communication between different projects of the target class in the subsequent process.
[0049] Specifically, refer to Figure 3 , build the serialization information of the target class, including:
[0050] S1001. Write the fully qualified name of the target class into the alias management mapping table;
[0051] S1002. If a unique identification string exists for the target class, obtain an alias for the target class based on a hash mapping of the unique identification string, and write the alias for the target class into an alias management mapping table. If no unique identification string is detected for the target class, obtain an alias for the target class based on a hash mapping of the fully qualified name of the target class, and write the alias for the target class into an alias management mapping table.
[0052] S1003. Match the corresponding serializer for the target class and write the serializer into the alias management mapping table.
[0053] Among them, the alias recorded here is a hash value calculated through a predefined unique identification string or the fully qualified name of the class. By providing an alias interface of a predefined class for external calls, the interface parameters only need to specify the unique identification string and the fully qualified name, and the alias registration operation can be performed through the interface. In addition, according to actual needs, the above alias can also be obtained by custom encoding through the unique identification string or the fully qualified name of the class. This application does not impose fixed restrictions on the encoding method of the alias, and will not be elaborated here.
[0054] During RPC communication, if the corresponding class relationship cannot be found in the alias management mapping table, the alias registration operation is performed. In addition, when the service is running, the system will automatically scan the classes involved in the service and perform alias registration operations on each class one by one.
[0055] The alias registration process is as follows:
[0056] a. Verify legitimacy: Determine whether the unique identifier string has been registered and whether the fully qualified name can reflect the corresponding class information;
[0057] b. Whether a unique identifier string is specified. If so, the hash value of the unique identifier string is calculated as the alias. Otherwise, the hash value of the fully qualified name is calculated and used as the alias.
[0058] c. Match the serializer of this class based on the fully qualified name;
[0059] d. The alias, fully qualified name, and class serializer constitute the serialization information and are recorded in the alias management mapping table.
[0060] Based on the above pre-built alias management mapping table, when performing RPC communication, the alias and serializer for performing RPC request message serialization operations can be determined by querying the alias management mapping table.
[0061] S120 : Serialize the RPC request message based on the serializer to generate a message byte stream corresponding to the RPC request message, and write the alias into the message byte stream.
[0062] Furthermore, the RPC request message is serialized based on the serializer corresponding to the target class previously obtained from the alias management mapping table. The core function of the serializer is to convert complex RPC request message objects into a specific byte stream format, namely the message byte stream. Because network transmission can only process byte data, serialization converts the RPC request message, which originally existed in object form, into a byte format that can be efficiently transmitted across the network.
[0063] Furthermore, after generating the message byte stream, the target class's alias must be written into the stream. Writing the alias is crucial, as it's a key step in enabling cross-project and cross-node communication. Because classes in different projects may have different fully qualified names, the alias, as a unified and unique identifier, accurately indicates which class's serialization information should be used for deserialization upon receiving the message byte stream.
[0064] Specifically, refer to Figure 4 , serialize the RPC request message based on the serializer, including:
[0065] S1201: Create a target cache and write the number of fields and field name strings included in the RPC request message into the target cache;
[0066] S1202: Based on the serializer, the type of each field included in the RPC request message is reflected as a corresponding hash value, and the hash value and field value of each field are written into the target cache one by one.
[0067] Given an object to be serialized (i.e., an RPC request message), the serialization steps of this application are as follows:
[0068] 1. Apply for cache out_cache (byte array), define it as the target cache, used to save serialization process data and final results;
[0069] 2. Determine whether the object to be serialized is a NULL value. If so, record the NULL value identifier in the target cache (for example, it can be represented by 0x00), return the result, and end the serialization;
[0070] 3. If the object to be serialized is not a NULL value, the object to be serialized is serialized:
[0071] a. According to the fully qualified name of the target class called by the serialized object, the serialization information of the class is obtained from the alias management mapping table, including the class name, fully qualified name, class serializer, etc.; if the serialization information of the class is not in the alias management mapping table, the class is dynamically registered to the mapping table;
[0072] b. Record the alias of the target class to out_cache: first write a non-NULL value identifier (for example, 0x01), then write the class name (a hash value calculated from a predefined unique identifier or the fully qualified name of the class) to out_cache;
[0073] c. Based on the serializer, the type of each field contained in the RPC request message is reflected as the corresponding hash value, and the hash value and field value of each field are written to out_cache one by one;
[0074] Optionally, different information can be stored in out_cache depending on the type of RPC request message. For basic types, the object value can be recorded in out_cache. For custom types, the number of fields, including NULL fields, is first recorded in out_cache, followed by the string names of all field names. Furthermore, for each type of message, the values of each field are retrieved through reflection.
[0075] After completing the above operations, the object serialization result (byte array) is returned as the message byte stream by clearing the process data temporarily stored during the serialization process.
[0076] Specifically, the above writes the hash value and field value of each field into the target cache one by one, including:
[0077] When the current field includes multiple types of subfields, determine the number of subfields of the current field, the subfield name string, the subfield hash value and the subfield value as the field value of the current field, and write the hash value and field value of the current field into the target cache.
[0078] For example, refer to the following object to be serialized:
[0079] ClassStudent{name:String;edge:Integer;classRoom:Room;}
[0080] class Room{name:String;stu_num:Integer;}
[0081] The objects to be serialized are the definitions of two classes (describing the class name, field names, and field types). The Student class, with its class name being Student, has a fully qualified name in Java that also includes the package name, so the fully qualified name could be com.bigo.web.Student. The fields in this class are name, edge, and classRoom, which are the field names. The corresponding classes are String, Integer, and Room. Similarly, in Java, the fully qualified name of a Room could be com.bigo.web.example.Room.
[0082] Assume that a Student class object is as follows:
[0083] stu1={name:"xiaoming";edge:17;classRoom:
[0084] {name: "Senior Three Class One", stu_num: 53}};
[0085] The serialization process of stu1 is as follows:
[0086] 1. First, find the class information of the object stu1. The fully qualified name of this object is com.bigo.web.Student, and the alias is the hash value of "com.bigo.web.Student", assumed to be the integer 48529475. Write the alias 48529475 to the output;
[0087] 2. Student is a custom type, and the fields to be serialized are: name, edge, classRoom. Among them:
[0088] a. Write the number of fields 3 to the output;
[0089] b. Write the field names name\edge\classRoom to the output
[0090] c. Process the value of each field. The type of the name field is String, which belongs to a basic type, and the assumed hash value is 432542648; the value of the name field is xiaoming; write the hash value of the type and the field value to the output: 432542648 / xiaoming. The serialization operations for edge and name are the same; for the Integer type, the assumed hash value is 87986420. Write the type hash value and the field value to the output: 87986420 / 17.
[0091] It should be noted that the classRoom field is a custom type, and the assumed hash value is 53175946. The above steps need to be repeated for its content "{name: String; stu_num: Integer;}", and the final output is: 53175946 / 2 / name / stu_num / 432542648 / "Senior Three Class One" / 87986420 / 53. Finally, the serialization result of stu1 is expressed as:
[0092] 48529475 / 3 / name / edge / classRoom / 432542648 / xiaoming / 87986420 / 17 / 53175946 / 2 / name / stu_num / 432542648 / "Senior Three Class One" / 87986420 / 53;
[0093] The serialization result will be stored in the form of a message byte stream for subsequent RPC communication.
[0094] S130. Send the message byte stream to the target node, receive the response information returned by the target node based on the message byte stream, the target node pre-configures the alias management mapping table, the target node is used to query the alias management mapping table based on the alias of the message byte stream, determine the serialization information of the corresponding target class, deserialize the message byte stream, and generate response information based on the RPC request message obtained by the deserialization process.
[0095] Furthermore, based on the message byte stream obtained by the above serialization, the target node for RPC communication is determined. The RPC request message is sent to the target node in the message byte stream. After receiving the message byte stream, the target node will query the pre-configured alias management mapping table based on the message byte stream to parse the byte stream. The alias management mapping table is a core configuration component in the target node. It stores the correspondence between aliases and target classes. For example, an alias may correspond to a specific service implementation class. The target node extracts the alias information by parsing the message byte stream, and then uses the alias to query the alias management mapping table to find the corresponding target class.
[0096] After determining the target class, the target node can select the appropriate deserialization tool or method based on the serialization information of the class to restore the message byte stream to the original RPC request message object. The deserialization process maintains consistency with the serialization process, that is, the sender and the target node use the same serialization protocol and rules.
[0097] After successfully deserializing the RPC request message, the target node executes the corresponding business logic based on the message content, such as calling a service method and processing the request parameters. Once this processing is complete, the target node generates a corresponding response message. This response message also needs to be converted into a byte stream using the corresponding serialization tool based on the target class's serialization information. This is then returned to the sender via the network transport protocol. Upon receiving the response byte stream, the sender performs the appropriate deserialization processing, restoring the byte stream into a response object, thus completing the entire RPC call process.
[0098] In this process, the alias management mapping table enables the target node to dynamically parse and process requests from different senders, improving the flexibility and scalability of the system. Finally, based on this remote procedure call method, the alias management mechanism is used to map the fully qualified name to the alias hash value, thus achieving class serialization and deserialization.
[0099] Based on this remote procedure call method, during RPC communication, for classes with inconsistent fully qualified names across different projects, developers only need to specify an alias mapping. For other classes, hash values are automatically calculated as aliases, eliminating the need for manual registration. Compared to the IDL approach, this makes development more concise and efficient, reducing subsequent maintenance costs. Furthermore, the integer hash value used for serialization is only 4 bytes, while the fully qualified name can easily take up dozens of bytes. Using hash values instead of fully qualified names for serialization significantly improves compression performance.
[0100] Specifically, the deserialization steps for a sequence data to be deserialized are as follows:
[0101] 1. Apply for input cache in_cache to store the sequence data to be deserialized;
[0102] 2. Parsing class serialization information:
[0103] a. Read the type identifier from in_cache and determine whether it is a NULL value. If so, return NULL; otherwise, continue to read the category name hash value from in_cache;
[0104] b. Find the class serialization information in the alias management mapping table based on the hash value and return it;
[0105] 3. Combined with the class serialization information, dynamically create the class object through reflection;
[0106] For basic types, the number of bytes corresponding to the data type is read from in_cache and assigned;
[0107] For custom types, read the number of fields from in_cache, and then read all field name strings; then obtain the target field information from the serializer of the class serialization information, that is, the field type information of the object created above, and filter the read field names based on this information, and identify whether the field is the target field; process the identified fields one by one. If the field is not the target field, skip the field data; if the field is the target field, read the field data from in_cache, deserialize to obtain the field object, and assign the corresponding field value to the created object through reflection;
[0108] 4. Clean up the deserialized temporary cache data and return the object obtained in the above steps.
[0109] Through the above method, the deserialization operation of an object can be completed.
[0110] Optionally, a message byte stream is sent to the target node, including:
[0111] Obtain the node status information of each candidate service node in the RPC request message, and calculate the dynamic weight value of each node based on the node status information;
[0112] The target node is selected from each candidate service node based on the dynamic weight value, and the message byte stream is sent to the target node.
[0113] In the complete process of sending the message byte stream to the target node, the real-time status of the candidate service nodes can be dynamically perceived to achieve intelligent routing. First, the system actively or passively collects multi-dimensional status information of each candidate node, such as hardware resource load (such as real-time utilization of CPU, memory, and thread queues), network quality indicators (such as round-trip delay RTT, packet loss rate, and available bandwidth), and service health status (such as heartbeat survival detection and historical request success rate). This information is reported through heartbeat packets, periodic probe requests, or monitoring components to form a global node status view.
[0114] Based on the collected raw data, the system constructs a dynamic weight calculation model. This model uses a weighted scoring algorithm to convert status indicators from different dimensions into quantifiable weight factors. For example, the load factor is calculated through a weighted combination of resource utilization, the network factor maps latency to a standardized range, and the health factor directly reflects service availability. The weight coefficients of each factor can be adjusted based on business priorities. For example, compute-intensive services may prioritize CPU, while real-time interactive services may emphasize network latency. The raw weight values of all nodes are normalized to ensure that they are compared on the same scale.
[0115] During the node screening phase, load balancing strategies are combined with dynamic weighting results. If a weighted random algorithm is used, the system generates a probability distribution based on the weight ratio and selects the target node using random numbers, ensuring that high-weight nodes are prioritized while retaining the participation of low-weight nodes. For scenarios requiring strong consistency, a round-robin or minimum connection strategy can be used after sorting by weight. In addition, the system can set safety thresholds. When the status of all nodes falls below the health standard, the circuit breaker degradation mechanism is triggered to prevent requests from being sent to unavailable nodes. A predefined error is returned to the client or an automatic retry is performed.
[0116] After the final message byte stream is sent to the target node, the system waits for an ACK from the target node. If no response is received within a timeout, retry logic is triggered, potentially combining previous weight information to reselect an alternative node to ensure the message is ultimately delivered. This entire process, through closed-loop state monitoring and dynamic decision-making, enables efficient service discovery and routing in a distributed environment.
[0117] Optionally, the node status information includes CPU utilization, memory utilization, average load, and service running time. The dynamic weight value of each node is calculated based on the node status information, including:
[0118] Calculate the weighted value of the service runtime based on the service runtime and the set warm-up time;
[0119] A weighted sum is performed based on CPU utilization, memory utilization and average load to obtain a weighted value of the node load status. When the CPU utilization, memory utilization or average load is less than a preset weight threshold, the weight for the weighted sum is set based on the preset weight threshold. When the CPU utilization, memory utilization or average load is greater than or equal to the preset weight threshold, the weight for the weighted sum is dynamically adjusted based on a weight increase coefficient. The weight increase coefficient is a monotonically increasing function greater than 1, and the weight increase coefficient is positively correlated with the corresponding CPU utilization, memory utilization or average load.
[0120] The dynamic weight value of each node is calculated based on the weighted value of the running time and the weighted value of the node load status.
[0121] It is understandable that during the operation of a service node, the node environmental factors that affect the efficiency of the task on the node include: CPU utilization, memory utilization, average load and other load information. The higher these load values are, the busier the machine is. At this time, the number of requests sent to the node should be reduced, that is, the weight of the node in the load balancing should be reduced. When a node's load indicator is abnormally high, the impact of this abnormality should be highlighted, and the number of requests to the node should be reduced to a greater extent to quickly reduce the impact of the node abnormality. In addition, after the service is started, initialization operations such as configuration loading and class loading are required. At this time, the efficiency of processing tasks is relatively low, and the weight of the node should be reduced.
[0122] Based on this, this application combines the state information of the above nodes to calculate the dynamic weight value of each node. The node state information includes CPU utilization U c , memory utilization U m , average load L avg , service running time T r , the dynamic weight value W is calculated as follows:
[0123] W=f(T r )·f(U c ,U m ,L avg )
[0124] Among them, f(T r ) represents the weighted value of the running time, and the weighted value of the running time f(T r ) According to the running time T r And the set preheating time T th calculate:
[0125]
[0126] Node load state weighted value f(U c ,U m ,L avg ) is the CPU utilization U c , memory utilization U m , average load L avg The weighted summation result of :
[0127]
[0128] Among them, CPU utilization U c , memory utilization U m The value range is 0 to 1. core Indicates the number of CPU logical cores of the node. Under normal circumstances, Less than 1; When it is greater than 1 or even greater, it means that the CPU resources are tight, the node load is too high, and performance problems may occur. c 、W m 、W l Represents the weights of CPU utilization, memory utilization, and average load for weighted summation, all of which are calculated by f W (x) calculation, that is, W c =f W (W c ), W m =f W (W m ), W l =f W (W l ). The weight calculation formula is as follows:
[0129]
[0130] Among them, x represents CPU utilization, memory utilization, and average load, V th is the preset weight threshold, W c 、W m 、W l Can have different sizes of V th , but 3 V th The sum of the sizes is 100. σ(x) is the weight increase coefficient, which is a monotonically increasing function and its value is greater than 1. When any of the CPU utilization, memory utilization, and average load of a node is greater than the preset weight threshold, the weight of that item is further increased, so that the corresponding calculated weight W has a greater attenuation, highlighting the difference with other nodes, which is beneficial to system stability. The value of σ(x) is not unique. For example, σ(x) = 3x-1.1, when U c 、U m、 When W is greater than 0.7, c 、W m 、W l It is no longer a constant value, but increases by a factor of 3.
[0131] After calculating the dynamic weight of each node using the above method, we can combine different load balancing algorithms, such as weighted randomization and weighted round-robin, to select the optimal target node, thereby achieving load balancing for service nodes. This dynamic weight allocation strategy allows for optimal resource utilization. Furthermore, by introducing a weight increase coefficient, the weight of each machine's load information can be made variable, highlighting the impact of individual load anomalies, significantly reducing the load on abnormal nodes, and improving system stability.
[0132] Exemplarily, based on the above-mentioned remote procedure call method, when performing RPC communication, a custom protocol is used for RPC communication to encapsulate RPC request messages and response messages; the message structure includes a check field, an event type, a remotely called method class name, a method name, a parameter type, a parameter value, and a response result. The web client first serializes the RPC request message into a message byte stream using the above-mentioned serialization method based on the alias management mechanism. Then, the optimal remote target node is routed through the above-mentioned dynamic weight-based load balancing algorithm, and the RPC message byte stream is sent to the target node through the network. The target node automatically generates an RPC proxy implementation method through a dynamic proxy mechanism, calculates, and returns an RPC response message. Afterwards, the client receives the RPC response message byte stream through the network, and deserializes it using the serialization method based on the alias management mechanism to obtain the remote call result.
[0133] In the above, by obtaining the RPC request message to be sent, the pre-built alias management mapping table is queried based on the fully qualified name of the target class called by the RPC request message, and the alias and serializer of the corresponding target class are determined from the serialization information of the target class stored in the alias management mapping table. The serialization information of the target class includes the alias, fully qualified name and serializer of the corresponding target class, and the alias is the designated unique identification information of the target class; the RPC request message is serialized based on the serializer to generate a message byte stream corresponding to the RPC request message, and the alias is written into the message byte stream; the message byte stream is sent to the target node, and the response information returned by the target node based on the message byte stream is received. The target node pre-configures the alias management mapping table, and the target node is used to query the alias management mapping table based on the alias of the message byte stream, determine the serialization information of the corresponding target class, deserialize the message byte stream, and generate response information based on the RPC request message obtained by the deserialization process. Using this technical approach, RPC request messages are serialized using serialization information containing a unified alias, eliminating the need to write an IDL file. This allows the target node to retrieve the corresponding serialization information based on the unified alias, deserialize the RPC request information, and respond to the RPC request. This improves the development and call efficiency of remote procedure call methods and enhances the user experience of remote procedure call services.
[0134] Based on the above embodiments, Figure 5 This is a schematic diagram of the structure of a remote procedure call system provided by this application. Figure 5 The remote procedure call system provided in this embodiment specifically includes: a query module 21, a serialization module 22 and a calling module 23.
[0135] The query module 21 is configured to obtain an RPC request message to be sent, query a pre-built alias management mapping table based on the fully qualified name of the target class called by the RPC request message, and determine the alias and serializer of the corresponding target class from the serialization information of the target class stored in the alias management mapping table, where the serialization information of the target class includes the alias, fully qualified name and serializer of the corresponding target class, and the alias is the specified unique identification information of the target class;
[0136] The serialization module 22 is configured to perform serialization processing on the RPC request message based on the serializer, generate a message byte stream corresponding to the RPC request message, and write the alias into the message byte stream;
[0137] The calling module 23 is configured to send the message byte stream to the target node, receive the response information returned by the target node based on the message byte stream, and pre-configure the alias management mapping table of the target node. The target node is used to query the alias management mapping table based on the alias of the message byte stream, determine the serialization information of the corresponding target class, deserialize the message byte stream, and generate response information based on the RPC request message obtained by the deserialization process.
[0138] Specifically, after querying the pre-built alias management mapping table based on the fully qualified name of the target class called by the RPC request message, it also includes:
[0139] If serialization information of the target class is not found based on the fully qualified name, the serialization information of the target class is constructed in the alias management mapping table.
[0140] Among them, the serialization information of the target class is constructed, including:
[0141] Write the fully qualified name of the target class into the alias management mapping table;
[0142] If the target class has a unique identification string, the alias of the target class is obtained based on the hash mapping of the unique identification string, and the alias of the target class is written into the alias management mapping table; if the target class does not have a unique identification string, the alias of the target class is obtained based on the hash mapping of the fully qualified name of the target class, and the alias of the target class is written into the alias management mapping table;
[0143] Match the corresponding serializer for the target class and write the serializer to the alias management mapping table.
[0144] Specifically, the RPC request message is serialized based on the serializer, including:
[0145] Create a target cache and write the number of fields and field name strings contained in the RPC request message into the target cache;
[0146] Based on the serializer, the type of each field contained in the RPC request message is reflected as the corresponding hash value, and the hash value and field value of each field are written into the target cache one by one.
[0147] The hash value and field value of each field are written into the target cache one by one, including:
[0148] When the current field includes multiple types of subfields, determine the number of subfields of the current field, the subfield name string, the subfield hash value and the subfield value as the field value of the current field, and write the hash value and field value of the current field into the target cache.
[0149] Specifically, the message byte stream is sent to the target node, including:
[0150] Obtain the node status information of each candidate service node in the RPC request message, and calculate the dynamic weight value of each node based on the node status information;
[0151] The target node is selected from each candidate service node based on the dynamic weight value, and the message byte stream is sent to the target node.
[0152] Node status information includes CPU utilization, memory utilization, average load, and service uptime. The dynamic weight value of each node is calculated based on the node status information, including:
[0153] Calculate the weighted value of the service runtime based on the service runtime and the set warm-up time;
[0154] A weighted sum is performed based on CPU utilization, memory utilization and average load to obtain a weighted value of the node load status. When the CPU utilization, memory utilization or average load is less than a preset weight threshold, the weight for the weighted sum is set based on the preset weight threshold. When the CPU utilization, memory utilization or average load is greater than or equal to the preset weight threshold, the weight for the weighted sum is dynamically adjusted based on a weight increase coefficient. The weight increase coefficient is a monotonically increasing function greater than 1, and the weight increase coefficient is positively correlated with the corresponding CPU utilization, memory utilization or average load.
[0155] The dynamic weight value of each node is calculated based on the weighted value of the running time and the weighted value of the node load status.
[0156] In the above, by obtaining the RPC request message to be sent, the pre-built alias management mapping table is queried based on the fully qualified name of the target class called by the RPC request message, and the alias and serializer of the corresponding target class are determined from the serialization information of the target class stored in the alias management mapping table. The serialization information of the target class includes the alias, fully qualified name and serializer of the corresponding target class, and the alias is the designated unique identification information of the target class; the RPC request message is serialized based on the serializer to generate a message byte stream corresponding to the RPC request message, and the alias is written into the message byte stream; the message byte stream is sent to the target node, and the response information returned by the target node based on the message byte stream is received. The target node pre-configures the alias management mapping table, and the target node is used to query the alias management mapping table based on the alias of the message byte stream, determine the serialization information of the corresponding target class, deserialize the message byte stream, and generate response information based on the RPC request message obtained by the deserialization process. Using this technical approach, RPC request messages are serialized using serialization information containing a unified alias, eliminating the need to write an IDL file. This allows the target node to retrieve the corresponding serialization information based on the unified alias, deserialize the RPC request information, and respond to the RPC request. This improves the development and call efficiency of remote procedure call methods and enhances the user experience of remote procedure call services.
[0157] The remote procedure call system provided in the embodiment of the present application can be configured to execute the remote procedure call method provided in the above embodiment, and has corresponding functions and beneficial effects.
[0158] Based on the above practical example, the present application embodiment also provides a remote procedure call device, referring to Figure 6 , the remote procedure call device includes: a processor 31, a memory 32, a communication module 33, an input device 34 and an output device 35. The memory, as a computer-readable storage medium, can be configured to store software programs, computer executable programs and modules, such as the program instructions / modules corresponding to the remote procedure call method described in any embodiment of the present application (for example, the query module, serialization module and call module in the remote procedure call system). The communication module is configured to perform data transmission. The processor executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory, that is, realizes the above-mentioned remote procedure call method. The input device can be configured to receive input digital or character information, and generate key signal input related to the user settings and function control of the device. The output device may include a display device such as a display screen. The remote procedure call device provided above can be configured to execute the remote procedure call method provided in the above embodiment, and has corresponding functions and beneficial effects.
[0159] Based on the above embodiments, an embodiment of the present application further provides a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by a computer processor, the computer-executable instructions are configured to execute a remote procedure call method. The storage medium can be any of various types of memory devices or storage devices. Of course, the computer-executable instructions of the non-volatile computer-readable storage medium provided in the embodiment of the present application are not limited to the remote procedure call method described above, and can also execute related operations in the remote procedure call method provided in any embodiment of the present application.
[0160] Based on the above embodiments, the embodiments of the present application also provide a computer program product. The technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer program product is stored in a storage medium and includes a number of instructions for enabling a computer device, a mobile terminal or a processor therein to execute all or part of the steps of the remote procedure call method described in each embodiment of the present application.
Claims
1. A remote procedure call method, characterized in that: include: Obtain an RPC request message to be sent, query a pre-built alias management mapping table based on the fully qualified name of a target class called by the RPC request message, and determine an alias and serializer corresponding to the target class from serialization information of the target class stored in the alias management mapping table, where the serialization information of the target class includes the alias, the fully qualified name, and the serializer corresponding to the target class, and the alias is designated unique identification information of the target class; Serializing the RPC request message based on the serializer to generate a message byte stream corresponding to the RPC request message, and writing the alias into the message byte stream; The message byte stream is sent to the target node, and the response information returned by the target node based on the message byte stream is received. The target node preconfigures the alias management mapping table, and the target node is used to query the alias management mapping table based on the alias of the message byte stream, determine the serialization information corresponding to the target class, deserialize the message byte stream, and generate the response information based on the RPC request message obtained by the deserialization process.
2. The remote procedure call method according to claim 1, wherein: The serializing the RPC request message based on the serializer includes: Create a target cache, and write the number of fields and field name strings included in the RPC request message into the target cache; Based on the serializer reflecting the type of each field included in the RPC request message into a corresponding hash value, the hash value and field value of each field are written into the target cache one by one.
3. The remote procedure call method according to claim 2, wherein: Writing the hash value and field value of each field into the target cache one by one includes: When the current field includes multiple types of subfields, the number of subfields, subfield name string, subfield hash value and subfield value of the current field are determined as the field value of the current field, and the hash value and field value of the current field are written into the target cache.
4. The remote procedure call method according to claim 1, wherein: After querying the pre-built alias management mapping table based on the fully qualified name of the target class called by the RPC request message, the method further includes: If the serialization information of the target class is not found based on the fully qualified name, the serialization information of the target class is constructed in the alias management mapping table.
5. The remote procedure call method according to claim 4, wherein: The constructing of the serialization information of the target class includes: Writing the fully qualified name of the target class into the alias management mapping table; If a unique identification string exists for the target class, an alias of the target class is obtained based on a hash mapping of the unique identification string, and the alias of the target class is written into the alias management mapping table; if a unique identification string is not detected for the target class, an alias of the target class is obtained based on a hash mapping of the fully qualified name of the target class, and the alias of the target class is written into the alias management mapping table; Match the corresponding serializer for the target class, and write the serializer into the alias management mapping table.
6. The remote procedure call method according to claim 1, wherein: The sending of the message byte stream to the target node comprises: Obtaining node status information of each candidate service node of the RPC request message, and calculating a dynamic weight value of each node based on the node status information; The target node is screened from the candidate service nodes based on the dynamic weight value, and the message byte stream is sent to the target node.
7. The remote procedure call method according to claim 6, wherein: The node status information includes CPU utilization, memory utilization, average load, and service running time. The dynamic weight value of each node is calculated based on the node status information, including: Calculating a weighted value of the service runtime based on the service runtime and a set warm-up time; A weighted sum is performed based on the CPU utilization, the memory utilization and the average load to obtain a weighted value of the node load state. When the CPU utilization, the memory utilization or the average load is less than a preset weight threshold, the weight for the weighted sum is set based on the preset weight threshold. When the CPU utilization, the memory utilization or the average load is greater than or equal to the preset weight threshold, the weight for the weighted sum is dynamically adjusted based on a weight increase coefficient. The weight increase coefficient is a monotonically increasing function greater than 1, and the weight increase coefficient is positively correlated with the corresponding CPU utilization, the memory utilization or the average load; The dynamic weight value of each node is calculated based on the running time weight value and the node load state weight value.
8. A remote procedure call system, characterized in that: include: a query module configured to obtain an RPC request message to be sent, query a pre-built alias management mapping table based on the fully qualified name of a target class called by the RPC request message, and determine an alias and a serializer corresponding to the target class from serialization information of the target class stored in the alias management mapping table, wherein the serialization information of the target class includes the alias, the fully qualified name, and the serializer corresponding to the target class, and the alias is designated unique identification information of the target class; a serialization module configured to perform serialization processing on the RPC request message based on the serializer, generate a message byte stream corresponding to the RPC request message, and write the alias into the message byte stream; A calling module is configured to send the message byte stream to a target node and receive response information returned by the target node based on the message byte stream. The target node preconfigures the alias management mapping table. The target node is used to query the alias management mapping table based on the alias of the message byte stream, determine the serialization information corresponding to the target class, perform deserialization processing on the message byte stream, and generate the response information based on the RPC request message obtained by the deserialization processing.
9. A remote procedure call device, characterized in that: include: memory and one or more processors; The memory is configured to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the remote procedure call method according to any one of claims 1 to 7.
10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer-executable instructions, which are configured to execute the remote procedure call method according to any one of claims 1 to 7 when executed by a computer processor.
11. A computer program product, characterized in that The computer program product includes instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes the remote procedure call method according to any one of claims 1 to 7.
Citation Information
Cited By
Service request processing method and device, equipment, medium and program product
CN121193791A
