Bars of connections opened for 3,200 bursty requests: urllib3 default 3,098, Go default 2,841, boto3 default 1,909, sized pools 32

Every new HTTPS connection costs two round trips before your request can leave: one for TCP, one for TLS 1.3. If your client throws connections away between requests, you pay that again and again, and the S3 server never complains. It just looks slow.

We counted connections for four clients (urllib3, boto3, aiohttp and Go's net/http) on 10,000 requests each, at 1, 8 and 32 workers, with default settings, with a pool sized to the workers, and with a new client for every request. The server side did the counting, so the numbers are not what the library thinks it did.

The setup

  • A stand-in server behind nginx 1.31 with TLS 1.3 on loopback, answering every GET with a 4 KB body after a fixed 5 ms. It is not an S3 server: we wanted one thing, connection behaviour. A real S3 first byte is slower, so your ratios will be gentler.
  • Clients: urllib3 2.8.0, boto3 (the same urllib3 underneath, signing every request), aiohttp 3.14.5, Go 1.27.4 net/http. Python 3.13. The cert is verified against a local CA in every client.
  • nginx logs $connection, a number unique per TCP connection. We count the distinct numbers: that is how many connections the server saw.
  • Sized pool means: urllib3 maxsize=workers, boto3 max_pool_connections=workers, Go MaxIdleConnsPerHost=workers. aiohttp's connector already allows 100 per host, so it only has a default row.
  • New client per request is the requests.get() / aiohttp.ClientSession() inside the handler habit. These runs use 3,000 requests, because macOS runs short of free local ports above that.

Steady load: default pools are fine, except in Go

10,000 requests, workers always busy. Connections the server saw:

Client / setting1 worker8 workers32 workers
urllib3 default1832
urllib3 sized pool1832
boto3 default (pool of 10)1832
boto3 sized pool1832
aiohttp default1832
Go default173240
Go sized pool1832
New client per request (3,000 requests)3,0003,0003,000

Python's defaults held up here. Our reading: under sustained load a connection is back in use before the pool is full of idle ones, so nothing gets dropped. Go's default is different: <code>http.DefaultTransport</code> keeps at most 2 idle connections per host. With 8 busy workers, Go closed and reopened connections 65 extra times in 10,000 requests, and 208 extra times with 32.

Per-request cost of a new connection

ClientReused connection p50New connection each time p50Added by connect + TLS
urllib37.9 ms11.4 ms3.5 ms
aiohttp7.3 ms11.8 ms4.5 ms
Go7.3 ms10.5 ms3.2 ms

These are one-worker runs on loopback, so 3 to 4 ms is pure CPU and kernel work: a TLS 1.3 handshake with an ECDSA certificate plus TCP setup. The request itself is 7 ms (5 ms server time plus the client). No network distance is in these numbers. That part you can calculate.

The round-trip arithmetic

  • A new TLS 1.3 connection needs 1 round trip for TCP and 1 for the TLS handshake (RFC 8446). The request goes out after that, so it takes 3 round trips instead of 1.
  • Extra wait per request on a new connection = 2 × RTT.
  • At 20 ms RTT: +40 ms. At 40 ms: +80 ms. At 100 ms (cross-ocean): +200 ms. TLS 1.2 adds one more round trip.

Go's default at 32 workers opened 208 extra connections. At 40 ms RTT that is 208 × 80 ms = 16.6 s of waiting, spread over 32 workers: about 0.5 s each, on a job that took 2 s on loopback. That is a 25% slower job from one setting.

Bursty load: where Python's defaults break

Web handlers and cron jobs do not run flat out. We sent 32 requests together, idled 100 ms, and did that 100 times (3,200 requests). While idle, a pool smaller than 32 can only keep a few connections, and the rest are closed. The next burst reconnects.

Client / settingConnections for 3,200 requestsp50p95
urllib3 default (pool of 1)3,09826.5 ms32.1 ms
urllib3 pool of 323211.8 ms14.8 ms
boto3 default (pool of 10)1,90924.0 ms35.3 ms
boto3 pool of 323217.8 ms31.8 ms
aiohttp default327.2 ms8.7 ms
Go default (2 idle per host)2,84122.3 ms27.6 ms
Go idle pool of 32328.9 ms10.6 ms

urllib3 defaults opened a new connection for 97% of the requests; the sized pool opened 32 once and kept them. The loopback p50 more than halved for urllib3 and Go. At 40 ms RTT, the urllib3 default's 3,098 new connections are 3,098 × 80 ms = 248 s of handshake waiting; the sized pool's 32 are 2.6 s.

aiohttp's default connector kept all 32 through the 100 ms idle, because it holds idle connections for 15 seconds by default and has no per-host cap below 100.

What to set

python
# boto3: pool = the most calls you make at once
from botocore.config import Config
s3 = boto3.client('s3', endpoint_url=URL, config=Config(max_pool_connections=32))

# urllib3 directly
http = urllib3.PoolManager(maxsize=32)

# aiohttp: reuse one ClientSession for the whole process
session = aiohttp.ClientSession()  # not one per request
go
tr := http.DefaultTransport.(*http.Transport).Clone()
tr.MaxIdleConnsPerHost = 32 // default is 2
tr.MaxIdleConns = 32
client := &http.Client{Transport: tr} // one client for the whole program
  • Set the pool to the number of requests you make at once, not to the average. A thread pool of 32 means a pool of 32.
  • Make one client at startup. Do not create it inside the request handler. boto3 clients are thread-safe.
  • Read the whole body, or close it. A response you do not finish reading keeps its connection out of the pool (Go and urllib3 both).
  • Check from the server: if your logs show a new connection per request, the client is not reusing. For an S3-compatible endpoint, a count of distinct source ports over a minute does the same job.

Pooling matters most for many small objects. If your uploads are large, tune parts first: multipart concurrency in boto3. When the server pushes back, see retries under 503 SlowDown.

Use any S3 client with an S3-compatible endpoint and scoped access keys.

Explore tport.space

Test record and sources

  • Run on 2026-11-14 on one Mac, loopback. 10,000 requests per steady run; 3,000 for new-client runs; 3,200 for bursts. One run per cell, so treat differences under about 10% as noise. Connection counts were exact and repeatable.
  • Not tested: real S3 or tport.space latency, HTTP/2, session resumption (no client resumed a TLS session), proxies, and Python sessions from requests.
  • Sources: RFC 8446 (TLS 1.3 handshake is one round trip), Go net/http (DefaultMaxIdleConnsPerHost is 2), urllib3 pool behaviour (maxsize, connections over it are discarded), botocore Config (max_pool_connections default 10), aiohttp TCPConnector (limit 100, keepalive_timeout 15 s).