All Projects → sogou → Srpc

sogou / Srpc

Licence: apache-2.0
RPC based on C++ Workflow

Projects that are alternatives of or similar to Srpc

Yarpc Go
A message passing platform for Go
Stars: ✭ 285 (-45.3%)
Mutual labels:  rpc, thrift, protobuf
tsrpc
A TypeScript RPC framework, with runtime type checking and serialization, support both HTTP and WebSocket. It is very suitable for website / APP / games, and absolutely comfortable to full-stack TypeScript developers.
Stars: ✭ 866 (+66.22%)
Mutual labels:  protobuf, rpc
cocolian-rpc
使用Apache Thrift作为容器,Google Protobuf作为协议的一个RPC框架。
Stars: ✭ 19 (-96.35%)
Mutual labels:  protobuf, rpc
rony
Fast and Scalable RPC Framework
Stars: ✭ 41 (-92.13%)
Mutual labels:  protobuf, rpc
raster
A micro server framework, support coroutine, and parallel-computing, used for building flatbuffers/thrift/protobuf/http protocol service.
Stars: ✭ 19 (-96.35%)
Mutual labels:  protobuf, thrift
elm-protobuf
protobuf plugin for elm
Stars: ✭ 93 (-82.15%)
Mutual labels:  protobuf, rpc
twjitm-core
采用Netty信息加载实现长连接实时通讯系统,客户端可以值任何场景,支持实时http通讯、webSocket通讯、tcp协议通讯、和udp协议通讯、广播协议等 通过http协议,rpc协议。 采用自定义网络数据包结构, 实现自定义网络栈。
Stars: ✭ 98 (-81.19%)
Mutual labels:  protobuf, rpc
Cellnet
High performance, simple, extensible golang open source network library
Stars: ✭ 3,714 (+612.86%)
Mutual labels:  rpc, protobuf
Gosercomp
⚡️ Golang Serializer Benchmark Comparison
Stars: ✭ 300 (-42.42%)
Mutual labels:  thrift, protobuf
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+551.06%)
Mutual labels:  rpc, thrift
Elixir Thrift
A Pure Elixir Thrift Implementation
Stars: ✭ 182 (-65.07%)
Mutual labels:  rpc, thrift
Javaspringbootsamples
SpringBoot、Dubbo、SpringCloud的各种集成例子:Atomikos、gRPC、Thrift、Seata、ShardingSphere、Dubbo、Hmily、Nacos、Consul、Ribbon、Jedis、Lettuce、Redisson等框架
Stars: ✭ 399 (-23.42%)
Mutual labels:  rpc, thrift
Go Grpc Examples
This repo contains examples and implementations of different types of GRPC services and APIs using Golang.
Stars: ✭ 180 (-65.45%)
Mutual labels:  rpc, protobuf
thrift-typescript
Generate TypeScript from Thrift IDL files
Stars: ✭ 129 (-75.24%)
Mutual labels:  thrift, rpc
Gayrpc
Full Duplex C++ RPC Library,Use Protobuf, Support HTTP API .
Stars: ✭ 157 (-69.87%)
Mutual labels:  rpc, protobuf
Netty Learning Example
🥚 Netty实践学习案例,见微知著!带着你的心,跟着教程。我相信你行欧。
Stars: ✭ 2,146 (+311.9%)
Mutual labels:  rpc, protobuf
Raptor
拍拍贷微服务rpc框架
Stars: ✭ 139 (-73.32%)
Mutual labels:  rpc, protobuf
Go Micro Boilerplate
The boilerplate of the GoLang application with a clear microservices architecture.
Stars: ✭ 147 (-71.79%)
Mutual labels:  rpc, protobuf
Flatbuffers
FlatBuffers: Memory Efficient Serialization Library
Stars: ✭ 17,180 (+3197.5%)
Mutual labels:  rpc, protobuf
Thriftpy2
Pure python approach of Apache Thrift.
Stars: ✭ 402 (-22.84%)
Mutual labels:  rpc, thrift

SRPC

License Language Platform

Wiki:SRPC架构介绍

Introduction

这是搜狗自研的RPC系统,主要功能和特点:

  • 这是一个基于Sogou C++ Workflow的项目,兼具:
    • 高性能
    • 低开发和接入门槛
    • 完美兼容workflow的串并联任务流
    • 对于已有pb/thrift描述文件的项目,可以做到一键迁移
  • 支持多种IDL格式,包括:
    • Protobuf
    • Thrift
  • 支持多种数据布局,使用上完全透明,包括:
    • Protobuffer serialize
    • Thrift Binary serialize
    • json serialize
  • 支持多种压缩,使用上完全透明,包括:
    • gzip
    • zlib
    • snappy
    • lz4
  • 支持多种通信协议,使用上完全透明,包括:
    • tcp
    • http
    • sctp
    • ssl
    • https
  • 用户可以通过http+json实现跨语言:
    • 如果自己是server提供方,用任何语言的http server接受post请求,解析若干http header即可
    • 如果自己是client调用方,用任何语言的http client发送post请求,添加若干http header即可
  • 内置了可以与其他RPC框架的server/client无缝互通的client/server,包括:
    • BPRC
    • GRPC
    • Thrift Framed Binary
    • Thrift Http Binary
  • 兼容workflow的使用方式:
    • 提供创建任务的接口来创建一个rpc任务
    • 可以把rpc任务放到任务流图中,回调函数里也可以拿到当前的任务流
    • workflow所支持的其他功能,包括upstream、计算调度、异步文件IO等
  • 更多功能和层次介绍

