AWS RDS(Relational Database Service)

Kay(Geun Woo)
12 min readFeb 2, 2024

--

What is RDS? How do I set up RDS?

Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the AWS Cloud. It provides cost-efficient, resizable capacity for an industry-standard relational database and manages common database administration tasks.

The above line is from the official AWS RDS documentation. It does not describe what RDS actually offer the users. Similar to EC2, RDS is Amazon’s service, which provides an easily scalable hardware to store your data remotely. Amazon highlights the advantages of RDS by comparing it to on-premises server.

  • On-premises : In software programming, “on-premises” means that the hardware or software is installed, owned, and used by the users, themselves.

The official documentation shows the comparison in a table like below.

Table from AWS official documentation — 1
Table from AWS official documentation — 2

In short, Amazon states that using AWS RDS is better than the developers setting up their own devices to run database servers because all the tedious parts, server maintenance, hardware lifecycle management, and resource allocation(Power, network, and cooling) are done by Amazon and the users can control the settings flexibly and Amazon does the actual works for you. These kind of jobs might cost tons if the developers and firms do so by themselves.

However, remember that there is no silver bullet in software programming, if there is an advantage, there is a disadvantage as well. It’s inevitable. Compare to using the local database devices, the databases which AWS provides are located physically far away usually. This means, depend on your settings and region of your work spot and service area, the latency of DB I/O might vary. Also, setting the RDS is relatively harder than setting the local devices since you have to follow the rules that AWS have to borrow its devices. However, despite its disadvantages, it is a fact that the Amazon’s service is high quality and eases the cost pressure of the majority of the firms in the world.

  • Latency : Latency means the time that the requestors(clients in our cases) have to wait for responses from the respondents to arrive. For example, if you took 2 seconds to load a page, 2 seconds are the latency for the response of the page. Latency is inevitable in the modern network because the requests sent wirelessly from your computers to the services are not actually wireless. They are wired, but you just can’t see the wire because they are hidden in the walls and under the ground(even at the bottom of the ocean). This is really interesting topic to discuss, but since we are talking about RDS in this post, you can look into the answers for a question in Quora.

Cut the discussion! What can I actually do with RDS?

Let’s go through the terminologies you need to be aware about before launching an actual RDS instance.

DB instances

Just like EC2, RDS manages the databases in instances. The instances can be created and modified by using AWS CLS, RDS API or the AWS Management Console.

DB Engines

The database engines means the relational database software that runs on your DB instance. If you are new to this term, the following examples are the DB Engines that RDS supports:

  • Db2
  • MariaDB
  • Microsof SQL server(MsSQL)
  • MySQL
  • Oracle
  • PostgreSQL

Not only the engine, but also the version of the engine can be selected.

As the name of the service represents, RDS supports the RDBMS(Relational Database) only.

DB instance classes

The instance class is the computation power and memory capacity of a DB instance. Consider this as the determination of number of CPUs and memory(RAM) for your instance. There are 4 types of classes.

  • General-purpose : The general-purpose instance class is a well balanced instance class type. “Well balanced” here means the balance between performance and the memory.
  • Memory-optimized : The memory-optimized instance class is a memory-intensive type of instance class.
  • Burstable-performance : The burstable-performance instance class focuses on the high performance.
  • Optimized Reads : The optimized reads instance class is optimized for “read” actions.

DB instance storage

RDS uses AWS EBS(Elastic Block Storage) as the volume for database and log storage. You can select one of the followings:

  • General Purpose SSD : Amazon claims that the general purpose SSD is cost-effective and ideal for the medium-sized DB instances. This is suited for development and testing environments.
  • Provisioned IOPS SSD : According to the Amazon’s official documentation, the provisioned IOPS SSD is suitable for the I/O-intensive DB instances. It’s for the developers who wants to serve low I/O latency and consistent I/O throughput. Hence, it is suited for the production environment.
  • Magnetic(HDD) : In simple, the magnetic storage is HDD. The slow hard drive disk. Amazon claims that the magnetic storage is for backward compatibility. What is backward compatibility? The backward compatibility is an ability of new version of a product working well with the older version of the product. The backward compatibility concept applies to any software products, but I think the backward compatibility that Amazon mentioning is a bit different from the definitions of it you can find on the internet. I think Magnetic storage is to test whether your new database schema works well with the HDD devices in terms of I/O latency, and resources. Amazon does not mention suggestible environment for the Magnetic storage. Regarding its spec, I understand why. I think the SI(System Integration) firms might consider using this option if they are developing the products to be implemented to the customers’ old database storage machines(HDD). Other than that, I can’t think of the possible cases.

