Skip to content

Instantly share code, notes, and snippets.

@bojand
Last active May 16, 2022 19:32
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bojand/6812179ee02d475a4d5f06447df83b39 to your computer and use it in GitHub Desktop.
Save bojand/6812179ee02d475a4d5f06447df83b39 to your computer and use it in GitHub Desktop.
gRPC benchmarks Go & Node.js

Microbenchmarks like this should always be taken with a grain of salt; but it's interesting to do a comparison.

Source code for the server implementations

Using:

Node

Unary

grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHello -d '{"name":"Bob"}' -n 4000 -c 40 0.0.0.0:50051

Summary:
  Count:	4000
  Total:	422.50 ms
  Slowest:	11.89 ms
  Fastest:	1.29 ms
  Average:	4.19 ms
  Requests/sec:	9467.51

Response time histogram:
  1.295 [1]	|
  2.355 [94]	|∎∎
  3.415 [764]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  4.475 [1971]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  5.535 [785]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  6.595 [202]	|∎∎∎∎
  7.655 [104]	|∎∎
  8.715 [0]	|
  9.774 [1]	|
  10.834 [56]	|∎
  11.894 [22]	|

Latency distribution:
  10% in 3.17 ms
  25% in 3.47 ms
  50% in 3.81 ms
  75% in 4.60 ms
  90% in 5.50 ms
  95% in 6.56 ms
  99% in 10.43 ms
Status code distribution:
  [OK]	4000 responses

Server Streaming

grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHellos -d '{"name":"Bob"}' -n 4000 -c 40 0.0.0.0:50051

Summary:
  Count:	4000
  Total:	813.73 ms
  Slowest:	22.00 ms
  Fastest:	0.76 ms
  Average:	8.07 ms
  Requests/sec:	4915.65

Response time histogram:
  0.765 [1]	|
  2.888 [11]	|
  5.012 [89]	|∎∎
  7.135 [1549]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  9.259 [1425]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  11.382 [599]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  13.506 [206]	|∎∎∎∎∎
  15.629 [43]	|∎
  17.753 [36]	|∎
  19.876 [1]	|
  22.000 [40]	|∎

Latency distribution:
  10% in 5.90 ms
  25% in 6.28 ms
  50% in 7.55 ms
  75% in 8.91 ms
  90% in 11.04 ms
  95% in 12.87 ms
  99% in 20.21 ms
Status code distribution:
  [OK]	4000 responses

Client Streaming

grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHelloCS -d '[{"name":"Bob"},{"name":"Kate"},{"name":"Sara"}]' -n 4000 -c 40 0.0.0.0:50051

Summary:
  Count:	4000
  Total:	708.79 ms
  Slowest:	17.31 ms
  Fastest:	2.03 ms
  Average:	7.02 ms
  Requests/sec:	564342

Response time histogram:
  2.029 [1]	|
  3.557 [93]	|∎∎
  5.085 [108]	|∎∎
  6.614 [2060]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  8.142 [1024]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  9.670 [149]	|∎∎∎
  11.199 [170]	|∎∎∎
  12.727 [280]	|∎∎∎∎∎
  14.255 [76]	|∎
  15.784 [0]	|
  17.312 [39]	|∎

Latency distribution:
  10% in 5.25 ms
  25% in 5.56 ms
  50% in 6.35 ms
  75% in 7.38 ms
  90% in 11.20 ms
  95% in 12.16 ms
  99% in 13.70 ms
Status code distribution:
  [OK]	4000 responses

Bidi / Duplex

grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHelloBidi -d '[{"name":"Bob"},{"name":"Kate"},{"name":"Sara"}]' -n 4000 -c 40 0.0.0.0:50051

Summary:
  Count:	4000
  Total:	891.05 ms
  Slowest:	18.92 ms
  Fastest:	1.46 ms
  Average:	8.85 ms
  Requests/sec:	4489.16

Response time histogram:
  1.459 [1]	|
  3.205 [12]	|
  4.950 [85]	|∎∎
  6.696 [138]	|∎∎∎
  8.442 [1794]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  10.187 [1048]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  11.933 [732]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  13.678 [141]	|∎∎∎
  15.424 [9]	|
  17.170 [0]	|
  18.915 [40]	|∎

Latency distribution:
  10% in 6.97 ms
  25% in 7.54 ms
  50% in 8.41 ms
  75% in 10.11 ms
  90% in 11.13 ms
  95% in 11.91 ms
  99% in 17.19 ms
Status code distribution:
  [OK]	4000 responses

