Interview: What are the Differences Between RPC and HTTP?

Interview: What are the Differences Between RPC and HTTP?What are 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 HTTP protocol.

2. Transmission Efficiency

RPC, using a custom TCP protocol, can make the request payload smaller, or using HTTP2 protocol can also significantly reduce the payload size, improving transmission efficiency.

HTTP, if based on HTTP1.1 protocol, the request will contain a lot of unnecessary content. 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 is mostly 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, high transmission efficiency, and convenient service governance. HTTP is mainly used for external heterogeneous environments, browser interface calls, APP interface calls, third-party interface calls, etc.

————————–

Leave a Comment