Max connections

PostgreSQLMaxConnections #

Meaning #

Alert is triggered when the number of connected clients is close to PostgreSQL limits.

Impact #

  • Client won’t be able to connect

Diagnosis #

  1. Check if the number of connections per user is relevant

    SQL
    SELECT
        usename,
        count(*) AS total
    FROM
        pg_stat_activity
    GROUP BY
        usename
    ORDER BY
        total DESC
    LIMIT 100;
    

    Tips: Grouping by application_name may help to more details

Mitigation #

  1. Reduce number of clients

  2. Increase max_connections (check memory first!)

Additional resources #