horaedb
horaedb copied to clipboard
Try replace `grpcio` with `tonic`
Describe This Problem
grpcio is currently used by CeresDB as gRPC implementation. It's a rust wrapper over the cpp implementation. We have used it for a long time but there are always some issues we are facing:
- long build time https://github.com/CeresDB/ceresdb/issues/151
- memory leak (from C++) https://github.com/grpc/grpc/issues?q=is%3Aissue+leak
- complicated build procedure (from both rust and C++) https://github.com/CeresDB/ceresdb-client-py/issues/20
tonic is a native gRPC implementation with these pros.:
- Native, and safety (maybe? https://github.com/hyperium/tonic/issues?q=is%3Aissue+leak)
- More users (compare to
grpcio) - Low memory consumption (see below)
And of cause, its cons.:
-
Performance (refer to https://github.com/LesnyRumcajs/grpc_bench/wiki/2022-04-23-bench-results)
name req/s avg. latency 90 % in 95 % in 99 % in avg. cpu avg. memory rust_tonic_mt 64091 13.53 ms 23.42 ms 28.17 ms 37.61 ms 277.41% 18.16 MiB rust_grpcio 68377 12.11 ms 18.79 ms 22.81 ms 32.61 ms 259.81% 25.3 MiB through this table,
grpciois faster thantonic. QpS on gRPC layer loss around 7%.
Proposal
With those improvements, I think tonic is worth a try
Additional Context
No response