Technologies/PostgreSQL/postgresql.connection.max
PostgreSQLPostgreSQLMetric

postgresql.connection.max

Max connections allowed
Dimensions:None
Available on:OpenTelemetryOpenTelemetry (1)DatadogDatadog (1)
Interface Metrics (2)
OpenTelemetryOpenTelemetry
Configured maximum number of client connections allowed
Dimensions:None
DatadogDatadog
The maximum number of client connections allowed to this database.
Dimensions:None

Technical Annotations (21)

Configuration Parameters (6)
pool_moderecommended: transaction
Returns connection after each transaction, recommended for most use cases
default_pool_sizerecommended: 20
Actual database connections per database/user pair
max_client_connrecommended: 1000
Maximum application connections to pooler
query_timeoutrecommended: 30
Kill queries running longer than 30 seconds to prevent connection starvation
max_connections
defines maximum simultaneous connections allowed
superuser_reserved_connectionsrecommended: 3
Connection slots reserved for superusers to maintain admin access during exhaustion
Error Signatures (2)
FATAL: sorry, too many clients alreadylog pattern
FATAL: remaining connection slots are reserved for non-replication superuser connectionslog pattern
CLI Commands (5)
SELECT query, calls, total_exec_time, mean_exec_time, rows FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 20;diagnostic
ulimit -ndiagnostic
SELECT count(*), state FROM pg_stat_activity GROUP BY state;diagnostic
SELECT pid, usename, application_name, state, query_start, state_change FROM pg_stat_activity WHERE state = 'idle';diagnostic
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE state = 'idle' AND state_change < NOW() - INTERVAL '1 hour';remediation
Technical References (8)
PgBouncercomponent/etc/pgbouncer/pgbouncer.inifile pathcheck_postgrescomponentmax_connectionscomponent/etc/security/limits.conffile pathpg_stat_activitycomponentpg_terminate_backend()componentpostgresql.conffile path
Related Insights (7)
Connection limit exhaustion causes memory pressure and context-switching overheadcritical
Connection count approaching max_connections causes connection failurescritical
Insufficient file descriptor limit prevents server startupcritical
Connection exhaustion prevents new client connectionscritical

Each PostgreSQL connection consumes 5-10MB RAM via fork model. At 200 connections: 1-2GB RAM overhead before queries run. At 500+ connections: excessive context-switching dominates query execution time. Database becomes unresponsive under concurrent load.

Connection slots exhausted preventing new client connectionscritical
Connection failure when requests exceed default 100 connection limitcritical
Connection exhaustion blocks new client connectionscritical