All Products
Search
Document Center

ApsaraDB RDS:Create a read-only ApsaraDB RDS for PostgreSQL instance

Last Updated:Nov 20, 2024

When your database system processes a large number of read requests from an application, you can create read-only ApsaraDB RDS for PostgreSQL instances to increase the read capability of the database system and the throughput of the application. Physical replication is implemented to synchronize data from the primary RDS instance to the read-only RDS instance in real time. This helps ensure data consistency between the primary and read-only RDS instances.

For more information about read-only RDS instances, see Overview of read-only ApsaraDB RDS for PostgreSQL instances.

Prerequisites

A primary RDS instance that meets the following requirements is created:

  • The primary RDS instance uses an available database engine version. Read-only RDS instances cannot be created for the primary RDS instance that uses a phased-out database engine version. For more information, see Phased-out versions.

  • The primary RDS instance runs RDS High-availability Edition.

  • The instance type of the primary RDS instance meets the following requirements:

    • If the primary RDS instance uses cloud disks, no limits are imposed on the instance type.

    • If the primary RDS instance uses local disks, the instance must use a dedicated instance type that provides at least 8 CPU cores and 32 GB of memory.

  • The primary RDS instance uses the subscription or pay-as-you-go billing method. Read-only RDS instances cannot be created for serverless RDS instances.

Note

Before you create a read-only RDS instance, you must check the RDS edition and instance type of the primary RDS instance on the Basic Information page in the ApsaraDB RDS console. If the RDS edition and instance type of the primary RDS instance do not meet the requirements, you can click Change Specifications to upgrade the primary RDS instance from RDS Basic Edition to RDS High-availability Edition and then create a read-only RDS instance. For more information, see Change instance specifications.

Usage notes

  • When you create a read-only RDS instance, you must select the virtual private cloud (VPC) in which the primary RDS instance resides for the read-only instance. Otherwise, the instance fails to be created, and a refund is issued.

  • You can create read-only RDS instances for the primary RDS instance, but cannot convert existing RDS instances to read-only RDS instances.

  • When you create a read-only RDS instance, the system replicates data from the secondary RDS instance to the read-only RDS instance. This prevents interruptions to your workloads that are run on the primary RDS instance.

  • A read-only RDS instance does not inherit the parameter settings of the primary RDS instance. Default parameter settings are generated for the read-only RDS instance. You can modify the default parameter settings in the ApsaraDB RDS console.

    Important

    Read-only RDS instances that are attached to the primary RDS instance of a new general-purpose instance type inherit the parameter settings of the primary RDS instance. For more information about read-only RDS instances that use new general-purpose instance types, see Instance types for read-only ApsaraDB RDS for PostgreSQL instances.

  • The storage type of the read-only RDS instance is the same as the storage type of the primary RDS instance.

  • If the primary RDS instance uses local disks, the specifications and storage capacity of its read-only RDS instances cannot be lower than the specifications and storage capacity of the primary RDS instance.

  • If the primary RDS instance uses cloud disks, we recommend that you make sure the specifications of its read-only RDS instances are the same as the specifications of the primary RDS instance or are higher than or equal to 50% of the specifications of the primary RDS instance. This helps prevent replication latency and out of memory (OOM) errors that are caused by a significant performance difference between the primary RDS instance and its read-only RDS instances.

  • If the primary RDS instance uses cloud disks, you must make sure that the storage capacity of its read-only RDS instance is greater than or equal to the storage capacity of the primary RDS instance. If the memory capacity of the primary RDS instance is greater than the memory capacity of its read-only RDS instance and you change the specifications of the primary RDS instance, the read-only RDS instance is restarted.

  • The memory capacity of the read-only RDS instance must meet the requirements in the following table.

    Memory capacity of the primary RDS instance

    Memory capacity of the read-only RDS instance

    Less than or equal to 64 GB

    At least 1/4 of the memory capacity of the primary RDS instance

    Larger than 64 GB and less than or equal to 256 GB

    At least 1/6 of the memory capacity of the primary RDS instance

    Larger than 256 GB and less than or equal to 9,999 GB

    At least 1/8 of the memory capacity of the primary RDS instance

  • If the primary RDS instance uses local disks, you can create up to 5 read-only RDS instances. If the primary RDS instance uses cloud disks, you can create up to 32 read-only RDS instances.

  • If the primary RDS instance uses local disks, its read-only RDS instances run based on a high-availability architecture. If the primary RDS instance uses cloud disks, its read-only RDS instances run based on a single-node architecture.

    Note

    In the standalone architecture, no secondary RDS instances are provisioned, and the availability cannot be ensured. We recommend that you purchase multiple read-only RDS instances and use libpq or Java Database Connectivity (JDBC) to implement automatic failover. You can also use the database proxy feature to implement automatic read/write splitting. For more information, see Configure automatic failover and read/write splitting and What are database proxies?

  • You are charged for the read-only RDS instances that you create based on the subscription billing method or the pay-as-you-go billing method. For more information about the fee for a subscription read-only RDS instance, visit the ApsaraDB RDS buy page. For more information about the fee for a pay-as-you-go read-only RDS instance, see Instance types for read-only ApsaraDB RDS instances.

