Auto Scaling in AWS Aurora Cluster

Harshal kondke
3 min readJan 21, 2022

--

In this Article we will see how to setup and configure the Aurora auto scaling. and how it works and affects the application workloads.

Quick Introduction:

Unlink AWS RDS where we have to predict the traffic usages, In Aurora we can use inbuild feature to auto scale the instance to handle dynamic workloads and unpredictable traffic. Auto Scaling is available for Aurora MySQL and Aurora PostgreSQL. If you are using any of these database engines, then Aurora should be your first choice.

In Aurora, the autoscaling works by creating more number of reader instances in multiple availability zones and when it has to scale down, it deletes the reader instances. This indeed takes some time to spin up so you should configure your autoscaling policy accordingly.

Autoscaling in Aurora works similar to Autoscaling in EC2 instances. You have to specify min and max number of instance count and scale in and scale out policy that will be used for autoscaling.

NOTE:

  1. For Aurora autoscaling to work, you Aurora cluster should have at least one read replica. (although if you don’t have a read replica then autoscaling will use writer instance config to create new read replicas. and you might want to have a bigger instance for writer and smaller ones for reader.)
  2. Aurora autoscaling only scale the cluster when read replicas are in available state.
  3. When new replica is added, it will have exact same instance class and configuration as the manually created read replica.
  4. Your application should use reader endpoints for read operations on your db cluster
  5. In case of failover, manually created replica will have the highest priory and will be promoted as a main instance. Replicas created using autoscaling will have the last priority which is by default set to 15.

How Aurora autoscaling works in the background?

When you create a new autoscaling policy for aurora you use the AWSServiceRoleForApplicationAutoScaling_RDSCluster service-linked role.

You have to specify the target matrix for autoscaling to scale up and down. lets say you consider using CPU utilization as a target matrix. Aurora autoscaling policy will create a cloud watch alarms that will trigger the policy to scale up and down when reached the specified threshold.

Keep in mind, spinning up new read replicas takes time so your configuration should support this.

Configuring the autoscaling policy

You can specify maximum number of read replicas managed by aurora autoscaling from 0–15. Minimum number is also should be between 0–15 but less than the maximum number.

Make sure to specify appropriate values for cooldown period. This will prevent continues trigger of scale in and scale out events. If you setup the cooldown period for scale in policy as 120 seconds. then, there will be no new scale in events until 120 seconds cooldown period is passed and same goes for the scale down event. this helps you to control the autoscaling behavior. Cooldown period is very important to avoid multiple scale in or out triggers and creating and deleting instances take time. by default the cooldown period is set to 300 seconds for scale in as well as scale out operations.

How to setup a autoscaling policy?

Note: You should have a Aurora cluster with one write and at least one reader node.

  1. Navigate to RDS console on AWS management console
  2. select the Aurora database cluster for which you want to create Autoscaling
  3. choose the Logs and Events tab.
  4. In the Autoscaling policy section choose ADD
  5. specify all the values as per your requirement
  6. for target matrix, you can either choose CPU utilization or Average connection to Aurora replicas and setup in scaling policy
  7. specify the target values. keep in mind that creating instance takes some time. so make sure your existing infra is able to handle the traffic till new replica gets created. I will suggest to setup the value near 40%
  8. Setup the cooldown period
  9. min and max capacity
  10. and finally hit add policy.

That’s it. I hope you find this article helpful.

Have a good day.

--

--

Harshal kondke
Harshal kondke

Written by Harshal kondke

a geek. passionate about technology.

No responses yet