Installation

  • srpc是一个静态库libsrpc.a,只有开发环境需要依赖libsrpc,编译后二进制发布不需要依赖libsrpc库
  • srpc依赖workflow和protobuf3
    • protobuf需要用户自行安装v3.0.0以上的版本
    • workflow可以通过git的submodule形式进行依赖
    • 压缩库snappy和lz4也以submodule的形式在third_party/中作源码依赖
git clone --recursive https://github.com/sogou/srpc.git
cd srpc
make
sudo make install

Quick Start

1. example.proto

syntax = "proto2";//这里proto2和proto3都可以,srpc都支持

message EchoRequest {
    optional string message = 1;
    optional string name = 2;
};

message EchoResponse {
    optional string message = 1;
};

service Example {
    rpc Echo(EchoRequest) returns (EchoResponse);
};

2. generate code

protoc example.proto --cpp_out=./ --proto_path=./
srpc_generator protobuf ./example.proto ./

3. server.cc

#include <stdio.h>
#include <signal.h>
#include "example.srpc.h"

using namespace srpc;

class ExampleServiceImpl : public Example::Service
{
public:
    void Echo(EchoRequest *request, EchoResponse *response, RPCContext *ctx) override
    {
        response->set_message("Hi, " + request->name());

        // gzip/zlib/snappy/lz4/none
        // ctx->set_compress_type(RPCCompressGzip);

        // protobuf/json
        // ctx->set_data_type(RPCDataJson);

        printf("get_req:\n%s\nset_resp:\n%s\n",
                request->DebugString().c_str(), response->DebugString().c_str());
    }
};

void sig_handler(int signo) { }

int main()
{
    signal(SIGINT, sig_handler);
    signal(SIGTERM, sig_handler);

    SRPCServer server_tcp;
    SRPCHttpServer server_http;

    ExampleServiceImpl impl;
    server_tcp.add_service(&impl);
    server_http.add_service(&impl);

    server_tcp.start(1412);
    server_http.start(8811);
    pause();
    server_http.stop();
    server_tcp.stop();

    return 0;
}

4. client.cc

#include <stdio.h>
#include "example.srpc.h"

using namespace srpc;

int main()
{
    Example::SRPCClient client("127.0.0.1", 1412);
    EchoRequest req;
    req.set_message("Hello, srpc!");
    req.set_name("workflow");

    client.Echo(&req, [](EchoResponse *response, RPCContext *ctx) {
        if (ctx->success())
            printf("%s\n", response->DebugString().c_str());
        else
            printf("status[%d] error[%d] errmsg:%s\n",
                    ctx->get_status_code(), ctx->get_error(), ctx->get_errmsg());
    });

    pause();
    return 0;
}

5. make

g++ -o server server.cc example.pb.cc -std=c++11 -lsrpc
g++ -o client client.cc example.pb.cc -std=c++11 -lsrpc

6. run

终端1

./server

终端2

./client
curl 127.0.0.1:8811/Example/Echo -H 'Content-Type: application/json' -d '{message:"from curl",name:"CURL"}'

终端1输出

get_req:
message: "Hello, srpc!"
name: "workflow"

set_resp:
message: "Hi, workflow"

get_req:
message: "from curl"
name: "CURL"

set_resp:
message: "Hi, CURL"

终端2输出

message: "Hi, workflow"
{"message":"Hi, CURL"}

Tutorial

Benchmark

  • CPU 2-chip/8-core/32-processor Intel(R) Xeon(R) CPU E5-2630 v3 @2.40GHz
  • Memory all 128G
  • 10 Gigabit Ethernet
  • BAIDU brpc-client使用连接池pooled模式

跨机单client→单server在不同并发的QPS

Client = 1
ClientThread = 64, 128, 256, 512, 1024
RequestSize = 32
Duration = 20s
Server = 1
ServerIOThread = 16
ServerHandlerThread = 16

IMG

跨机多client→单server在不同client进程数的QPS

Client = 1, 2, 4, 8, 16
ClientThread = 32
RequestSize = 32
Duration = 20s
Server = 1
ServerIOThread = 16
ServerHandlerThread = 16

IMG

同机单client→单server在不同并发下的QPS

Client = 1
ClientThread = 1, 2, 4, 8, 16, 32, 64, 128, 256
RequestSize = 1024
Duration = 20s
Server = 1
ServerIOThread = 16
ServerHandlerThread = 16

IMG

同机单client→单server在不同请求大小下的QPS

Client = 1
ClientThread = 100
RequestSize = 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768
Duration = 20s
Server = 1
ServerIOThread = 16
ServerHandlerThread = 16

IMG

同机单client→单server在固定QPS下的延时CDF

Client = 1
ClientThread = 50
ClientQPS = 10000
RequestSize = 1024
Duration = 20s
Server = 1
ServerIOThread = 16
ServerHandlerThread = 16
Outiler = 1%

IMG

跨机多client→单server在固定QPS下的延时CDF

Client = 32
ClientThread = 16
ClientQPS = 2500
RequestSize = 512
Duration = 20s
Server = 1
ServerIOThread = 16
ServerHandlerThread = 16
Outiler = 1%

IMG

Authors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].