System and method for integrating http2-based rpc with actors

By integrating RPC and Actor models based on HTTP/2, the incompatibility between RPC and Actor models in microservice system design is resolved. This achieves efficient network communication and system resource optimization, supports large-scale data communication between nodes, and provides high-performance and low-latency network communication capabilities.

CN120144332BActive Publication Date: 2025-10-24ZHONGGUAN ZHIYUN (BEIJING) TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510092030.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-21
Publication Date
2025-10-24
Estimated Expiration
2045-01-21

AI Technical Summary

Technical Problem

The existing RPC model and Actor model are incompatible in microservice system design, leading to increased system complexity and excessive resource consumption, and making it impossible to achieve efficient network communication and system resource optimization.

Method used

An HTTP/2-based RPC and Actor integration method is adopted. By combining the RPC management module, Actor system module, interface management module, transmission module and execution module, unified network communication between RPC and Actor models is achieved, sharing network traffic entry and exit points, using the HTTP/2 protocol for data transmission, and using the Disruptor ring array data structure and time wheel scheduling mechanism to optimize resource utilization.

Benefits of technology

It achieves efficient integration of RPC and Actor models, reduces system resource consumption, improves system operating efficiency, supports large-scale data communication between nodes, and has high-performance, low-latency and backpressure control network communication capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144332B_ABST
    Figure CN120144332B_ABST
Patent Text Reader

Abstract

The application provides an integrated component and method of RPC and Actor based on HTTP2, which comprises an RPC management module, an Actor system module, an interface management module, a transmission module and an execution module which are connected in series; the RPC management module and the Actor system module register interface definitions to the interface management module respectively, and create an Actor or add an RPC interface service; the interface management module is used for adding and deleting interface definitions; the transmission module realizes network data exchange between services, data encoding and decoding and flow control; the execution module comprises multiple working threads which continuously execute various types of tasks. The application realizes the integration of two network communication paradigms of RPC and Actor; the two network communication paradigms can be selected according to design requirements, and two sets of systems and frameworks do not need to be maintained; the HTTP2 protocol is adopted, and the network communication has high performance, low delay and back pressure control; and the efficient use of system resources is realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer software system design, in particular to an RPC and Actor integrated system and method based on HTTP2. BACKGROUND

[0002] Remote Procedure Call (RPC) is a technology that allows one program to call the method of another program in a different address space. HTTP2 is an application layer transmission protocol widely used in the Web field. At the same time, because HTTP2 has functions such as multiplexing, flow control, and header compression, it is used as the preferred data transmission protocol scheme by a large number of mainstream RPC frameworks, such as Google's gRPC and Alibaba's Dubbo. These RPC frameworks can not only support the common'request-response' communication mode, but also support the streaming communication mode, including client stream, server stream, and bidirectional stream, with the support of the HTTP2 protocol.

[0003] Actor model is a concurrent computing model. The core idea of Actor is to regard computation as a series of message passing and processing. Each 'actor' that receives and processes messages is an independent computing unit. Actor model has a wide range of applications in distributed systems, parallel computing, and concurrent programming. Commonly used Actor model-based frameworks and languages include Akka and Erlang.

[0004] In current microservice system design, RPC model is the most commonly used communication scheme between microservices. However, in the construction of complex, high-concurrency, high-elasticity, and high-availability distributed systems, Actor model is the most optimal solution.

[0005] However, the framework technologies used by the current RPC model and Actor model are often incompatible. If an application system needs both RPC model and Actor model, it needs to maintain two network communication models, two thread models, and two serialization systems, increasing the complexity of the system and occupying system resources. For example, gRPC-java is based on the network communication framework Netty, and serialization is based on Protobuf. Akka is based on the network communication framework Aeron, the thread model Dispatcher, and an independent serialization scheme. Although Akka provides API layer compatibility for gRPC, the underlying network and thread model are still independent of each other, and cannot achieve optimal system resource occupation. SUMMARY

[0006] In view of this, the purpose of the present invention is to develop an integration method of the two network communication paradigms of RPC model and Actor model, and propose an integration method of RPC and Actor based on HTTP2. The two frameworks of RPC model and Actor model can be used for network communication according to design requirements. There is no need to maintain two systems and frameworks at the same time, so as to achieve low resource occupation and ensure the high scalability, maintainability, ease of use and high performance of the system.

[0007] The present invention provides an integrated system of RPC and Actor based on HTTP2, comprising: an RPC management module, an Actor system module, and an interface management module, a transmission module, and an execution module which are sequentially connected in series; the RPC management module and the Actor system module are respectively connected to the interface management module, register interface definitions with the interface management module, create actors, or add new RPC interface services;

[0008] Furthermore, the RPC management module includes: an RPC service submodule and an RPC client submodule; the RPC service submodule interacts with the RPC client submodule.

[0009] Specifically, on the server side, the RPC server submodule executes the logic of the RPC interface server defined by the user, registers the interface definition to the interface management module, and provides the RPC service of the RPC interface to the outside world; on the client side, the RPC client submodule can create the data flow of the external RPC server and execute RPC calls.

[0010] The interface management module is used to add and delete interface definitions; the RPC service terminal module registers the interface definition with the interface management module, and the interface definition information is synchronized to the routing controller of the transmission module, and the interface is created and the interface is put online; the RPC service terminal module applies to the interface management module to delete the interface definition information, and then the interface definition information in the routing controller is synchronously deleted, the interface is deleted, and the interface is taken offline; after the client establishes a connection with the server, it directly pulls the available interface from the server to obtain the client interface;

