Using RDS for MySQL Database Proxies for Read/Write Splitting

Updated on 2025-03-19 GMT+08:00

You can enable database proxy for your RDS for MySQL instance to automatically forward read and write requests though a proxy address. To reduce read pressure of the primary instance, write requests are forwarded to the primary instance and read requests to read replicas based on the routing policy of the database proxy.

This section describes how to use a database proxy to implement read/write splitting. The process is as follows:

Precautions

  • Both the primary instance and read replicas must be available.
  • You have learned the regions and versions that support database proxies. For details, see Constraints on Database Proxy.
  • Only Pay-per-use can be selected for pay-per-use DB instances.
  • Both pay-per-use and yearly/monthly proxy instances can be created for yearly/monthly DB instances. To create yearly/monthly proxy instances, you must contact customer service.

Step 2: Grant Access Permissions

Before using a database proxy to connect to an RDS for MySQL instance, ensure that the current database account has the permission to access the proxy address.

You can perform the following steps to check and grant an account the permission to access a proxy address.

  1. Connect to your RDS for MySQL instance.
  2. Check whether host of your account contains a database proxy address.

    SELECT user,host FROM mysql.user;

  3. If the host does not contain the CIDR block where the database proxy is located, grant the access permission to the account.

    For example, if you want to connect to an RDS for MySQL instance from the IP address range starting with 192.168.0 as the root user, you can set host of the account to 192.168.% on the user management page of Data Admin Service (DAS).

Step 3: Check Security Group Rules

Ensure that there is an inbound rule that allows access from the proxy address. The default port is 3306.

  1. On the Instances page, click the DB instance name.
  2. In the navigation pane, choose Connectivity & Security. In the Security Group Rules area, click the security group name to view the security group rules.
  3. On the Inbound tab, check whether access through port 3306 is allowed by default.

    Figure 6 Allowing access through port 3306

    If there is no such a rule, click Add Inbound Rule or Allow All IP.

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback