01Please explain the differences between RPC and HTTP?
1. Differences:
1. Transmission Protocol
RPC can be based on TCP protocol or HTTP protocol.
HTTP is based on the HTTP protocol.
2. Transmission Efficiency
RPC, using a custom TCP protocol, can make the request payload smaller, or by using HTTP2 protocol, it can also significantly reduce the payload size and improve transmission efficiency.
HTTP, if based on HTTP1.1 protocol, will include a lot of unnecessary content in the request. If based on HTTP2.0, then a simple encapsulation can be used as an RPC, where standard RPC frameworks focus more on service governance.
3. Performance Consumption, mainly in the time taken for serialization and deserialization
RPC can achieve high-efficiency binary transmission based on Thrift.
HTTP, most of the time, is implemented through JSON, which consumes more performance in terms of byte size and serialization time compared to Thrift.
4. Load Balancing
RPC generally comes with built-in load balancing strategies.
HTTP requires configuration of Nginx or HAProxy to implement.
5. Service Governance (how to avoid affecting upstream callers when adding, restarting, or taking down downstream services)
RPC can automatically notify without affecting upstream.
HTTP requires prior notification and modification of Nginx/HAProxy configuration.
2. Summary:
RPC is mainly used for internal service calls within a company, with low performance consumption and high transmission efficiency, making service governance convenient. HTTP is mainly used for external heterogeneous environments, such as browser interface calls, APP interface calls, and third-party interface calls.
————————–