[0011] Specifically, each interface definition contains a route (i.e., the mapping between the HTTP2 request path and the RPC interface or Actor), a serializer, and other communication parameter information. Every time a new RPC interface is added or a new Actor is created, a new interface definition is added to the interface management module. When creating an Actor, a sticky ID is also configured in the parameter information of the interface definition to implement the distributor's sticky queue selection strategy.

[0012] The transmission module is a unified access of network communication in the system, and is used for realizing network data exchange between services, data encoding and decoding, and flow control functions.

[0013] The execution module comprises multiple working threads, which continuously execute various types of tasks, and the task types include RPC tasks, Actor message processing tasks, timing tasks and user-defined asynchronous execution tasks.

[0014] The execution module is essentially a thread pool, and different from a common thread pool, the execution module can require specific threads to execute specified tasks according to the task types and requirements, and provides targeted performance optimization for network communication message processing and local asynchronous task processing.

[0015] Further, the transmission module comprises an HTTP2 controller, a routing controller, a serializer and a write queue; the routing controller is downstream of the HTTP2 controller, and the serializer is downstream of the routing controller; the routing controller interacts with the HTTP2 controller, the serializer interacts with the routing controller, and the write queue is connected to the serializer.

[0016] Specifically, the HTTP2 controller is used to realize format conversion between an HTTP2 protocol data frame and a system message. In a sending end, a frame codec encodes a message from the system into an HTTP2 data frame; in a receiving end, the frame codec decodes the data frame and delivers it to a downstream; and the HTTP2 controller abstracts a TCP connection into an HTTP2 protocol data stream, multiple data streams can be multiplexed in the same TCP connection, and a multiplexing controller can provide a flow control function to realize back pressure control, and a blockage of a certain data stream does not affect data transmission of other data streams.

[0017] The routing controller is used to realize routing control of a message object to an RPC interface or an Actor. The routing controller analyzes path information in an HTTP2 request header, finds a corresponding serializer and an RPC interface or an Actor object through an internal routing table, and sends the information to a downstream. The routing controller can listen to routing information changes in a routing registration module in real time, and update the local routing table.

[0018] The serializer is used to serialize a message object from an RPC call and an Actor into binary data in a sending end, and deliver the binary data to the HTTP2 controller for further encoding into a data frame; and in a receiving end, the serializer is used to deserialize binary data decoded from the HTTP2 controller into a message object, and send the message object and other information obtained by the routing controller to a downstream.

[0019] The write queue is used for data sending, adopts the ring array data structure of Disruptor, and the messages of external threads are first written into the write queue for caching, and then the IO threads of the transmission module pull data from the write queue, send the data to the serializer to convert the data into binary format data, and then the HTTP2 controller encapsulates the data into frames.

[0020] Further, the execution module comprises a distributor, an event queue, a timer, and an executor; the distributor is connected to the serializer of the upstream transmission module; the event queue is downstream of the distributor, and the executor is downstream of the event queue and connected to the event queue; the event queue comprises an SPSC queue and an MPSC queue; the distributor is connected to the SPSC queue, and the timer is connected to the MPSC queue.

[0021] Specifically, the IO thread of each upstream transmission module corresponds to a distributor, each distributor corresponds to multiple downstream event queues, when a new HTTP2 data stream is created, the distributor selects an event queue and binds the data stream, and then all messages of the data stream are written into the event queue; the distribution strategies of the distributor for selecting the event queue include four kinds of strategies, i.e., polling, random, load balancing, and sticky strategy; the load balancing strategy means that the distributor monitors the production and consumption rates of the event queues and selects one of the event queues with the highest rate; the sticky strategy means that when the HTTP2 data stream is created, the distributor selects a specified event queue according to the sticky id configured in the interface definition. The sticky strategy can ensure that multiple HTTP2 data streams can be processed by the same worker thread downstream, because in order to ensure the thread safety inside each Actor, all messages passed to the specified Actor must be scheduled to a unique thread for processing, so the sticky strategy is necessary in the design of the Actor model.

[0022] The event queue is used to realize the asynchronous transmission of messages. The event queue adopts the Disruptor ring array data structure and can be divided into a single producer single consumer (SPSC) queue and a multiple producer multiple consumer (MPSC) queue. The SPSC queue is used to connect the IO thread of the upstream transmission module and the worker thread of the downstream executor, and the SPSC queue requires that each queue can only correspond to one producer IO thread and one consumer worker thread, so as to ensure as few multithreading operations as possible and maximize the calculation efficiency. The MPSC queue is used for local message transmission of the system, can support any thread to send messages to the queue, and is processed by a single executor worker thread, and the message transmission between local Actors is realized through the MPSC queue.

[0023] The number of event queues in a system is calculated as follows: assuming that there are n IO threads in the transmission module in the system and m worker threads in the executor, the total number of SPSC queues is n*m, the number of downstream SPSC queues corresponding to each IO thread is m, and the number of upstream SPSC queues corresponding to each execution thread is n; the total number of MPSC queues is m, and the number of upstream MPSC queues corresponding to each execution thread is 1.

