{"id":13629794,"url":"https://github.com/sogou/srpc","last_synced_at":"2025-12-25T16:54:34.540Z","repository":{"id":37002459,"uuid":"295369297","full_name":"sogou/srpc","owner":"sogou","description":"RPC framework based on C++ Workflow. Supports SRPC, Baidu bRPC, Tencent tRPC, thrift protocols.","archived":false,"fork":false,"pushed_at":"2025-05-09T14:05:23.000Z","size":1573,"stargazers_count":2026,"open_issues_count":32,"forks_count":397,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-05-09T15:24:24.084Z","etag":null,"topics":["brpc","opentelemetry","protobuf","rpc","thrift","trpc","workflow"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sogou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2020-09-14T09:35:14.000Z","updated_at":"2025-05-09T14:05:27.000Z","dependencies_parsed_at":"2023-02-17T20:46:06.732Z","dependency_job_id":"386fa872-260d-468b-ab31-7947119e8f83","html_url":"https://github.com/sogou/srpc","commit_stats":{"total_commits":588,"total_committers":26,"mean_commits":"22.615384615384617","dds":0.5289115646258503,"last_synced_commit":"bb882f98820bff7fa91aa83b29640fa753e11772"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogou%2Fsrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogou%2Fsrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogou%2Fsrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sogou%2Fsrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sogou","download_url":"https://codeload.github.com/sogou/srpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076850,"owners_count":22010611,"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":["brpc","opentelemetry","protobuf","rpc","thrift","trpc","workflow"],"created_at":"2024-08-01T22:01:19.750Z","updated_at":"2025-12-25T16:54:34.535Z","avatar_url":"https://github.com/sogou.png","language":"C++","readme":"[中文版入口](README_cn.md)\n\n\u003cbr/\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/wiki/sogou/srpc/srpc-logo-min.png\" width = \"140\" height = \"40\" alt=\"srpc-logo\"/\u003e\n\n\u003ca href=\"https://github.com/sogou/srpc/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/sogou/srpc?color=379c9c\u0026style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://en.cppreference.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/language-C++-black.svg?color=379c9c\u0026style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-black.svg?color=379c9c\u0026style=flat-square\"\u003e\u003cimg src=\"https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-black.svg?color=379c9c\u0026style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/sogou/srpc/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/sogou/srpc?color=379c9c\u0026logoColor=ffffff\u0026style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/sogou/srpc/actions?query=workflow%3A%22ci+build%22++\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/sogou/srpc/ci.yml?branch=master\u0026color=379c9c\u0026style=flat-square\"/\u003e\u003c/a\u003e\n\n### NEW !!!  👉 [SRPC tools : build Workflow and SRPC projects easily.](/tools/README.md)\n\n## Introduction\n\n**SRPC is an enterprise-level RPC system used by almost all online services in Sogou. It handles tens of billions of requests every day, covering searches, recommendations, advertising system, and other types of services.**\n\nBases on [Sogou C++ Workflow](https://github.com/sogou/workflow), it is an excellent choice for high-performance, low-latency, lightweight RPC systems. Contains AOP aspect-oriented modules that can report Metrics and Trace to a variety of cloud-native systems, such as OpenTelemetry, etc.\n\nIts main features include:\n\n  * Support multiple RPC protocols: [`SRPC`](/tutorial/tutorial-01-srpc_pb_server.cc), [`bRPC`](/tutorial/tutorial-05-brpc_pb_server.cc), [`Thrift`](/tutorial/tutorial-07-thrift_thrift_server.cc), [`tRPC`](/tutorial/tutorial-11-trpc_pb_server.cc)\n  * Support multiple operating systems: `Linux`, `MacOS`, `Windows`\n  * Support several IDL formats: [`Protobuf`](/tutorial/echo_pb.proto), [`Thrift`](/tutorial/echo_thrift.thrift)\n  * Support several data formats transparently: `Json`, `Protobuf`, `Thrift Binary`\n  * Support several compression formats, the framework automatically decompresses: `gzip`, `zlib`, `snappy`, `lz4`\n  * Support several communication protocols transparently: `tcp`, `udp`, `sctp`, `tcp ssl`\n  * With [HTTP+JSON](/docs/docs-07-srpc-http.md), you can communicate with the client or server in any language\n  * Use it together with [Workflow Series and Parallel](/docs/docs-06-workflow.md) to facilitate the use of calculations and other asynchronous resources\n  * Perfectly compatible with all Workflow functions, such as name service, [upstream](docs/docs-06-workflow.md#3-upstream) and other components\n  * Report [Tracing](/docs/docs-08-tracing.md) to [OpenTelemetry](https://opentelemetry.io)\n  * Report [Metrics](/docs/docs-09-metrics.md) to [OpenTelemetry](https://opentelemetry.io) and [Prometheus](https://prometheus.io)\n  * [More features...](/docs/en/rpc.md)\n\n## Installation\n\nsrpc has been packaged for Debian and Fedora. Therefore, we can install it from source code or from the package in the system.\n\nreference: [Linux, MacOS, Windows Installation and Compilation Guide](docs/en/installation.md)\n\n## Quick Start\n\nLet's quickly learn how to use it in a few steps.\n\nFor more detailed usage, please refer to [Documents](/docs) and [Tutorial](/tutorial).\n\n#### 1\\. example.proto\n\n~~~proto\nsyntax = \"proto3\";// You can use either proto2 or proto3. Both are supported by srpc\n\nmessage EchoRequest {\n    string message = 1;\n    string name = 2;\n};\n\nmessage EchoResponse {\n    string message = 1;\n};\n\nservice Example {\n    rpc Echo(EchoRequest) returns (EchoResponse);\n};\n~~~\n\n#### 2\\. generate code\n\n~~~sh\nprotoc example.proto --cpp_out=./ --proto_path=./\nsrpc_generator protobuf ./example.proto ./\n~~~\n\n#### 3\\. server.cc\n\n~~~cpp\n#include \u003cstdio.h\u003e\n#include \u003csignal.h\u003e\n#include \"example.srpc.h\"\n\nusing namespace srpc;\n\nclass ExampleServiceImpl : public Example::Service\n{\npublic:\n    void Echo(EchoRequest *request, EchoResponse *response, RPCContext *ctx) override\n    {\n        response-\u003eset_message(\"Hi, \" + request-\u003ename());\n        printf(\"get_req:\\n%s\\nset_resp:\\n%s\\n\",\n                request-\u003eDebugString().c_str(), response-\u003eDebugString().c_str());\n    }\n};\n\nvoid sig_handler(int signo) { }\n\nint main()\n{\n    signal(SIGINT, sig_handler);\n    signal(SIGTERM, sig_handler);\n\n    SRPCServer server_tcp;\n    SRPCHttpServer server_http;\n\n    ExampleServiceImpl impl;\n    server_tcp.add_service(\u0026impl);\n    server_http.add_service(\u0026impl);\n\n    server_tcp.start(1412);\n    server_http.start(8811);\n    getchar(); // press \"Enter\" to end.\n    server_http.stop();\n    server_tcp.stop();\n\n    return 0;\n}\n~~~\n\n#### 4\\. client.cc\n\n~~~cpp\n#include \u003cstdio.h\u003e\n#include \"example.srpc.h\"\n\nusing namespace srpc;\n\nint main()\n{\n    Example::SRPCClient client(\"127.0.0.1\", 1412);\n    EchoRequest req;\n    req.set_message(\"Hello, srpc!\");\n    req.set_name(\"workflow\");\n\n    client.Echo(\u0026req, [](EchoResponse *response, RPCContext *ctx) {\n        if (ctx-\u003esuccess())\n            printf(\"%s\\n\", response-\u003eDebugString().c_str());\n        else\n            printf(\"status[%d] error[%d] errmsg:%s\\n\",\n                    ctx-\u003eget_status_code(), ctx-\u003eget_error(), ctx-\u003eget_errmsg());\n    });\n\n    getchar(); // press \"Enter\" to end.\n    return 0;\n}\n~~~\n\n#### 5\\. make\n\nThese compile commands are only for Linux system. On other system, complete cmake in [tutorial](/tutorial) is recommended.\n\n~~~sh\ng++ -o server server.cc example.pb.cc -std=c++11 -lsrpc\ng++ -o client client.cc example.pb.cc -std=c++11 -lsrpc\n~~~\n\n#### 6\\. run\n\nTerminal 1:\n\n~~~sh\n./server\n~~~\n\nTerminal 2:\n\n~~~sh\n./client\n~~~\n\nWe can also use CURL to post Http request:\n\n~~~sh\ncurl 127.0.0.1:8811/Example/Echo -H 'Content-Type: application/json' -d '{message:\"from curl\",name:\"CURL\"}'\n~~~\n\nOutput of Terminal 1:\n\n~~~sh\nget_req:\nmessage: \"Hello, srpc!\"\nname: \"workflow\"\n\nset_resp:\nmessage: \"Hi, workflow\"\n\nget_req:\nmessage: \"from curl\"\nname: \"CURL\"\n\nset_resp:\nmessage: \"Hi, CURL\"\n\n~~~\n\nOutput of Terminal 2:\n\n~~~sh\nmessage: \"Hi, workflow\"\n~~~\n\nOutput of CURL:\n\n~~~sh\n{\"message\":\"Hi, CURL\"}\n~~~\n\n## Benchmark\n\n* CPU 2-chip/8-core/32-processor Intel(R) Xeon(R) CPU E5-2630 v3 @2.40GHz\n* Memory all 128G\n* 10 Gigabit Ethernet\n* BAIDU brpc-client in pooled (connection pool) mode\n\n#### QPS at cross-machine single client→ single server under different concurrency\n\n~~~\nClient = 1\nClientThread = 64, 128, 256, 512, 1024\nRequestSize = 32\nDuration = 20s\nServer = 1\nServerIOThread = 16\nServerHandlerThread = 16\n~~~\n\n![IMG](/docs/images/benchmark2.png)\n\n#### QPS at cross-machine multi-client→ single server under different client processes\n\n~~~\nClient = 1, 2, 4, 8, 16\nClientThread = 32\nRequestSize = 32\nDuration = 20s\nServer = 1\nServerIOThread = 16\nServerHandlerThread = 16\n~~~\n\n![IMG](/docs/images/benchmark4.png)\n\n#### QPS at same-machine single client→ single server under different concurrency\n\n~~~\nClient = 1\nClientThread = 1, 2, 4, 8, 16, 32, 64, 128, 256\nRequestSize = 1024\nDuration = 20s\nServer = 1\nServerIOThread = 16\nServerHandlerThread = 16\n~~~\n\n![IMG](/docs/images/benchmark3.png)\n\n#### QPS at same-machine single client→ single server under different request sizes\n\n~~~\nClient = 1\nClientThread = 100\nRequestSize = 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768\nDuration = 20s\nServer = 1\nServerIOThread = 16\nServerHandlerThread = 16\n~~~\n\n![IMG](/docs/images/benchmark1.png)\n\n#### Latency CDF for fixed QPS at same-machine single client→ single server \n\n~~~\nClient = 1\nClientThread = 50\nClientQPS = 10000\nRequestSize = 1024\nDuration = 20s\nServer = 1\nServerIOThread = 16\nServerHandlerThread = 16\nOutlier = 1%\n~~~\n\n![IMG](/docs/images/benchmark5.png)\n\n#### Latency CDF for fixed QPS at cross-machine multi-client→ single server \n\n~~~\nClient = 32\nClientThread = 16\nClientQPS = 2500\nRequestSize = 512\nDuration = 20s\nServer = 1\nServerIOThread = 16\nServerHandlerThread = 16\nOutlier = 1%\n~~~\n\n![IMG](/docs/images/benchmark6.png)\n\n## Contact\n\n* **Email** - **[liyingxin@sogou-inc.com](mailto:liyingxin@sogou-inc.com)** - main author\n* **Issue** - You are very welcome to post questions to [issues](https://github.com/sogou/srpc/issues) list.\n* **QQ** - Group number: ``618773193``\n","funding_links":[],"categories":["Inter-process communication","C++","workflow"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsogou%2Fsrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsogou%2Fsrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsogou%2Fsrpc/lists"}