https://github.com/dunnock/tonic-bench
End to end naive benchmarks for tonic - Rust grpc implementation
https://github.com/dunnock/tonic-bench
Last synced: about 1 year ago
JSON representation
End to end naive benchmarks for tonic - Rust grpc implementation
- Host: GitHub
- URL: https://github.com/dunnock/tonic-bench
- Owner: dunnock
- License: mit
- Created: 2020-01-16T11:16:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-16T22:24:57.000Z (over 6 years ago)
- Last Synced: 2025-06-17T02:12:57.718Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 382 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This package contains naive implementation of benchmarks for [tonic](https://docs.rs/tonic/0.1.0/tonic/index.html)
# Test with ghz
```
cargo run --bin=server --release
```
> Rust version will start on port 50051
```
ghz --insecure --proto proto/hellobench.proto --call hellobench.Greeter.SayEmpty -d '{}' -n 100000 -c 16 --connections=4 localhost:50051
```
```
Summary:
Count: 100000
Total: 6.26 s
Slowest: 100.07 ms
Fastest: 0.16 ms
Average: 0.96 ms
Requests/sec: 15984.89
```
## Compile and run go version
```
cd go
go build server.go
server
```
> Go version will start on port 50050, so above ghz should be amended:
```
ghz --insecure --proto proto/hellobench.proto --call hellobench.Greeter.SayEmpty -d '{}' -n 100000 -c 16 --connections=4 localhost:50051
```
```
Summary:
Count: 100000
Total: 4.57 s
Slowest: 14.45 ms
Fastest: 0.11 ms
Average: 0.67 ms
Requests/sec: 21890.10
```
# Test with Rust client
Load with empty request/response
```
target/release/client --connections=4 --concurency=8 --request=Empty --messages=100000 --port=50051
```
```
Elapsed: 20022ms
processed 400000 with 19978 rps
successful 400000 failed 0 requests
```
OR Load with string request/response
```
target/release/client --connections=4 --concurency=8 --request=Something --messages=100000 --port=50051
```
```
Elapsed: 22059ms
processed 400000 with 18133 rps
successful 400000 failed 0 requests
```
# Run with flamegraph
```
sudo flamegraph target/release/server
```

# Comparison with plain text hyper http
Simple naive hyper HTTP server on same machine gives about ~3x more requests/responses
```
cargo run --release --bin=http_server
```
```
❯ ab -n 100000 -c 4 -k http://127.0.0.1:3000/
...
Concurrency Level: 4
Time taken for tests: 3.125 seconds
Requests per second: 32004.64 [#/sec] (mean)
Transfer rate: 3500.51 [Kbytes/sec] received
```
