Load balancing in Azure Postgres Flexible Server

Sai Vihari 20 Reputation points
2025-02-17T17:19:55.6466667+00:00

Does Azure Database for Postgresql Flexible Server support Load Balancing?What are the best practices for the same?

Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. Mallaiah Sangi 255 Reputation points Microsoft External Staff
    2025-02-19T17:02:33.11+00:00

    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.

    User's 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

    Connection pooling best practices - Azure Database for PostgreSQL - Flexible Server | Microsoft Learn

    https://techcommunity.microsoft.com/blog/adforpostgresql/steps-to-install-and-setup-pgbouncer-connection-pooling-proxy-with-azure-db-for-/730555

    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


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.