Table of contents
RDS is the Relational Database Service of AWS. It allows you to build fully-managed SQL Servers. There are six main database engines out there you can use:
Microsoft SQL Server
This post is about scaling up or down your database. RDS offers options to scale your database horizontally or vertically.
Why do you need to scale anyway? There are a couple of reasons why scaling makes sense. Let's have a look at two examples.
Predictable Workload - Ride-hailing app
You have an application like Uber. You know that many requests are coming in at times when people commute a lot, for example, 7 AM and 5 PM (going to work and leaving work).
You know that your database gets a lot of requests at that time.
You don't want to have a big instance running all the time because it is really expensive so you provision a small instance and only scale it up at that time.
This is a predictable workload. You know that you get a lot of requests at that time.
With the same example, we can also have unpredictable workloads. If there are events you weren't aware of like huge football matches or concerts there could also be a huge surge in requests. To cover that your system needs to scale up & down automatically. This is called Auto Scaling and RDS supports this function.
Upscaling & Downscaling
Upscaling means your database requires more resources like CPU or storage.
Downscaling means that your database needs fewer resources to save costs.
You can configure auto-scaling policies with RDS. But it is not automatically activated like in services such as DynamoDB. You need to configure it properly so that everything works out.
Horizontal scaling adds more instances while vertical scaling enhances the current instance
First, we need to look at the different types of scaling.
Horizontal scaling adds more instances
Horizontal scaling means adding more instances. Instead of having one database instance, you would have two or three for example. Adding read replicas is one of the most straightforward ways of horizontal scaling. If your application only needs to scale for reading reasons, which is often the case, add a read replica and point all read applications to this database.
Let's have an example. If your primary database is in
us-east-1 and you have users from the US and Europe, your users in Europe will experience longer latencies.
RDS allows you to create a read replica in
eu-central-1 also. Your EU users can now use this database to be able to read data. Writing is still happening in
Another way to increase the performance by scaling horizontally is by adding an RDS proxy. This allows much more connections to the database.
Vertical Scaling enhances the current database instance
Vertical scaling refers to scaling the actual hardware. For example more memory, more CPU, or more storage.
Auto Scaling allows you to scale up and down automatically, based on a policy. A policy can be based on a metric like free storage.
A common example is: if there is only 10% free storage → Scale up
You can enable auto-scaling in the RDS properties.
If the free storage is less than 10 % of the allocated storage and it lasts for at least five minutes and six hours have passed since the last storage update it will scale up automatically.
Auto-scaling is only possible for storage not for the actual instance class. If you want to scale the instance class you need to do that manually with another solution like EventBridge & Lambda.
What are the benefits of scaling with RDS?
Scaling with RDS allows you to respond to changes in workloads by either adding more instances (horizontal scaling) or enhancing the current instance (vertical scaling). This helps you save costs by avoiding the need for large, expensive instances that are not needed all the time.
What is the difference between horizontal and vertical scaling?
Horizontal scaling adds more instances while vertical scaling enhances the current instance. For example, horizontal scaling could involve adding read replicas or an RDS proxy, while vertical scaling could involve increasing memory, CPU, or storage.
Does RDS support auto-scaling?
Yes, RDS does support auto-scaling, but it is not automatically activated like in other services such as DynamoDB. You need to configure auto-scaling policies in order for auto-scaling to work.
Does Autoscaling cost something?
No, but check out the general guide about RDS Pricing here.
I hope this post could introduce you to different scaling methodologies and how to use them in RDS. RDS is an amazing service of AWS that allows you to build highly-scalable and performant applications.
Most of these scaling properties are in fully serverless services like in DynamoDB already implemented. Make sure to check out this service as well.