Skip to content

Beginner · Networking and databases: VPC and RDS · topic 16 of 50 · 30 min

Managed relational databases: RDS and Aurora

Explanation

Amazon RDS runs MySQL, PostgreSQL, MariaDB, Oracle, SQL Server and Db2 for you, handling patching, backups and failover. Multi-AZ keeps a synchronous standby in another zone for high availability; read replicas are asynchronous copies for scaling reads. Aurora is AWS's own MySQL- and PostgreSQL-compatible engine. Keep databases in private subnets and let only the app's security group in.

Why a managed database?

Running a database yourself on EC2 means installing it, applying security patches, taking backups, testing restores, setting up replication and waking up at 3 am when the disk fills. Amazon RDS (Relational Database Service) does those jobs for you. You still design tables, write queries, choose indexes and size the instance. "Managed" means AWS runs the engine; it does not mean AWS tunes your slow queries.

Think of it like this: Self-managed MySQL on EC2 is like owning a car: you arrange servicing, insurance and repairs. RDS is like a car on a full-service lease: you still drive and choose the route, but the company handles servicing and gives you a spare car if yours breaks down.

Engines

RDS supports MySQL, PostgreSQL, MariaDB, Oracle, Microsoft SQL Server and IBM Db2. Amazon Aurora is a separate engine built by AWS that is compatible with MySQL or PostgreSQL, so most apps work with it unchanged. Aurora stores six copies of your data across three AZs on a shared storage layer, grows storage automatically, and can fail over to a replica quickly. Aurora Serverless v2 scales capacity up and down with load, which suits spiky or development workloads.

Multi-AZ versus read replicas

These two features solve different problems, and mixing them up is the most common interview mistake.

Multi-AZ (DB instance)Read replica
GoalHigh availability: survive an AZ or instance failureScale reads: offload reports and read-heavy pages
Copy methodSynchronous: every write is on the standby before it is confirmedAsynchronous: may lag behind by seconds
Can you read from it?No, the standby only waitsYes, it has its own endpoint
On failureAutomatic failover, same DNS endpoint, usually one to two minutesManual: you can promote it to a standalone database
WhereAnother AZ, same regionSame AZ, another AZ, or another region

RDS also offers Multi-AZ DB clusters for MySQL and PostgreSQL, with one writer and two readable standbys. You can combine features: a production database is often Multi-AZ and also has one or two read replicas for reporting. Read replicas for cross-region use also help with disaster recovery.

Backups, point-in-time restore and snapshots

Automated backups take a daily snapshot plus transaction logs, kept for a retention period you choose from 1 to 35 days (0 turns them off). With them you can do point-in-time restore (PITR) to any second in the retention window, usually up to the last five minutes. A restore always creates a NEW database instance; you then point the app at it. Manual snapshots are kept until you delete them, even after the database is deleted, so use them before risky changes and for long-term copies.

bash
aws rds create-db-instance \
  --db-instance-identifier shop-db \
  --engine postgres \
  --db-instance-class db.t4g.medium \
  --allocated-storage 50 --storage-type gp3 \
  --master-username shopadmin \
  --manage-master-user-password \
  --db-subnet-group-name shop-db-private \
  --vpc-security-group-ids sg-0db111 \
  --multi-az \
  --backup-retention-period 7 \
  --storage-encrypted \
  --no-publicly-accessible

aws rds create-db-instance-read-replica --db-instance-identifier shop-db-reports --source-db-instance-identifier shop-db
aws rds restore-db-instance-to-point-in-time --source-db-instance-identifier shop-db \
  --target-db-instance-identifier shop-db-restored --restore-time 2026-10-19T09:45:00Z
--manage-master-user-password keeps the admin password in AWS Secrets Manager, so it never appears in scripts.

Networking, configuration and encryption

  • DB subnet group: the list of private subnets (in at least two AZs) where RDS may place the database. Keep "publicly accessible" off.
  • Security group: allow the database port (5432 for PostgreSQL, 3306 for MySQL) only from the app's security group.
  • Parameter groups hold engine settings such as max_connections or time zone. Changing some settings needs a reboot. Option groups add engine features for engines like Oracle and SQL Server.
  • Encryption at rest uses KMS and must be chosen when you create the database. To encrypt an existing unencrypted database: snapshot it, copy the snapshot with encryption on, and restore from the copy.
  • Use TLS for connections, and consider RDS Proxy when many short-lived connections (for example from Lambda functions) would overload the database.
