Enable a database proxy

Updated at:

If your primary instance is under high load or requires read/write splitting, enable the database proxy for ApsaraDB RDS for PostgreSQL. The proxy supports 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

The RDS PostgreSQL instance must meet the following requirements:

  • Major engine version: PostgreSQL 10 or later.

  • Storage type: cloud disk.

  • Edition: RDS High-availability Edition or RDS Cluster Edition.

  • Instance role: primary instance.

  • The database proxy feature is not supported in China (Hangzhou) Zone C and Zone D. To use this feature, you can migrate your instance to another zone. For more information, see Migrate to another zone.

Billing

Usage notes

  • After you enable the database proxy, do not migrate the primary instance to a different zone. Cross-zone placement between the instance and proxy increases access latency.

    Note

    If a failover places the primary instance and the proxy in different zones, perform a manual switchover to realign them. Perform a manual primary/secondary switchover.

  • Create a read-only instance before enabling the proxy. You can enable the proxy without one, but you cannot configure an access policy for the proxy endpoint. 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): Enables the proxy with the recommended specification. You can change it later.

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

    Note
    • If prompted that a service-linked role (SLR) is not authorized, click Authorize, and then click OK. Alibaba Cloud then creates the AliyunServiceRoleForRdsProxyOnEcs SLR, which allows the proxy to attach an elastic network interface for connectivity.

    • Compare General-purpose and Dedicated types in Proxy types.

    • The recommended proxy specification is calculated as follows:

      • Formula: Recommended proxy specification = Number of recommended proxy nodes × Specification per proxy node. Each 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.

      Example: An RDS PostgreSQL instance with an 8-core primary and a 4-core read-only instance has a Dedicated proxy node count of (8 + 4) / 8 = 2 (rounded up from 1.5), giving a proxy specification of 2 × 2 CPU cores = 4 CPU cores.

  4. Click OK.

    After the database proxy is enabled, the Database Proxy tab displays the following information.

    Category

    Parameter

    Description

    Basic Information

    Primary Instance

    The ID of the RDS PostgreSQL instance.

    Proxy Instance Status

    The running state of the proxy.

    Proxy Type

    The proxy type. Valid values: General-purpose and Dedicated. Proxy types.

    Zone

    The zone of the proxy. Defaults to the same zone as the primary instance.

    Proxy Specifications

    The current proxy specification.

    Calculated as: Proxy specification = Specification per proxy node × Number of proxy nodes. Each node is fixed at 2 CPU cores. Example: 3 nodes = 2 CPU cores × 3 = 6 CPU cores.

    Proxy Version

    The minor version of the proxy engine.

    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 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.

    Configure read/write attributes and read weights.

    Internal Endpoint/Port

    The internal endpoint and port of the proxy.

    Use this endpoint for internal network connections to the RDS PostgreSQL instance.

    Note

    Public Endpoint/Port

    The public endpoint and port of the proxy.

    Use this endpoint for internet connections to the RDS PostgreSQL instance.

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

    • After you apply for a public endpoint, click the image.png icon next to the endpoint to modify the prefix and port. Configure a proxy endpoint.

API reference

API

Description

ModifyDBProxy

Enables or disables the database proxy feature.

DescribeDBProxy

Queries the details of a database proxy.