Hi @Sai Vihari
Thank you for reaching out with your inputs.
Connection pooling strategy for Azure Database for PostgreSQL - Flexible Server using PgBouncer
When using Azure Database for PostgreSQL flexible server, establishing a connection to the database involves creating a communication channel between the client application and the server
Once the connection is established, the client application can send commands to the server and receive responses. However, creating a new connection for each operation can cause performance issues for mission-critical applications which consumes more resources
To mitigate this issue, connection pooling is used to create a cache of connections that can be reused in Azure Database for PostgreSQL flexible server
PgBouncer deployed in Application VM
If your application runs on an Azure VM, you can set up PgBouncer on the same VM. To install and configure PgBouncer as a connection pooling proxy with Azure Database for PostgreSQL flexible server, follow the instructions provided.
PgBouncer connection proxy is set up between the application and database layer behind an Azure Load Balancer as shown in the image.
In this pattern multiple PgBouncer instances are deployed behind a load balancer as a service to mitigate single point of failure.
Benefits:
- Application connectivity may not be affected by the failure of a single PgBouncer VM, as there are several PgBouncer instances behind Azure Load Balancer.
- If PgBouncer is deployed as a single instance on the application server, it becomes a potential single point of failure. If the PgBouncer instance goes down, it can disrupt the entire database connection pool, causing downtime for the application. To mitigate Single point of failure, you can set up multiple PgBouncer instances behind a load balancer for high availability.
Please refer to the document links below, which will help you configure PgBouncer using a Load Balancer
Hope this helps. Do let us know if you any further queries. If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know