Go

Unary

grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHello -d '{"name":"Bob"}' -n 4000 -c 40 0.0.0.0:50051

Summary:
  Count:	4000
  Total:	83.15 ms
  Slowest:	5.08 ms
  Fastest:	0.15 ms
  Average:	0.80 ms
  Requests/sec:	48105.99

Response time histogram:
  0.154 [1]	|
  0.646 [1876]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.139 [1508]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.631 [480]	|∎∎∎∎∎∎∎∎∎∎
  2.123 [85]	|∎∎
  2.616 [13]	|
  3.108 [1]	|
  3.600 [9]	|
  4.093 [9]	|
  4.585 [17]	|
  5.077 [1]	|

Latency distribution:
  10% in 0.48 ms
  25% in 0.55 ms
  50% in 0.67 ms
  75% in 0.92 ms
  90% in 1.28 ms
  95% in 1.49 ms
  99% in 2.24 ms
Status code distribution:
  [OK]	4000 responses

Server Streaming

grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHellos -d '{"name":"Bob"}' -n 4000 -c 40 0.0.0.0:50051

Summary:
  Count:	4000
  Total:	125.44 ms
  Slowest:	4.97 ms
  Fastest:	0.20 ms
  Average:	1.22 ms
  Requests/sec:	31888.04

Response time histogram:
  0.205 [1]	|
  0.681 [341]	|∎∎∎∎∎∎∎∎
  1.157 [1818]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.633 [1183]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  2.110 [429]	|∎∎∎∎∎∎∎∎∎
  2.586 [125]	|∎∎∎
  3.062 [51]	|∎
  3.538 [32]	|∎
  4.015 [14]	|
  4.491 [4]	|
  4.967 [2]	|

Latency distribution:
  10% in 0.70 ms
  25% in 0.86 ms
  50% in 1.11 ms
  75% in 1.46 ms
  90% in 1.87 ms
  95% in 2.18 ms
  99% in 3.23 ms
Status code distribution:
  [OK]	4000 responses

Client Streaming

Summary:
  Count:	4000
  Total:	111.07 ms
  Slowest:	3.76 ms
  Fastest:	0.18 ms
  Average:	1.08 ms
  Requests/sec:	36012239.41

Response time histogram:
  0.178 [1]	|
  0.537 [131]	|∎∎∎
  0.895 [1615]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.254 [1138]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.612 [702]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.970 [229]	|∎∎∎∎∎∎
  2.329 [110]	|∎∎∎
  2.687 [35]	|∎
  3.046 [13]	|
  3.404 [19]	|
  3.763 [7]	|

Latency distribution:
  10% in 0.65 ms
  25% in 0.77 ms
  50% in 0.95 ms
  75% in 1.31 ms
  90% in 1.63 ms
  95% in 1.94 ms
  99% in 2.68 ms
Status code distribution:
  [OK]	4000 responses

Bidi / Duplex

grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHelloBidi -d '[{"name":"Bob"},{"name":"Kate"},{"name":"Sara"}]' -n 4000 -c 40 0.0.0.0:50051

Summary:
  Count:	4000
  Total:	126.37 ms
  Slowest:	4.05 ms
  Fastest:	0.17 ms
  Average:	1.23 ms
  Requests/sec:	31654254.26

Response time histogram:
  0.165 [1]	|
  0.554 [37]	|∎
  0.942 [1220]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.330 [1336]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.718 [878]	|∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  2.107 [345]	|∎∎∎∎∎∎∎∎∎∎
  2.495 [90]	|∎∎∎
  2.883 [43]	|∎
  3.272 [38]	|∎
  3.660 [8]	|
  4.048 [4]	|

Latency distribution:
  10% in 0.77 ms
  25% in 0.89 ms
  50% in 1.12 ms
  75% in 1.49 ms
  90% in 1.81 ms
  95% in 2.06 ms
  99% in 2.98 ms
Status code distribution:
  [OK]	4000 responses

Brief comparison:

Unary

Node

Average:  4.19 ms
95% in 6.56 ms

Go

Average:  0.80 ms
95% in 1.49 ms

Server Streaming

Node

Average:  8.07 ms
95% in 12.87 ms

Go

Average:  1.22 ms
95% in 2.18 ms

Client Stream

Node

Average:  7.02 ms
95% in 12.16 ms

Go

Average:  1.08 ms
95% in 1.94 ms

Bidi

Node

Average:  8.85 ms
95% in 11.91 ms

Go

Average:  1.23 ms
95% in 2.06 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment