pub struct PoolConfig {
pub max_idle_per_origin: usize,
pub idle_timeout: Duration,
pub max_connection_lifetime: Option<Duration>,
pub max_conns_per_origin: usize,
pub h2_target_streams_per_conn: usize,
pub h2_min_conns_per_origin: usize,
pub h2_max_conns_per_origin: usize,
pub h2_scale: ScaleThresholds,
pub checkout_timeout: Option<Duration>,
pub h2_zero_capacity_drain: Duration,
}Expand description
Pool limits and timeouts.
Fields§
§max_idle_per_origin: usizeIdle HTTP/1 connections kept per origin (default 256, the same as max_conns_per_origin, so a burst
does not close connections it will want again; idle_timeout closes the unused ones). Each idle
connection holds a file descriptor: lower this for clients that talk to many origins.
idle_timeout: DurationIdle HTTP/1 connections older than this are discarded at checkout, and HTTP/2 connections without streams for this long are closed (default 90 s).
max_connection_lifetime: Option<Duration>Connections are retired once they are this old, so traffic follows DNS and load-balancer changes
(default None: no limit). HTTP/1 connections are closed when they are next returned or checked out;
an HTTP/2 connection stops taking new streams after its replacement is up and closes once its
in-flight requests finish.
max_conns_per_origin: usizeHTTP/1: maximum connections (in use + idle + dialing) per origin (default 256).
h2_target_streams_per_conn: usizeStreams per HTTP/2 connection (default 128, or less when the server’s MAX_CONCURRENT_STREAMS is lower).
Requests beyond it go to another connection, which the pool dials if needed.
h2_min_conns_per_origin: usizeHTTP/2 connections kept per origin: dialed eagerly once the origin is known to speak h2 and never scaled below (default 1). Leave it alone: the pool adds connections under load by itself.
h2_max_conns_per_origin: usizeHTTP/2 autoscaling ceiling per origin (default: std::thread::available_parallelism(); one
connection is one actor task, so more connections than cores cannot add parallelism). Autoscaling
also stays within the tokio runtime’s worker count (unless h2_min_conns_per_origin is higher). Set equal to
h2_min_conns_per_origin to pin the connection count. Replacing a connection past
max_connection_lifetime may exceed it by one for a moment. See scale for the policy.
h2_scale: ScaleThresholdsHTTP/2 scale-up thresholds (defaults: the constants in scale).
checkout_timeout: Option<Duration>Maximum time a request waits for a connection or stream slot (default 30 s; None waits forever).
Failure is PoolTimeout with Recovery::Unprocessed.
h2_zero_capacity_drain: DurationAn HTTP/2 connection whose peer advertises SETTINGS_MAX_CONCURRENT_STREAMS = 0 is retired after
this long (default 10 s). Such a connection never counts as capacity and never triggers scale-up.