Enable a database proxy

更新时间:
复制 MD 格式

If your primary instance is under high load or you need to implement read/write splitting, enable the database proxy feature for ApsaraDB RDS for PostgreSQL. It provides features like read/write splitting and transaction splitting to reduce the load on your primary instance.

For questions about the ApsaraDB RDS database proxy, join our DingTalk user group (ID: 106730000316) to communicate with our team.

Prerequisites

Your ApsaraDB RDS for PostgreSQL instance must meet the following requirements:

  • The major engine version of the instance is PostgreSQL 10 or later.

  • The storage type of the instance is cloud disk.

  • The instance edition is High-availability Edition.

  • The instance is a primary instance.

  • The database proxy feature is not supported in Zone C and Zone D of the China (Hangzhou) region. If your instance is in one of these zones, migrate the instance to another zone. For more information, see Migrate an instance across zones.

Billing

  • The General-purpose proxy is free of charge.

  • The Dedicated proxy is pay-as-you-go. For more information, see Database proxy billing.

Usage notes

  • After enabling the database proxy, avoid migrating the primary instance to a different zone. A migration can place the primary instance and the database proxy in different zones, which increases access latency.

    Note

    If a service failure triggers a primary/secondary switchover that places the primary instance and the database proxy in different zones, you can perform another manual primary/secondary switchover to align their zones and reduce access latency. For more information, see Perform a manual primary/secondary switchover.

  • Ensure that you have created a read-only instance. You can enable the database proxy feature without a read-only instance, but you cannot configure an access policy for the proxy endpoint. For instructions on how to create a read-only instance, 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 Proxy Type and click Enable Now.

    • General-purpose (free of charge): The system enables the proxy with the recommended proxy specification. You can change the configuration later.

    • Dedicated (pay-as-you-go): You can select the proxy specification.

    Note
    • If you are prompted that a service-linked role (SLR) is not authorized when you enable the database proxy, click Authorize, and then click OK in the dialog box. Alibaba Cloud automatically creates the AliyunServiceRoleForRdsProxyOnEcs service-linked role. This role allows the database proxy service to attach an elastic network interface for network connectivity.

    • For more information about the differences between the General-purpose and Dedicated proxy types, see Proxy types.

    • The recommended proxy specification is calculated as follows:

      • The recommended proxy specification is calculated using the following formula: Recommended proxy specification = Number of recommended proxy nodes × Specification per proxy node. The specification per proxy node is fixed at 2 CPU cores.

      • The maximum specification is 16 CPU cores for a General-purpose proxy and 32 CPU cores for a Dedicated proxy. The number of recommended proxy nodes is calculated as follows:

        Proxy type

        Recommended nodes

        General-purpose

        (Number of CPU cores of the primary instance + Number of CPU cores of all associated read-only instances) / 4, rounded up.

        Dedicated

        (Number of CPU cores of the primary instance + Number of CPU cores of all associated read-only instances) / 8, rounded up.

      For example, if a High-availability Edition ApsaraDB RDS for PostgreSQL instance has an 8-core primary instance and a 4-core read-only instance, the recommended number of proxy nodes for a Dedicated proxy is (8 + 4) / 8 = 2 (rounded up from 1.5). In this case, the recommended proxy specification is 2 × 2 CPU cores = 4 CPU cores.

  4. Click OK.

    After you enable the database proxy, you can view the basic information and connection information of the database proxy on the Database Proxy tab.

    Category

    Parameter

    Description

    Basic Information

    Primary Instance

    The ID of the ApsaraDB RDS for PostgreSQL instance.

    Proxy Instance Status

    The running state of the proxy instance.

    Proxy Type

    The type of the proxy. Valid values: General-purpose and Dedicated. For more information about the differences between the General-purpose and Dedicated proxy types, see Proxy types.

    Zone

    The zone of the proxy instance. By default, the proxy instance is in the same zone as the primary instance.

    Proxy Specifications

    The current proxy specification.

    The proxy specification is related to the number of proxy nodes based on the following formula: Proxy specification = Specification per proxy node × Number of proxy nodes. The specification per proxy node is fixed at 2 CPU cores. For example, if a proxy instance has 3 proxy nodes, the proxy specification is 2 CPU cores × 3 = 6 CPU cores.

    Proxy Version

    The minor engine version of the proxy.

    Proxy Instance ID

    The ID of the proxy instance.

    Proxy Node

    Node ID

    The ID of the proxy node.

    Zone

    The zone of the proxy node.

    CPU Cores on Proxy Node

    The specification of a single proxy node.

    Connection Information

    Proxy Endpoint (Terminal) ID

    The proxy endpoint ID. Each endpoint can have a different access policy.

    Note

    Read/Write Attributes

    Valid values: Read/Write and Read-only.

    For more information, see Configure read/write attributes and read weights.

    Internal Endpoint/Port

    The internal endpoint and port of the proxy.

    Use this endpoint to connect to the ApsaraDB RDS for PostgreSQL instance over the internal network.

    Note

    Public Endpoint/Port

    The public endpoint and port of the proxy.

    Use this endpoint to connect to the ApsaraDB RDS for PostgreSQL instance over the internet.

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

    • After you apply for a public endpoint, you can click the image.png icon next to the endpoint to modify the endpoint prefix and port number. For more information, see Configure a proxy endpoint.

API reference

API

Description

ModifyDBProxy

Enables or disables the database proxy feature.

DescribeDBProxy

Queries the details of a database proxy.