- 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.
- 程序員面試筆試寶典
- Building a RESTful Web Service with Spring
- Web交互界面設計與制作(微課版)
- 實戰(zhàn)低代碼
- 基于差分進化的優(yōu)化方法及應用
- 從0到1:Python數(shù)據(jù)分析
- C語言程序設計上機指導與習題解答(第2版)
- RESTful Web Clients:基于超媒體的可復用客戶端
- C指針原理揭秘:基于底層實現(xiàn)機制
- Java7程序設計入門經(jīng)典
- OpenCV Android開發(fā)實戰(zhàn)
- UI動效設計從入門到精通
- Less Web Development Cookbook
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- C語言程序設計