grpc / grpc-java

The Java gRPC implementation. HTTP/2 based RPC
https://grpc.io/docs/languages/java/
Apache License 2.0
11.41k stars 3.84k forks source link

What does "length" means in i.g.n.NettyClientHandler INBOUND DATA #11393

Closed UserNoOne closed 2 months ago

UserNoOne commented 3 months ago

I was not able to figure out what does length means in one of print statements in i.g.n.NettyClientHandler. Please share some data on this and how can I control the length size as I was seeing default value as max 8192

[DEBUG] i.g.n.NettyClientHandler - [id: 0xb9c8d8e4,] INBOUND DATA: streamId=5 padding=0 endStream=false length=748 bytes=**. [DEBUG] i.g.n.NettyClientHandler - [id: 0xb9c8d8e4,] INBOUND DATA: streamId=5 padding=0 endStream=false length=8192 bytes=4d [DEBUG] i.g.n.NettyClientHandler - [id: 0xb9c8d8e4,] INBOUND DATA: streamId=5 padding=0 endStream=false length=757 bytes=45d [DEBUG] i.g.n.NettyClientHandler - [id: 0xb9c8d8e4,] INBOUND DATA: streamId=5 padding=0 endStream=false length=8192 bytes=f4 [DEBUG] i.g.n.NettyClientHandler - [id: 0xb9c8d8e4,] INBOUND DATA: streamId=5 padding=0 endStream=false length=8192 bytes=dd [DEBUG] i.g.n.NettyClientHandler - [id: 0xb9c8d8e4,] INBOUND DATA: streamId=5 padding=0 endStream=false length=8192 bytes=55 [DEBUG] i.g.n.NettyClientHandler - [id: 0xb9c8d8e4,] INBOUND DATA: streamId=5 padding=0 endStream=false length=8174 bytes=d7 [DEBUG] i.g.n.NettyClientHandler - [id: 0xb9c8d8e4,] INBOUND DATA: streamId=5 padding=0 endStream=false length=8192 bytes=95

kannanjgithub commented 2 months ago

It is the length of a data frame received. The header of each data frame contains the length of the data in that frame. The length is controlled by the sender side. It cannot be higher than the maxInboundMessageSize set on the receiver's channel.

ejona86 commented 2 months ago

It cannot be higher than the maxInboundMessageSize set on the receiver's channel.

That is the maximum gRPC message size. That's unrelated to the HTTP/2 framing size.

The default SETTINGS_MAX_FRAME_SIZE is actually 16 KiB. Those are inbound data frames, so whatever is sending the data is choosing to send in 8 KiB chunks. You'd need to look into the sender to understand why that is. But 8 KiB chunks is not outlandish. There are latency reasons to uses smaller sizes in certain conditions.