Non-original, only targeted summary: references are attached at the bottom
Noun explanation
- Remote Procedure Call (RPC)
- HyperText Transfer Protocol (HTTP)
RPC is mainly based on TCP/IP, while HTTP services are mainly based on HTTP, which as we all know is on top of TCP.
The RPC service
There are four core components in RPC architecture:
- A Client is the caller of a service.
- A Server is a real service provider.
- The Client Stub stores the address message of the server, packages the request parameters of the Client into network messages, and sends them to the server remotely over the network.
- The Server Stub receives the message sent by the client, unpacks the message, and invokes local methods.
Support synchronous and asynchronous invocation
The HTTP service
That is, RESTful service interfaces. The advantages are simplicity, directness and ease of development. Use the existing HTTP protocol for transport.
The interface may return a JSON string or an XML document. The returned information is then processed by the client, allowing for faster development.
RPC VS HTTP
For large enterprises, when there are many internal subsystems and many interfaces, the benefits of RPC framework will be shown. First of all, long links do not require three handshakes like HTTP for each communication, which reduces the network overhead. Secondly, RPC frameworks generally have registries and rich monitoring management. Publishing, offline interfaces, dynamic extensions, etc., are unaware and unified operations for callers.
1. Transport protocol
RPC, which can be based on TCP or HTTP
HTTP, based on HTTP protocol
2. Transmission efficiency
RPC uses the customized TCP protocol to reduce the size of request packets. HTTP2 can also reduce the size of request packets to improve transmission efficiency
HTTP, if the protocol is based on HTTP1.1, will contain a lot of useless content in the request, if it is based on HTTP2.0, then simple encapsulation below can be used as an RPC, then the standard RPC framework is more service governance
3. Performance consumption
This is mainly due to serialization and deserialization time
RPC, which can implement efficient binary transport HTTP based on THRIFT, mostly through JSON, is more performance costly in terms of byte size and serialization time
4. Load balancing
RPC, basically has its own load balancing policy HTTP, need to configure Nginx, HAProxy to achieve
5. Service governance (how does it not affect upstream callers when downstream services are added, restarted and offline?)
RPC, can achieve automatic notification, does not affect the upstream HTTP, need to notify in advance, modify Nginx/HAProxy configuration
The above comes from:
www.jianshu.com/p/b61695e6b…
Blog.csdn.net/wangyunpeng…