Home

Awesome

<p align="center"> <img width="583" alt="image" src="https://user-images.githubusercontent.com/9642092/189478887-a9ad0a81-8cdc-4983-8954-80347feb002e.png">

CI <img alt="Discord" src="https://img.shields.io/discord/932736311733915668.svg?style=for-the-badge&label=Discord&logo=discord" height="20">

One repo to finally have a clear, objective gRPC benchmark with code for everyone to verify and improve.

Contributions are most welcome! Feel free to use discussions if you have questions/issues or ideas. There is also a category where you are encouraged to submit your own benchmark results!

See Nexthink blog post for a deeper overview of the project and recent results.

Goal

The goal of this benchmark is to compare the performance and resource usage of various gRPC libraries across different programming languages and technologies. To achieve that, a minimal protobuf contract is used to not pollute the results with other concepts (e.g. performances of hash maps) and to make the implementations simple.

That being said, the service implementations should NOT take advantage of that and keep the code generic and maintainable. What does generic mean? One should be able to easily adapt the existing code to some fundamental use cases (e.g. having a thread-safe hash map on server side to provide values to client given some key, performing blocking I/O or retrieving a network resource).
Keep in mind the following guidelines:

You decide what is better

Although in the end results are sorted according to the number of requests served, one should go beyond and look at the resource usage - perhaps one implementation is slightly better in terms of raw speed but uses three times more CPU to achieve that. Maybe it's better to take the first one if you're running on a Raspberry Pi and want to get the most of it. Maybe it's better to use the latter in a big server with 32 CPUs because it scales. It all depends on your use case. This benchmark is created to help people make an informed decision (and get ecstatic when their favourite technology seems really good, without doubts).

Metrics

We try to provide some metrics to make this decision easier:

What this benchmark does NOT take into account

  1. Completeness of the gRPC library. We test only basic unary RPC at the moment. This is the most common service method which may be enough for some business use cases, but not for the others. When you're happy about the results of some technology, you should check out it's documentation (if it exists) and decide yourself if is it production-ready.
  2. Taste. Some may find beauty in Ruby, some may feel like Java is the only real deal. Others treat languages as tools and don't care at all. We don't judge (officially 😉 ). Unless it's a huge state machine with raw void pointers. Ups!

Prerequisites

Linux or MacOS with Docker. Keep in mind that the results on MacOS may not be that reliable, Docker for Mac runs on a VM.

Running benchmark

To build the benchmarks images use: ./build.sh [BENCH1] [BENCH2] ... . You need them to run the benchmarks.

To run the benchmarks use: ./bench.sh [BENCH1] [BENCH2] ... . They will be run sequentially.

To clean-up the benchmark images use: ./clean.sh [BENCH1] [BENCH2] ...

Configuring the benchmark

The benchmark can be configured through the following environment variables:

NameDescriptionDefault value
GRPC_BENCHMARK_DURATIONDuration of the benchmark.20s
GRPC_BENCHMARK_WARMUPDuration of the warmup. Stats won't be collected.5s
GRPC_REQUEST_SCENARIOScenario (from scenarios/) containing the protobuf and the data to be sent in the client request.complex_proto
GRPC_SERVER_CPUSMaximum number of cpus used by the server.1
GRPC_SERVER_RAMMaximum memory used by the server.512m
GRPC_CLIENT_CONNECTIONSNumber of connections to use.50
GRPC_CLIENT_CONCURRENCYNumber of requests to run concurrently. It can't be smaller than the number of connections.1000
GRPC_CLIENT_QPSRate limit, in queries per second (QPS).0 (unlimited)
GRPC_CLIENT_CPUSMaximum number of cpus used by the client.1
GRPC_IMAGE_NAMEName of Docker image built by ./build.sh'grpc_bench'

Parameter recommendations

Other parameters will depend on your use-case. Choose wisely.

Results

You can find our old sample results in the Wiki. Be sure to run the benchmarks yourself if you have sufficient hardware, especially for multi-core scenarios. New results will be posted to discussions and you are encouraged to publish yours as well!