This topic describes how to change the data replication mode of an ApsaraDB RDS for PostgreSQL instance to improve the performance or availability of the RDS instance.

Prerequisites

  • Your RDS instance runs RDS High-availability Edition with standard SSDs or enhanced SSDs (ESSDs).
  • If you want to set the Data Replication Mode parameter to Semi-synchronous, the minor engine version of your RDS instance must be 20220228 or later. For information about how to update the minor engine version of an RDS instance, see Update the minor engine version of an ApsaraDB RDS for PostgreSQL instance.

Background information

ApsaraDB RDS for PostgreSQL allows you to change the data replication mode of an RDS instance that runs RDS High-availability Edition and uses standard SSDs or ESSDs. This way, different levels of instance protection can be implemented based on your requirements for database availability and performance.

The following table describes the mappings between the data replication modes and protection levels.
Data replication mode Protection level Description
Asynchronous Optimal performance This is the default protection level. This protection level delivers the highest response speed but medium data persistence.
Synchronous Optimal protection This protection level delivers high data persistence but medium response speed.
Semi-synchronous High availability This protection level balances the response speed and data persistence.

You can change the data replication mode in the ApsaraDB RDS console or by modifying parameters.

Change the data replication mode in the ApsaraDB RDS console

  1. Access RDS Instances, select a region at the top, and then click the ID of the target RDS instance.
  2. In the left-side navigation pane, click Service Availability.
  3. On the page that appears, click Change Data Replication Mode.
    Change Data Replication Mode
  4. Configure the Data Replication Mode parameter.
    Data Replication Mode
    Notice If you want to set the Data Replication Mode parameter to Semi-synchronous, make sure that the minor engine version of your RDS instance is 20220228 or later. For information about how to update the minor engine version of an RDS instance, see Update the minor engine version of an ApsaraDB RDS for PostgreSQL instance.
  5. Click OK.

Change the data replication mode by modifying parameters

You can configure the following parameters to change the data replication mode: synchronous_commit, rds_sync_replication_timeout, and synchronous_standby_names.

  1. Access RDS Instances, select a region at the top, and then click the ID of the target RDS instance.
  2. In the left-side navigation pane, click Parameters.
  3. On the Editable Parameters tab, find the synchronous_commit, rds_sync_replication_timeout, and synchronous_standby_names parameters.
  4. In the Running Parameter Value column for each parameter, click the Edit icon icon next to the original value. In the dialog box that appears, enter the new value and click OK.
    The following table describes the parameters that you must configure for each data replication mode.
    Data replication mode Parameter
    Asynchronous synchronous_commit = off
    Note If you set the synchronous_commit parameter to off, the rds_sync_replication_timeout parameter is invalid.
    Synchronous
    • synchronous_commit = remote_write
    • rds_sync_replication_timeout = 0
    • synchronous_standby_names = 'standby1'
      Notice The default value of the synchronous_standby_names parameter is standby1. If you have a self-managed secondary RDS instance, we recommend that you do not name the self-managed secondary RDS instance as standby1. If you name the self-managed secondary RDS instance as standby1, your RDS instance may replicate data to the self-managed secondary RDS instance in synchronous or semi-synchronous mode. As a result, data loss may occur in the event of a primary/secondary switchover.
    Semi-synchronous
    Note If you want to set the Data Replication Mode parameter to Semi-synchronous, make sure that the minor engine version of your RDS instance is 20220228 or later. For information about how to update the minor engine version of an RDS instance, see Update the minor engine version of an ApsaraDB RDS for PostgreSQL instance.
    • synchronous_commit = remote_write
    • rds_sync_replication_timeout > 0
      Note The rds_sync_replication_timeout parameter specifies the data synchronization timeout period in milliseconds. The value of this parameter ranges from 0 to 300000. We recommend that you set this parameter to 500. If a synchronization operation times out, the protection level is decreased to the optimal performance protection level that makes your RDS instance run in asynchronous mode. After data is synchronized, the protection level is increased to the high-availability protection level that makes your RDS instance run in semi-synchronous mode.
    • synchronous_standby_names = 'standby1'
      Notice The default value of the synchronous_standby_names parameter is standby1. If you have a self-managed secondary RDS instance, we recommend that you do not name the self-managed secondary RDS instance as standby1. If you name the self-managed secondary RDS instance as standby1, your RDS instance may replicate data to the self-managed secondary RDS instance in synchronous or semi-synchronous mode. As a result, data loss may occur in the event of a primary/secondary switchover.
  5. Click Apply Changes.
    Apply Changes