Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【DefaultHttp2HeadersEncoder】can not config HeaderTableSize in grpc-java-api #11793

Open
vio-lin opened this issue Dec 31, 2024 · 3 comments
Labels

Comments

@vio-lin
Copy link

vio-lin commented Dec 31, 2024

@Override
  public NettyServerBuilder configureServerBuilder(NettyServerBuilder builder, URL url) {
    builder.addStreamTracerFactory(new ServerStreamTracer.Factory() {
      @Override
      public ServerStreamTracer newServerStreamTracer(String fullMethodName, Metadata headers) {
        String contentType = cDubboUtils.extractContextType(headers);
        return new ServerStreamTracer() {
          @Override
          public Context filterContext(Context context) {
            return context.withValue(GrpcConstants.Serialization.SERIALIZATION_KEY, contentType);
          }
        };
      }
    });
    return builder;
  }

we want to use http2 to encode headers to optimise data transport.
as DefaultHttp2HeadersEncoder HeaderTableSize default 4096
when we add headers size over 4096 can not be compression in grpc

io.netty.handler.codec.http2.HpackEncoder#ensureCapacity   
size over 4096 will note be compress

and for grpc server i can not find any way to config thsi properties

@ejona86
Copy link
Member

ejona86 commented Jan 7, 2025

"content type" is over 4 KiB in size? How is it so large? Are you saying you are sending something in the headers instead of a message so that you can use HPACK's window? How often is the value identical between requests?

Increasing the table size increases the memory used for the connection for the life of the connection, even when it is idle.

@vio-lin
Copy link
Author

vio-lin commented Jan 7, 2025

"content type" is over 4 KiB in size? How is it so large? Are you saying you are sending something in the headers instead of a message so that you can use HPACK's window? How often is the value identical between requests?

Increasing the table size increases the memory used for the connection for the life of the connection, even when it is idle.

some trace context parameter,which will be pass all over the route。
in our situation,header over 4kib may be a normal request。
if can be compress it may be a significantly enhance.

@ejona86
Copy link
Member

ejona86 commented Jan 7, 2025

There's two types of compression:

  1. huffman encoding
  2. hpack table

(1) can still be applied to the 4 KiB header. (2) only helps if the same identical value is used for multiple requests. So it is important whether the value is identical between requests. If the value varies, then just getting huffman encoding is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants