Understand the RPC framework thoroughly

Source: Internet
Author: User
RPCFramework, first understand what is called RPC, why to RPC,RPC refers to the remote procedure call, that is, two server a,b, an application deployed on a server, want to call the B server application provided function/method, because it is not a memory space, can not be called directly, The network is needed to express the semantics of the call and convey the data of the call.

For example, a method might be defined in this way:
Employee getemployeebyname (String fullName)
So:
First, to solve the problem of communication, it is primarily through the establishment of a TCP connection between the client and the server that all the exchanged data from the remote procedure call is transmitted in this connection. A connection can be an on-demand connection, broken after the call ends, or a long connection, and multiple remote procedure calls share the same connection. Second, to address the problem of addressing, that is, how the application on a server tells the underlying RPC framework how to connect to a B server (such as a host or IP address) and a specific port, and what the name of the method is, so that the call can be completed. RPC based on the Web service protocol stack, for example, provides a endpoint URI or is found from a UDDI service. If RMI is invoked, an RMI registry is also required to register the address of the service.
Third, when the application on a server initiates a remote procedure call, the parameter of the method needs to be passed to the B server via the underlying network protocol, such as TCP, because the network protocol is based on binary, and the value of the parameter in the memory is serialized into binary form. That is, serialization (Serialize) or marshalling (marshal), which sends the serialized binary to the B server through addressing and transport. Four, after the B server receives the request, it needs to deserialize the parameters (the serialized reverse operation), revert to the expression in memory, and find the corresponding method (part of the addressing) to call locally, and then get the return value. The return value is also sent back to the application on Server A, also to be serialized way to send, Server A received, then deserialized, revert to the memory of the expression, to a server on the application


Why RPC? Is the need not to be done within a process, or even within a computer, by local invocation, such as communication between different systems, or even between different organizations. Because computing power needs to be scaled horizontally, applications need to be deployed on a cluster of multiple machines,

RPC has many protocols, such as the RPC style of the earliest Corba,java rmi,web service, the Hessian,thrift, and even the rest API.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.