[0024] In the RPC and Actor models, there are often some processing of timed tasks, such as timeout detection, timed heartbeat, etc., which are scheduled through timers. The timer adopts a time wheel data structure, and when the timed task reaches the execution time point, the timer will send the task to the specified MPSC queue, and finally the task will be executed by the specified executor thread.

[0025] The executor internally includes multiple execution threads, each of which continuously consumes the upstream event queue and processes the consumed messages. The executor itself is stateless, and for RPC type messages, the executor will execute the user-defined code logic according to the RPC interface information obtained by the routing controller and the sent messages. For Actor type messages, the executor will execute the user-defined Actor execution logic according to the Actor information obtained by the routing controller.

[0026] Further, the Actor system module includes a life cycle manager, a stream health manager, and a serialization registration center; the life cycle manager is connected to the interface management module; the stream health manager is connected to the transmission module; and the serialization registration center is connected to the life cycle manager.

[0027] Specifically, the life cycle manager is used to implement the life cycle management of local Actors, and when an Actor is created, the routing and serialization information of the Actor and the interface definition information such as sticky id are registered to the interface management module, and when the Actor is destroyed, the corresponding interface definition is deleted from the interface management module.

[0028] The stream health manager is used to ensure the continuous availability of data streams between Actors across nodes, and when the data stream is disconnected or abnormal, the stream health manager will try to recreate a new data stream to ensure timely communication between Actors.

[0029] The Actor model has higher requirements on message serialization than RPC, and the type of message transferred between Actors is often dynamic, so a unified serialization registration center is needed to uniformly manage message types and serialization. When an Actor is created, the serialization registration center provides a dynamically typed serializer for the Actor, and the interface definition is registered with the life cycle manager. In addition, the serializer generated by the serialization registration center can also support the serialization of the Actor, and the essence is the serialization of the interface definition. For example, Actor1 of node a can send itself as a message content to Actor2 of node b, and Actor2 receives the message and directly communicates with Actor1, and the address of Actor1 is transparent to Actor2.

[0030] Further, the interface management module comprises an interface registration submodule, the upstream of the interface registration submodule is connected with the life cycle manager and / or the RPC management module, and the downstream of the interface registration submodule is connected with the route controller.

[0031] Specifically, after each RPC interface or Actor life cycle ends, the corresponding interface information is also deleted in the interface registration submodule.

[0032] The application further provides an RPC and Actor integration method based on HTTP2, applied to the RPC and Actor integration system based on HTTP2, comprising an RPC interface management method, an Actor management method, a network communication data receiving method, and a network communication data sending method.

[0033] A1, the RPC server submodule registers the interface definition to the interface management module, the interface definition information is synchronized to the route controller of the transmission module, an interface is created, and the interface is online;

[0034] A2, the RPC server submodule applies to the interface management module for deleting the interface definition information, and then the interface definition information in the route controller is synchronously deleted, the interface is deleted, and the interface is offline;

[0035] A3, after the client and the server establish a connection, the available interface is directly pulled from the server, and the client interface is obtained;

[0036] The Actor management method comprises:

[0037] B1, life cycle management: the Actor system module first binds an interface definition for an Actor when creating the Actor, and registers the interface definition to the interface management module; the life cycle manager listens to the Actor state changes in real time, and triggers a cleaning task to delete the interface definition corresponding to the Actor from the interface management module when the Actor life cycle ends and needs to be destroyed;

[0038] B2, local communication between Actors: assuming that Actor1 sends a message to local Actor2, the data transmission process is as follows: Actor1 obtains the sticky id in the interface definition of Actor2 according to the interface definition information bound to Actor2, finds the execution thread and MPSC queue corresponding to the execution module based on the sticky id, and sends the message and the interface definition bound to Actor2 to the MPSC queue; the execution thread pulls the message from the MPSC queue, and performs according to the interface definition, without caring whether the message is from the network or the local.

[0039] The network communication data receiving method comprises:

[0040] C1, network data enters the HTTP2 controller of the transmission module to perform frame decoding, and the data frame is parsed into binary data;

[0041] Specifically, each TPC connection and the HTTP2 data stream established on the TPC connection have a special IO thread for processing;

[0042] C2, the server receives HTTP2 request data, the routing controller parses the request message header to obtain the interface definition information corresponding to the HTTP2 request after the HTTP2 data stream is established, and delivers the data stream to the downstream processing; the client receives HTTP2 response data, and the routing controller directly obtains the interface definition information according to the request header information corresponding to the HTTP2 response data stream, and delivers the data stream to the downstream processing;

[0043] C3, the serializer deserializes the binary data into a message object, and sends the message object and the interface definition information to the distributor of the execution module;

[0044] C4, the distributor sends the message and the interface definition information to the SPSC queue according to the distribution strategy of the interface definition;

[0045] C5, the execution thread of the execution module pulls the message from the SPSC queue, and performs a task according to the interface definition;

[0046] The network communication data sending method comprises:

[0047] D1, the client sends a request, and the server sends a response;

[0048] D2, the client or the server writes the message to be sent into the write queue of the transmission module, and the IO thread of the transmission module pulls the message object data from the write queue and converts the message object data into binary format data through the serializer;

[0049] D3, the frame codec encapsulates the binary format data into frames and sends the message to the external network.

[0050] Further, the contents of the interface definition registered in the interface management module of the RPC interface management method and the Actor management method include:

