{"id":20608801,"url":"https://github.com/andeya/erpc-book","last_synced_at":"2025-07-15T17:36:50.954Z","repository":{"id":88419577,"uuid":"221828273","full_name":"andeya/erpc-book","owner":"andeya","description":"Handbook of eRPC which is an efficient, extensible and easy-to-use RPC framework.","archived":false,"fork":false,"pushed_at":"2019-11-18T07:15:29.000Z","size":690,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T04:38:31.850Z","etag":null,"topics":["book","doc","erpc","handbook","manual"],"latest_commit_sha":null,"homepage":"https://henrylee2cn.github.io/erpc-book","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andeya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://github.com/henrylee2cn/erpc/issues/73"}},"created_at":"2019-11-15T02:34:05.000Z","updated_at":"2022-02-27T17:30:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"82e074c1-bb76-4c58-9180-4fba2334491a","html_url":"https://github.com/andeya/erpc-book","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andeya/erpc-book","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andeya%2Ferpc-book","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andeya%2Ferpc-book/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andeya%2Ferpc-book/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andeya%2Ferpc-book/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andeya","download_url":"https://codeload.github.com/andeya/erpc-book/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andeya%2Ferpc-book/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265450576,"owners_count":23767649,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["book","doc","erpc","handbook","manual"],"created_at":"2024-11-16T10:11:53.993Z","updated_at":"2025-07-15T17:36:50.946Z","avatar_url":"https://github.com/andeya.png","language":"Go","funding_links":["https://github.com/henrylee2cn/erpc/issues/73"],"categories":[],"sub_categories":[],"readme":"# eRPC 使用手册\n\n[eRPC](https://github.com/henrylee2cn/erpc) 是一个高效、可扩展且简单易用的 RPC 框架。\n\n适用于 RPC、微服务、点对点长连接、IM 和游戏等领域。\n\n![eRPC-Framework](https://github.com/henrylee2cn/erpc/raw/master/doc/erpc_module_diagram.png)\n\n\n## 安装\n\n```sh\ngo get -u -f github.com/henrylee2cn/erpc\n```\n\n```go\nimport \"github.com/henrylee2cn/erpc/v6\"\n```\n\n## 特性\n\n- 使用 peer 为 server 和 client 提供相同的 API 封装\n- 提供多层抽象，如：\n  - peer\n  - session/socket\n  - router\n  - handle/context\n  - message\n  - protocol\n  - codec\n  - transfer filter\n  - plugin\n- 支持平滑重启和关闭\n- 兼容 HTTP 的消息格式：\n  - 由 `Header` 和 `Body` 两部分组成\n  - `Header` 包含与 HTTP header 格式相同的 metadata\n  - `Body` 支持类似 Content Type 的自定义编解码器，已经实现的：\n    - Protobuf\n    - Thrift\n    - JSON\n    - XML\n    - Form\n    - Plain\n  - 支持 push、call-reply 和更多的消息类型\n- 支持自定义消息协议，并提供了一些常见实现：\n  - `rawproto` - 默认的高性能二进制协议\n  - `jsonproto` - JSON 消息协议\n  - `pbproto` - Ptotobuf 消息协议\n  - `thriftproto` - Thrift 消息协议\n  - `httproto` - HTTP 消息协议\n- 可优化的高性能传输层\n  - 使用 Non-block socket 和 I/O 多路复用技术\n  - 支持设置套接字 I/O 的缓冲区大小\n  - 支持设置读取消息的大小（如果超过则断开连接）\n  - 支持控制连接的文件描述符\n- 支持多种网络类型：\n  - `tcp`\n  - `tcp4`\n  - `tcp6`\n  - `unix`\n  - `unixpacket`\n  - `quic`\n  - 其他\n    - websocket\n    - evio\n- 提供丰富的插件埋点，并已实现：\n  - auth\n  - binder\n  - heartbeat\n  - ignorecase(service method)\n  - overloader\n  - proxy(for unknown service method)\n  - secure\n- 强大灵活的日志系统：\n  - 详细的日志信息，支持打印输入和输出详细信息\n  - 支持设置慢操作警报阈值\n  - 支持自定义实现日志组件\n- 客户端会话支持在断开连接后自动重拨\n\n\n## 性能测试\n\n**自测**\n\n- 一个服务端与一个客户端进程，在同一台机器上运行\n- CPU:    Intel Xeon E312xx (Sandy Bridge) 16 cores 2.53GHz\n- Memory: 16G\n- OS:     Linux 2.6.32-696.16.1.el6.centos.plus.x86_64, CentOS 6.4\n- Go:     1.9.2\n- 信息大小: 581 bytes\n- 信息编码：protobuf\n- 发送 1000000 条信息\n\n- erpc\n\n| 并发client | 平均值(ms) | 中位数(ms) | 最大值(ms) | 最小值(ms) | 吞吐率(TPS) |\n| -------- | ------- | ------- | ------- | ------- | -------- |\n| 100      | 1       | 0       | 16      | 0       | 75505    |\n| 500      | 9       | 11      | 97      | 0       | 52192    |\n| 1000     | 19      | 24      | 187     | 0       | 50040    |\n| 2000     | 39      | 54      | 409     | 0       | 42551    |\n| 5000     | 96      | 128     | 1148    | 0       | 46367    |\n\n- erpc/socket\n\n| 并发client | 平均值(ms) | 中位数(ms) | 最大值(ms) | 最小值(ms) | 吞吐率(TPS) |\n| -------- | ------- | ------- | ------- | ------- | -------- |\n| 100      | 0       | 0       | 14      | 0       | 225682   |\n| 500      | 2       | 1       | 24      | 0       | 212630   |\n| 1000     | 4       | 3       | 51      | 0       | 180733   |\n| 2000     | 8       | 6       | 64      | 0       | 183351   |\n| 5000     | 21      | 18      | 651     | 0       | 133886   |\n\n**对比测试**\n\n\u003ctable\u003e\n\u003ctr\u003e\u003cth\u003eEnvironment\u003c/th\u003e\u003cth\u003eThroughputs\u003c/th\u003e\u003cth\u003eMean Latency\u003c/th\u003e\u003cth\u003eP99 Latency\u003c/th\u003e\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd width=\"10%\"\u003e\u003cimg src=\"https://github.com/henrylee2cn/rpc-benchmark/raw/master/result/env.png\"\u003e\u003c/td\u003e\n\u003ctd width=\"30%\"\u003e\u003cimg src=\"https://github.com/henrylee2cn/rpc-benchmark/raw/master/result/throughput.png\"\u003e\u003c/td\u003e\n\u003ctd width=\"30%\"\u003e\u003cimg src=\"https://github.com/henrylee2cn/rpc-benchmark/raw/master/result/mean_latency.png\"\u003e\u003c/td\u003e\n\u003ctd width=\"30%\"\u003e\u003cimg src=\"https://github.com/henrylee2cn/rpc-benchmark/raw/master/result/p99_latency.png\"\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n**[More Detail](https://github.com/henrylee2cn/rpc-benchmark)**\n\n- CPU耗时火焰图 erpc/socket\n\n![erpc_socket_profile_torch](https://github.com/henrylee2cn/erpc/raw/master/doc/erpc_socket_profile_torch.png)\n\n**[svg file](https://github.com/henrylee2cn/erpc/raw/master/doc/erpc_socket_profile_torch.svg)**\n\n- 堆栈信息火焰图 erpc/socket\n\n![erpc_socket_heap_torch](https://github.com/henrylee2cn/erpc/raw/master/doc/erpc_socket_heap_torch.png)\n\n**[svg file](https://github.com/henrylee2cn/erpc/raw/master/doc/erpc_socket_heap_torch.svg)**\n\n\n## 企业用户\n\n\u003ca href=\"http://www.xiaoenai.com\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/henrylee2cn/imgs-repo/master/xiaoenai.png\" height=\"50\" alt=\"深圳市梦之舵信息技术有限公司\"/\u003e\u003c/a\u003e\n\u0026nbsp;\u0026nbsp;\n\u003ca href=\"https://tech.pingan.com/index.html\"\u003e\u003cimg src=\"http://pa-tech.hirede.com/templates/pa-tech/Images/logo.png\" height=\"50\" alt=\"平安科技\"/\u003e\u003c/a\u003e\n\u003cbr/\u003e\n\u003ca href=\"http://www.fun.tv\"\u003e\u003cimg src=\"http://static.funshion.com/open/static/img/logo.gif\" height=\"70\" alt=\"北京风行在线技术有限公司\"/\u003e\u003c/a\u003e\n\u0026nbsp;\u0026nbsp;\n\u003ca href=\"http://www.kejishidai.cn\"\u003e\u003cimg src=\"http://simg.ktvms.com/picture/logo.png\" height=\"70\" alt=\"北京可即时代网络公司\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://www.kuaishou.com/\"\u003e\u003cimg src=\"https://inews.gtimg.com/newsapp_bt/0/4400789257/1000\" height=\"70\" alt=\"快手短视频平台\"/\u003e\u003c/a\u003e\n\n## 附\n\neRPC 原名 Teleport，以下是一些相关介绍文章，可供参考：\n\n1. [《Go Socket编程之teleport框架是怎样炼成的？》](https://github.com/henrylee2cn/tpdoc/blob/master/01/README.md)\n2. [《聊聊 Go Socket 框架 Teleport 的设计思路》](https://github.com/henrylee2cn/tpdoc/blob/master/02/README.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandeya%2Ferpc-book","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandeya%2Ferpc-book","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandeya%2Ferpc-book/lists"}