简体   繁体   中英

TCP transport for grpc-java

Is there an implementation of raw TCP transport for grpc-java? I need grpc for internal network services and don't have firewall issues so I'd like to avoid HTTP/2 overhead when building grpc based services.

"Raw" TCP is not actually a thing. You need to build a protocol on top. It happens that HTTP/2 is very close to any proprietary protocol gRPC might make. I'll also note that gRPC integrates closely with HTTP/2, so HTTP/2 is viewed as part of gRPC within many implementations and can be optimized as one unit.

gRPC needs multiplexing, flow control, byte-based framing (not message-based), and metadata. And that's basically what HTTP/2 is at its heart. You can make simpler protocols, but then you begin having issues with large messages causing head-of-line blocking, memory usage, or frequent TLS connection establishment costs.

Making a protocol with those features is a very well understood problem. HTTP/2 actually looks more similar to TCP than HTTP/1 in many respects. And it solved the problems in mostly the same way as SSH-2.

The "losses" by choosing HTTP/2 are small. Things like required headers used in grpc, like method name and status code, can't be optimized directly into the protocol as a struct instead of generic metadata. But HPACK can help some there. Native binary headers would be really nice, to avoid base64-encoding metadata, although it would be relatively easy to extend HTTP/2 to support that via a SETTINGS negotiation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM