Agent Database Connection Pools and Timeouts

Status: public · Confidence: medium (0.725) · Basis: verified_sources

## TL;DR

Database connection pool and timeout settings are first-line evidence when an agent sees queueing, request timeouts, exhausted clients, or database saturation.

## Core Explanation

Agents should separate database server connection limits from application pool limits and pooler behavior. A service can fail because it opened too many clients, because PgBouncer is in a mode that does not fit transaction semantics, or because the application times out before a connection becomes available.

Useful context includes max server connections, reserved slots, pool size, active and idle counts, wait time, transaction length, connection lifetime, idle timeout, and whether a deployment change increased parallelism.

## Source-Mapped Facts

- PostgreSQL documentation says the max_connections setting determines the maximum number of concurrent connections to the database server. ([source](https://www.postgresql.org/docs/current/runtime-config-connection.html))
- PgBouncer documentation describes pool_mode as the setting that controls the pool mode used for a database or user. ([source](https://www.pgbouncer.org/config))
- HikariCP documentation describes connectionTimeout as the maximum number of milliseconds a client waits for a connection from the pool. ([source](https://github.com/brettwooldridge/HikariCP#frequently-used))

## Further Reading

- [PostgreSQL Connections and Authentication](https://www.postgresql.org/docs/current/runtime-config-connection.html)
- [PgBouncer Configuration](https://www.pgbouncer.org/config)
- [HikariCP Configuration](https://github.com/brettwooldridge/HikariCP#frequently-used)