Skip to content

Improve connection pool configuration with explicit defaults#74

Merged
dkropachev merged 2 commits intomainfrom
dk/connection-pool-config-improvements
Mar 3, 2026
Merged

Improve connection pool configuration with explicit defaults#74
dkropachev merged 2 commits intomainfrom
dk/connection-pool-config-improvements

Conversation

@dkropachev
Copy link
Collaborator

@dkropachev dkropachev commented Mar 3, 2026

Summary

  • Replace the CONNECTION_POOL_DEFAULT = 0 ("use SDK default") convention with explicit, Alternator-optimized defaults: maxConnections=400, connectionMaxIdleTimeMs=600000 (10 min), connectionTimeToLiveMs=0 (unlimited), connectionAcquisitionTimeoutMs=10000 (10 sec), connectionTimeoutMs=15000 (15 sec)
  • Add two new connection pool settings: connectionAcquisitionTimeoutMs (controls wait time when pool is exhausted) and connectionTimeoutMs (controls TCP handshake timeout)
  • Handle CRT HTTP client limitations gracefully: log info messages when zero-duration timeouts fall back to SDK defaults, log warnings when unsupported connectionTimeToLiveMs is set
  • Apache sync client now explicitly disables the idle connection reaper when connectionMaxIdleTimeMs=0
  • Log a warning when idle connection eviction is explicitly disabled (connectionMaxIdleTimeMs=0)
  • Document all connection pool settings with defaults table in README

Breaking changes

  • CONNECTION_POOL_DEFAULT constant removed (was 0)
  • hasCustomConnectionPoolSettings() method removed
  • maxConnections=0 now throws IllegalArgumentException (must be positive)
  • Default behavior changes: pool settings are now always applied with explicit values instead of deferring to SDK defaults

Test plan

  • Unit tests for new config fields, defaults, and validation
  • Connection pool exhaustion tests for all HTTP clients (Apache, CRT sync/async, Netty) using real HTTP server
  • Zero-timeout fallback tests for CRT sync/async
  • Idle connection reaper enable/disable tests for Apache
  • Connection TTL tests for Netty
  • Warning/info log verification tests for CRT and config

Replace CONNECTION_POOL_DEFAULT sentinel with explicit per-setting defaults
in AlternatorConfig. Add info-level logging in CRT factories when zero-value
timeouts fall back to SDK defaults. Document asymmetric zero-value semantics
across HTTP clients (unlimited for Apache/Netty, unsupported for CRT).
@dkropachev dkropachev force-pushed the dk/connection-pool-config-improvements branch from da1b5ff to 6aff809 Compare March 3, 2026 22:49
@dkropachev dkropachev changed the title Improve connection pool configuration with explicit defaults and logging Improve connection pool configuration with explicit defaults Mar 3, 2026
@dkropachev dkropachev marked this pull request as ready for review March 3, 2026 22:59
@dkropachev dkropachev merged commit ffd1e37 into main Mar 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant