Help Center/ Relational Database Service_RDS for PostgreSQL/ User Guide/ Instance Modifications/ Manually Switching Between Primary and Standby DB Instances
Updated on 2026-11-17 GMT+08:00

Manually Switching Between Primary and Standby DB Instances

Scenarios

After a primary/standby DB instance is successfully created, the system creates a standby DB instance for it in the same region. Data is synchronized between the primary and standby DB instances in real time. You can access data only on the primary DB instance, while the standby DB instance serves solely as a backup. You can perform a primary/standby switchover as needed based on your workloads. After the switchover, the original primary DB instance becomes the standby DB instance, providing rack-level disaster recovery.

Introduction to Primary/Standby Instances

Primary/standby instances use an HA architecture and can be deployed across AZs. The primary and standby instances share the same IP address.

  • Standby instances improve instance reliability. When you create a primary instance, a standby instance is automatically created alongside it. Once created, the standby instance is invisible on the console.
  • If the primary instance fails, a failover occurs, during which clients may experience a brief interruption. If there is a replication delay between the primary and standby instances, the failover takes an extended period of time. Clients need to be able to reconnect to the instance.

Precautions

  • During a primary/standby switchover, the database will experience a brief interruption. Perform this operation during off-peak hours to avoid impact on your workloads.
  • Scenarios that may trigger a switchover include primary/standby switchovers, instance class changes of primary/standby instances, and minor version upgrades.

    If there is any slow SQL statement still running during a primary/standby switchover, the slow SQL connection may be suspended (new connections and other idle connections are not affected). After a period of time, an error is returned to the client. The time when the error is reported is related to the settings of TCP parameters such as keepalives_idle, keepalives_interval, and keepalives_count on the client. For details, see the official documentation.

Constraints

  • A manual switchover does not change the connection information of the instance, including its VPC, subnet, security group, floating IP address, private domain name, and database port.
  • A primary/standby switchover may cause a brief interruption of several seconds or minutes (depending on the replication delay). If transaction logs are generated at a speed higher than 30 MB/s, workloads will probably be interrupted for several minutes. To prevent traffic congestion, perform a switchover during off-peak hours.
  • You can perform a switchover only when all of the following conditions are met:
    • The primary/standby instance is running properly.
    • The primary/standby replication is normal.
    • The replication delay is less than 5 minutes, and the data on the primary and standby instances is consistent.

Procedure

  1. Log in to the RDS console.
  2. Click in the upper left corner and select a region.
  3. On the Instances page, click the target primary/standby instance name to go to the Summary page.
  4. Under DB Instance Type, click Switch.
  5. If you have enabled operation protection, click Send Code in the displayed Identity Verification dialog box and enter the obtained verification code. Then, click OK.

    Two-factor authentication improves the security of your account and cloud product. For details about how to enable operation protection, see the Identity and Access Management User Guide.

  6. In the displayed dialog box, click Yes.
  7. After the switchover is successful, check the status of the DB instance on the Instances page.

    • During the switchover, the DB instance status is Switchover in progress.
    • In the upper right corner of the DB instance list, click to refresh the list. After the switchover is successful, the DB instance status will become Available.