Expose disposeInactivePoolsInBackground for HttpClient connection pool#4191
Open
seonwooj0810 wants to merge 1 commit into
Open
Expose disposeInactivePoolsInBackground for HttpClient connection pool#4191seonwooj0810 wants to merge 1 commit into
seonwooj0810 wants to merge 1 commit into
Conversation
Add configuration properties to expose Reactor Netty's ConnectionProvider.Builder#disposeInactivePoolsInBackground(disposeInterval, poolInactivity). Unlike the existing eviction-interval (which evicts idle connections), this disposes connection pools that have been entirely inactive, preventing unbounded growth of the channelPools map when downstream instances churn (e.g. Kubernetes pods rolling, so the remote address changes). Both spring.cloud.gateway.server.webflux.httpclient.pool.inactive-pool-dispose-interval and ...pool.pool-inactivity must be set for the background disposal to be enabled; otherwise behavior is unchanged. Fixes spring-cloudgh-4165 Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4165
Problem
HttpClientProperties.Poolexposes several Reactor Netty connection-pool knobs (max-idle-time,max-life-time,eviction-interval, …) but notConnectionProvider.Builder#disposeInactivePoolsInBackground(disposeInterval, poolInactivity).The existing
eviction-interval(evictInBackground) only evicts idle connections within a pool; it does not remove the pool entries themselves from Reactor Netty's internalchannelPoolsmap. When downstream instances churn — e.g. Kubernetes pods rolling, so the remoteIP:port(and therefore thePoolKey) keeps changing — entries accumulate and are never reclaimed, which manifests as a slow memory leak (see #4165 for the analysis and a linked Reactor Netty report).Change
Expose the missing knob, mirroring how the other pool properties are wired:
inactive-pool-dispose-intervalandpool-inactivity(bothDuration, null/disabled by default) toHttpClientProperties.Pool.HttpClientFactory#buildConnectionProvider, callbuilder.disposeInactivePoolsInBackground(...)only when both are set, so default behavior is unchanged.Test evidence
Extended the existing
GatewayAutoConfigurationTests#nettyHttpClientConfiguredbinding test to set and assert both new properties.checkstyle + spring-javaformat
validatepass. Commit is DCO signed-off.Verification done
disposeInactive/4165— none). 2. No self-claim comments on the issue. 3. Code-focused — touches only.java. 4. Confirmed the property/builder call is absent on currentmain. 6. Triage gate N/A (spring-cloud/, not spring-projects/).