Adding a Read Replica
Application Scenario
In read-intensive scenarios, a single DB instance may be unable to handle the read pressure and service performance may be affected. To offload read pressure on the database, you can create read replicas in a region. These read replicas can process a large number of read requests and increase application throughput. Data synchronization between the primary DB instance and read replicas is not affected by network latency. Read replicas and the primary DB instance must be in the same region but can be in different AZs. This section describes how to use Terraform scripts to create an RDS read replica.
Related Resources
Procedure
- For details about how to create a MySQL database, see Creating an RDS MySQL DB Instance.
- Create an RDS read replica. The following uses MySQL as an example.
data "huaweicloud_availability_zones" "myaz" {} resource "huaweicloud_rds_read_replica_instance" "myreplica" { name = "myreplica" flavor = "rds.mysql.c2.large.rr" primary_instance_id = huaweicloud_rds_instance.myinstance.id availability_zone = data.huaweicloud_availability_zones.myaz.names[1] volume { type = "ULTRAHIGH" } tags = { type = "readonly" } }
- Run terraform plan to view resources.
- After you confirm that the resource information is correct, run terraform apply to start resource creation.
- Run terraform show to view information about the created RDS read replica.
Resource Name |
Parameter |
Description |
|
---|---|---|---|
huaweicloud_rds_read_replica_instance |
name |
(Mandatory) Read replica name.
|
|
flavor |
(Mandatory) Read replica flavor. In this example, rds.mysql.c2.large.rr is used. You can query the instance flavor via huaweicloud_rds_flavors. |
||
primary_instance_id |
(Mandatory) Primary DB instance ID. |
||
availability_zone |
(Mandatory) AZ where the read replica is located. For details, see Regions and Endpoints. |
||
tags |
(Optional) Instance tags. |
||
volume |
type |
(Mandatory) Disk type of the read replica. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot