- 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.
- The DevOps 2.3 Toolkit
- jQuery EasyUI網(wǎng)站開發(fā)實戰(zhàn)
- 程序員考試案例梳理、真題透解與強(qiáng)化訓(xùn)練
- Implementing Cisco Networking Solutions
- Hands-On JavaScript High Performance
- 游戲程序設(shè)計教程
- Flux Architecture
- Yocto for Raspberry Pi
- Jupyter數(shù)據(jù)科學(xué)實戰(zhàn)
- 自然語言處理Python進(jìn)階
- Nginx實戰(zhàn):基于Lua語言的配置、開發(fā)與架構(gòu)詳解
- Mastering Unity 2D Game Development(Second Edition)
- RealSenseTM互動開發(fā)實戰(zhàn)
- ArcGIS for Desktop Cookbook
- Go語言開發(fā)實戰(zhàn)(慕課版)