Establishing a new TCP connection — and especially a TLS connection — adds meaningful latency to every request. The TCP handshake alone requires a round trip; TLS adds another one or two. At any significant scale these costs compound into substantial overhead. Pingora eliminates this overhead automatically: when a request to an upstream server completes, the connection is placed in a pool keyed by the upstream’s identity. The next request to the same upstream picks up that connection from the pool and proceeds directly to sending the request, skipping the handshake entirely. This happens with no special configuration. The pool is maintained per Pingora worker thread and connections are transparently recycled. The result is lower latency, reduced CPU usage (fewer cryptographic handshakes), and higher throughput on the same hardware.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cloudflare/pingora/llms.txt
Use this file to discover all available pages before exploring further.
Peer Identity for Pooling
Only connections to the exact same peer are reusable. Pingora determines peer identity by comparing all of the following attributes. If every attribute matches, an existing pooled connection can be reused; if any attribute differs, a new connection is established.| Attribute | Why it matters for pooling |
|---|---|
| IP:port | Connections are to a specific server instance |
| Scheme | HTTP and HTTPS connections are not interchangeable |
| SNI | Different SNI values may reach different virtual hosts on the same IP |
| Client certificate | mTLS connections are bound to a specific client identity |
| verify_cert | A connection with certificate verification disabled is not safe to reuse for a request that requires verification |
| verify_hostname | Same reasoning as verify_cert |
| alternative_cn | Part of the TLS identity — different CN acceptance means different security posture |
| Proxy settings | Connections routed through different CONNECT proxies are physically distinct |
Disabling Pooling
To opt out of connection pooling for a specific peer, setidle_timeout to zero in PeerOptions. A connection with an idle timeout of zero is never added to the pool after use — it is closed immediately when the request completes.
Pool Size Configuration
The maximum number of idle connections held in the pool per-thread is controlled byupstream_keepalive_pool_size in Pingora’s server configuration YAML:
Connection Reuse Failure
A connection is marked as not reusable if any error occurs during the request that uses it. This prevents a half-open or corrupted connection from being returned to the pool and given to a future request.
error_while_proxy() is called, the connection is discarded rather than pooled. If the error was on a previously reused connection (i.e., the upstream dropped an idle connection before the proxy could use it), the default implementation of error_while_proxy() automatically marks the error as retryable — allowing Pingora to establish a fresh connection and retry the request transparently, provided the downstream has not yet received any response bytes.
This means transient “connection reset on reuse” failures are typically handled automatically and invisibly to the downstream client.