A drop-in, lightweight gRPC replacement.
Links
Highlights
- Simple, at just a few thousand lines of code.
- Small dependencies. Only 3 requirements in go.mod, and 9 lines of
go mod graph
! - Compatible. Works for many gRPC use-cases as-is!
- Fast. DRPC has a lightning quick wire format.
- Extensible. DRPC is transport agnostic, supports middleware, and is designed around interfaces.
- Battle Tested. Already used in production for years across tens of thousands of servers.
External Packages
-
- Simplified TLS setup (for client and server)
- Server middleware, including basic components for logging, token-based auth, rate limit, panic recovery, etc
- Client middleware, including basic components for logging, custom metadata, panic recovery, etc
- Bi-directional streaming support over upgraded HTTP(S) connections using WebSockets
- Concurrent RPCs via connection pool
-
- Concurrent RPCs based on yamux
- Simple drop-in replacements for
drpcserver
anddrpcconn
-
Open an issue or join the Zulip chat if you'd like to be featured here.
Examples
- A basic drpc client and server
- A basic drpc client and server that also serves a Twirp/grpc-web compatible http server on the same port
- Serving gRPC and DRPC on the same port
Other Languages
DRPC can be made compatible with RPC clients generated from other languages. For example, Twirp clients and grpc-web clients can be used against the drpchttp package.
Native implementations can have some advantages, and so some support for other languages are in progress, all in various states of completeness. Join the Zulip chat if you want more information or to help out with any!
Language | Repository | Status |
---|---|---|
C++ | https://github.com/storj/drpc-cpp | Incomplete |
Rust | https://github.com/zeebo/drpc-rs | Incomplete |
Node | https://github.com/mjpitz/drpc-node | Incomplete |
Licensing
DRPC is licensed under the MIT/expat license. See the LICENSE file for more.
Benchmarks
These microbenchmarks attempt to provide a comparison and come with some caveats. First, it does not send data over a network connection which is expected to be the bottleneck almost all of the time. Second, no attempt was made to do the benchmarks in a controlled environment (CPU scaling disabled, noiseless, etc.). Third, no tuning was done to ensure they're both performing optimally, so there is an inherent advantage for DRPC because the author is familiar with how it works.
Measure | Benchmark | Small | Medium | Large | |||||||||
gRPC | DRPC | delta | gRPC | DRPC | delta | gRPC | DRPC | delta | |||||
time/op | Unitary | 24.5Β΅s | 6.1Β΅s | -74.87% | 32.4Β΅s | 8.8Β΅s | -72.89% | 1.43ms | 0.58ms | -59.47% | |||
Input Stream | 745ns | 528ns | -29.13% | 2.63Β΅s | 1.46Β΅s | -44.66% | 512Β΅s | 236Β΅s | -53.89% | ||||
Output Stream | 711ns | 532ns | -25.11% | 2.63Β΅s | 1.51Β΅s | -42.59% | 515Β΅s | 210Β΅s | -59.26% | ||||
Bidir Stream | 7.29Β΅s | 2.52Β΅s | -65.46% | 12.3Β΅s | 3.9Β΅s | -68.68% | 1.44ms | 0.44ms | -69.05% | ||||
speed | Unitary | 80.0kB/s | 325.0kB/s | +306.25% | 63.4MB/s | 234.3MB/s | +269.56% | 734MB/s | 1812MB/s | +146.99% | |||
Input Stream | 2.69MB/s | 3.79MB/s | +41.00% | 780MB/s | 1409MB/s | +80.67% | 2.05GB/s | 4.45GB/s | +117.12% | ||||
Output Stream | 2.81MB/s | 3.76MB/s | +33.52% | 780MB/s | 1360MB/s | +74.23% | 2.04GB/s | 5.01GB/s | +145.53% | ||||
Bidir Stream | 274kB/s | 794kB/s | +189.95% | 166MB/s | 533MB/s | +220.19% | 730MB/s | 2360MB/s | +223.10% | ||||
mem/op | Unitary | 8.66kB | 1.42kB | -83.62% | 22.2kB | 7.8kB | -64.83% | 6.61MB | 3.16MB | -52.21% | |||
Input Stream | 381B | 80B | -79.01% | 7.08kB | 2.13kB | -69.95% | 3.20MB | 1.05MB | -67.17% | ||||
Output Stream | 305B | 80B | -73.80% | 7.00kB | 2.13kB | -69.62% | 3.20MB | 1.05MB | -67.19% | ||||
Bidir Stream | 1.00kB | 0.24kB | -75.90% | 14.5kB | 4.3kB | -70.10% | 6.61MB | 2.10MB | -68.20% | ||||
allocs/op | Unitary | 168 | 7 | -95.83% | 170 | 9 | -94.71% | 400 | 9 | -97.75% | |||
Input Stream | 9 | 1 | -88.89% | 10 | 2 | -80.00% | 118 | 2 | -98.31% | ||||
Output Stream | 9 | 1 | -88.89% | 10 | 2 | -80.00% | 120 | 2 | -98.33% | ||||
Bidir Stream | 39 | 3 | -92.31% | 42 | 5 | -88.10% | 277 | 5 | -98.20% |
Lines of code
DRPC is proud to get as much done in as few lines of code as possible. It's the author's belief that this is only possible by having a clean, strong architecture and that it reduces the chances for bugs to exist (most studies show a linear corellation with number of bugs and lines of code). This table helps keep the library honest, and it would be nice if more libraries considered this.
Package | Lines |
---|---|
storj.io/drpc/drpchttp | 478 |
storj.io/drpc/drpcstream | 435 |
storj.io/drpc/cmd/protoc-gen-go-drpc | 424 |
storj.io/drpc/drpcmanager | 338 |
storj.io/drpc/drpcwire | 336 |
storj.io/drpc/drpcmigrate | 239 |
storj.io/drpc/drpcpool | 233 |
storj.io/drpc/drpcsignal | 133 |
storj.io/drpc/drpcserver | 133 |
storj.io/drpc/drpcconn | 116 |
storj.io/drpc/drpcmetadata | 115 |
storj.io/drpc/drpcmux | 95 |
storj.io/drpc/drpccache | 54 |
storj.io/drpc | 47 |
storj.io/drpc/drpctest | 45 |
storj.io/drpc/drpcerr | 42 |
storj.io/drpc/drpcctx | 41 |
storj.io/drpc/drpcdebug | 22 |
storj.io/drpc/drpcenc | 15 |
storj.io/drpc/internal/drpcopts | 14 |
Total | 3355 |