Skip to content

perf: raise the default connection pool size from 5 to 100 - #173

Merged
mogita merged 2 commits into
mainfrom
perf/connection-pool-default-100
Oct 1, 2026
Merged

mogita merged 2 commits into
mainfrom
perf/connection-pool-default-100

Conversation

@mogita

@mogita mogita commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The default transport capped each client at 5 concurrent connections per host (MaxConnsPerHost = 5). The API is served over HTTP/1.1, so a 6th concurrent request waits for a free connection, and that wait counts against the request timeout.

Solution

  • Raise the WithMaxConnsPerHost default from 5 to 100. It also sets MaxIdleConnsPerHost, so up to 100 connections are kept warm for reuse. Idle connections still close after 55s.
  • Set MaxIdleConns to 0. The cloned http.DefaultTransport caps idle connections at 100 across all hosts, which would otherwise override a larger WithMaxConnsPerHost.
  • 100 matches stream-py (#299).
  • Apps that relied on the old limit to throttle traffic can pass WithMaxConnsPerHost(5).

How to verify

  1. go test -short -run 'TestClientDefaultTransportConfig|TestClientInfoLogOnConstruction' -v .
  2. Both pass and assert MaxConnsPerHost and MaxIdleConnsPerHost at 100, MaxIdleConns at 0, and the client.initialized log line at 100.

The default of 5 capped each client at 5 concurrent requests, so busy servers queued behind the pool. 100 matches httpx's default and stream-py.
@mogita
mogita requested a review from tbarbugli as a code owner October 1, 2026 12:10
Comment thread client.go
@mogita
mogita merged commit 93d769a into main Oct 1, 2026
15 checks passed
@mogita
mogita deleted the perf/connection-pool-default-100 branch October 1, 2026 13:44
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