This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Download Microsoft Edge
More info about Internet Explorer and Microsoft Edge
Important
Azure Database for PostgreSQL - Single Server is on the retirement path. We strongly recommend for you to upgrade to Azure Database for PostgreSQL - Flexible Server. For more information about migrating to Azure Database for PostgreSQL - Flexible Server, see
What's happening to Azure Database for PostgreSQL Single Server
?
In this article, you learn how to create and manage read replicas in Azure Database for PostgreSQL from the Azure portal. To learn more about read replicas, see the
overview
.
Prerequisites
An
Azure Database for PostgreSQL server
to be the primary server.
Azure replication support
Read replicas
and
logical decoding
both depend on the Postgres write ahead log (WAL) for information. These two features need different levels of logging from Postgres. Logical decoding needs a higher level of logging than read replicas.
To configure the right level of logging, use the Azure replication support parameter. Azure replication support has three setting options:
Off
- Puts the least information in the WAL. This setting is not available on most Azure Database for PostgreSQL servers.
Replica
- More verbose than
Off
. This is the minimum level of logging needed for
read replicas
to work. This setting is the default on most servers.
Logical
- More verbose than
Replica
. This is the minimum level of logging for logical decoding to work. Read replicas also work at this setting.
When deploying read replicas for persistent heavy write-intensive primary workloads, the replication lag could continue to grow and may never be able to catch-up with the primary. This may also increase storage usage at the primary as the WAL files are not deleted until they are received at the replica.
Prepare the primary server
In the Azure portal, select an existing Azure Database for PostgreSQL server to use as a primary.
From the server's menu, select
Replication
. If Azure replication support is set to at least
Replica
, you can create read replicas.
If Azure replication support is not set to at least
Replica
, set it. Select
Save
.
Refresh the Azure portal page to update the Replication toolbar. You can now create read replicas for this server.
Create a read replica
To create a read replica, follow these steps:
Select an existing Azure Database for PostgreSQL server to use as the primary server.
On the server sidebar, under
SETTINGS
, select
Replication
.
Select
Add Replica
.
To learn more about which regions you can create a replica in, visit the
read replica concepts article
.
Select
OK
to confirm the creation of the replica.
After the read replica is created, it can be viewed from the
Replication
window:
Important
Review the
considerations section of the Read Replica overview
.
Before a primary server setting is updated to a new value, update the replica setting to an equal or greater value. This action helps the replica keep up with any changes made to the primary.
Stop replication
You can stop replication between a primary server and a read replica.
Important
After you stop replication to a primary server and a read replica, it can't be undone. The read replica becomes a standalone server that supports both reads and writes. The standalone server can't be made into a replica again.
To stop replication between a primary server and a read replica from the Azure portal, follow these steps:
In the Azure portal, select your primary Azure Database for PostgreSQL server.
On the server menu, under
SETTINGS
, select
Replication
.
Select the replica server for which to stop replication.
Delete a primary server
To delete a primary server, you use the same steps as to delete a standalone Azure Database for PostgreSQL server.
Important
When you delete a primary server, replication to all read replicas is stopped. The read replicas become standalone servers that now support both reads and writes.
To delete a server from the Azure portal, follow these steps:
In the Azure portal, select your primary Azure Database for PostgreSQL server.
Open the
Overview
page for the server. Select
Delete
.
Delete a replica
You can delete a read replica similar to how you delete a primary server.
In the Azure portal, open the
Overview
page for the read replica. Select
Delete
.
You can also delete the read replica from the
Replication
window by following these steps:
In the Azure portal, select your primary Azure Database for PostgreSQL server.
On the server menu, under
SETTINGS
, select
Replication
.
Select the read replica to delete.
Monitor a replica
Two metrics are available to monitor read replicas.
Max Lag Across Replicas metric
The
Max Lag Across Replicas
metric shows the lag in bytes between the primary server and the most-lagging replica.
In the Azure portal, select the primary Azure Database for PostgreSQL server.
Select
Metrics
. In the
Metrics
window, select
Max Lag Across Replicas
.
Replica Lag metric
The
Replica Lag
metric shows the time since the last replayed transaction on a replica. If there are no transactions occurring on your primary, the metric reflects this time lag.
In the Azure portal, select the Azure Database for PostgreSQL read replica.
Select
Metrics
. In the
Metrics
window, select
Replica Lag
.