All Products
Search
Document Center

ApsaraDB RDS:Enable the database proxy feature

Last Updated:Jan 11, 2024

If your primary ApsaraDB RDS for PostgreSQL instance is heavily loaded due to an excessively large number of connections or your workloads require read/write splitting, you can use the database proxy feature of ApsaraDB RDS for PostgreSQL. This topic describes how to enable the database proxy feature for an RDS instance. The database proxy feature provides capabilities such as read/write splitting and transaction splitting to offload requests from the primary RDS instance.

Prerequisites

Your RDS instance meets the following conditions:

  • The RDS instance runs PostgreSQL 10 or later.

  • The RDS instance uses cloud disks.

  • The RDS instance runs RDS High-availability Edition.

  • The RDS instance is a primary RDS instance.

  • If your RDS instance resides in Hangzhou Zone C or Hangzhou Zone D, database proxies cannot be enabled for the RDS instance. If you want to enable database proxies for the RDS instance, you must migrate the RDS instance from Hangzhou Zone C or Hangzhou Zone D to another zone. For more information, see Migrate an ApsaraDB RDS for PostgreSQL instance across zones in the same region.

Billing rules

  • General-purpose database proxies are provided free of charge.

  • Dedicated database proxies are charged based on the pay-as-you-go billing method. For more information, see Billing rules for database proxies.

Usage notes

  • After the database proxy feature is enabled, we recommend that you do not migrate the primary RDS instance across zones. If you migrate the primary RDS instance across zones, the primary RDS instance and its proxy instances are in different zones. This increases access latency and slows down responses.

    Note

    If a primary/secondary switchover is triggered due to service failures, the primary RDS instance and its database proxy instances are in different zones. To reduce access latency, you can perform a primary/secondary switchover to make sure that the primary RDS instance and its database proxy instances are in the same zone. For more information, see Switch workloads over between primary and secondary ApsaraDB RDS for PostgreSQL instances.

  • A read-only RDS instance is created for your RDS instance. If no read-only RDS instances are created for your RDS instance, you can enable the database proxy feature for the RDS instance but cannot configure connection settings for a database proxy endpoint. For more information, see Create a read-only ApsaraDB RDS for PostgreSQL instance.

Procedure

  1. 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 ID of the instance.
  2. In the left-side navigation pane, click Database Proxy.

  3. Select a database proxy type and click Enable Now.

    • General-purpose: General-purpose database proxies are provided free of charge. When you enable a general-purpose database proxy, the system automatically uses the recommended proxy specification. After the database proxy is enabled, you can change the proxy specification.

    • Dedicated: Dedicated database proxies are charged based on the pay-as-you-go billing method. When you enable a dedicated database proxy, you can configure the proxy specification.

    Note
    • If the system prompts that service-linked role (SLR) authorization is not complete, click Authorize. In the dialog box that appears, click OK. Alibaba Cloud automatically creates a service-linked role named AliyunServiceRoleForRdsProxyOnEcs. Then, the database proxy feature can use this role to bind elastic network interfaces (ENIs) and establish network connections.

    • For more information about the differences between general-purpose database proxies and dedicated database proxies, see What are database proxies?

    • The recommended specification of database proxies is calculated by using the following formula:

      • Recommended specification of proxies = Recommended number of database proxies × Unit specification of a database proxy The unit specification of a database proxy is fixed as 2 CPU cores.

      • The highest specification of a general-purpose database proxy is 16 CPU cores. The highest specification of a dedicated database proxy is 32 CPU cores. The following table describes how the recommended number of database proxies is calculated.

        Database proxy type

        Recommend number of database proxies

        General-purpose

        (Number of CPU cores of the primary RDS instance + Number of CPU cores of all read-only RDS instances that belong to the primary RDS instance)/4. The result is rounded up.

        Dedicated

        (Number of CPU cores of the primary RDS instance + Number of CPU cores of all read-only RDS instances that belong to the primary RDS instance)/8. The result is rounded up.

      For example, if your primary RDS instance that runs RDS High-availability Edition has 8 CPU cores and its read-only RDS instance has 4 CPU cores, the recommended number of database proxies is 2. The number is obtained based on the following calculation: (8 + 4)/8 = 1.5. The result 1.5 is rounded up to 2. The recommended specification of database proxies is 4 CPU cores. The number is obtained based on the following calculation: 2 × 2 = 4.

  4. Click OK.

    After you enable the database proxy feature, you can go to the Database Proxy page to view the basic information and connection information about the database proxy.

    Section

    Parameter

    Description

    Basic Information

    Primary Instance

    The ID of the RDS instance.

    Proxy Instance Status

    The status of the database proxy instance.

    Proxy Type

    The database proxy type. The value can be General-purpose and Dedicated. For more information about the differences between general-purpose database proxies and dedicated database proxies, see What are database proxies?

    Zone

    The zone of the database proxy instance. By default, the zone of the database proxy instance is the same as that of the primary RDS instance.

    Proxy Specifications

    The specification of the database proxy.

    The following calculation describes the relationship between the specification of database proxies and the number of database proxies: Specification of database proxies = Unit specification of a database proxy × Number of database proxies. In this calculation, the unit specification of a database proxy is fixed as 2 CPU cores. For example, if the number of database proxies is 3, the specification of the database proxies is 6 CPU cores. The value is obtained based on the following calculation: 2 x 3 = 6.

    Proxy Version

    The database proxy version.

    Connection Information

    Proxy Endpoint (Terminal) ID

    The ID of the database proxy endpoint. You can configure different connection settings for each database proxy endpoint.

    Note
    • Each RDS instance supports up to seven database proxy endpoints. You can apply for one internal endpoint and one public endpoint for each database proxy endpoint.

    • After you configure connection settings for a database proxy endpoint, you can use the database proxy endpoint to connect to your RDS instance. For more information, see Configure the connection settings for a database proxy endpoint and Use a database proxy endpoint to connect to an ApsaraDB RDS for PostgreSQL instance.

    • You can move the pointer over the ID of the database proxy endpoint to view the connection settings of the database proxy endpoint. The connection settings include Read/Write Attributes and the information in the Read Weight Information section.

    Read/Write Attributes

    The read/write attributes of the database proxy. The value can be Read/Write and Read-only.

    For more information, see Configure the read/write attributes and the read weight of the database proxy.

    Internal Endpoint/Port

    The internal endpoint of the database proxy endpoint and the port that is associated with the database proxy endpoint.

    You can use the internal endpoint to connect to your RDS instance over the internal network to use the database proxy feature.

    Note

    Public Endpoint/Port

    The public endpoint of the database proxy endpoint and the port that is associated with the database proxy endpoint.

    You can use the public endpoint to connect to your RDS instance over the Internet to use the database proxy feature.

    Note
    • The database proxy provides an internal endpoint by default. You can apply for a public endpoint.

    • After you apply for a public endpoint, you can click the image.png icon to the right of the endpoint to modify the prefix of the endpoint and the port that is associated with the endpoint. For more information, see Manage the database proxy endpoints.

Related operations

API

Description

ModifyDBProxy

Enables or disables the database proxy feature for an instance.

DescribeDBProxy

Queries the details of a database proxy.