分布式服务 RPC 简介
一、简述
- wiki 介绍
- remote procedure call
- procedure [prəˈsiːdʒə®] 过程
- subroutine [ˈsʌbruːtiːn] 子程序
- 核心:
像调用本地方法一样调用远程方法
In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure (subroutine) to execute in a different address space (commonly on another computer on a shared network), which is coded as if it were a normal (local) procedure call, without the programmer explicitly coding the details for the remote interaction
- 核心流程
Clinet Method Server Method
↓ ↑
Clinet Stub Server Stub
↓ ↑
Serialization - Network → Deserialization
-- request ----------------------------------
------------------------------------ reply --
Deserialization ← Network - Serialization
↓ ↑
Clinet Stub Server Stub
↓ ↑
Clinet Method Server Method
二、原理
- RPC 设计实现
-
核心:
实体定义
、接口定义
-
IDL
- 接口定义语言 Interface Difinition Language
- JNI、JSON-WSP、WADL、WSDL
- Protocol Buffers、RESTful Service Description Language (RSDL)
- 序列化
- 编程语言内置
- 二进制
- Hession
- Avro
- Kryo
- FST (fast-serialization)
- 通用
- XML
- JSON
- 网络协议
- http/https
- tcp/udp
三、框架/工具
- gRPC
- Thrift
- Protocol Buffer
- Dubbo
- Finagle
- Spring Cloud