Create a read-only RDS instance

  1. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.

  2. In the Instance Distribution section of the page that appears, click Add to the right of Read-only Instance.

    Note

    If you use the original ApsaraDB RDS console, click Create Read-only Instance in the Distributed by Instance Role section of the Basic Information page.

    添加只读实例

  3. Configure the following parameters.

    Parameter

    Description

    Billing Method

    • Subscription: A subscription instance is an instance for which you pay an upfront fee. If you want to use the read-only RDS instance for a long period of time, we recommend that you select the subscription billing method. If you select the subscription billing method, you must specify a subscription duration.

    • Pay-as-you-go: A pay-as-you-go instance is an instance for which you are charged per hour based on your resource usage. If you want to use the read-only RDS instance for a short period of time, we recommend that you select the pay-as-you-go billing method. You can create a pay-as-you-go read-only RDS instance. After you confirm that the created read-only RDS instance meets your business requirements, you can change the billing method of the read-only RDS instance from pay-as-you-go to subscription.

    Product Type

    The YiTian product type is available only when the Storage Type parameter of the primary RDS instance is set to ESSD or General ESSD.

    For more information about the Standard and YiTian product types, see Product types.

    Zone

    Each zone is an independent physical location within a region. Zones in the same region do not have substantial differences. The multi-zone deployment method supports zone-disaster recovery.

    Instance Type

    • General-purpose Instance Types: allows you to select a general-purpose instance type. A general-purpose RDS instance exclusively occupies the allocated memory and I/O resources. It shares CPU and storage resources with other general-purpose instances that are deployed on the same host.

    • Dedicated Instance Types: allows you to select a dedicated instance type or a dedicated host instance type. A dedicated RDS instance exclusively occupies the CPU, memory, storage, and I/O resources that are allocated. Dedicated host instance types provide the highest specifications in the dedicated instance family. A dedicated host RDS instance exclusively occupies all CPU, memory, storage, and I/O resources on the physical host on which the RDS instance is deployed.

    Note

    Each instance type supports a specific number of CPU cores, memory capacity, maximum number of connections, and maximum IOPS. If the primary RDS instance uses local disks, the specifications of a read-only RDS instance must be higher than or equal to the specifications of the primary RDS instance. For more information about the instance types, see Instance types for read-only ApsaraDB RDS for PostgreSQL instances.

    Storage Capacity

    The maximum amount of storage that is provisioned to store data files, system files, WAL files, and transaction files in the read-only RDS instance. You can change the storage capacity at a step size of 5 GB.

    Note

    For more information about the storage capacity range that is supported by each instance type, see Instance types for read-only ApsaraDB RDS for PostgreSQL instances.

    • If the primary RDS instance uses cloud disks, you must make sure that the storage capacity of its read-only RDS instance is greater than or equal to the storage capacity of the primary RDS instance. If the memory capacity of the primary RDS instance is greater than the memory capacity of the read-only RDS instance and you change the specifications of the primary RDS instance, the read-only RDS instance is restarted.

    • If the primary RDS instance uses local disks, the storage capacity of a read-only RDS instance must be greater than or equal to the storage capacity of the primary RDS instance.

  4. Click Next: Instance Configuration and configure the following parameters.

    Parameter

    Description

    Network Type

    The network type of the read-only RDS instance, which is the same as the network type of the primary RDS instance. If the primary RDS instance uses the VPC network type, make sure that the primary and read-only RDS instances use the same vSwitch in the same VPC.

    Release Protection

    Specifies whether to enable release protection. If you set the Billing Method parameter to Pay-as-you-go, you can select Release Protection. This helps prevent the RDS instance from being accidentally released. For more information, see Enable or disable the release protection feature for an ApsaraDB RDS for PostgreSQL instance.

    Time Zone

    The time zone of the read-only RDS instance, which is the same as the time zone of the primary RDS instance.

    SLR Authorization

    You do not need to configure this parameter. Permissions are granted when you purchase the primary RDS instance. For more information about SLR authorization, see [Product changes/Feature changes] SLR authorization is required to create an ApsaraDB RDS for PostgreSQL instance from October 10, 2022.

    Instance Description

    The description of the read-only RDS instance to facilitate instance management.

    Tag

    When you create RDS instances, you can bind tags to the instances. After the instances are created, you can filter the instances by tag. For more information, see Use tags to filter ApsaraDB RDS for PostgreSQL instances.

  5. Click Next: Confirm Order.

  6. Read and select Terms of Service, click Pay Now, and then complete the payment.

