| title | description | ms.service | ms.subservice | ms.topic | ms.author | ms.date |
|---|---|---|---|---|---|---|
Azure Database for PostgreSQL Flexible Server - PgBouncer metrics (Preview) |
Metrics to monitor PgBouncer |
postgresql |
flexible-server |
conceptual |
varun.dhawan |
11/01/2022 |
Postgres is a powerful and popular open-source relational database management system (RDBMS). However, as the number of connections to a Postgres database grows, managing and monitoring those connections can become a challenge. That's where connection pooling comes in.
PgBouncer probably the most popular connection pooler in postgrtes. It is a lightweight connection pooler that helps to improve the performance and scalability of your Postgres databases by managing and reusing database connections. By pooling connections, PgBouncer reduces the number of connections that need to be opened and closed, reducing the load on your Postgres server and improving overall performance.
Azure Database for PostgreSQL – Flexible Server offers PgBouncer as a built-in option, wherein customers can easily enable PgBouncer from Azure Postgres server parameters and update the app connection string to talk to PgBouncer on port 6432, rather than directly to the database server.
When using PgBouncer, it's important to monitor the performance of PgBouncer to ensure that it's functioning as expected and to identify any potential issues. Here are some key metrics to monitor when using PgBouncer with Azure Postgres Flexible Server:
| Metrics ID | Description | SHOW commands | Dimension | Status |
|---|---|---|---|---|
| pgbouncer.pools.cl_active | Client connections linked to server connection and able to process queries | SHOW POOLS | DatabaseName | Committed (M26) |
| pgbouncer.pools.cl_waiting | Client connections waiting on a server connection | SHOW POOLS | DatabaseName | Committed (M26) |
| pgbouncer.pools.sv_active | Server connections linked to a client connection | SHOW POOLS | DatabaseName | Committed (M26) |
| pgbouncer.pools.sv_idle | Server connections idle and ready for a client query | SHOW POOLS | DatabaseName | Committed (M26) |
| pgbouncer.database.active_connections | Current number of connections (client-2-pgBouncer) | SHOW DATABASES | DatabaseName | Committed (M26) |
| pgbouncer.pools.pools_per_database | Total no. of pools per DB | CUSTOM METRICS | DatabaseName | Committed (M26) |
- Most of these new metrics are disabled by default
- To enable these metrics, please turn ON the server parameter
pgbouncer.diagnostics.- This parameter is dynamic, and will not require instance restart.
- PgBouncer Admin Console - https://www.pgbouncer.org/usage.html
- Engineering - [email protected], [email protected]
- Product - [email protected], [email protected]