Amazon RDS
What Amazon RDS manages, the six engines, instance and storage choices, storage auto scaling, and why it can't be reached over SSH.
What it is
Amazon RDS (Relational Database Service) runs relational databases as a managed service. The customer picks an engine, an instance size and some storage; AWS sets up the database server and keeps it running. The application connects to an endpoint with the normal driver for that engine and sends SQL.
RDS supports six engines:
- MySQL, PostgreSQL and MariaDB (open source);
- Oracle and Microsoft SQL Server (commercial, licence included or customer-supplied licence, BYOL);
- IBM Db2.
Aurora, AWS's own MySQL- and PostgreSQL-compatible engine, is part of the RDS family but works differently. It has its own page: Amazon Aurora.
Why use RDS instead of a database on EC2
MySQL could be installed on an EC2 instance directly. Then every job that keeps a database healthy falls to the customer. RDS takes most of them away:
With RDS, AWS:
- provisions the server and installs the database;
- patches the operating system and the database engine in a chosen maintenance window;
- takes continuous backups, allowing a restore to any second in the last 1 to 35 days (point-in-time restore);
- provides monitoring dashboards (CloudWatch metrics, Performance Insights);
- adds read replicas for read performance and a Multi-AZ standby for disaster recovery;
- scales vertically (a bigger instance class) and horizontally (more read replicas);
- stores the data on EBS volumes.
The trade-off: an RDS instance can't be reached over SSH. Only the database connection is available. If the operating system is needed, use RDS Custom (Oracle and SQL Server) or run the database on EC2.
Instances and storage
Creating an RDS database means choosing:
- The engine and version, for example PostgreSQL 17.
- The DB instance class, which sets CPU and memory, such as
db.t4g.micro(burstable, for tests),db.m7g.large(general purpose) ordb.r7g.xlarge(memory optimised). - The storage type and size: General Purpose SSD (
gp3orgp2) or Provisioned IOPS SSD (io2,io1) for heavy I/O. - The network: a VPC, a DB subnet group (subnets in at least two AZs) and security groups. Databases normally sit in private subnets, with Public access set to No.
Storage auto scaling
Running out of disk space stops a database. Storage auto scaling grows the storage automatically when it's nearly full, with no downtime.
- Turn it on and set a maximum storage threshold, the most it may grow to (at least 10% above the current size).
- RDS grows the storage when all of these are true:
- free space is 10% or less of the allocated storage;
- the low-storage condition has lasted at least 5 minutes;
- the previous storage change has finished optimising, and there have been fewer than four changes in the last 24 hours.
- Each step adds the largest of: 10 GiB, 10% of the current size, or the growth predicted for the next 7 hours.
- It works with every RDS engine, and suits unpredictable workloads where the size can't be planned.
Updated since the slides
The slides say a new change waits until 6 hours after the last one. The AWS documentation now says RDS waits until the previous change has finished optimising, with at most four changes in 24 hours.
Limits and pricing
- Billing is per instance hour (by instance class, more for Multi-AZ), per GB-month of storage and provisioned IOPS, and for backup storage beyond the free amount (free up to 100% of the provisioned storage in each Region).
- Commercial engines can include the licence in the hourly price.
- A stopped instance still pays for storage and backups. RDS starts it again automatically after 7 days. To keep a database off for longer, take a snapshot and delete it, then restore when needed.
- Reserved Instances lower the price for steady databases (see purchasing options).
Real-world examples
- A web shop moves its MySQL server from one EC2 instance to RDS MySQL with Multi-AZ. Patching and backups stop being a weekend job.
- A company running Oracle moves to RDS for Oracle, keeping its PL/SQL code and the licence it already owns.
- A start-up's app grows faster than planned. Storage auto scaling adds space before the disk fills, instead of an outage at 3 am.
Exam tips
- "Managed relational database", "MySQL / PostgreSQL / Oracle / SQL Server", "less operational overhead" → RDS.
- "Database storage grows unpredictably", "avoid running out of space" → turn on storage auto scaling with a maximum threshold.
- "Need OS access or custom patches on Oracle or SQL Server" → RDS Custom. "Full control of any engine" → database on EC2.
- "Stop a database for months to save money" → snapshot, delete, restore later (a stopped instance restarts after 7 days).
Common traps
- "SSH into the RDS instance to tune the OS." Not possible on normal RDS.
- "A stopped RDS instance costs nothing." Storage and backups are still billed.
- "Storage auto scaling also scales the instance class." It only grows storage; changing the instance class is a separate change.
Hands-on lab: create a small RDS database
Goal: create a PostgreSQL database with storage auto scaling, connect to it from an EC2 instance, and look at what RDS set up.
Costs money
A Single-AZ db.t4g.micro with 20 GiB of gp3 storage costs about $0.02 an hour in us-east-1, plus the EC2 instance you connect from. Delete it the same day and the lab costs a few cents. Any Region works.
Before you start: you need the saa-web instance (or any Amazon Linux 2023 instance) in the default VPC, from the EC2 basics lab.
Create the database
RDS → Create database → Standard create. Engine PostgreSQL, template Dev/Test, availability Single-AZ DB instance. DB instance identifier saa-db, master username postgres, choose Self managed credentials and set a password. Instance class db.t4g.micro. Storage gp3, 20 GiB, tick Enable storage autoscaling with a maximum of 30 GiB.
Connect it to your instance
Under Connectivity, choose Connect to an EC2 compute resource and pick saa-web. RDS creates two security groups so only that instance can reach port 5432. Keep Public access: No. Add the tag Project=saa-lab and create. It takes about 5 to 10 minutes.
Look around
Open saa-db. Note the endpoint (a DNS name, not an IP), the port, the Maintenance & backups tab (backup retention, maintenance window) and Monitoring. Under Configuration, see the storage auto scaling limit.
Connect and run SQL
Connect to saa-web with EC2 Instance Connect and run:
sudo dnf install -y postgresql17
psql -h <your-endpoint> -U postgres -d postgres -c "select version();"Enter the password. You see the PostgreSQL version: you're talking to a managed database you never logged in to.
Expected result: a working PostgreSQL database reachable only from your EC2 instance, with backups and storage auto scaling already on.
Clean up: delete saa-db (untick Create final snapshot, tick the acknowledgement; untick Retain automated backups). Then delete the two security groups RDS created (rds-ec2-* and ec2-rds-*) and stop or terminate saa-web if you don't need it. Check Billing → Bills the next day.