Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account


What is the RPC framework?

2024-07-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >


Shulou( Report--

This article mainly introduces "what is the RPC framework". In the daily operation, I believe that many people have doubts about what is the RPC framework. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what is the RPC framework?" Next, please follow the editor to study!

About RPC

First of all, understand what is called RPC, why RPC,RPC refers to remote procedure calls, that is to say, two servers A Magi B, an application deployed on server A, want to call the functions / methods provided by the application on server B, because it is not in a memory space, can not be called directly, need to express the semantics of the call and convey the data of the call through the network.

For example, a method might be defined like this:

Employee getEmployeeByName (String fullName)


First of all, to solve the communication problem, mainly through the establishment of a TCP connection between the client and the server, all the exchanged data of the remote procedure call is transmitted in this connection. The connection can be an on-demand connection, which is broken at the end of the call, or a long connection, where multiple remote procedure calls share the same connection.

Second, to solve the problem of addressing, that is, how the application on the A server tells the underlying RPC framework, how to connect to the B server (such as the host or IP address) and the specific port, what is the name of the method, so that the call can be completed. For example, RPC based on the Web service stack should provide an endpoint URI, or look it up from the UDDI service. If it is a RMI call, you also need a RMI Registry to register the address of the service.

Third, when the application on the A server initiates the remote procedure call, the parameters of the method need to be passed to the B server through the underlying network protocol such as TCP. Because the network protocol is based on binary, the values of the parameters in memory should be serialized into binary form, that is, serialization (Serialize) or grouping (marshal). The serialized binary is sent to server B through addressing and transmission.

Fourth, after receiving the request, the B server needs to deserialize the parameters (the reverse operation of serialization), restore to the in-memory expression, and then find the corresponding method (part of the addressing) to make local calls, and then get the return value.

Fifth, the return value should be sent back to the application on server A, and it should also be sent by serialization. Server A receives it, then deserializes it, returns it to the expression in memory, and gives it to the application on server A.

(photo Source:

Why RPC? It is a requirement that cannot be done locally within a process, or even within a computer, such as communication between different systems, or even between different organizations. Because computing power needs to scale out, applications need to be deployed on a cluster composed of multiple machines.

There are many protocols for RPC, such as the earliest CORBA,Java RMI,Web Service RPC style, Hessian,Thrift, and even Rest API.

About Netty

The Netty framework is not limited to RPC, but more as an implementation framework of network protocols, such as HTTP. Because RPC needs efficient network communication, it may choose to be based on Netty. In addition to network communication, RPC also needs a more efficient serialization framework and an addressing method. If it is a RPC call with session (state), you also need to have the ability to maintain session and state.

Generally speaking, Netty provides an event-driven, chain of responsibility (or pipelined) implementation of network protocols. The network protocol consists of many layers and many parts, such as transport layer protocol, encoding and decoding, compression and decompression, identity authentication, encryption and decryption, request processing logic, how to better reuse and expand, the common method in the industry is the responsibility chain.

A request response network interaction usually consists of two chains. One chain (Upstream) goes from the transport layer to the business layer through a series of steps, such as authentication, decryption, log, traffic control, and * *. A chain (DownStream) returns to the business layer, and then returns to the transport layer after a series of steps, such as encryption.

In this way, each layer has a processing interface, which can perform different operations, such as identity authentication, encryption and decryption, log, flow control, and plug different processing implementations like building blocks to achieve a network protocol (rapid development). Each layer has its own implementation, and the upper layer does not need to pay attention to network-oriented operations (maintainable). Netty already provides a number of implementations.

Of course, Netty also has many benefits, such as support for non-blocking IO (NIO), such as reducing the copy of buffer (high performance) when passing on the chain.

At this point, the study on "what is the RPC framework" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To



© 2024 SLNews company. All rights reserved.