[0051] Routing: one-to-one mapping relationship between HTTP2 request header and receiving object;

[0052] Call type: including RPC and Actor;

[0053] Receiving object: if it is RPC call type, the receiving object is the RPC interface execution logic defined by the server user, and if it is Actor call type, the receiving object is the corresponding Actor;

[0054] Interface type: including request-response, client stream, server stream and bidirectional stream four types; if it is RPC call type, all four types are supported; if it is Actor call type, only client stream type is supported;

[0055] Serializer: used for serializing and deserializing the message object of the interface;

[0056] Sticky id; distributor distribution strategy; HTTP2 protocol parameters; connection timeout, heartbeat configuration parameters.

[0057] Among them, sticky id is a necessary parameter for Actor call type, which is used to ensure that the distributor of the execution module can deliver messages sent to the same Actor to the same thread for processing; for RPC call type, this parameter is optional;

[0058] The distributor distribution strategy includes round robin, random, load balancing and sticky strategy;

[0059] HTTP2 protocol parameters are used for data transmission optimization of HTTP2 protocol.

[0060] Preferably, an event-driven asynchronous non-blocking model is adopted, and through ring array, time wheel and other data structures, resource occupation can be further optimized.

[0061] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned method for integrating RPC and Actor based on HTTP2.

[0062] The present invention also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the HTTP2-based RPC and Actor integration method as described above are implemented.

[0063] Compared with the prior art, the present invention has the following beneficial effects:

[0064] The HTTP2-based RPC and Actor integration method provided by the present invention realizes the integration of two network communication paradigms, RPC and Actor models; the two can be arbitrarily selected for network communication according to design requirements, for example, RPC is used when performing data communication between the server and the client; the Actor model is used when building a cluster or large-scale data communication between nodes, without the need to maintain two systems and frameworks; efficient and reliable network data communication is achieved; the network communication adopts the industry's mature HTTP2 protocol, which can achieve reliable data transmission, connection multiplexing, and flow control; high performance, low latency and back pressure control of network communication are achieved; efficient use of system resources is achieved, and the RPC model and the Actor model can share the same network traffic inlet and outlet, while reducing system resource usage, improving the system's operating efficiency and supporting data communication between large-scale nodes. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Various other advantages and benefits will become apparent to those skilled in the art by reading the following detailed description of the preferred embodiment.The accompanying drawings are only for the purpose of illustrating the preferred embodiment and are not to be considered as limiting the present invention.

[0066] In the attached figure:

[0067] Figure 1 1 is a schematic diagram of the component structure of an HTTP2-based RPC and Actor integration system according to an embodiment of the present invention;

[0068] Figure 2 The internal execution logic and principle diagram of the HTTP2-based RPC and Actor integration system and integration method according to an embodiment of the present invention;

[0069] Figure 3 This is a diagram showing an example of usage under the RPC paradigm of an embodiment of the present invention;

[0070] Figure 4This is a diagram showing an example of usage under the Actor paradigm of an embodiment of the present invention;

[0071] Figure 5 Schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0072] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, like numbers in different figures represent like or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible embodiments consistent with the present disclosure. Rather, they are merely examples of devices and products consistent with certain aspects of the present disclosure, as detailed in the appended claims.

[0073] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0074] It should be understood that although the terms first, second, third, etc. may be used in this disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this disclosure, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining."

[0075] The embodiments of the present invention are described in further detail below.

[0076] The embodiment of the present invention provides an integrated system of RPC and Actor based on HTTP2, such as Figure 1 As shown, it includes: an RPC management module, an Actor system module, and an interface management module, a transmission module, and an execution module that are sequentially connected in series; the RPC management module and the Actor system module are respectively connected to the interface management module, register interface definitions with the interface management module, create actors, or add new RPC interface services;

[0077] The interface management module is used to add and delete interface definitions;

[0078] Each newly added RPC interface or newly created Actor will have a corresponding interface definition added in the interface management module, and a sticky id will be configured in the parameter information of the interface definition when the Actor is created, which is used to implement the distributor sticky queue selection strategy;

[0079] The transmission module is the unified entrance and exit of network communication in the system, and is used to implement network data exchange between services, data encoding and decoding, and flow control functions;

[0080] The execution module includes multiple worker threads that continuously execute various types of tasks, including RPC tasks, Actor message processing tasks, timing tasks, and user-defined asynchronous execution tasks.

[0081] The execution module can require specific threads to execute specified tasks according to task types and requirements, and provides targeted performance optimization for network communication message processing and local asynchronous task processing.

[0082] The transmission module includes an HTTP2 controller, a routing controller, a serializer, and a write queue. The routing controller is downstream of the HTTP2 controller, and the serializer is downstream of the routing controller. The routing controller interacts with the HTTP2 controller, the serializer interacts with the routing controller, and the write queue is connected to the serializer.

[0083] The HTTP2 controller is used to implement the format conversion between HTTP2 protocol data frames and system internal messages. In the sending end, the frame codec encodes the messages from the system into HTTP2 data frames; in the receiving end, the frame codec decodes the data frames and passes them to the downstream; and the HTTP2 controller abstracts the TCP connection into an HTTP2 protocol data stream, multiple data streams can reuse the same TCP connection, and the multiplexing controller can provide flow control function, while implementing back pressure control, the blockage of a certain data stream does not affect the data transmission of other data streams;

