Rediger

Configure high availability for Azure Database for PostgreSQL flexible server

This article describes how to enable or disable high availability (HA) on your Azure Database for PostgreSQL flexible server. The information applies whether you're using servers in the same zone or using a zone-redundant deployment model. This article describes how to enable or disable high availability (HA) on your Azure Database for PostgreSQL flexible server. The information applies whether you're using servers in the same zone or using a zone-redundant deployment model.

The high-availability feature deploys physically separate primary and standby replicas. You can provision the replicas within the same availability zone or in different zones, depending on the deployment model that you choose. For more information, see the article about high-availability concepts. You can enable high availability during or after the creation of your Azure Database for PostgreSQL flexible server. The high-availability feature deploys physically separate primary and standby replicas. You can provision the replicas within the same availability zone or in different zones, depending on the deployment model that you choose. For more information, see the article about high-availability concepts. You can enable high availability during or after the creation of your Azure Database for PostgreSQL flexible server.

Enable high availability for existing servers

You can enable high availability on an existing Azure Database for PostgreSQL flexible server at any time. When you enable high availability, the service creates a standby replica that mirrors your primary server. Depending on regional capacity and your configuration choices, the standby can be deployed in a different availability zone for maximum protection or in the same zone as the primary. You can enable high availability on an existing Azure Database for PostgreSQL flexible server at any time. When you enable high availability, the service creates a standby replica that mirrors your primary server. Depending on regional capacity and your configuration choices, the standby can be deployed in a different availability zone for maximum protection or in the same zone as the primary.

Using the Azure portal:

  1. Select your Azure Database for PostgreSQL flexible server. Using the Azure portal:

  2. Select your Azure Database for PostgreSQL flexible server.

  3. In the resource menu, under the Settings section, select High availability.

The Zonal resiliency option controls whether your server is protected across availability zones. You have two choices:

  • Disabled (99.9% SLA): High availability isn't configured.
  • Enabled (99.99% SLA): When you select this option, Azure tries to create the standby server in a different availability zone than the primary. This option gives you the best protection against zone-level failures.

If you enable zonal resiliency but your region lacks capacity for a zone redundant setup, an extra checkbox appears under the Enabled (99.99% SLA) option. Select this checkbox to allow the standby server to be created in the same zone as the primary server. When zonal capacity becomes available, Azure automatically migrates your workloads from same zone to zone redundant.

  1. If you didn't enable zonal resiliency, select the Enabled option.

    Screenshot showing the High availability page for configuring high availability.

  2. When you select the Enabled option, the Zone redundant option is applied by default for regions that support availability zones. This configuration protects against zonal failures.

    Screenshot showing the radio button selected to enable high availability.

  3. If the region doesn't have zonal capacity, to make sure that high availability (HA) gets enabled in your preferred region, select the checkbox under the enabled option to allow creating HA with Same-Zone mode of the region:

    Screenshot showing selection of the same zone option for high availability.

  4. When you're done configuring the settings, select Save to apply the changes.

  5. A dialog shows the cost increase associated with the deployment of the standby server. If you decide to proceed, select Enable high availability.

    Screenshot showing the dialog to confirm the enablement of high availability.

  6. A new deployment is launched to enable high availability on your Azure Database for PostgreSQL flexible server.

    Screenshot showing the deployment in progress of a high-availability configuration.

  7. When the deployment completes, you can select Go to resource to go back to your Azure Database for PostgreSQL flexible server.

    Screenshot showing the deployment successfully completed to enable a high-availability configuration.

Disable high availability

You can disable high availability on your Azure Database for PostgreSQL flexible server when you no longer need the protection of a standby replica. Disabling high availability removes the standby server and reduces costs, but your server is no longer protected against zone or server failures.

Using the Azure portal:

  1. Select your Azure Database for PostgreSQL flexible server.

  2. In the resource menu, under the Settings section, select High availability.

  3. If high availability is enabled, the Enabled radio button for Zonal Resiliency is already selected. Also, High availability mode is set to the configured mode, and the High availability status value is typically Healthy.

    Screenshot showing the pane for configuring high availability, with high-availability options already selected and a status of Healthy.

  4. Select the Disabled radio button to disable high availability.

    Screenshot showing the checkbox for enabling high availability cleared.

  5. Select Save to apply the changes.

  6. A dialog shows the cost reduction associated with the removal of the standby server. If you decide to proceed, select Disable high availability.

    Screenshot showing the dialog to confirm disablement of high availability.

  7. A deployment starts. When it finishes, a notification shows that you successfully disabled high availability.

    Screenshot showing a notification about successful disablement of high availability.

Enable Business Critical (High Availability) during server provisioning

You can configure high availability when you first create your Azure Database for PostgreSQL flexible server. By enabling high availability during provisioning, you deploy a standby replica alongside your primary server, so you get immediate protection against zone or server failures.

Using the Azure portal:

  1. During provisioning of a new Azure Database for PostgreSQL flexible server, go to the Business Critical (High availability) section. Select Enabled option in the Zonal resiliency section.

    • By default, the server tries to create the standby server in a different availability zone with Zone-Redundant HA mode for maximum zonal resiliency.

    Screenshot showing enabling HA with zone-redundant option.

    • If zonal capacity isn't available, select the Allow standby in same zone if zonal resiliency fails checkbox as a fallback. If you don't select this option, you can't proceed to the next step in the create workflow. This check ensures high availability remains enabled. When zonal capacity becomes available, Azure automatically migrates your workloads from Same-Zone HA to Zone-redundant HA.

      Screenshot showing validation error message for same-zone HA option.

    • After you select the checkbox, proceed to the Authentication section in the create workflow.

      Screenshot showing high-availability with same-zone HA option.

  2. Select a specific zone for the primary server by setting Availability zone to any value other than No preference.

    Screenshot showing the selection of specific availability zones for primary server.

