1
votes

I am new to AWS and facing RDS CPU usage. Following is the RDS information:

  • Instance type: t3.medium
  • DB type: Postgres
  • Storage: 50GB

I get warning for 80% CPU usage during a certain period of time of the day. Thus I am thinking of migrating to Aurora DB which supports auto scaling but the official document says that I will have to manage the scaled out instance of Aurora DB on application side.

To benefit from Aurora Auto Scaling, your applications must support connections to new Aurora Replicas. To do so, we recommend using the Aurora reader endpoint. For Aurora MySQL you can use a driver such as the MariaDB Connector/J utility. For more information, see Connecting to an Amazon Aurora DB Cluster.

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Integrating.AutoScaling.html

Above is the link to the official documentation.

My question is:

  • Will Aurora DB creates a new replica with new endpoint on scale out?
  • Do I really have to manage connection information of multiple instances in my application when RDS scales out?
  • If yes, then how will my application get to know about how many new replica's have been created and for read or write and what is the endpoint?
  • Is there any way to automatically balance the load without adding extra DB endpoints on application side?

Note: I am accessing DB with Ruby on Rails web application.

Thanks.

1

1 Answers

2
votes

You have to use reader endpoint in your application:

A reader endpoint for an Aurora DB cluster provides load-balancing support for read-only connections to the DB cluster. Use the reader endpoint for read operations, such as queries. [...] If the cluster contains one or more Aurora Replicas, the reader endpoint load-balances each connection request among the Aurora Replicas.

Generally you don't have to do anything, just use the reader endpoint as you wrote in your question:

To benefit from Aurora Auto Scaling, your applications must support connections to new Aurora Replicas. To do so, we recommend using the Aurora reader endpoint.

The way it works is that when when you resolve reader's endpoint DNS name, it will return IP of a replica at random.

Reader endpoint is also automatically updated on AWS-side when new replicas are added. This process is transparent to you.

It should be noted though, that the load balancing is done at connection level. So if you open up and keep only one connection throughout the live of your app, it will not be load balanced. This is because a replica to connect to is going to be chosen at the connection time.