We are facing strange memory leak in Spring Cloud Gateway that only appears in one route, that points to a regular Spring Web Rest service that returns response with non standart content-type: "application/jwt" and JWT-token as response body as string.
Heap dump shows that all memory is allocated by reactor.netty.http.client.HttpClientConfig.
So i've tried to set:
- spring.cloud.gateway.httpclient.pool.max-idle-time: "20s"
- spring.cloud.gateway.httpclient.pool.max-life-time: "30s"
And it helped, no more issues with memory leak.
But i'm curious what is the problem with non-standart content-type?
Secondly, i've tested pool timeouts locally and see no difference in response timeouts, when channel is closed.
First request is creating new connection, so response timeout is pretty big (300ms+), then after 30+ seconds (i'am checking via metrics that no more active/idle connections) i'm doing next request and getting standart response time as 10-30ms.
Real connection from pool is not closed or what?
Dependencies:
- spring boot 2.7.5
- spring cloud gateway 3.1.4
- netty-all 4.1.84Final
- reactor-netty 1.0.24