README.md
1# [![DRPC](logo.png)](https://storj.github.io/drpc/)
2
3A drop-in, lightweight gRPC replacement.
4
5[![Go Report Card](https://goreportcard.com/badge/storj.io/drpc)](https://goreportcard.com/report/storj.io/drpc)
6[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://pkg.go.dev/storj.io/drpc)
7![Beta](https://img.shields.io/badge/version-beta-green.svg)
8[![Zulip Chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://drpc.zulipchat.com)
9
10## Links
11
12 * [DRPC website](https://storj.github.io/drpc/)
13 * [Examples](https://github.com/storj/drpc/tree/main/examples)
14 * [Quickstart documentation](https://storj.github.io/drpc/docs.html)
15 * [Launch blog post](https://www.storj.io/blog/introducing-drpc-our-replacement-for-grpc)
16
17## Highlights
18
19* Simple, at just a few thousand [lines of code](#lines-of-code).
20* [Small dependencies](./blob/main/go.mod). Only 3 requirements in go.mod, and 9 lines of `go mod graph`!
21* Compatible. Works for many gRPC use-cases as-is!
22* [Fast](#benchmarks). DRPC has a lightning quick [wire format](https://github.com/storj/drpc/wiki/Docs:-Wire-protocol).
23* [Extensible](#external-packages). DRPC is transport agnostic, supports middleware, and is designed around interfaces.
24* Battle Tested. Already used in production for years across tens of thousands of servers.
25
26## External Packages
27
28 * [go.bryk.io/pkg/net/drpc](https://pkg.go.dev/go.bryk.io/pkg/net/drpc)
29 - Simplified TLS setup (for client and server)
30 - Server middleware, including basic components for logging, token-based auth, rate limit, panic recovery, etc
31 - Client middleware, including basic components for logging, custom metadata, panic recovery, etc
32 - Bi-directional streaming support over upgraded HTTP(S) connections using WebSockets
33 - Concurrent RPCs via connection pool
34
35## Other Languages
36
37Some bindings for other languages are in progress, all in various states of completeness. Join the [Zulip chat](https://drpc.zulipchat.com) if you want more information or to help out with any!
38
39| Language | Repository | Status |
40|----------|-------------------------------------|------------|
41| C++ | https://github.com/storj/drpc-cpp | Incomplete |
42| Rust | https://github.com/zeebo/drpc-rs | Incomplete |
43| Node | https://github.com/mjpitz/drpc-node | Incomplete |
44
45## Licensing
46
47DRPC is licensed under the MIT/expat license. See the LICENSE file for more.
48
49---
50
51## Benchmarks
52
53These 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.
54
55<table>
56 <tr>
57 <td rowspan=2>Measure</td>
58 <td rowspan=2>Benchmark</td><td rowspan=2></td>
59 <td colspan=3>Small</td><td rowspan=2></td>
60 <td colspan=3>Medium</td><td rowspan=2></td>
61 <td colspan=3>Large</td>
62 </tr>
63 <tr>
64 <td>gRPC</td><td>DRPC</td><td>delta</td>
65 <td>gRPC</td><td>DRPC</td><td>delta</td>
66 <td>gRPC</td><td>DRPC</td><td>delta</td>
67 </tr>
68 <tr><td colspan=14></td></tr>
69 <tr>
70 <td rowspan=4>time/op</td>
71 <td>Unitary</td><td rowspan=4></td>
72 <td>30.2µs</td><td>8.6µs</td><td>-71.60%</td><td rowspan=4></td>
73 <td>38.0µs</td><td>11.1µs</td><td>-70.88%</td><td rowspan=4></td>
74 <td>1.33ms</td><td>0.63ms</td><td>-52.30%</td>
75 </tr>
76 <tr>
77 <td>Input Stream</td>
78 <td>878ns</td><td>759ns</td><td>-13.54%</td>
79 <td>2.85µs</td><td>2.00µs</td><td>-29.69%</td>
80 <td>508µs</td><td>249µs</td><td>-51.08%</td>
81 </tr>
82 <tr>
83 <td>Output Stream</td>
84 <td>862ns</td><td>757ns</td><td>-12.18%</td>
85 <td>2.76µs</td><td>1.99µs</td><td>-27.92%</td>
86 <td>487µs</td><td>239µs</td><td>-50.94%</td>
87 </tr>
88 <tr>
89 <td>Bidir Stream</td>
90 <td>9.81µs</td><td>3.30µs</td><td>-66.38%</td>
91 <td>14.8µs</td><td>4.9µs</td><td>-66.69%</td>
92 <td>1.31ms</td><td>0.55ms</td><td>-58.41%</td>
93 </tr>
94 <tr><td colspan=14></td></tr>
95 <tr>
96 <td rowspan=4>speed</td>
97 <td>Unitary</td><td rowspan=4></td>
98 <td>70.0kB/s</td><td>230.0kB/s</td><td>+228.57%</td><td rowspan=4></td>
99 <td>54.0MB/s</td><td>185.3MB/s</td><td>+243.44%</td><td rowspan=4></td>
100 <td>791MB/s</td><td>1658MB/s</td><td>+109.62%</td>
101 </tr>
102 <tr>
103 <td>Input Stream</td>
104 <td>2.29MB/s</td><td>2.64MB/s</td><td>+15.37%</td>
105 <td>721MB/s</td><td>1026MB/s</td><td>+42.21%</td>
106 <td>2.06GB/s</td><td>4.22GB/s</td><td>+104.32%</td>
107 </tr>
108 <tr>
109 <td>Output Stream</td>
110 <td>2.32MB/s</td><td>2.64MB/s</td><td>+13.67%</td>
111 <td>743MB/s</td><td>1031MB/s</td><td>+38.74%</td>
112 <td>2.15GB/s</td><td>4.39GB/s</td><td>+103.75%</td>
113 </tr>
114 <tr>
115 <td>Bidir Stream</td>
116 <td>200kB/s</td><td>604kB/s</td><td>+201.87%</td>
117 <td>138MB/s</td><td>415MB/s</td><td>+200.20%</td>
118 <td>799MB/s</td><td>1920MB/s</td><td>+140.44%</td>
119 </tr>
120 <tr><td colspan=14></td></tr>
121 <tr>
122 <td rowspan=4>mem/op</td>
123 <td>Unitary</td><td rowspan=4></td>
124 <td>8.37kB</td><td>1.29kB</td><td>-84.59%</td><td rowspan=4></td>
125 <td>21.8kB</td><td>7.7kB</td><td>-64.81%</td><td rowspan=4></td>
126 <td>6.50MB</td><td>3.16MB</td><td>-51.38%</td>
127 </tr>
128 <tr>
129 <td>Input Stream</td>
130 <td>399B</td><td>80B</td><td>-79.96%</td>
131 <td>7.09kB</td><td>2.13kB</td><td>-69.97%</td>
132 <td>3.20MB</td><td>1.05MB</td><td>-67.16%</td>
133 </tr>
134 <tr>
135 <td>Output Stream</td>
136 <td>309B</td><td>80B</td><td>-74.13%</td>
137 <td>6.98kB</td><td>2.13kB</td><td>-69.53%</td>
138 <td>3.20MB</td><td>1.05MB</td><td>-67.17%</td>
139 </tr>
140 <tr>
141 <td>Bidir Stream</td>
142 <td>1.02kB</td><td>0.24kB</td><td>-76.40%</td>
143 <td>14.4kB</td><td>4.3kB</td><td>-69.99%</td>
144 <td>6.52MB</td><td>2.10MB</td><td>-67.74%</td>
145 </tr>
146 <tr><td colspan=14></td></tr>
147 <tr>
148 <td rowspan=4>allocs/op</td>
149 <td>Unitary</td><td rowspan=4></td>
150 <td>169</td><td>7</td><td>-95.86%</td><td rowspan=4></td>
151 <td>171</td><td>9</td><td>-94.74%</td><td rowspan=4></td>
152 <td>403</td><td>9</td><td>-97.76%</td>
153 </tr>
154 <tr>
155 <td>Input Stream</td>
156 <td>11</td><td>1</td><td>-90.91%</td>
157 <td>12</td><td>2</td><td>-83.33%</td>
158 <td>121</td><td>2</td><td>-98.35%</td>
159 </tr>
160 <tr>
161 <td>Output Stream</td>
162 <td>9</td><td>1</td><td>-88.89%</td>
163 <td>10</td><td>2</td><td>-80.00%</td>
164 <td>117</td><td>2</td><td>-98.29%</td>
165 </tr>
166 <tr>
167 <td>Bidir Stream</td>
168 <td>41</td><td>3</td><td>-92.68%</td>
169 <td>44</td><td>5</td><td>-88.64%</td>
170 <td>272</td><td>5</td><td>-98.16%</td>
171 </tr>
172</table>
173
174## Lines of code
175
176| Package | Lines |
177| --- | --- |
178| storj.io/drpc/cmd/protoc-gen-go-drpc | 418 |
179| storj.io/drpc/drpcstream | 388 |
180| storj.io/drpc/drpcwire | 326 |
181| storj.io/drpc/drpcmanager | 280 |
182| storj.io/drpc/drpcmigrate | 237 |
183| storj.io/drpc/drpchttp | 214 |
184| storj.io/drpc/drpcsignal | 133 |
185| storj.io/drpc/drpcconn | 116 |
186| storj.io/drpc/drpcmetadata | 115 |
187| storj.io/drpc/drpcmux | 95 |
188| storj.io/drpc/drpcserver | 76 |
189| storj.io/drpc/drpccache | 54 |
190| storj.io/drpc | 48 |
191| storj.io/drpc/drpcerr | 42 |
192| storj.io/drpc/drpcctx | 37 |
193| storj.io/drpc/drpcdebug | 19 |
194| storj.io/drpc/drpcenc | 15 |
195| storj.io/drpc/internal/drpcopts | 11 |
196| **Total** | **2624** |
197