Beginner · Networking and databases: VPC and RDS · topic 16 of 50 · 30 min
Managed relational databases: RDS and Aurora
Explanation
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.
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 | |
|---|---|---|
| Goal | High availability: survive an AZ or instance failure | Scale reads: offload reports and read-heavy pages |
| Copy method | Synchronous: every write is on the standby before it is confirmed | Asynchronous: may lag behind by seconds |
| Can you read from it? | No, the standby only waits | Yes, it has its own endpoint |
| On failure | Automatic failover, same DNS endpoint, usually one to two minutes | Manual: you can promote it to a standalone database |
| Where | Another AZ, same region | Same 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.
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:00ZNetworking, 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.
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
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)
Your main goal is that the database survives an Availability Zone failure with automatic failover. What do you enable?
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.
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
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Choosing a database: DynamoDB, caches and warehousesNetworking and databases: VPC and RDS · same module
- Backups and disaster recoveryHigh availability, scaling and disaster recovery
- Choosing a database, and keeping it safeSQL and Databases · Procedures, triggers, SQL engines and NoSQL
- Designing for high availabilityHigh availability, scaling and disaster recovery
- Scaling: handling more usersBackend Development · Deployment and scaling
- Encryption, keys and secretsCloud security and compliance
Questions people ask about this
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.
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.
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.
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.
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
- 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.
- Module 4 exam: Networking and databases, VPC and RDS · 14 questions · 25 min, without help. 5 topics of this module still to finish first.
- Then the next module, Serverless, monitoring and cost control. 50 topics left in the course before the final exam.