RPC Implementation Summary

There are many implementations of RPC. I saw a friend's summary on Zhihu and felt that it was very comprehensive (without verifying each one), and recorded it for review and research. Know the post address: https://www.zhihu.com/question/25536695

 

Author: Ma Bingyao
Link : https://www.zhihu.com/question/25536695/answer/109977506
Source: Zhihu The
copyright belongs to the author, please contact the author for authorization.

What is RPC (Remote Procedure Call)

  • Simply put, RPC is to call a function or method (which can be collectively referred to as a service) on another machine (server) by passing parameters from one machine (client) and get the returned result.
  • RPC will hide the underlying communication details (no need to deal with Socket communication or Http communication directly)
  • RPC is a request-response model. The client initiates a request and the server returns a response (similar to how Http works)
  • RPC uses the same form as calling a local function (or method) to call a remote function (or method).

The history of remote procedure call

  • ONC RPC (Remote Procedure Call for Open Network Computing), OSF RPC (Open Software Foundation's Remote Procedure Call)
  • CORBA (Common Object Request Broker Architecture Common Object Request Broker Architecture)
  • DCOM (Distributed Component Object Model), COM+
  • Java RMI
  • .NET Remoting
  • XML-RPC,SOAP,Web Service
  • PHPRPC,Hessian,JSON-RPC
  • Microsoft WCF,WebAPI
  • ZeroC Ice,Thrift,GRPC
  • Hprose

early RPC

  • The first generation of RPC (ONC RPC, OSF RPC) does not support passing objects.
  • CORBA is too complicated, and the various implementations are incompatible, and the average programmer can't play it.
  • DCOM, COM+ cannot escape the palm of Windows.
  • RMI can only be played in Java.
  • .NET Remoting can only be played on the .NET platform.

XML-RPC,SOAP,WebService

  • There is too much redundant data and the processing speed is too slow.
  • RPC-style Web Services are poorly cross-language, and Document-style Web Services are too difficult to use.
  • Web services don't solve the user's real problem, they just turn one problem into another.
  • The specification for Web Services is so complex that there is no really useful, or even usable, implementation outside of the .NET and Java platforms.
  • Cross-language and cross-platform is just a slogan of Web Services, although many people believe this, but in fact it does not really come true.

PHPRPC

  • Based on PHP's built-in serialization format, there are flaws in cross-language type mapping.
  • The communication relies on the HTTP protocol, and there is no choice of other underlying communication methods.
  • The built-in encrypted transmission is both a feature and a drawback.
  • While faster than XML-based RPC, it's not fast enough.

Hessian

  • The binary data format is completely unreadable.
  • The official only provides two and a half language implementations (Java, ActionScript and the less-than-perfect Python implementation), and third-party implementations in other languages ​​are mixed.
  • Not enough languages ​​are supported, and there is a complete disregard for JavaScript on the web front end.
  • Although it is a dynamic RPC, it is still not very dynamic.
  • While faster than XML-based RPC, it's not fast enough.

JSON-RPC

  • JSON is text-readable and more concise than XML.
  • JSON is limited by a subset of the JavaScript language and cannot represent enough data types.
  • The JSON format cannot represent self-references, mutual references and circular references within the data.
  • Some languages ​​have multiple versions of the implementation, but there is no unified standard for type insinuation, and there are compatibility problems.
  • Although JSON-RPC has a specification, there is no unified implementation. The respective implementations in different languages ​​have compatibility problems and cannot really communicate with each other.

Microsoft WCF,WebAPI

  • They are Microsoft's unified encapsulation of existing technologies on a .NET platform, and an integration of technologies such as .NET Remoting, WebService, and REST-style services based on data formats such as JSON and XML.
  • Although it claims to be able to call these services outside the .NET platform, it is actually completely different from calling within the .NET platform. It doesn't provide any tools that can be used in the languages ​​of other platforms.

ZeroC Ice,Thrift,GRPC

  • A cross-language object-oriented return to the original RPC technology.
  • Type and interface definitions still need to be written through an intermediate language.
  • You still need code generators to translate type and interface definitions written in the intermediate language into client-side and server-side stubs for your programming language.
  • You have to write the service separately based on the generated server code, you cannot publish the existing code directly as a service.
  • You have to use the generated client code to call the service, there is no other more flexible way.
  • If your intermediate code is modified, you must repeat all the above steps at least once.

Hprose

  • Non-intrusive design, no need to define types separately, no need to write services separately, existing code can be directly published as services.
  • With rich data types and perfect cross-language type mapping, it supports self-reference, mutual reference and circular reference data.
  • Supports many transmission methods, such as HTTP, TCP, Websocket, etc.
  • The client has a more flexible calling method, supports synchronous calling, asynchronous calling, dynamic parameters, variable parameters, reference parameter passing, multiple result return (Golang) and other language features, Hprose 2.0 even supports push.
  • It has good scalability, and can achieve various functional extensions such as encryption, compression, caching, and proxy through filters and middleware.
  • Compatible indiscriminate cross-language calls
  • Support for more common languages ​​and platforms
  • Supports cross-domain calls on the browser side
  • No intermediate language, no learning cost
  • Great performance and easy to use

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326839615&siteId=291194637