Class CommonInternalServiceConnectionPoolProperties
Configures the dedicated Reactor Netty connection pool backing internal service-to-service
WebClient communication.
Without this pool, every HttpClient.create() in the JVM shares Reactor Netty's global
HttpResources pool. That pool is anonymous and has metrics disabled, so there is no way
to observe how saturated outbound connections are for a given service. Declaring an explicitly
named pool is what makes the reactor.netty.connection.provider.* meters possible, since
Reactor Netty tags those meters with the pool name.
- Since:
- MicroExtensionCommon 3.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default maximum number of pooled connections. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanThe interval at which the pool proactively evicts connections that are no longer usable, rather than waiting for them to be acquired again.intThe maximum number of concurrent connections the pool will open before further acquisitions are queued.How long a connection may sit unused in the pool before it is evicted.The maximum absolute age of a pooled connection, after which it is evicted once its in-flight request completes.getName()The name of the connection pool.The maximum number of requests that may be queued waiting for a connection.How long a request may wait for a connection once the pool is saturated before failing.inthashCode()booleanWhether internal service-to-serviceWebClients should use a dedicated, named connection pool rather than Reactor Netty's globalHttpResourcespool.booleanWhether Reactor Netty should publish connection pool metrics for this pool.voidsetEnabled(boolean enabled) Whether internal service-to-serviceWebClients should use a dedicated, named connection pool rather than Reactor Netty's globalHttpResourcespool.voidsetEvictInBackground(Duration evictInBackground) The interval at which the pool proactively evicts connections that are no longer usable, rather than waiting for them to be acquired again.voidsetMaxConnections(int maxConnections) The maximum number of concurrent connections the pool will open before further acquisitions are queued.voidsetMaxIdleTime(Duration maxIdleTime) How long a connection may sit unused in the pool before it is evicted.voidsetMaxLifeTime(Duration maxLifeTime) The maximum absolute age of a pooled connection, after which it is evicted once its in-flight request completes.voidsetMetricsEnabled(boolean metricsEnabled) Whether Reactor Netty should publish connection pool metrics for this pool.voidThe name of the connection pool.voidsetPendingAcquireMaxCount(Integer pendingAcquireMaxCount) The maximum number of requests that may be queued waiting for a connection.voidsetPendingAcquireTimeout(Duration pendingAcquireTimeout) How long a request may wait for a connection once the pool is saturated before failing.toString()
-
Field Details
-
DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_MAX_CONNECTIONSThe default maximum number of pooled connections. This deliberately mirrors the formula Reactor Netty uses when it builds the globalHttpResourcesHTTP pool (TcpResources.create), so that introducing a dedicated pool does not change the connection ceiling internal traffic has been running with.
-
-
Constructor Details
-
CommonInternalServiceConnectionPoolProperties
public CommonInternalServiceConnectionPoolProperties()
-
-
Method Details
-
isEnabled
public boolean isEnabled()Whether internal service-to-serviceWebClients should use a dedicated, named connection pool rather than Reactor Netty's globalHttpResourcespool. Disabling this restores the pre-3.0.0 behavior, at the cost of losing connection pool metrics.- Returns:
- whether the dedicated connection pool is used
-
getName
The name of the connection pool. This is emitted as theidtag on everyreactor.netty.connection.provider.*meter, so it is what distinguishes this pool from any other pool in the same application.- Returns:
- the name of the connection pool
-
isMetricsEnabled
public boolean isMetricsEnabled()Whether Reactor Netty should publish connection pool metrics for this pool. When enabled, the following gauges are registered against Micrometer's global registry (which Spring Boot binds to the application's
MeterRegistryby default, viamanagement.metrics.use-global-registry):reactor.netty.connection.provider.total.connectionsreactor.netty.connection.provider.active.connectionsreactor.netty.connection.provider.idle.connectionsreactor.netty.connection.provider.pending.connectionsreactor.netty.connection.provider.max.connectionsreactor.netty.connection.provider.max.pending.connectionsreactor.netty.connection.provider.pending.connections.time
Each meter is tagged with
id(the poolname) andremote.address. Meters are registered lazily, as connections to a given remote address are first established. Requiresio.micrometer:micrometer-coreon the classpath; if it is absent, metrics are skipped with a warning rather than failing startup.- Returns:
- whether connection pool metrics are published
-
getMaxConnections
public int getMaxConnections()The maximum number of concurrent connections the pool will open before further acquisitions are queued.
This defaults to
DEFAULT_MAX_CONNECTIONSin order to match the globalHttpResourcespool that this pool displaces. Note that this is not the same asConnectionProvider.builder(name)'s own default, which is only twice the number of available processors (minimum 16) - a fraction of the 500 that internal service-to-service traffic has effectively been running with. Leaving this unset must not quietly shrink the ceiling, or a busy service would start queueing requests until they hitgetPendingAcquireTimeout().MicroPM#6849 proposes lowering this to 350 on the grounds that only ~200 Tomcat worker threads can be initiating outbound requests anyway; that is a deliberate tuning decision and belongs to that work, not here.
- Returns:
- the maximum number of pooled connections
-
getMaxLifeTime
The maximum absolute age of a pooled connection, after which it is evicted once its in-flight request completes.nullleaves Reactor Netty's default in place (no limit, meaning keep-alive connections live indefinitely).- Returns:
- the maximum lifetime of a pooled connection
-
getMaxIdleTime
How long a connection may sit unused in the pool before it is evicted.nullleaves Reactor Netty's default in place (no limit).- Returns:
- the maximum idle time of a pooled connection
-
getPendingAcquireTimeout
How long a request may wait for a connection once the pool is saturated before failing.nullleaves Reactor Netty's default in place (45 seconds).- Returns:
- the maximum time spent waiting for a pooled connection
-
getPendingAcquireMaxCount
The maximum number of requests that may be queued waiting for a connection.nullleaves Reactor Netty's default in place (twicegetMaxConnections()).- Returns:
- the maximum number of queued connection acquisitions
-
getEvictInBackground
The interval at which the pool proactively evicts connections that are no longer usable, rather than waiting for them to be acquired again.nullleaves Reactor Netty's default in place (background eviction disabled). Reactor Netty requires a value of at least 1 second when this is set.- Returns:
- the background eviction interval
-
setEnabled
public void setEnabled(boolean enabled) Whether internal service-to-serviceWebClients should use a dedicated, named connection pool rather than Reactor Netty's globalHttpResourcespool. Disabling this restores the pre-3.0.0 behavior, at the cost of losing connection pool metrics.- Parameters:
enabled- whether the dedicated connection pool is used
-
setName
The name of the connection pool. This is emitted as theidtag on everyreactor.netty.connection.provider.*meter, so it is what distinguishes this pool from any other pool in the same application.- Parameters:
name- the name of the connection pool
-
setMetricsEnabled
public void setMetricsEnabled(boolean metricsEnabled) Whether Reactor Netty should publish connection pool metrics for this pool. When enabled, the following gauges are registered against Micrometer's global registry (which Spring Boot binds to the application's
MeterRegistryby default, viamanagement.metrics.use-global-registry):reactor.netty.connection.provider.total.connectionsreactor.netty.connection.provider.active.connectionsreactor.netty.connection.provider.idle.connectionsreactor.netty.connection.provider.pending.connectionsreactor.netty.connection.provider.max.connectionsreactor.netty.connection.provider.max.pending.connectionsreactor.netty.connection.provider.pending.connections.time
Each meter is tagged with
id(the poolname) andremote.address. Meters are registered lazily, as connections to a given remote address are first established. Requiresio.micrometer:micrometer-coreon the classpath; if it is absent, metrics are skipped with a warning rather than failing startup.- Parameters:
metricsEnabled- whether connection pool metrics are published
-
setMaxConnections
public void setMaxConnections(int maxConnections) The maximum number of concurrent connections the pool will open before further acquisitions are queued.
This defaults to
DEFAULT_MAX_CONNECTIONSin order to match the globalHttpResourcespool that this pool displaces. Note that this is not the same asConnectionProvider.builder(name)'s own default, which is only twice the number of available processors (minimum 16) - a fraction of the 500 that internal service-to-service traffic has effectively been running with. Leaving this unset must not quietly shrink the ceiling, or a busy service would start queueing requests until they hitgetPendingAcquireTimeout().MicroPM#6849 proposes lowering this to 350 on the grounds that only ~200 Tomcat worker threads can be initiating outbound requests anyway; that is a deliberate tuning decision and belongs to that work, not here.
- Parameters:
maxConnections- the maximum number of pooled connections
-
setMaxLifeTime
The maximum absolute age of a pooled connection, after which it is evicted once its in-flight request completes.nullleaves Reactor Netty's default in place (no limit, meaning keep-alive connections live indefinitely).- Parameters:
maxLifeTime- the maximum lifetime of a pooled connection
-
setMaxIdleTime
How long a connection may sit unused in the pool before it is evicted.nullleaves Reactor Netty's default in place (no limit).- Parameters:
maxIdleTime- the maximum idle time of a pooled connection
-
setPendingAcquireTimeout
How long a request may wait for a connection once the pool is saturated before failing.nullleaves Reactor Netty's default in place (45 seconds).- Parameters:
pendingAcquireTimeout- the maximum time spent waiting for a pooled connection
-
setPendingAcquireMaxCount
The maximum number of requests that may be queued waiting for a connection.nullleaves Reactor Netty's default in place (twicegetMaxConnections()).- Parameters:
pendingAcquireMaxCount- the maximum number of queued connection acquisitions
-
setEvictInBackground
The interval at which the pool proactively evicts connections that are no longer usable, rather than waiting for them to be acquired again.nullleaves Reactor Netty's default in place (background eviction disabled). Reactor Netty requires a value of at least 1 second when this is set.- Parameters:
evictInBackground- the background eviction interval
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-