RDS (Relational Database Service)
Prerequisites
1. RDS
Amazon RDS is a managed relational database service that allows you to run databases without managing infrastructure.
AWS automatically handles:
- OS patching
- Backup
- Failover
- Monitoring
1-1. Supported Engines
- MySQL
- PostgreSQL
- MariaDB
- Oracle
- SQL Server
- Amazon Aurora
1-2. Architecture (with EC2)
1
2
3
4
| User
β ALB
β EC2 (Application Server)
β RDS (Database)
|
π Users do NOT access RDS directly π Only EC2 communicates with RDS
1-3. Network Placement
1
2
3
4
5
6
| Public Subnet:
- ALB
Private Subnet:
- EC2
- RDS
|
π RDS must be placed in a Private Subnet
- Instance size (CPU / RAM)
- Storage IOPS
- Number of connections
- Query complexity
2. How to work RDS
| Component | Role |
|---|
| RDS | Managed database |
| Endpoint | Database access point |
| Security Group | Access control |
| Multi-AZ | High availability |
| Read Replica | Read scaling |
2-1. Connectivity Flow
Application β Database
Example:
1
| mydb.abc123.ap-southeast-2.rds.amazonaws.com:3306
|
Protocol
- MySQL β TCP 3306
- PostgreSQL β TCP 5432
2-2. Routing (VPC Internal)
π Communication stays inside VPC
2-3. Security
RDS Security Group
1
2
3
| Inbound:
Port: 3306
Source: EC2 Security Group
|
1
2
| Outbound:
Allow all (default)
|
1
2
| EC2 β RDS β
Internet β RDS β
|
2-4. Multi-AZ
Single AZ
Multi-AZ
1
2
3
| Primary DB (AZ1)
β replication
Standby DB (AZ2)
|
Failover
1
2
| Primary failure
β Automatic switch to standby
|
3. How to create RDS
3-1. Search RDS
3-2. Click Navigation pane β βDashboardβ
3-4. Create database
3-5. Connect EC2
3-6. Check Connection steps on EC2
3-7. Connect RDSβs SQL on EC2
3-8. Command SQL on EC2