The amount of time that is required to create a read-only RDS instance varies based on the storage type and storage capacity of the primary RDS instance.

  • If the primary RDS instance uses standard SSDs, the amount of time that is required to create a read-only RDS instance is approximately 20 minutes plus the amount of time that is required for a full backup.

  • If the primary RDS instance uses Enterprise SSDs (ESSDs), the amount of time required to create a read-only RDS instance is approximately 20 minutes.

Note
  • When you create a read-only RDS instance, the primary RDS instance is not affected. After the read-only RDS instance is created, a WAL Sender process is generated in the primary RDS instance and is used to send WAL files to the read-only RDS instance.

  • In ApsaraDB RDS for PostgreSQL, snapshots are used to create read-only RDS instances, regardless of the data volume.

View a read-only RDS instance

  • To view a read-only RDS instance on the Instances page of the Primary RDS instance, perform the following steps:

    1. Log on to the ApsaraDB RDS console. In the left-side navigation pane, click Instances. In the top navigation bar, select the region in which your RDS instance resides.

    2. Find the primary instance in the instance list and expand the drop-down list of the primary instance.

      image

    3. Find the read-only RDS instance and click the instance ID.

  • To view a read-only RDS instance on the Basic Information page of the primary RDS instance, perform the following steps:

    1. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.

    2. On the Basic Information page, move the pointer over the number of read-only RDS instances and click the ID of the read-only RDS instance that you want to view.主实例内跳转只读实例

View the data replication latency for a read-only RDS instance

A read-only RDS instance may synchronize data from the primary RDS instance at a specific latency. You can go to the Basic Information page of a read-only RDS instance to view the latency of data replication to the instance.

只读实例延迟

Related operations

Operation

Description

CreateReadOnlyDBInstance

Creates a read-only instance.

FAQ

  • Can I change the billing method of a read-only RDS instance?

    Yes, you can change the billing method of a read-only RDS instance. For more information, see Switch an ApsaraDB RDS for PostgreSQL instance from pay-as-you-go to subscription or Change the billing method of an ApsaraDB RDS instance from subscription to pay-as-you-go.

  • If I change the configuration of a read-only RDS instance, release the read-only RDS instance, or change the billing method of the read-only RDS instance, does the primary RDS instance to which the read-only RDS instance is attached is affected?

    No, the primary RDS instance is not affected.

  • After I create accounts on my primary RDS instance, can I manage the accounts on the read-only RDS instances of my primary RDS instance?

    No, you cannot manage the accounts on the read-only RDS instances. The accounts that are created on your primary RDS instance are synchronized to the read-only RDS instances and and have only read permissions on the read-only RDS instances.

  • Can a read-only RDS instance be converted into a regular RDS instance, such as a disaster recovery RDS instance?

    No, a read-only RDS instance cannot be converted into a regular RDS instance.

  • Can I back up the data of a read-only RDS instance? Do read-only RDS instances support automatic backup?

    You do not need to back up read-only RDS instances. Backups are performed on the primary RDS instance. In ApsaraDB RDS for PostgreSQL, snapshot backups are used, and no performance overhead is caused on the primary RDS instance.

  • Do read-only RDS instances support parallel replication?

    In ApsaraDB RDS for PostgreSQL, physical replication is used to synchronize data. Physical replication uses WAL files for data synchronization and playback, which is more efficient than parallel replication.

  • How are transaction logs deleted?

    After the WAL files of an RDS instance are backed up, AliPG clears the transaction logs during checkpointing.

  • How do I determine whether replication is normal based on the latency of data replication for a read-only RDS instance?

    In most cases, if the latency of data replication for a read-only RDS instance is less than or equal to 1 second, the data replication is implemented as expected. If the latency of data replication for a read-only RDS instance is greater than 1 second, the data is replicated at a specific latency, and disconnection may occur.

  • What causes a replication latency between a primary RDS instance and a read-only RDS instance?

    The following section describes the common causes and solutions:

    • Cause: The specifications of the primary RDS instance are higher than the specifications of the read-only RDS instance.

      Solution: Upgrade the specifications of the read-only RDS instance. For more information, see Change instance specifications.

    • Cause: The max_standby_streaming_delay parameter is improperly configured. For more information, see Modify the parameters of an ApsaraDB RDS for PostgreSQL instance.

      Solution: Modify the value of the max_standby_streaming_delay parameter.

      • If you set this parameter to a small value, the latency at which a read-only RDS instance replicates data from its primary RDS instance is reduced. However, if the value of the parameter is excessively small, the transactions executed on the read-only RDS instance may be canceled.

      • If the value is excessively large, replication latency may occur.