Initiate a forced failover

Follow these steps to force a failover of your primary server to the standby server in Azure Database for PostgreSQL.

When you initiate a forced failover, the primary server immediately goes down and triggers a failover to the standby server. Initiating a forced failover is useful when you want to test how a failover caused by an unplanned outage affects your workload.

Important

  • Don't perform immediate, back-to-back failovers. Wait for at least 15 to 20 minutes between failovers. This wait time allows the new standby server to be fully established.

  • The overall end-to-end operation time, as reported on the portal, might be longer than the actual downtime that the application experiences. You should measure the downtime from the application's perspective.

Using the Azure portal:

  1. Select your Azure Database for PostgreSQL flexible server that has high availability enabled.

  2. In the resource menu, under the Settings section, select High availability.

  3. If the primary and standby servers are deployed in different zones, note the values assigned to Primary availability zone and Standby availability zone. These values reverse after the failover operation finishes.

    Screenshot showing the availability zones of primary and standby.

  4. Select Forced failover to start the manual failover procedure. A dialog informs you of the expected downtime until the failover finishes. If you decide to proceed, select Initiate forced failover.

    Screenshot showing the dialog displayed before the initiation of a forced failover.

  5. A notification appears and mentions that a failover is in progress.

    Screenshot showing a notification about a failover in progress after the initiation of a forced failover.

  6. After the failover to the standby server completes, a notification informs you of the completion.

    Screenshot showing the notification displayed when a forced failover finishes.

  7. If the primary and standby servers are deployed in different zones, confirm that the values of Primary availability zone and Standby availability zone are reversed, compared to how they were before failover started.

Initiate a planned failover

Follow these steps to perform a planned failover from your primary server to the standby server in Azure Database for PostgreSQL. When you initiate this operation, it prepares the standby server and then performs the failover.

This failover operation provides the least downtime, because it performs a graceful failover to the standby server. It's useful for situations like bringing the primary server back to your preferred availability zone after an unexpected failover.

Important

  • Don't perform immediate, back-to-back failovers. Wait for at least 15 to 20 minutes between failovers. This wait time allows the new standby server to be fully established.

  • Perform planned failovers during low-activity periods.

  • The overall end-to-end operation time, as reported on the portal, might be longer than the actual downtime that the application experiences. You should measure the downtime from the application's perspective.

Using the Azure portal:

  1. Select your Azure Database for PostgreSQL flexible server that has high availability enabled.

  2. In the resource menu, under the Settings section, select High availability.

  3. If the primary and standby servers are deployed in different zones, note the values assigned to Primary availability zone and Standby availability zone. These values reverse after the failover operation finishes.

    Screenshot showing the availability zones of primary and standby.

  4. Select Planned failover to start the manual failover procedure. A dialog informs you of the expected downtime until the failover finishes. If you decide to proceed, select Initiate planned failover.

    Screenshot showing the dialog displayed before the initiation of a planned failover.

  5. A notification appears and mentions that failover is in progress.

    Screenshot showing a notification about a failover in progress after the initiation of a planned failover.

  6. After the failover to the standby server completes, a notification informs you of the completion.

    Screenshot showing the notification displayed when a planned failover finishes.

  7. If the high-availability mode is configured as Zone redundant, confirm that the values of Primary availability zone and Standby availability zone are now reversed.

Limitations and considerations

  • When you enable or disable high availability on an Azure Database for PostgreSQL flexible server, the service doesn't change other settings. These settings include networking configuration, firewall settings, parameters, and backup retention. Enabling or disabling high availability is an online operation. This operation doesn't affect your application connectivity and operations.

  • Azure Database for PostgreSQL supports high availability with both replicas deployed in the same zone. You can use this configuration in all supported regions. However, high availability with zone redundancy is available only in certain regions.

  • The Burstable tier doesn't support high availability. Only the General purpose and Memory optimized tiers support high availability.

  • If you deploy a server in a region that consists of a single availability zone, you can enable high availability in the same-zone mode only. If Microsoft enhances the region in the future with multiple availability zones, you can deploy new Azure Database for PostgreSQL flexible servers with high availability configured as same zone or zone redundant.

    However, you can't directly enable high availability in zone-redundant mode for any server that you deployed in the region when the region consisted of a single availability zone. As a workaround, you can use the restore option or read replica option:

Restore option

  1. Restore to latest restore point.
  2. After you create the new server, enable high availability with zone redundancy.
  3. After data verification, you can optionally delete the old server.
  4. Make sure that you modify the connection strings of your clients to point to your newly restored server.

Read replica option

  1. Create a read replica in the same region as your primary server.

  2. Promote the read replica to become the new primary server.

  3. To preserve the original name, either use virtual endpoints or drop the old primary, then create and promote a new read replica.

  4. For portal users, enable Zonal Resiliency. For developer tools, set High Availability with the Zone-Redundant option.

  5. Create a read replica in the same region as your primary server.

  6. Promote the read replica to become the new primary server.

  7. To preserve the original name, either use virtual endpoints or drop the old primary, then create and promote a new read replica.

  8. For portal users, enable Zonal Resiliency. For developer tools, set High Availability with the Zone-Redundant option.