Why this problem matters
When connection count approaches max_connections, new clients may be rejected and operational access can become difficult. A large backend population can also increase memory and scheduler pressure.
How to diagnose it
Break down total, active, and idle connections by user and application. Prepared connections and reserved administrative capacity mean a simple total may not fully describe usable slots.
The statements provide read-only summaries of the current limit, connection states, and prepared transactions. Preserve null state values when interpreting totals.
SHOW max_connections;
SELECT state, count(*) AS connections
FROM pg_stat_activity
GROUP BY state
ORDER BY connections DESC;
SELECT count(*) AS prepared_transactions FROM pg_prepared_xacts;A safe solution approach
Correct connection sources, leaks, and pool configuration first. Consider raising max_connections only after testing process, memory, and operating-system capacity.
Why continuous monitoring matters
moon continuously monitors connection use at low overhead to help expose saturation early. Alerts can be routed to on-call staff through Slack, PagerDuty, or webhooks.
Frequently asked questions
Will increasing max_connections solve saturation?
Not always, because more backend processes can amplify memory and CPU pressure. Examine pooling, connection lifecycle, and application concurrency first.
How does moon help with this problem?
moon continuously observes SQL Server, PostgreSQL, and MongoDB signals, helping teams evaluate the problem as a trend instead of relying on a one-time check.