[0084] The routing controller is used to implement the routing control of message objects to RPC interfaces or Actors. The routing controller parses the path information in the HTTP2 request header, finds the corresponding serializer and RPC interface or Actor object through the internal routing table, and sends these information to the downstream. The routing controller will listen to the changes in the routing information in the routing registration module in real time and update the local routing table.

[0085] The serializer is used at the sending end to serialize the message object from RPC call and Actor into binary data and pass to HTTP2 controller to further encode into data frame; at the receiving end to deserialize the binary data decoded from HTTP2 controller into message object and send the message object and other information parsed from routing controller to downstream;

[0086] The write queue is used for data sending, which adopts the ring array data structure of Disruptor, and the message of external thread is first written into the write queue for caching, and then the data is pulled from the write queue by the IO thread of the transmission module, sent to the serializer to convert into binary format data, and then encapsulated into frame by the HTTP2 controller.

[0087] The execution module includes a distributor, an event queue, a timer and an executor; the distributor is connected to the serializer of the upstream transmission module; the event queue is downstream of the distributor, and the executor is downstream of the event queue and connected to the event queue; the event queue includes an SPSC queue and an MPSC queue; the distributor is connected to the SPSC queue, and the timer is connected to the MPSC queue.

[0088] Each IO thread of the upstream transmission module corresponds to a distributor, and each distributor corresponds to multiple downstream event queues; when a new HTTP2 data stream is created, the distributor selects an event queue and binds the data stream, and then all messages of the data stream are written into the event queue; the distribution strategy of the distributor includes four kinds of strategies: polling, random, load balancing and sticky strategy; the load balancing strategy means that the distributor monitors the production and consumption rate of the event queue and selects one event queue with the highest rate; the sticky strategy means that when the HTTP2 data stream is created, the distributor selects a specified event queue according to the sticky id configured in the interface definition. The sticky strategy can ensure that multiple HTTP2 data streams can be processed by the same worker thread downstream, because in order to ensure the thread safety of each Actor, all messages passed to the specified Actor must be scheduled to a unique thread for processing, so the sticky strategy is necessary in the design of Actor model.

[0089] Event queue is used to realize the asynchronous delivery of messages. The event queue adopts Disruptor ring array data structure, which can be divided into single producer single consumer (SPSC) queue and multi-producer multi-consumer (MPSC) queue. The SPSC queue is used to connect the IO thread of the upstream transmission module and the worker thread of the downstream executor, and the SPSC queue requires that each queue can only correspond to one producer IO thread and one consumer worker thread, so as to ensure as few multithreading operations as possible and maximize the calculation efficiency. The MPSC queue is used for local message delivery of the system, and can support any thread to send messages to the queue and be processed by a single executor worker thread. The message delivery between local actors is realized through the MPSC queue.

[0090] The number of event queues in a system is calculated as follows: assuming that there are n IO threads of the transmission module in the system and m worker threads of the executor, then the total number of SPSC queues is n*m, the number of SPSC queues corresponding to each IO thread in the downstream is m, and the number of SPSC queues corresponding to each execution thread in the upstream is n; the total number of MPSC queues is m, and the number of MPSC queues corresponding to each execution thread in the upstream is 1.

[0091] There are often some processing of timing tasks in the RPC and Actor models, such as timeout detection, timing heartbeat, etc., which are scheduled through timers. The timer adopts a time wheel data structure, and when the timing task reaches the execution time point, the timer will send the task to the specified MPSC queue, and finally the task will be executed by the specified executor thread.

[0092] The executor internally includes multiple execution threads, and each execution thread continuously consumes the upstream event queue and processes the consumed messages. The executor itself is stateless, and for RPC type messages, the executor will execute the user-defined code logic according to the RPC interface information obtained by the routing controller and the sent messages. For Actor type messages, the executor will execute the user-defined Actor execution logic according to the Actor information obtained by the routing controller.

[0093] The RPC management module includes an RPC server sub-module and an RPC client sub-module; the RPC server sub-module interacts with the RPC client sub-module.

[0094] On the server side, the RPC server sub-module registers the interface definition to the interface management module according to the user-defined RPC interface server execution logic, so as to provide the RPC service of the RPC interface to the outside; on the client side, the data stream of the external RPC server can be created through the RPC client sub-module, and the RPC call can be executed.

[0095] The Actor system module comprises a life cycle manager, a flow health manager and a serialization registration center; the life cycle manager is connected with the interface management module; the flow health manager is connected with the transmission module; and the serialization registration center is connected with the life cycle manager.

[0096] The life cycle manager is used for realizing the life cycle management of a local Actor, and the routing and serialization information of the Actor and interface definition information such as sticky id are registered to the interface management module when the Actor is created, and the corresponding interface definition is deleted from the interface management module when the Actor is destroyed.

[0097] The flow health manager is used for ensuring the continuous availability of data flow between Actors across nodes, and the flow health manager attempts to re-create a new data flow when the data flow is disconnected or abnormal, so as to ensure that the Actors can communicate in time.

