AWS RDS (Relational Database Service)
AWS RDS stands for Relational Database Service. It is a managed database service that makes it easy to set up, operate, and scale relational databases in the cloud. AWS handles the heavy lifting — hardware provisioning, database setup, patching, backups, and monitoring — so the focus can stay on the application rather than database administration.
What Is a Relational Database?
A relational database stores data in tables — rows and columns — with defined relationships between tables. SQL (Structured Query Language) is used to create, read, update, and delete data.
Example: An e-commerce database has a customers table and an orders table. Each order in the orders table links back to a customer in the customers table through a customer ID — this is the "relationship".
Database Engines Supported by RDS
RDS supports six major database engines:
| Engine | Type | Best For |
|---|---|---|
| Amazon Aurora | AWS-built (MySQL/PostgreSQL compatible) | High performance, enterprise workloads |
| MySQL | Open source | Web applications, general use |
| PostgreSQL | Open source | Complex queries, geospatial data |
| MariaDB | Open source (MySQL fork) | General web applications |
| Oracle | Commercial | Enterprise legacy systems |
| SQL Server | Microsoft commercial | .NET applications, Windows environments |
RDS vs Self-Managed Database on EC2
| Responsibility | Self-Managed (EC2) | RDS (Managed) |
|---|---|---|
| Install database software | Manual | AWS handles it |
| OS patching | Manual | AWS handles it |
| Database backups | Manual scripts | Automated by AWS |
| High availability setup | Complex manual setup | One checkbox (Multi-AZ) |
| Scaling storage | Manual, requires downtime | Automated storage scaling |
| Monitoring | Custom setup required | Built-in via CloudWatch |
Key RDS Features
1. Multi-AZ Deployment
Multi-AZ (Multi-Availability Zone) deployment creates a standby replica of the database in a different AZ. AWS synchronously replicates data to the standby instance.
If the primary database fails — due to hardware failure, AZ outage, or maintenance — RDS automatically fails over to the standby instance within 1–2 minutes. Applications reconnect via the same DNS endpoint. No manual intervention is required.
PRIMARY DB (AZ: ap-south-1a)
|
[Synchronous replication]
|
STANDBY DB (AZ: ap-south-1b) ← takes over if primary fails
[Application always connects to the same DNS endpoint]
[RDS handles the switchover automatically]
2. Read Replicas
Read Replicas are read-only copies of the database used to offload read traffic from the primary instance. Unlike Multi-AZ (which is for disaster recovery), Read Replicas improve read performance.
Example: A news website with millions of readers and far fewer writers. 1 primary instance handles all writes. 5 Read Replicas handle all read queries. The primary database is no longer overwhelmed by read requests.
- Read Replicas use asynchronous replication — data may be slightly behind the primary.
- Up to 5 Read Replicas per primary database (15 for Aurora).
- Read Replicas can be in the same Region or a different Region (cross-region replicas).
3. Automated Backups
RDS automatically takes daily backups of the database and stores transaction logs. This enables point-in-time recovery — restoring the database to any second within the retention period (1 to 35 days).
Example: A database is accidentally corrupted at 3:47 PM on Tuesday. Using point-in-time recovery, it can be restored to its exact state at 3:46 PM — losing only 1 minute of data.
4. Database Snapshots
Manual snapshots are user-initiated backups that persist indefinitely (unlike automated backups which expire after the retention period). A snapshot captures the entire database at a specific moment and can be used to restore or clone the database.
5. Encryption
RDS supports encryption at rest (data stored on disk) and in transit (data moving between the application and database). Encryption at rest uses AWS KMS (Key Management Service). It must be enabled at database creation — it cannot be enabled on an existing unencrypted database directly.
6. Storage Auto Scaling
When storage on an RDS instance is nearing capacity, Storage Auto Scaling automatically increases the allocated storage without downtime. A threshold is set (example: scale when storage is 90% full) and a maximum storage limit is defined.
Amazon Aurora — AWS's Premium Database Engine
Aurora is AWS's own database engine, fully compatible with MySQL and PostgreSQL. It offers significant improvements over standard MySQL/PostgreSQL running on RDS:
- Performance: Up to 5x faster than MySQL and 3x faster than PostgreSQL.
- Storage: Auto-scales from 10 GB to 128 TB automatically.
- Replicas: Supports up to 15 low-latency read replicas.
- Availability: Data is replicated 6 times across 3 AZs by default.
- Serverless option: Aurora Serverless automatically starts, stops, and scales based on application demand.
Connecting an Application to RDS
Application (EC2 in Private Subnet)
|
[Security Group: allow 3306 from App SG]
|
RDS MySQL Instance (Private Subnet)
|
Connection string example:
mysql -h mydb.abc123.ap-south-1.rds.amazonaws.com -u admin -p
The RDS instance endpoint (DNS hostname) is used to connect from applications. The endpoint stays the same even during a Multi-AZ failover.
RDS Subnet Group
An RDS DB Subnet Group defines which subnets (in different AZs) the RDS instance can use. For Multi-AZ, the subnet group must include subnets in at least two AZs. RDS instances should always be placed in private subnets — never in public subnets unless absolutely necessary.
Real-World Example — Hospital Management System
A hospital runs an application that manages patient records:
- Engine: PostgreSQL on RDS — supports complex queries for patient history and lab reports.
- Multi-AZ: Enabled — patient data must always be available. No downtime tolerated.
- Encryption: Enabled — healthcare data requires compliance with privacy regulations.
- Backups: 30-day retention — allows recovery from any accidental data deletion within the last month.
- Read Replicas: 2 replicas — reporting dashboards query replicas, keeping the primary database fast for live patient data.
Summary
- RDS is a managed relational database service. AWS handles backups, patching, and high availability.
- Supported engines: Aurora, MySQL, PostgreSQL, MariaDB, Oracle, and SQL Server.
- Multi-AZ provides disaster recovery. Read Replicas provide read scalability.
- Automated backups enable point-in-time recovery within the retention window.
- Aurora is AWS's highest-performance database engine, compatible with MySQL and PostgreSQL.
