rest and rpc

RPC: RPC (Remote Procedure Call) - Remote Procedure Call , which is a protocol that requests services from a remote computer program over a network without knowing the underlying network technology. Invoke the server's service (method) like a local service (method).

    RPC uses a client/server model. The requestor is a client, and the service provider is a server. First, the client calling process sends a call message with process parameters to the server process, and then waits for a reply message. On the server side, the process stays asleep until the call message arrives. When a call message arrives, the server obtains the process parameters, calculates the result, sends a reply message , and then waits for the next call message. Finally, the client calls the process to receive the reply message, obtain the process result, and then the call execution continues.

RESTful: is an architectural style, not a protocol. Check out my other blog: https://blog.csdn.net/zzzzzztt/article/details/80170228

Those that conform to the REST specification can be called RESTful. Based on the http protocol, REST regards all resources as resources, and the noun is the resource address. The operation of the resource is completed by adding the noun to the HTTP operation.

RPC: The subject in RPC is an action, a verb, which means what I want to do

The following is from: https://www.cnblogs.com/miketwais/articles/RPC_REST_SOA.html

Difference between RPC and REST

If you want to just remember one thing, then remember that  RPC is verb-centric, REST is noun-centric , where verbs refer to methods and nouns refer to resources.

You will find that verb-centric means that when you need to add new functions, you have to add more verbs. At this time, the server side needs to implement the corresponding verb (method), and the client needs to know this new verb and make a call.

With nouns as the center, if I request hostname/friends/, no matter how the service corresponding to this URI changes, the client does not need to pay attention and update, and this change is also transparent to the client.

As for other differences, such as dependency on the implementation language, coupling, etc., these are derived from the fundamental difference mentioned above.

When you use HTTP to surf every day, you are using REST to communicate with remote servers. When you use Gtalk to communicate with colleagues and friends, you are enjoying the convenience of RPC.

   Scenarios and options:

For example, if the company wants to do a social game project, and let you be responsible for the back-end architecture and communication of the entire system, it is necessary for us to carefully study and study the opening of social networking sites (games) such as facebook/renren.com/sina. API, we know that facebook uses the REST architecture, so even if facebook itself is developed in PHP, this does not prevent us from using python to develop, and there are more client API packages such as PHP, Java, .net, Perl, etc. In this way, it can be flexibly adapted to multi-terminal services.

So I was thinking, if facebook's architecture is not REST, will there be such flexibility? If it is using RPC, it may not be so convenient.

In addition, because our front-end uses flash, and the python communication with the back-end uses Django+Flex+AMF, if you know flash, you will know that AMF is a binary flash data exchange protocol, and  it is based on RPC  !

Therefore, we need to choose REST or RPC according to the current needs


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325213640&siteId=291194637
RPC
RPC