[0098] The Actor model has higher requirements on message serialization than RPC, and the type of the message transmitted between the Actors is often dynamic, so a unified serialization registration center is needed to uniformly manage the message type and serialization. When the Actor is created, the serialization registration center provides a dynamic type serializer for the Actor, and the life cycle manager is used for interface definition registration. In addition, the serializer generated by the serialization registration center can also support the serialization of the Actor, and the essence is the serialization of the interface definition. For example, Actor1 of node a can send itself as message content to Actor2 of node b, and Actor2 directly communicates with Actor1 after receiving the message, and the address of Actor1 is transparent to Actor2.

[0099] The interface management module comprises an interface registration sub-module, the upstream of the interface registration sub-module is connected with the life cycle manager and / or the RPC management module, and the downstream of the interface registration sub-module is connected with the routing controller.

[0100] The embodiment of the application also provides an integration method of RPC and Actor based on HTTP2, which is applied to the integration system of RPC and Actor based on HTTP2 and comprises an RPC interface management method, an Actor management method, a network communication data receiving method and a network communication data sending method.

[0101] A1, the RPC server sub-module registers the interface definition to the interface management module, the interface definition information is synchronized to the routing controller of the transmission module, an interface is created, and the interface is completed online;

[0102] A2, the RPC service terminal module applies to delete the interface definition information to the interface management module, and then the interface definition information in the route controller is synchronously deleted, the interface is deleted, and the interface is completed offline;

[0103] A3, after the client and the server establish a connection, the available interface is directly pulled from the server, and the client interface is obtained;

[0104] The Actor management method comprises:

[0105] B1, life cycle management: when the Actor system module creates an Actor, first, an interface definition is bound to the Actor, and the interface definition is registered to the interface management module; the life cycle manager listens to the Actor state change in real time, when the Actor life cycle ends and needs to be destroyed, the life cycle manager triggers the cleaning task, and deletes the interface definition corresponding to the Actor from the interface management module;

[0106] In the embodiment, the content of the interface definition registered to the interface definition in the interface management module of the RPC interface management method and the Actor management method comprises:

[0107] Routing: that is, a one-to-one mapping relationship between the HTTP2 request header and the receiving object;

[0108] Call type: including RPC and Actor two kinds;

[0109] Receiving object: if it is an RPC call type, the receiving object is a service end user-defined RPC interface execution logic, if it is an Actor call type, the receiving object is a corresponding Actor;

[0110] Interface type: including request-response, client stream, server stream, and bidirectional stream four types; if it is an RPC call type, all four types are supported; if it is an Actor call type, only the client stream type is supported;

[0111] Serializer: used for serializing and deserializing the message object used for the interface;

[0112] Other parameters, including: sticky id; distributor distribution strategy; HTTP2 protocol parameter; connection timeout, heartbeat configuration, etc.

[0113] Among them, the sticky id is a parameter required for the Actor call type, and the sticky id is used to ensure that the distributor of the execution module can transmit the messages sent to the same Actor to the same thread for processing; for the RPC call type, the parameter is optional;

[0114] The distributor distribution strategy includes polling, random, load balancing and sticky strategy;

[0115] The HTTP2 protocol parameter is used for data transmission optimization of the HTTP2 protocol.

[0116] B2, local communication between actors is implemented: Actor1 sends a message to local Actor2, and the data transmission process is as follows: Actor1 obtains the sticky id in the interface definition of Actor2 according to the interface definition information bound by Actor2, finds the execution thread and the MPSC queue corresponding to the execution module based on the sticky id, and sends the message and the interface definition bound by Actor2 to the MPSC queue; the execution thread pulls the message from the MPSC queue, and performs according to the interface definition. No need to care whether the message is from the network or the local.

[0117] The network communication data receiving method comprises:

[0118] C1, network data enters the HTTP2 controller of the transmission module for frame decoding, and the data frame is parsed into binary data;

[0119] C2, the server receives the HTTP2 request data, the routing controller parses the request message header after the HTTP2 data stream is established, obtains the interface definition information corresponding to the HTTP2 request, and delivers the data stream to the downstream processing; the client receives the HTTP2 response data, and the routing controller directly obtains the interface definition information according to the request header information corresponding to the HTTP2 response data stream, and delivers the data stream to the downstream processing;

[0120] C3, the serializer deserializes the binary data into a message object, and sends the message object and the interface definition information to the distributor of the execution module;

[0121] C4, the distributor sends the message and the interface definition information to the SPSC queue according to the distribution strategy of the interface definition;

[0122] C5, the execution thread of the execution module pulls the message from the SPSC queue, and executes the task according to the interface definition;

[0123] The network communication data sending method comprises:

[0124] D1, the client sends a request, and the server sends a response;

[0125] D2, the client or the server writes the message to be sent into the write queue of the transmission module, the IO thread of the transmission module pulls the message object data from the write queue, and converts the message object data into binary format data through the serializer;

[0126] D3, frame codec encapsulates the binary format data into frames, sends messages to external networks.

[0127] Figure 2 The internal execution logic and principle of the HTTP2-based RPC and Actor integrated system and integrated method of the embodiment are shown.

[0128] Figure 3 As a use example under the RPC paradigm of the embodiment, the server registers the interface definition, and the client can establish a connection with the server, supporting RPC calling of four interface types of request-response, client stream, server stream and bidirectional stream. Under the RPC paradigm, the service is centralized, and the client needs to actively establish a connection with the server. The client is isolated from the client. It is suitable for micro-service development and common business development.

