https://github.com/andeya/erpc-book
Handbook of eRPC which is an efficient, extensible and easy-to-use RPC framework.
https://github.com/andeya/erpc-book
book doc erpc handbook manual
Last synced: 3 months ago
JSON representation
Handbook of eRPC which is an efficient, extensible and easy-to-use RPC framework.
- Host: GitHub
- URL: https://github.com/andeya/erpc-book
- Owner: andeya
- Created: 2019-11-15T02:34:05.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-18T07:15:29.000Z (almost 6 years ago)
- Last Synced: 2025-04-15T04:38:31.850Z (6 months ago)
- Topics: book, doc, erpc, handbook, manual
- Language: Go
- Homepage: https://henrylee2cn.github.io/erpc-book
- Size: 674 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# eRPC 使用手册
[eRPC](https://github.com/henrylee2cn/erpc) 是一个高效、可扩展且简单易用的 RPC 框架。
适用于 RPC、微服务、点对点长连接、IM 和游戏等领域。

## 安装
```sh
go get -u -f github.com/henrylee2cn/erpc
``````go
import "github.com/henrylee2cn/erpc/v6"
```## 特性
- 使用 peer 为 server 和 client 提供相同的 API 封装
- 提供多层抽象,如:
- peer
- session/socket
- router
- handle/context
- message
- protocol
- codec
- transfer filter
- plugin
- 支持平滑重启和关闭
- 兼容 HTTP 的消息格式:
- 由 `Header` 和 `Body` 两部分组成
- `Header` 包含与 HTTP header 格式相同的 metadata
- `Body` 支持类似 Content Type 的自定义编解码器,已经实现的:
- Protobuf
- Thrift
- JSON
- XML
- Form
- Plain
- 支持 push、call-reply 和更多的消息类型
- 支持自定义消息协议,并提供了一些常见实现:
- `rawproto` - 默认的高性能二进制协议
- `jsonproto` - JSON 消息协议
- `pbproto` - Ptotobuf 消息协议
- `thriftproto` - Thrift 消息协议
- `httproto` - HTTP 消息协议
- 可优化的高性能传输层
- 使用 Non-block socket 和 I/O 多路复用技术
- 支持设置套接字 I/O 的缓冲区大小
- 支持设置读取消息的大小(如果超过则断开连接)
- 支持控制连接的文件描述符
- 支持多种网络类型:
- `tcp`
- `tcp4`
- `tcp6`
- `unix`
- `unixpacket`
- `quic`
- 其他
- websocket
- evio
- 提供丰富的插件埋点,并已实现:
- auth
- binder
- heartbeat
- ignorecase(service method)
- overloader
- proxy(for unknown service method)
- secure
- 强大灵活的日志系统:
- 详细的日志信息,支持打印输入和输出详细信息
- 支持设置慢操作警报阈值
- 支持自定义实现日志组件
- 客户端会话支持在断开连接后自动重拨## 性能测试
**自测**
- 一个服务端与一个客户端进程,在同一台机器上运行
- CPU: Intel Xeon E312xx (Sandy Bridge) 16 cores 2.53GHz
- Memory: 16G
- OS: Linux 2.6.32-696.16.1.el6.centos.plus.x86_64, CentOS 6.4
- Go: 1.9.2
- 信息大小: 581 bytes
- 信息编码:protobuf
- 发送 1000000 条信息- erpc
| 并发client | 平均值(ms) | 中位数(ms) | 最大值(ms) | 最小值(ms) | 吞吐率(TPS) |
| -------- | ------- | ------- | ------- | ------- | -------- |
| 100 | 1 | 0 | 16 | 0 | 75505 |
| 500 | 9 | 11 | 97 | 0 | 52192 |
| 1000 | 19 | 24 | 187 | 0 | 50040 |
| 2000 | 39 | 54 | 409 | 0 | 42551 |
| 5000 | 96 | 128 | 1148 | 0 | 46367 |- erpc/socket
| 并发client | 平均值(ms) | 中位数(ms) | 最大值(ms) | 最小值(ms) | 吞吐率(TPS) |
| -------- | ------- | ------- | ------- | ------- | -------- |
| 100 | 0 | 0 | 14 | 0 | 225682 |
| 500 | 2 | 1 | 24 | 0 | 212630 |
| 1000 | 4 | 3 | 51 | 0 | 180733 |
| 2000 | 8 | 6 | 64 | 0 | 183351 |
| 5000 | 21 | 18 | 651 | 0 | 133886 |**对比测试**
EnvironmentThroughputsMean LatencyP99 Latency
![]()
![]()
![]()
**[More Detail](https://github.com/henrylee2cn/rpc-benchmark)**
- CPU耗时火焰图 erpc/socket

**[svg file](https://github.com/henrylee2cn/erpc/raw/master/doc/erpc_socket_profile_torch.svg)**
- 堆栈信息火焰图 erpc/socket

**[svg file](https://github.com/henrylee2cn/erpc/raw/master/doc/erpc_socket_heap_torch.svg)**
## 企业用户
## 附
eRPC 原名 Teleport,以下是一些相关介绍文章,可供参考:
1. [《Go Socket编程之teleport框架是怎样炼成的?》](https://github.com/henrylee2cn/tpdoc/blob/master/01/README.md)
2. [《聊聊 Go Socket 框架 Teleport 的设计思路》](https://github.com/henrylee2cn/tpdoc/blob/master/02/README.md)