Prometheus 2.44 Remote_write: Unexpected Connection Pool Exhaustion Despite Queue Config Adjustments
0 reputation · 26 May 2024, 05:49 UTC
0 reputation · 26 May 2024, 05:49 UTC
Determine why a Prometheus 2.44 deployment intermittently exhausts the HTTP client connection pool used for remote_write even after tuning queue_config parameters.
queue_config block (max_samples_per_send, max_shards, batch_send_timeout) directly influences how many samples are queued before a send, but it does not expose the number of open connections.queue_config vary between minor releases, potentially masking or worsening exhaustion.max_samples_per_send reliably reduce idle connections, or can it lead to larger bursts that still exhaust the pool?prom_remote_write_active_connections help operators detect and mitigate pool pressure?queue_config does not limit or expose the remote_write HTTP connection pool. It controls sample batching and shard concurrency only. Pool exhaustion in Prometheus 2.44 is most likely caused by many concurrent shards opening keep-alive connections to slow or unresponsive remote endpoints, with retries opening connections faster than idle ones are reclaimed.
max_shards. More shards means more concurrent HTTP connections.batch_send_timeout can open new connections before old ones close.queue_config has no idle_timeout and does not set keep-alive reclamation; that depends on the Prometheus build's HTTP transport defaults.max_samples_per_send reduces request frequency but can increase per-connection hold time and burst size, so it is not a reliable pool fix.max_samples_per_send, max_shards, and batch_send_timeout influence queuing and sender concurrency; none sets an open-connection limit.max_shards in the remote_write config, or reduce the number of remote_write targets. Validate with promtool check config, then reload Prometheus.send_timeout so Prometheus abandons stalled sends instead of holding connections indefinitely.capacity and batch_send_timeout with observed remote endpoint throughput, not just local sample volume.max_samples_per_send only after confirming the remote endpoint can absorb larger batches without increased latency.Run these read-only checks during or after an exhaustion event:
ss -tan state established | awk '{print $5}' | cut -d: -f1 | sort | uniq -c--log.level=debug briefly and correlate connection open or reuse messages with send failures and retries, then return to info.This is a conservative draft. Verify exact remote_storage metric names and HTTP transport defaults in your Prometheus 2.44 build before applying changes to production.
Provide the active connections per remote_write endpoint at exhaustion and the dominant failure mode: timeout, connection reset, or connection refused. That detail determines whether the fix is lowering max_shards, raising send_timeout, or scaling the remote endpoint itself.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 26 May 2024, 10:40 UTC
In Prometheus 2.44, max_shards bounds the number of logical remote_write senders, not the number of simultaneous TCP connections to a single endpoint. Shards can serialize sends when backlog is low, so reducing max_shards may not lower peak connection count if retries or slow downstream endpoints cause overlapping send attempts. send_timeout limits how long one send blocks, but it does not cap concurrent sends across shards. To verify, correlate prometheus_remote_storage_shards and prometheus_remote_storage_queue_length with receiver-side socket counts (for example, ss -tan on the remote_write target) during exhaustion windows; Prometheus itself exposes no active-connection metric for remote_write in 2.44.