[0129] Figure 4 As a use example under the Actor paradigm of the embodiment, each Actor node is equivalent to a server. The communication between the Actor nodes is all client stream, that is, the source end Actor pushes data to the target end Actor in real time. Under the Actor paradigm, the service is decentralized, and the Actor nodes can establish a connection with each other and communicate with each other. It is suitable for cluster construction.

[0130] The embodiment of the application further provides a computer device, Figure 5 is a structural schematic diagram of a computer device provided by the embodiment of the application; referring to the accompanying drawings Figure 5 As shown in the drawings, the computer device comprises an input system 23, an output system 24, a memory 22 and a processor 21; the memory 22 is used for storing one or more programs; when the one or more programs are executed by the one or more processors 21, the one or more processors 21 implement the HTTP2-based RPC and Actor integrated method provided by the above-mentioned embodiment; wherein the input system 23, the output system 24, the memory 22 and the processor 21 can be connected through a bus or other means, Figure 5 For example, the bus connection.

[0131] The memory 22 can be used as a readable and writable storage medium of the computing device, and can be used to store software programs, computer executable programs, and the like. For example, the memory 22 can store program instructions of the HTTP2-based RPC and Actor integration method according to an embodiment of the present application. The memory 22 can mainly include a program storage area and a data storage area. The program storage area can store an operating system and at least one application required by a function. The data storage area can store data created according to use of the device, and the like. In addition, the memory 22 can include a high-speed random access memory, and can further include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state memory device. In some examples, the memory 22 can further include a memory remotely arranged with respect to the processor 21, and the remote memory can be connected to the device through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0132] The input system 23 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the device. The output system 24 can include a display device such as a display screen.

[0133] The processor 21 can execute various function applications and data processing of the device by running software programs, instructions, and modules stored in the memory 22, that is, implement the HTTP2-based RPC and Actor integration method described above.

[0134] The computer device provided above can be used to execute the HTTP2-based RPC and Actor integration method provided in the above embodiments, and has corresponding functions and advantages.

[0135] The embodiment of the present application further provides a storage medium containing computer executable instructions, which are used for executing the HTTP2-based RPC and Actor integration method provided by the above embodiment when executed by a computer processor. The storage medium is any various type of memory device or storage device, and the storage medium includes: installation medium, such as CD-ROM, floppy disk or tape system; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic medium (for example, hard disk or optical storage); register or other similar type of memory element, etc.; the storage medium can further include other types of memory or combinations thereof; in addition, the storage medium can be located in a first computer system in which the program is executed, or can be located in a different second computer system, which is connected to the first computer system through a network (such as the Internet); the second computer system can provide program instructions to the first computer for execution. The storage medium includes two or more storage media that can reside in different locations (for example, in different computer systems connected through a network). The storage medium can store program instructions (for example, specifically implemented as a computer program) executable by one or more processors.

[0136] Of course, the storage medium containing computer executable instructions provided by the embodiment of the present application is not limited to the HTTP2-based RPC and Actor integration method described in the above embodiment, and can also perform related operations in the HTTP2-based RPC and Actor integration method provided by any embodiment of the present application.

[0137] So far, the technical solutions of the present application have been described in combination with preferred embodiments, but those skilled in the art can easily understand that the protection scope of the present application is obviously not limited to these specific embodiments. Those skilled in the art can make equivalent changes or replacements to related technical features without departing from the principles of the present application, and the technical solutions after the changes or replacements will fall within the protection scope of the present application.

[0138] The above description is only the preferred embodiments of the present application and is not used to limit the present application; for those skilled in the art, the present application can have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. An integrated system of RPC and Actor based on HTTP2, characterized in that, The application relates to a system and method for RPC and Actor system management. The system comprises an RPC management module, an Actor system module, and an interface management module, a transmission module and an execution module connected in sequence; the RPC management module and the Actor system module are connected with the interface management module, register interface definitions to the interface management module, create Actors or add RPC interface services; The RPC management module comprises an RPC server sub-module and an RPC client sub-module; the RPC server sub-module interacts with the RPC client sub-module; The interface management module is used for adding and deleting interface definitions; the RPC server sub-module registers interface definitions to the interface management module, the interface definition information is synchronized to a routing controller of the transmission module, an interface is created, and the interface is put on line; the RPC server sub-module applies to delete the interface definition information to the interface management module, and then the interface definition information in the routing controller is synchronously deleted, the interface is deleted, and the interface is taken off line; after the client and the server establish a connection, the client directly pulls available interfaces from the server and obtains client interfaces; The transmission module is a unified entrance and exit of network communication in the system and is used for realizing network data exchange between services, data coding and decoding and flow control functions; The execution module comprises multiple working threads which continuously execute various types of tasks; the task types include RPC tasks, Actor message processing tasks, timing tasks and user-defined asynchronous execution tasks. 2.The HTTP2 based RPC and Actor integration system of claim 1, wherein, The transmission module comprises an HTTP2 controller, a routing controller, a serializer and a write queue; the routing controller is downstream of the HTTP2 controller, and the serializer is downstream of the routing controller; the routing controller interacts with the HTTP2 controller, the serializer interacts with the routing controller, and the write queue is connected with the serializer. 3.The HTTP2 based RPC and Actor integration system of claim 2, wherein, The execution module comprises a distributor, an event queue, a timer and an executor; the distributor is connected with the serializer of the transmission module upstream; the event queue is downstream of the distributor, the executor is downstream of the event queue, and the executor is connected with the event queue; the event queue comprises an SPSC queue and an MPSC queue; the distributor is connected with the SPSC queue, and the timer is connected with the MPSC queue; The distribution strategy of the distributor for the event queue comprises four strategies, namely, polling, random, load balancing and sticky strategy; the load balancing strategy means that the distributor monitors the production and consumption rates of the event queue and selects an event queue with the highest rate; the sticky strategy means that when an HTTP2 data flow is created, the distributor selects a specified event queue according to a sticky id configured in the interface definition; the sticky strategy ensures that multiple HTTP2 data flows can be processed by the same working thread downstream. The SPSC queue is used for connecting the IO thread of the upstream transmission module and the work thread of the downstream executor, and the SPSC queue requires that each queue can correspond to only one producer IO thread and one consumer work thread, so that the number of multithreading operations is minimized, and the calculation efficiency is maximized; the MPSC queue is used for local message transmission of the system, and any thread can send a message to the queue. 4.The HTTP2 based RPC and Actor integration system of claim 2, wherein, The Actor system module comprises a life cycle manager, a flow health manager and a serialization registration center; the life cycle manager is connected to the interface management module; the flow health manager is connected to the transmission module; and the serialization registration center is connected to the life cycle manager. 5.The HTTP2 based RPC and Actor integration system of claim 4, wherein, The interface management module comprises an interface registration sub-module, wherein the upstream of the interface registration sub-module is connected to the life cycle manager and / or the RPC management module, and the downstream of the interface registration sub-module is connected to the routing controller.

