You can use Classic Load Balancer (CLB) to efficiently forward access requests to an RDS Custom instance to achieve load balancing. This solution lets you connect to your RDS Custom instance over the Internet. It effectively protects the security of your internal network and improves service availability and scalability.
Prerequisites
An application is deployed on the RDS Custom instance. In this example, NGINX is deployed. Deployment commands:
yum install -y nginx
systemctl start nginx.service
cd /usr/share/nginx/html/
echo "Hello World ! this is RDS Custom." > index.htmlStep 1: Obtain ENI information about the RDS Custom instance
Call the DescribeNetworkInterfaces operation to obtain elastic network interface (ENI) information about the RDS Custom instance. The following table describes the request parameters in the operation. The VpcId, VSwitchId, and PrimaryIpAddress parameters are optional. You can use these parameters to quickly obtain ENI information about the RDS Custom instance.
Parameter | Description | Example |
RegionId | The ID of the region in which the RDS Custom instance resides. | cn-hangzhou |
ServiceManaged | In this topic, you need to query the ENI attached to the RDS Custom instance. Set this parameter to true. | true |
VpcId | The ID of the virtual private cloud (VPC) to which the ENI belongs, which is the same as the VPC ID of the RDS Custom instance. Note You can view network information about the RDS Custom instance in the Basic Information section of the Configuration Information page. | vpc-bp16sm1hwzyutuohe**** |
VSwitchId | The ID of the vSwitch to which the ENI belongs, which is same as the vSwitch ID of the RDS Custom instance. | vsw-bp1nb3pv03878tgnj**** |
PrimaryIpAddress | The primary private IP address of the ENI, which is the same as the private IP address of the RDS Custom instance. | 172.16.XX.XX |
In the response, the PrivateIpAddress parameter indicates the ENI IP address, and the NetworkInterfaceId parameter indicates the ENI ID. Example:
{
...
"NetworkInterfaceSets": {
"NetworkInterfaceSet": [
{
...
"PrivateIpAddress": "172.16.XX.XX", //ENI IP address
"ServiceManaged": true,
"DeleteOnRelease": true,
"ResourceGroupId": "",
"Attachment": {},
"NetworkInterfaceId": "eni-bp1j7sqxlbjnnccf****", //ENI ID
...
}
]
}
}Step 2: Create an Internet-facing CLB instance
Log on to the CLB console. In the top navigation bar, select the region in which the RDS Custom instance resides.
Click Create CLB. On the buy page, select a region and zone for the CLB instance and specify an instance name.
Complete the payment. The newly created CLB instance is displayed on the CLB console page.
Step 3: Create a vServer group
On the Instances page of the CLB console, click the ID of the CLB instance to go to the instance details page.
Click the vServer Groups tab. Then, click Create VServer Group.

Enter a name for the vServer group and click Create.
Step 4: Add the RDS Custom instance to the vServer group
Call the AddVServerGroupBackendServers operation to add the RDS Custom instance to the vServer group. The following table describes the request parameters in the operation. You must set the ServerId and ServerIp parameters to the ID and IP address of the ENI attached to the RDS Custom instance that you obtained in Step 1.
Parameter | Description | Example |
RegionId | The ID of the region in which the CLB instance resides. | cn-hangzhou |
VServerGroupId | The ID of the vServer group. | rsp-bp1zgr6ci**** |
BackendServers | The backend servers that you want to add. The value consists of the following fields:
The value is in the following format: | |
Step 5: Configure a listener for the CLB instance
On the Instances page of the CLB console, find the required CLB instance and click Configure Listener in the Actions column.
Configure the listener protocol and port. Then, click Next.
Configure a backend server group. Specifically, select an existing vServer group, confirm the ENI information about the RDS Custom instance, and then click Next.
Perform a health check. We recommend that you use the default health check configuration.
Confirm the configuration and click Submit.
If Configuration Successful is displayed, the listener is configured.
Step 6: Verify the result
On the Instances page of the CLB console, obtain the IP Address of the CLB instance.

Run the following
telnetcommand on an Elastic Compute Service (ECS) instance that resides in the same region and VPC as the RDS Custom instance to verify the forwarding result. In this example, an ECS instance running CentOS 7 is used.NoteIf Telnet is not installed, you must run the
yum install -y telnetcommand to install Telnet.telnet <Destination address> <Listener port>Destination address: the service address of the CLB instance or the private IP address of the RDS Custom instance.
Listener port: the listener port configured for the CLB instance. In this example, port 80 is used.
In this example, the service address of the CLB instance is used. Sample command:
telnet 172.16.XX.XX 80If the following command output is returned, the CLB instance can forward requests to the backend server:
Trying 172.16.XX.XX... Connected to 172.16.XX.XX. Escape character is '^]'.Run the
curlcommand to access the default web page of the NGINX service on the RDS Custom instance.curl http://172.16.XX.XXThe following information is returned:
Hello World ! this is RDS Custom.
(Optional) Use an Internet-facing CLB instance to forward requests to an RDS Custom instance
Create an Internet-facing CLB instance and set the Instance Type parameter to Internet.
Verify the result.
Use a browser to access
http://<Service address of the CLB instance>. The web page loads normally and displaysHello World ! this is RDS Custom..