RPC: dignified programmer should know something about RPC

From the micro-distributed to service, Internet companies pay more attention to high-performance and high availability, here, I want to write about that point thing about the RPC. If a developer does not know what is RPC, I am embarrassed to say where is the Internet company's own property company.

model

Architects started when a building should have a sand table, can be considered a model to build its aesthetic and architectural principles, the same RPC, RPC concept appears very early, and later in Bruce Jay Nelson's thesis, defines the RPC call standard. All RPC rear frame are in accordance with this standard pattern. The so-called RPC (Remote Procedure Call) Remote Procedure Call.

Ideas and remote operation of remote calls are the same, just as you do locally. So NFS protocol is RPC-based implementation. Of course, no matter what RPC, are the underlying Socket programming.

Bloggers in your sleep: can also be achieved by remote RPC, can also be implemented in the form of a URL, then use RPC what good is it? RPC Interface Socket go directly to speed up the transmission speed services, URL need to go through the data link layer, network layer, transport layer, application layer go step by step, the performance should have a big gap. These represent only bloggers immature point of view.

SOAP

SOAP, the full name of the Simple Object Access Protocol (Simple Object Access Protocol). It uses a simple request and reply messages written in XML, and HTTP transmission protocol.

SOAP requests and responses in one envelope inside, just the same as a mail delivery. A letter inside the envelope sub-header and text.

POST /purchaseOrder HTTP/1.1
Host: www.zhuangbfan.com
Content-Type: application/xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<order>
<date>2019-07-31</date>
<className>RPC学习笔记</className>
<Author>stark</Author>
<price>99</price>
</order>

And XML format can be changed to another simple text representation of an object format JSON. JSON better Js compatible and PHP language, programming style is more we receive and love.

{
  "head": {
    "status": 500,
    "hasMore": false
  },
  "body": "网络异常,请稍候重试"
}

Often write Web applications should have been found, and this is the way the RESTful API format.

RESTful

When working in the former company's main duties is to write and client interaction interfaces, each iteration version of the process is the usual demand, technical review, and update wiki to write code ... but every time iterative version had difficulty, so on the use of RESTful Api.

RESTful:全称Representational State Transfer,更多可以说的是一种架构风格,加上json的方便快捷,越来越成为互联网的Api的标准。

特点:

  • API必须有版本的概念,v1,v2,v3
  • 使用Token令牌来做用户身份的校验与权限分级,而不是Cookie。
  • url中大小写不敏感,不要出现大写字母
  • 使用 - 而不是使用 _ 做URL路径中字符串连接。
  • 有一份漂亮的文档~(很重要)

总结

微服务的诞生于多容器之间的链接,RPC的方便快捷了远程服务,让程序像调用自己的本地服务一样快捷、简单、方便,可跨语言、只要定义相同的协议就好了。如果后面有新的认识,在更新文章。

谢谢你的阅读。
En。

发布了98 篇原创文章 · 获赞 185 · 访问量 9万+

Guess you like

Origin blog.csdn.net/xuezhiwu001/article/details/97945523
RPC
RPC