I have a service using grpc (in C++) to stream data to client-side (it's streaming grpc).
For the original implementation, the average throughput could be ~110MBps with a 1Gbps NIC, so I think bandwidth itself is a bottleneck. The usual way is to enable compression/decompression.
I found grpc supports compression natively. The only code I added at server side is
builder.SetDefaultCompressionAlgorithm(GRPC_COMPRESS_DEFLATE);
builder.SetDefaultCompressionLevel(GRPC_COMPRESS_LEVEL_LOW);
with no change at client-side. But the throughput drops stably.
From the network's behavior, it's ~20MBps.
Calculating from protobuf messages' ByteSizeLong(), it's ~26MBps, but still far less than 100MBps.
I also tried for other compression algorithm (deflate/GRPC_COMPRESS_ALGORITHMS_COUNT) and levels (low/medium/high),
Some initial guess might be: Compression is performed synchronously, and compression rate does match IO throughput, which leads to a bottleneck at server-side.
I intended to investigate whether it supports derived class, so that I could implement my own, but from this issue, it seems C++ currently doesn't support it.
I want to know if I'm using grpc compression wrongly, or if there's any work-around for my issue. Thank you!