X/net/http: http client with custom TLS Config and ForceAttemptHTTP2 set to true leading to memory issues

In my golang application we were using the http Client with custom TLS config, and as per the golang’s x/net/http package if we provide a custom TLS Config then the support for http/2 will be disabled. So for enabling the http/2 support with custom TLS config I enabled the flag ForceAttemptHTTP2 flag, but with that I’m seeing a 200MB of memory spike in my application.

I’m running this application on a 800 Hosts setup. But as of now none of the Hosts has a http/2 support enabled still I’m seeing this memory spike.

Did the profiling of my application using the pprof, adding profiling details in thread.

Any ideas on why this high memory usage is happening?
Since I enabled the http/2 support, after the protocol negotiation since I didn’t had any hosts supporting http/2 the request should fallback to http/1.1 and application should behave normally.
Though requests were falling back to http/1.1 but there was 250MB more memory usage by the application.

1.1. Profile With custom TLS Changes and ForceAttemptHTTP2 as true:

1.2. Profile With custom TLS Changes and ForceAttemptHTTP2 as true:

1.3. Profile With custom TLS Changes and ForceAttemptHTTP2 as true:

2.1. Profile without changes:

2.2 Profile without changes:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.