I want to distribute read requests across multiple Amazon Relational Database Service (Amazon RDS) read replicas.
Short description
You can use Amazon Route 53 weighted record sets to distribute requests across your read replicas. Within a Route 53 hosted zone, create individual record sets for each DNS endpoint associated with your read replicas. Then, give them the same weight, and direct requests to the endpoint of the record set.
Resolution
Find the DNS endpoint URLs for the read replicas
- Open the Amazon RDS console.
- Choose Databases from the navigation pane, and then select each read replica.
- Note (or copy) the DNS endpoint URL, next to Endpoint.
Create a Route 53 hosted zone
Note: Skip this step If you already have a hosted zone.
- Open the Route 53 console, and choose Hosted zones from the navigation pane.
- Choose Create Hosted Zone.
- For Domain Name and Comment, enter a name and a comment.
- For Type, choose the Private Hosted Zone for the VPC that your read replicas are located in. Choosing a private hosted zone blocks access to the read replicas from external resources. Or, leave Type set as Public.
Note: You must own the domain that you specify in the hosted zone if you specify Public.
- Choose Create.
Create the record set
After the hosted zone is created, select it, and choose Create Record Set. Use these attributes:
- For Name, enter a name. You use this as the endpoint URL to access the read replicas.
- Set Type to CNAME.
- For TTL value, set a value that is appropriate for your needs. This determines how often each read replica receives requests.
- In the Value field, paste the DNS endpoint of the first read replica.
- For Routing Policy, choose Weighted.
- In the Weight field, enter a value. Be sure to use the same value for each replica's record set.
- For Set ID, enter a name.
- It's a best practice to configure Health Check. For more information, see Creating Amazon Route 53 health checks and configuring DNS failover.
After configuring the record set, choose Create.
Repeat these steps to create a record set for each additional read replica. Be sure that the record sets use the same name, and the same values for time to live (TTL), and for weight. This helps to distribute requests equally.
You can add more read replicas to respond to more connections or high resource use without changing your application endpoint. You can incorporate Route 53 health checks to be sure that Route 53 directs traffic away from unavailable read replicas.
Related information
Choosing a routing policy
Working with private hosted zones