Amazon Virtual Private Cloud(VPC)

The DB instances needs to be ran on a VPC. If you are new to VPC, think of it as a room provided by Amazon for you to set up your systematic requirements to run your services. The room has a lock, called security group, to filter the people who can enter your room, and placing the services inside a VPC lets you to manage your system conveniently.

AWS Regions and Availability Zones

As the name represents, regions are the geographical areas of the Amazon’s hardwares(storage devices in this case) placed. The availability zones are the geographical areas of the hardwares placed in each region. Think of the relationship between the regions and availability zones as the relationship between the central base of a city, monitoring CCTV footages, and the CCTVs distributed in the city.

Security Group

The security group is closely related to VPC. It’s a list of IP addresses that you register to give authorization to access your infrastructure.

Monitoring

According to Amazon, it uses its CloudWatch service to monitor the performance and health of a DB instance. You might think monitoring is not an important part of constructing an infrastructure. In fact, preparing a strong and visible monitoring system might be more important than setting it up. Fortunately, Amazon provides various options to monitor the instances. At the bottom line, you can check the health of your instances in the dashboard indicated in words. Not only verbal reporting, but also monitoring with Amazon’s own monitoring system like CloudWatch. For the details, click here.

Billing

The billing amount of RDS is measured by on-demand method, which means it charges you as much as you use. Or, as little as you use. Luckily, Amazon offers few options for free, called Free tier. You can use the following connections as Free tier

  • 750 hours of Amazon RDS Single-AZ db.t2.micro, db.t3.micro, db.t4.micro.
  • 750 hours of Amazon RDS Single db.t2.micro Instance usage of runnig SQL Server each month.
  • 20GB of General Purpose SSD(gp2) storage per month.
  • Free backup storage up to 100% of the total provisioned storage size of your active DB instances for a region.

Set up your own instance(Free Tier)

Before launching your own RDS instance, Amazon suggests you to enable IAM Identity Center. This is to manage team and the developers(users) in the team, and allow them accessing AWS outside of the AWS Management console. If you want to enable IAM Identity Center as Amazon suggests, you can click here and follow the instructions to do so. If you are fine without it, you can just proceed.

As it was mentioned, RDS is a flexible service. Inevitably, more flexible the service is, more information need to set it up. Before setting your instance, you have to be aware of certain values or rules which you or your team will follow. Amazon suggests you to consider the following things before selecting options to launch an instance:

  • Resource Requirement : How much memory will your project require?
  • VPC, subnet and security group : Which IPs will your project allow to access, send requests, and receive responses?
  • Level of availability : How much traffic are you expecting?
  • IAM policies : Which users of your group will have which permissions?
  • Open port : What port number will your database listen on? If you are working in a security-intense firm, your company’s netwrok firwalls might block connections to the default port for the database engines(e.g. 3306 for MySQL, 5432 for postgreSQL)
  • AWS Region : Where do you want your data storage to be? For example, if you try to execute queries to a database in a region far away from where you are sending queries, it will take longer time for the output of queries to be arrived than doing so to a database in located in the closer region.
  • DB disk subsystem : Which kind of disk do you want your database to use? SSD or HDD?

Amazon suggests you to set a security group before creating a RDS instance. You can either look into my post about EC2 tutorial or the official Amazon’s documentation about RDS set up.

Now let’s start creating and connecting to a DB instance. I am going to introduce how to create a MySQL instance because it’s the most common DB engine that the people use. The official documentation provides tutorials for creating the data engines that RDS supports. Hence, click here to see if you want to create MariaDB, MsSQL server, Oracle, or PostgreSQL instance.

Diagram of relationship between EC2 and RDS imported from Amazon.

RDS instance is usually used with an EC2 instance because they are like a couple, a server storage and database storage. Hence, the official tutorial start from creating an EC2 instance. In this post, I’m skipping it because I already posted about it here. Hence, if you do not have an EC2 instance ready, please follow the tutorial there, and come back to continue creating a RDS instance.

