azuresu user and NULL user occupying connections in Azure Database for PostgreSQL - Flexible Servers

nikithakoshy 80 Reputation points
2024-10-14T14:48:25.57+00:00

I am using a Standard_B1ms postgres server in Azure which has 50 as max_connections. I am temporarily using a higher number of connections (still within the limit of 50) as I am running a migration.

While running the following query, we noticed that around 5-10 connections are used by the usename azuresu or NULL

SELECT datname, usename, client_addr, backend_start, state_change, state, query FROM pg_stat_activity where usename = 'azuresu' or NULL order by backend_start

As no other users have super_user privilege, it is impossible to kill those connections as well.

As far as I can see, it isn't doing any activities as well

User's image

May I know what these connections are? are they really necessary? If not, how can I remove these?

[As I am using Standard_B1ms, I guess I can't use PgBouncer]

Thanks

Azure Database for PostgreSQL
0 comments No comments
{count} votes

Accepted answer
  1. Amira Bedhiafi 33,071 Reputation points Volunteer Moderator
    2024-10-15T07:41:37.96+00:00

    The connections made by the azuresu user and the NULL user in Azure Database for PostgreSQL - Flexible Servers are system-related connections.

    1. azuresu User:
      • The azuresu user is a built-in superuser account that Azure Database for PostgreSQL uses for various internal management and maintenance tasks. These can include activities like monitoring, logging, replication, and other background processes essential for the database’s smooth operation.
      • Since this is a system user, you typically do not have the ability to terminate these connections directly, nor is it advisable to do so. These connections ensure the proper functioning of your PostgreSQL instance, and killing them may cause disruptions or unintended side effects.
    2. NULL User:
      • Seeing NULL in the usename field in the pg_stat_activity table can be related to idle connections that haven’t been fully initialized or connections from an external monitoring tool that does not pass a user name in certain states.
      • These connections may appear idle and not consuming active resources, but they still count toward the total number of connections allowed by your PostgreSQL server.

    Recommendations:

    • While you cannot terminate azuresu or NULL connections directly, you can ensure that your application manages its connections efficiently, especially during high-traffic periods like migrations.
    • Consider optimizing your connection usage by reducing the number of idle connections or using connection pooling (e.g., PgBouncer). If PgBouncer is not available in your current tier, you may want to evaluate upgrading temporarily for better connection handling.
    • Use pg_stat_activity regularly to monitor active connections and state. If the number of azuresu or NULL connections spikes unexpectedly, it might indicate a potential issue with internal processes or monitoring tools. Azure's support might help clarify any unusual patterns.
    • If your migration process requires more concurrent connections, you might consider scaling up to a tier with higher connection limits (like Standard_B2ms or higher) temporarily to accommodate the additional load.
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.