Traditional Culture Encyclopedia - Traditional culture - What's the difference between rpc and http? What are their advantages and disadvantages?

What's the difference between rpc and http? What are their advantages and disadvantages?

It is very useful for large-scale, multi-organization and uncontrollable information systems. In contrast, the mechanism of rpc is defined according to the language API, not according to the network-based application.

The advantages and disadvantages of HTTP and RPC mainly explain the similarities and differences between HTTP and RPC, so that everyone can choose a more suitable scheme according to their actual situation.

transport protocols

RPC: It can be based on TCP protocol or HTTP protocol.

HTTP: based on HTTP protocol

transmission efficiency

RPC: Using the customized TCP protocol can make the request message smaller, or using the HTTP2 protocol can also reduce the message size and improve the transmission efficiency.

HTTP: If the protocol is based on HTTP 1. 1, the request will contain a lot of useless content. If it is based on HTTP2.0, then simple encapsulation can be used as RPC. At this point, the standard RPC framework is more about service governance.

Performance consumption

RPC: Efficient binary transmission can be achieved based on thrift.

HTTP: Most of them are implemented in json, and the byte size and serialization time are more expensive than frugality.

load leveling

RPC: Basically, they all have their own load balancing strategies.

HTTP: Nginx and HAProxy need to be configured to implement.

Service governance

RPC: Automatic notification can be realized without affecting the upstream.

The configuration of HTTP:Nginx/ha proxy needs to be modified in advance.

abstract

RPC is mainly used for internal service calling, with low performance consumption, high transmission efficiency and convenient service governance. HTTP is mainly used in external heterogeneous environment, browser interface call, APP interface call, third-party interface call and so on.