Careful: Common mistakes: (1) Expecting Multi-AZ to make reads faster; the standby cannot be read. (2) Sending writes to a read replica endpoint; replicas are read-only. (3) Making the database publicly accessible with port 5432 open to 0.0.0.0/0 "for testing". (4) Thinking PITR fixes the database in place; it creates a new instance. (5) Forgetting that encryption cannot simply be switched on later. (6) Never testing a restore until the day you need it.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Managed relational databases: RDS and Aurora · 1/7

RDS = managed relational DB

Amazon RDS runs relational databases for you: patching, backups, monitoring and failover. You still design tables and queries.

Prefer a video by a teacher? Find free videos on “aws rds multi-az vs read replica aurora explained” on YouTube ↗

In real life: IRCTC-style booking load on a travel site

A regional bus booking site runs PostgreSQL on RDS in ap-south-1 with Multi-AZ. At 10 am, when festival bookings open, thousands of people search seats while a smaller number pay. Seat searches and the operator dashboards go to two read replicas; bookings and payments write to the primary. One morning an AZ has a power issue: RDS fails over to the standby automatically, and the app reconnects to the same endpoint within about two minutes. A week later a developer deletes a table by mistake, and the team restores to a point five minutes earlier as a new instance and copies the table back.

Practice (0/3 done)

Task 1 · Question

Your main goal is that the database survives an Availability Zone failure with automatic failover. What do you enable?

Task 2 · Code · Python

Write recommend(scenario) that returns a list of RDS features for a scenario dict with keys "must_survive_az_failure" (bool), "read_share" (fraction of queries that are reads, 0 to 1), "primary_cpu" (percent) and "users_in_other_region" (bool). Add, in this order: "Multi-AZ" if it must survive an AZ failure; "read replica" if read_share is at least 0.7 AND primary_cpu is at least 70; "cross-Region read replica" if users are in another region. Return [] if nothing applies.

Task 3 · Practice

Write the plan (and the CLI commands if you like) for a production PostgreSQL database on RDS for an online pharmacy: subnet placement, security group, availability, backups, encryption, and how the app gets the password. Explain how you would recover if someone ran DELETE without a WHERE clause at 11:02 am.

Quick quiz

Question 1

1.How is data copied to a Multi-AZ standby (DB instance deployment)?

Question 2

2.Reporting queries slow down your busy primary database. What helps most?

Question 3

3.What is the maximum retention period for RDS automated backups?

Question 4

4.What does a point-in-time restore produce?

Question 5

5.Which statement about Aurora is correct?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

How is data copied to a Multi-AZ standby (DB instance deployment)?

Answer: Synchronously, before each write is confirmed

Multi-AZ uses synchronous replication, so the standby has every committed write.

Reporting queries slow down your busy primary database. What helps most?

Answer: A read replica for the reports

Read replicas take read traffic off the primary. The Multi-AZ standby cannot serve reads.

What is the maximum retention period for RDS automated backups?

Answer: 35 days

Automated backup retention can be set from 1 to 35 days. Use manual snapshots for longer.

What does a point-in-time restore produce?

Answer: A new DB instance with the data as of the chosen time

PITR always creates a new instance; you then repoint the app or copy data back.

Which statement about Aurora is correct?

Answer: It is compatible with MySQL and PostgreSQL

Aurora is an AWS-built engine compatible with MySQL or PostgreSQL.

A developer accidentally deletes a table. The database is RDS Multi-AZ. What recovers the data?Related

Answer: A point-in-time restore from backups taken before the delete

The standby copied the delete too. Only a backup from before the mistake has the data.

From Backups and disaster recovery

Which job suits a search engine such as Elasticsearch or OpenSearch best?Related

Answer: Typo-tolerant product search with filters and ranking

Search engines use inverted indexes built for full-text search and relevance ranking.

From Choosing a database, and keeping it safe

A web tier (99.9%) depends on an auth service (99.9%) and a database (99.95%). All three must work. What is the overall availability, roughly?Related

Answer: 99.75%

In series: 0.999 × 0.999 × 0.9995 ≈ 0.9975, about 99.75%, lower than any single part.

From Designing for high availability

What does "incremental" mean for EBS snapshots?Related

Answer: After the first, only changed blocks are stored

Later snapshots store only blocks that changed since the previous one, which saves cost.

From Block and file storage: EBS, instance store and EFS

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 2 more topics in “Networking and databases: VPC and RDS” before its exam: Choosing a database: DynamoDB, caches and warehouses, DNS and CDN: Route 53 and CloudFront.
  2. Module 4 exam: Networking and databases, VPC and RDS · 14 questions · 25 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, Serverless, monitoring and cost control. 50 topics left in the course before the final exam.

← Previous: VPC security and connectivity