6. The integration method of RPC and Actor based on HTTP2, applied to the integration system of RPC and Actor based on HTTP2 as claimed in any one of claims 1-5, characterized in that, The method comprises: The RPC interface management method comprises: A1, the RPC server sub-module registers the interface definition to the interface management module, the interface definition information is synchronized to the routing controller of the transmission module, the interface is created, and the interface is completed online; A2, the RPC server sub-module applies to delete the interface definition information to the interface management module, and then the interface definition information in the routing controller is synchronously deleted, the interface is deleted, and the interface is completed offline; A3, after the client and the server establish a connection, the available interface is directly pulled from the server, and the client interface is obtained; The Actor management method comprises: B1, life cycle management: when the Actor system module creates an Actor, an interface definition is first bound to the Actor, and the interface definition is registered to the interface management module; the life cycle manager listens to the Actor state change in real time, and when the Actor life cycle ends and needs to be destroyed, the life cycle manager triggers a cleaning task to delete the interface definition corresponding to the Actor from the interface management module; B2, local communication between Actors is achieved: assuming that Actor1 sends a message to local Actor2, the data transmission process is as follows: Actor1 obtains the sticky id in the interface definition of Actor2 according to the interface definition information bound to Actor2, finds the execution module corresponding to the execution thread and the MPSC queue based on the sticky id, and sends the message and the interface definition bound to Actor2 to the MPSC queue; after the execution thread pulls the message from the MPSC queue, the execution is performed according to the interface definition; The network communication data receiving method comprises: C1, network data enters the HTTP2 controller of the transmission module for frame decoding, and the data frame is parsed into binary data; C2, the service end receives the data of the HTTP2 request, after the HTTP2 data stream is established, the routing controller parses the request message header to obtain the interface definition information corresponding to the HTTP2 request, and delivers the data stream to the downstream processing; the client receives the data of the HTTP2 response, and the routing controller directly obtains the interface definition information according to the request header information corresponding to the data stream of the HTTP2 response, and delivers the data stream to the downstream processing; C3, the serializer deserializes the binary data into a message object, and sends the message object and the interface definition information to the distributor of the execution module; C4, the distributor sends the message and the interface definition information to the SPSC queue according to the distribution strategy of the interface definition; C5, the execution thread of the execution module pulls the message from the SPSC queue, and executes the task according to the interface definition; The network communication data sending method comprises: D1, the client sends a request, and the service end sends a response; D2, the client or the service end writes the message to be sent into the write queue of the transmission module, the IO thread of the transmission module pulls the message object data from the write queue, and converts the message object data into binary format data through the serializer; D3, the frame encoder and decoder encapsulates the binary format data into frames and sends the message to the external network.

7. The HTTP2-based RPC and Actor integration method of claim 6, wherein, The contents of the interface definition registered in the interface management module of the RPC interface management method and the Actor management method include: Routing: one-to-one mapping relationship between HTTP2 request header and receiving object; Call type: including RPC and Actor; Receiving object: if it is an RPC call type, the receiving object is the RPC interface execution logic defined by the user of the service end, and if it is an Actor call type, the receiving object is the corresponding Actor; Interface type: including request-response, client stream, service end stream and bidirectional stream; if it is an RPC call type, all four types are supported; if it is an Actor call type, only the client stream is supported; Serializer: used for serializing and deserializing the message object of the interface; Sticky id; distributor distribution strategy; HTTP2 protocol parameters; connection timeout, heartbeat configuration parameters.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to realize the steps of the HTTP2-based RPC and Actor integration method of claim 6 or 7.

9. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to realize the steps of the HTTP2-based RPC and Actor integration method of claim 6 or 7.

Citation Information

Patent Citations

  • Network protocol communication middleware based on TCP protocol

    CN112363830A

  • Data processing method and device and distributed data processing system

    CN118227316A