- Building Microservices with Go
- Nic Jackson
- 418字
- 2021-07-15 17:28:13
RPC APIs
RPC stands for remote procedure call; it is a method of executing a function or method on a remote machine. RPC has been around since the dawn of time and there are many different types of RPC technology some of which relies on there being an interface definition (SOAP, Thrift Protocol Buffers). This interface definition can make it easier to generate client and server stubs for different technology stacks. Generally, the interface is defined using a DSL (domain specific language) and a generator program will use this to create application clients and servers.
Where REST needs to use HTTP as a transport layer, RPC is not bound by this constraint, and while it is possible to send RPC calls over HTTP, you can use the lightness of TCP or even UDP sockets if you choose to.
RPC has seen a resurgence in use lately with many large-scale systems built by the likes of Uber, Google, Netflix, and so on are using RPC. Due to the speed and performance that you can get from the lower latency from not using HTTP and the smaller message size attained by implementing a binary message format rather than JSON or XML.
The detractors of RPC mention the tight coupling that can occur between the client and the server in that if you update the contract on the server then all the clients need to be updated too. With many modern RPC implementations this is less of a problem and in fact is no less a problem than you can have with RESTful APIs. Whilst old technology such as JMI was tightly bound, requiring the client and the server to share the same interface, modern implementations such as Protocol Buffers marshal the object sensibly and will not throw an error should there be minor differences. Thus by following the standard guidelines in the Versioning APIs section you have no less a problem than if you were implementing a RESTful API.
One of the benefits of RPC is that you can quickly generate a client for your users, this allows an abstraction from both the transport and the message type and allows them to depend upon an interface. As the creator you can change the underlying implementation of your application such as a move from Thrift to Proto buffers, without requiring the client to do anything other than use the latest version of your provided client. Versioning also allows you to retain the same backward compatibility that you can achieve with REST.
- CentOS 7 Server Deployment Cookbook
- Rake Task Management Essentials
- Learning RabbitMQ
- Functional Programming in JavaScript
- Raspberry Pi 2 Server Essentials
- Web Application Development with MEAN
- C語言程序設計實踐教程
- 程序員修煉之道:通向務實的最高境界(第2版)
- 用戶體驗增長:數字化·智能化·綠色化
- 精通MATLAB(第3版)
- iOS開發實戰:從入門到上架App Store(第2版) (移動開發叢書)
- 學習OpenCV 4:基于Python的算法實戰
- R語言數據可視化:科技圖表繪制
- Hands-On Neural Network Programming with C#
- Go語言從入門到精通