跳转至

RPC

Features

  • Simple and lightweight
  • High performance
  • Support port multiplexing (Multiple protocols on the same port)
  • Support multiple codecs: JSON, HTTP, Protocol Buffers...
  • Load balance: Random, RoundRobin...
  • OpenTracing support
  • Service discovery and governance with etcd, consul...
  • Support authentication and authorization (TODO)
  • Circuit breaker (TODO)
  • Rate limit (TODO)

Architecture

┌───────┬────────────────────────┐
│Client │                        │
├───────┘                        │
│ ┌────────────────────────────┐ │
│ │  .─────────────────────.   │ │
│ │ (         Node          )  │ │                 ┌───────────────┬───────┐
│ │  `─────────────────────'   │ │                 │               │Server │
│ │  .─────────────────────.   │ │                 │               └───────┤
│ │ (         Node          )  │─┼─────Channel────▶│ ┌───────────────────┐ │──┐
│ │  `─────────────────────'   │ │                 │ │ 192.168.2.2:9000  │ │  │
│ ├────────────────┐           │ │                 │ └───────────────────┘ │  │
│ │192.168.2.2:9000│           │ │                 └───────────────────────┘  │
│ └────────────────┴───────────┘ │                                            │
│ ┌────────────────────────────┐ │                                            │
│ │  .─────────────────────.   │ │                                            │
│ │ (         Node          )  │ │                 ┌───────────────┬───────┐  │
│ │  `─────────────────────'   │ │                 │               │Server │  │
│ │  .─────────────────────.   │ │                 │               └───────┤  │
│ │ (         Node          )  │─┼─────Channel────▶│ ┌───────────────────┐ │  │
│ │  `─────────────────────'   │ │                 │ │ 192.168.2.3:9000  │ │  │
│ ├────────────────┐           │ │                 │ └───────────────────┘ │  │
│ │192.168.2.3:9000│           │ │                 └───────────────────────┘  │
│ └────────────────┴───────────┘ │                             │              │
└────────────────────────────────┘                             │              │
                 │                                             │              │
             Resolver                                      Register       Register
                 │                                             │              │
                 │       ┌──────────────────────────────────┐  │              │
                 └──────▶│         Service Registry         │◀─┴──────────────┘
                         └──────────────────────────────────┘

Code generating

If you use Protocol Buffers codec, you can generate contract codes from Protocol Buffers service definition files with protoc-gen-auxo.

Install

Use go get to install the code generator:

go get github.com/cuigh/protoc-gen-auxo

You will also need:

  • protoc, the protobuf compiler. You need version 3+.
  • protoc-gen-go, the Go protobuf generator plugin. Get this with go get github.com/golang/protobuf/protoc-gen-go.

Usage

Just like grpc:

protoc --go_out=. --auxo_out=. hello.proto

Service interfaces and client proxies were generated into a separate file [name].auxo.go:

hello.auxo.go
hello.pb.go
hello.proto

Performance

Performance issues are always controversial, but they can't be avoided. The following test results are for informational purposes only.

Environment

  • Codes: rpcx-benchmark
  • Hardware: MacBook Pro (15-inch, Late 2013), 2.3 GHz Intel Core i7, 16 GB 1600 MHz DDR3
  • OS: macOS 10.13.3
  • Go version: 1.9.3
  • Concurrency: 100
  • Total requests: 1000000

Benchmark

Framework TPS Mean Min Max P99
auxo 78733 1ms 0ms 8ms 3ms
grpc 35985 2ms 0ms 54ms 19ms
rpcx 76031 1ms 0ms 10ms 4ms