rpc对比http有啥好处

网上的文章我也看了不少, 可是老实说, 我还是没有决定性的觉得rpc比http好多了, 谁能给我说个原因嘛

tips:

  1. 正常内部接口用rpc, 外部用http
  2. rpc基于tcp, http是http

还有啥好处我就不写了, 目前我有点模糊, rpc的决定性优势在哪里, 有老铁指教嘛

阅读 2.7k
1 个回答

rpc 不是一个协议。rpc 也可以基于 rpc 实现。grpc 用的就是 protobuf over http/2。

这里说比 http 好,其实应该主要是比 http/1.x 好。http/1.x 作为一个历史悠久的协议,现在网页浏览上都已经开始不太能很好支撑现在复杂的网页了,用在 rpc 上就更力不从心了。

下面介绍 HTTP/2 的文章里说了一些 http/1.x 的问题:

From: Introduction to HTTP/2:

Unfortunately, implementation simplicity also came at a cost of application performance: HTTP/1.x clients need to use multiple connections to achieve concurrency and reduce latency; HTTP/1.x does not compress request and response headers, causing unnecessary network traffic; HTTP/1.x does not allow effective resource prioritization, resulting in poor use of the underlying TCP connection; and so on.
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进