Launching a MySQL RDS instance

RDS dashboard

1. Click Create database button on RDS dashboard.

2. Choose one of create methods under Choose a database creation method. Easy Create will offer you a list of predefined settings. This usually works fine, and Amazon’s tutorial uses this method as well, but I’m choosing Standard create to give instructions about the options in detail.

Engine options — 1
Engine options — 2

3. Choose MySQL and select a desired version under Engine options.

4. Select one of Production, Dev/Test, and Free tier under Templates. All of them differs in terms of performance and stability. If you are creating an instance for production server(the server that actually provides service to your customers), select Production. Select Dev/Test if you are creating an instance for your development or test server(A server being used while developing your product). For this tutorial, we are just making an instance to study. So, let’s choose Free tier.

5. Under Settings, you can determine DB instance identifier(instance name), Master username(username for the database), and Master password(password for the database). You have to determine your password cautiously, though it’s obvious. There are some assaulters, who cracks the username and password by brute force search, access the cracked instances, encrypt the data inside, and threats you to transact some money to decrypt the data back. Because they use brute force search, which is try-and-error-kind search method, if you choose passwords like 12345678, and use default username, which is “admin”, it won’t take long for you to receive the threatening email.

6. You can choose instance class under the Instance configuration. Unfortunately, the Free tier template supports Burstable classes only. You can choose the other classes if you choose Production or Dev/Test option for Template option.

7. You can choose instance storage and the size of it under Storage. Depends on your Template and storage type options, the options under Storage vary. You can also set your storage to automatically scale its storage size by expanding Storage autoscaling.

8. Free tier database instance does not offer Availability & duration options. Multi-AZ deployment is about if you are going to create replicas of your database in different availability zone. The replicas created can be used to troubleshoot, reduce latency, and data distribution(Distributed GIS).

Connectivity — 1
Connectivity — 2
Connectivity — 3

9. Under Connectivity, you can choose whether you are going to connect this instance with an existing EC2 instance, so that it shares the same security group with the EC2 instance and live in the same VPC, or connect to another VPC(new/existing) with different subset group and security group. Also, you can determine your port number for this instance’s database engine under Database port, which appears when you expand Additional configuration of Connectivity. For this tutorial, let’s assume we are connecting this to an existing EC2 resource. Then you will see EC2 instance with dropbox, which you can choose an existing EC2 instance. After that, you can choose one of IPv4 and Dual-stack mode for Network type. You can set up other options as well, but you can just leave them with default values for now.

Monitoring — 1
Monitoring — 2

10. Under Monitoring, you can choose whether you are going to monitor your instance, and if so, you can choose the frequency of the logs, and the role of the monitoring.

Additional configuration — Database options
Additional configuration — Backup
Additional configuration — Encryption, Log exports
Additional configuration — Maintenance

11. Under Additional configuration, you can determine Database options, Backup, Encryption, Maintenance, and Deletion protections. For now, let’s leave them as they are.

Estimated Monthly costs

At the end of the window, Amazon gives you Estimated Monthly costs. However, this number may not be the actual cost Amazon charges you because it is measured as much as you use. It can be less or more.

Connect to your DB instance!

To connect to your DB instance, first we have to access our EC2 instance. The tutorial for accessing EC2 instance is in my other post.

Assuming you are already in your EC2 instance, install mysql first. Depend on the AMI that your instance uses, the shell script for mysql installation differs. To see the list of shell scripts, click here.

After installation, connect to the MySQL DB instance by passing the following shell script.

$ mysql -h ENDPOINT -P 3306 USERNAME -p
$ PASSWORD(invisible)

*IMPORTANT* :

  • You must substitute ENDPOINT with your DB instance’s Endpoint under Connectivity & security tab in the dashboard of the DB instance.
  • You must substitute 3306 with your DB instance’s Port under Connectivity & security tab in the dashboard of the DB instance.
  • You must substitute USERNAME with your DB instance’s username.
  • You must substitute PASSWORD with your DB instance’s password. Though you won’t be able to see them while typing.

That’s it! You can find the details in the Amazon’s official documentation about RDS.

--

--